0% found this document useful (0 votes)
9 views32 pages

AI UNIT -4

The document discusses propositional logic and first-order logic as foundational elements in artificial intelligence (AI) for knowledge representation and reasoning. It explains key components such as propositions, logical operators, quantifiers, and the syntax and semantics of first-order logic, highlighting their roles in expressing complex relationships and making intelligent decisions. Additionally, it covers concepts like unification and resolution, which are essential for AI applications in natural language processing, logic programming, and expert systems.

Uploaded by

vasantha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views32 pages

AI UNIT -4

The document discusses propositional logic and first-order logic as foundational elements in artificial intelligence (AI) for knowledge representation and reasoning. It explains key components such as propositions, logical operators, quantifiers, and the syntax and semantics of first-order logic, highlighting their roles in expressing complex relationships and making intelligent decisions. Additionally, it covers concepts like unification and resolution, which are essential for AI applications in natural language processing, logic programming, and expert systems.

Uploaded by

vasantha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

UNIT-4

Symbolic Logic
Propositional Logic

• Propositional logic is a fundamental building block in AI, serving as the language in which we express knowledge and
information in a structured manner.

• This system allows us to represent the world's knowledge, facts, and relationships using simple, atomic propositions, and
logical operators like "AND," "OR," and "NOT."

• This structured representation is incredibly valuable because it enables AI systems to reason and make intelligent decisions
based on the information they have.

• In AI, we face complex challenges that involve dealing with vast amounts of information and making decisions based on
this information.

• Propositional logic provides a powerful tool to represent this information, allowing us to create models of the world,
formulate hypotheses, and perform deductive and inductive reasoning.

• It's the backbone of knowledge representation and reasoning in AI, helping systems process, store, and retrieve knowledge
efficiently.
• Propositional logic also known as propositional calculus, is a branch of formal logic that deals with
propositions or statements, and the logical relationships between them.

• In the context of artificial intelligence (AI), propositional logic serves as a foundational framework for
representing and manipulating knowledge.

• It enables AI systems to model the world, infer new information from existing knowledge, and make
intelligent choices based on logical deductions.

• By using propositions and logical operators, AI systems can process information in a way that resembles
human thought processes, making it a vital tool for various AI applications.
Explain the Key Components of Propositional Logic:
1. Propositions (Statements): In propositional logic, propositions are the basic building blocks. A proposition
represents a declarative statement that can be either true or false but not both.
These statements can be about anything, from simple facts to more complex statements.
For example, "The sky is blue" is a proposition because it can be evaluated as either true or false.
2. Logical Operators:
• AND (Conjunction): The AND operator, often represented by ∧, is used to combine two or more
propositions. It yields a true result only when all the propositions it connects are true. For example, if P
represents "It's raining" and Q represents "I have an umbrella," then P ∧ Q is true only if both "It's raining"
and "I have an umbrella" are true.
• OR (Disjunction): The OR operator, represented by ∨, combines propositions and results in true if at least
one of the connected propositions is true. For instance, if P represents "It's sunny" and Q represents "It's
warm," then P ∨ Q is true if either "It's sunny" or "It's warm" or both are true.
• NOT (Negation): The NOT operator, represented by ¬, is used to negate or reverse the truth value of a single
proposition. If P is "The store is open," then ¬P is true if the store is not open.

3. Truth Values (True and False): Every proposition in propositional logic has one of two possible truth values—true
or false. These truth values indicate whether the statement is valid or not in a given context.

Let's consider a few examples to illustrate propositions and logical operators:

1. Propositions:

• P: "The cat is on the mat" (This proposition can be true or false depending on the cat's location).

• Q: "It's 10:00 AM" (This proposition is true if the time is exactly 10:00 AM).

• R: "The car is red" (This proposition is true if the car's color is red).
2. Logical Operators:

• P ∧ Q: "The cat is on the mat, and it's 10:00 AM." This proposition is true only if both P and Q are true.

• R ∨ ¬P: "The car is red, or the cat is not on the mat." This proposition is true if either R is true or the negation of P
is true.

• These propositional logic in ai examples demonstrate how propositions and logical operators help us create complex
statements that capture relationships and conditions, allowing us to represent and reason about information in a
structured and logical manner within the realation of artificial intelligence.
First-Order Logic in Artificial intelligence

• In the topic of Propositional logic, we have seen that how to represent statements using propositional logic. But
unfortunately, in propositional logic, we can only represent the facts, which are either true or false.

• PL is not sufficient to represent the complex sentences or natural language statements.

• The propositional logic has very limited expressive power.

• Consider the following sentence, which we cannot represent using PL logic.

• "Some humans are intelligent", or

• "Sachin likes cricket."

To represent the above statements, PL logic is not sufficient, so we required some more powerful logic, such as
first-order logic.
First-Order logic:

• First-order logic is another way of knowledge representation in artificial intelligence. It is an extension to propositional
logic.

• FOL is sufficiently expressive to represent the natural language statements in a concise way.

• First-order logic is also known as Predicate logic or First-order predicate logic. First-order logic is a powerful language
that develops information about the objects in a more easy way and can also express the relationship between those
objects.

• First-order logic (like natural language) does not only assume that the world contains facts like propositional logic but
also assumes the following things in the world:

• Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......

• Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation such as: the sister of, brother of, has
color, comes between

• Function: Father of, best friend, third inning of, end of, ......
As a natural language, first-order logic also has two main parts:

• Syntax

• Semantics

Syntax of First-Order logic:

• The syntax of FOL determines which collection of symbols is a logical expression in first-order logic. The
basic syntactic elements of first-order logic are symbols. We write statements in short-hand notation in FOL.
Atomic sentences:

• Atomic sentences are the most basic sentences of first-order logic. These sentences are formed from a
predicate symbol followed by a parenthesis with a sequence of terms.

• We can represent atomic sentences as Predicate (term1, term2, ......, term n).

Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).

Chinky is a cat: => cat (Chinky).

Complex Sentences:

• Complex sentences are made by combining atomic sentences using connectives.

• First-order logic statements can be divided into two parts:

Subject: Subject is the main part of the statement.

Predicate: A predicate can be defined as a relation, which binds two atoms together in a statement.
• Consider the statement: "x is an integer.", it consists of two parts, the first part x is the subject of the
statement and second part "is an integer," is known as a predicate.

Quantifiers in First-order logic:

• A quantifier is a language element which generates quantification, and quantification specifies the quantity of specimen
in the universe of discourse.

• These are the symbols that permit to determine or identify the range and scope of the variable in the logical expression.
There are two types of quantifier:

1)Universal Quantifier, (for all, everyone, everything)

2)Existential quantifier, (for some, at least one).


Universal Quantifier:

• Universal quantifier is a symbol of logical representation, which specifies that the statement within its range is true for
everything or every instance of a particular thing.

• The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.

If x is a variable, then ∀x is read as:

• For all x

• For each x

• For every x.

Example:

All man drink coffee.

• Let a variable x which refers to a cat so all x can be represented in UOD as below:

• ∀x man(x) → drink (x, coffee).

• It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier:

• Existential quantifiers are the type of quantifiers, which express that the statement within its scope is true for at least one
instance of something.

• It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with a predicate variable then it is called
as an existential quantifier.

If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:

• There exists a 'x.'

• For some 'x.'

• For at least one 'x.'

Example:

Some boys are intelligent.

∃x: boys(x) ∧ intelligent(x)

It will be read as: There are some x where x is a boy who is intelligent.
Semantics of First-Order Logic

• Semantics in first-order logic deals with the interpretation of sentences and formulas within the framework of a mathematical
model. It provides a way to assign meanings to the symbols and structures used in first-order logic.

Key Elements of Semantics in First-Order Logic

• Variables: These represent placeholders for objects or elements within a domain.

• Constants: These represent specific elements within the domain.

• Predicates: These are expressions that can be true or false depending on the objects they’re applied to.

• Functions: These map elements from the domain to other elements in the domain.

• Quantifiers: Such as “for all” (∀) and “exists” (∃), used to express universal and existential quantification, respectively.
Representing INSTANCE and ISA Relationships:

• Specific attributes instance and isa play important role particularly in a useful form of reasoning called
property inheritance.

• The predicates instance and isa explicitly captured the relationships they are used to express, namely class
membership and class inclusion.

Below figure shows the first five sentences of the last section represented in logic in three different ways.

• The first part of the figure contains the representations we have already discussed. In these representations,
class membership is represented with unary predicates (such as Roman), each of which corresponds to a
class.

Asserting that P(x) is true is equivalent to asserting that x is an instance (or element) of P.

The second part of the figure contains representations that use the instance predicate explicitly.
Figure: Three ways of representing class membership
• The predicate instance is a binary one, whose first argument is an object and whose second argument is a class
to which the object belongs.

• But these representations do not use an explicit isa predicate.

• Instead, subclass relationships, such as that between Pompeians and Romans, are described as shown in
sentence 3.

• The implication rule states that if an object is an instance of the subclass Pompeian then it is an instance of the
superclass Roman.

• Note that this rule is equivalent to the standard set-theoretic definition of the subclass-superclass relationship.

• The third part contains representations that use both the instance and isa predicates explicitly.

• The use of the isa predicate simplifies the representation of sentence 3, but it requires that one additional axiom
(shown here as number 6) be provided.
Computable Functions and Predicates
• It may be necessary to compute functions as part of a fact. In these cases a computable predicate is used.
• A computable predicate may include computable functions such as +, -, *, etc.
• For example, gt(x-y,10) →bigger(x) contains the computable predicate gt which performs the greater
than function.
Ex 1. Marcus was a man.
man(Marcus).
2. Marcus was Pompeian.
Pompeian(Marcus).
3. Marcus was born in 40 A.D.
born(Marcus,40).
4. All men are mortal.

∀x: man(x) → mortal(x).

5. All Pompeians died when the volcano erupted in 79 A.D.

erupted(volcano,79) /\ ∀x: Pompeian(x) → died(x,79).

6. No mortal lives longer than 150 years.

∀x ∀t1 ∀t2: mortal(x) /\ born(x,t1) /\ gt(t2-t1,150) →dead(x,t2)

7. It is now 1991.

now=1991.

8. Alive means not dead.

∀x ∀t: [alive(x,t) → ~dead(x,t)] /\ [~dead(x,t)→alive(x,t)]

9. If someone dies, he is dead at all later times.

∀x ∀t1 ∀t2:died(x,t1) /\ gt(t2,t1) →dead(x,t2).


• Ex - “Is Marcus alive now?”.
~alive(Marcus,now)
↓8
~[~dead(Marcus,now)]
↓ negation operation
dead(Marcus,now)
↓9
died(Marcus,t1) /\ gt(now,t1)
↓5
erupted(volcano,79) /\ Pompeian(Marcus) /\ gt(now,79)
↓fact, 2
gt(now,79)

gt(1991,79)
↓ compute gt
nil
Disjunctive Normal Forms (DNF) :

• A formula which is equivalent to a given formula and which consists of a sum of elementary products is called a disjunctive
normal form of given formula.

Example :

(P ∧ ~ Q) ∨ (Q ∧ R) ∨ (~ P ∧ Q ∧~ R)

• The DNF of formula is not unique.

Conjunctive Normal Form (CNF) :

• A formula which is equivalent to a given formula and which consists of a product of elementary sums is called a conjunctive
normal form of given formula.

Example :

(P~ ∨ Q) ∧ (Q ∨ R) ∧ (~ P ∨ Q ∨ ~ R)

• The CNF of formula is not unique.

• If every elementary sum in CNF is tautology, then given formula is also tautology.
Unification and resolution:
What is Unification in AI?
Unification is a fundamental process in artificial intelligence (AI) and symbolic reasoning that involves finding a
common solution or "unified" form for expressions containing variables.
It is the process of making different expressions or terms identical by assigning values to variables in a way that
allows them to match or unify.
Unification plays a crucial role in knowledge representation, logic programming, and natural language processing, as
it enables AI systems to reason, infer, and handle uncertainty by reconciling disparate pieces of information.
The Role of Unification in AI:
1. Natural Language Processing (NLP): Unification is used in NLP for various tasks, such as parsing and semantic
analysis. In parsing, unification helps identify the relationships between words in a sentence, allowing the system to
build syntactic and semantic structures. Unification is also essential for handling ambiguous language constructs and
resolving pronoun references. For example, unification can help determine that "he" refers to a specific person or
entity mentioned earlier in a text.
2. Logic Programming: Unification is a cornerstone of logic programming languages like Prolog. In logic programming,
unification is used to match query predicates with database predicates. It enables the system to find solutions to logical queries
by unifying the query with known facts and rules.

For example, in a Prolog program, unification helps establish whether a given set of conditions satisfies a rule, thus making it a
fundamental mechanism for rule-based reasoning.

3. Symbolic Reasoning: In symbolic reasoning and theorem proving, unification is employed to determine whether two
logical expressions are equivalent or if one can be transformed into the other by substituting values for variables. This is
crucial for verifying the validity of logical statements and making logical inferences. Unification is an essential component of
resolution-based theorem proving methods.

4. Semantic Web and Knowledge Representation: Unification plays a significant role in the Semantic Web, where it helps
link and integrate diverse pieces of data from various sources. It facilitates knowledge representation by unifying different data
representations, making them compatible and interoperable.
5. Expert Systems: Unification is used in expert systems to match user queries with the knowledge stored in the
system's database. It helps determine which rules or pieces of information are relevant to a specific problem or
query, facilitating the expert system's decision-making process.

In essence, unification enables AI systems to reconcile, integrate, and reason about information, making it a
fundamental process for knowledge representation and reasoning. Its applications extend to various AI domains,
allowing systems to perform tasks that involve matching, resolution, and inference.
Resolution
• Resolution proves facts and answers queries by refutation. This involves assuming the fact/query is
untrue and reaching a contradiction which indicates that the opposite must be true. The wffs must
firstly be firstly converted to clause form before using resolution.
Algorithm: Converting wffs to Clause Form
1. Remove all implies, i.e. → by applying the following: a → b is equivalent to ~a \/ b.
2. Use the following rules to reduce the scope of each negation operator to a single term:
• ~(~a) = a

• ~(a /\ b) = ~a \/ ~b
• ~(a \/ b) = ~a /\ ~b
• ~∀x: p(x) = ∃x: ~p(x)

• ~∃x: p(x) = ∀x: ~p(x)


3. Each quantifier must be linked to a unique variable.

For example, consider ∀x: p(x) \/ ∀x: q(x).

In this both quantifiers are using the same variable and one must changed to another variable: ∀x: p(x) \/ ∀y: q(y).

4. Move all quantifiers, in order, to the left of each wff.

5. Remove existential quantifiers by using Skolem constants or functions.

For example, ∃x: p(x) becomes p(s1) and ∀x ∃y:

• q(x,y) is replaced with ∀x: q(s2(x), x).

6. Drop the quantifier prefix.

7. Apply the associative property of disjunctions: a \/ (b \/ c) =

(a \/ b) \/ c and remove brackets giving a \/ b \/ c.


8. Remove all disjunctions of conjunctions from predicates, i.e.

• create conjunctions of disjunctions instead, by applying the

• following rule iteratively: (a /\ b) \/ c = (a \/ c) /\ (b \/ c).

9. Create a separate clause for each conjunction.

10. Rename variables in the clauses resulting from step 9. to ensure that no two clauses refer to the same variable.

Algorithm: Resolution

1. Convert the wffs to clause form.

2. Add the fact (or query) P to be proved to the set of clauses:

i. Negate P.

ii. Convert negated P to clause form.

iii. Add the result of ii to the set of clauses.


3. Repeat

i. Select two clauses.

ii. Resolve the clauses using unification.

iii. If the resolvent clause is the empty clause, then a contradiction has been reached. If not add the resolvent to the set of clauses.

Consider the following wffs:

1. man(Marcus).

man(Marcus).

2. Pompeian(Marcus).

Pompeian(Marcus).

3. ∀x: Pompeian(x) → Roman(x).

~Pompeian(x) \/ Roman(x).

4. ruler(Caesar).

ruler(Caesar).
5. ∀x: Roman(x) → loyalto(x,Caesar) \/ hate(x,Caesar).

~Roman(x1) \/ loyalto(x1,Caesar) \/ hate(x1,Caesar).

6. ∀x ∃y: loyalto(x,y)

loyalto(x2,s1(x2))

7. ∀x ∀y: person(x) /\ ruler(y) /\ tryassassinate(x,y) →

~loyalto(x,y)

~person(x3) \/ ~ruler(y) \/ ~tryassassinate(x3,y) \/

~loyalto(x3,y)

8. tryassassinate(Marcus,Caesar).

tryassassinate(Marcus, Caesar).

9. ∀x: man(x) → person(x)

~man(x4) \/ person(x4)
• we want to prove that Marcus hates Caesar.

• We firstly convert this to a wff: hate(Marcus,Caesar).

• The wff is then negated and converted to clause form:


~hate(Marcus,Caesar).
This clause is added to the set of clauses and the resolution is algorithm is applied:
~hate(Marcus,Caesar)
↓5
~Roman(Marcus) \/ loyalto(x1,Caesar)
↓3
~Pompeian(Marcus) \/ loyalto(Marcus,Caesar)
↓2
loyalto(Marcus,Caesar)
↓7
~person(Marcus) \/ ~ruler(Caesar) \/ ~tryassassinate(Marcus,Caesar)
↓4
~person(Marcus) \/ ~tryassassinate(Marcus,Caesar)
↓8
~person(Marcus)
↓9
~man(Marcus)
↓1
Natural Deduction

• Normal human reasoning is generally a train of thought moving linearly from the premises to the conclusion.

• This natural process is mimicked by the "Natural"Deduction Method of Propositional Logic (also called Propositional
Calculus, abbreviated PC).

• This method in PC is what is used in mathematics proofs.

• A Natural Deduction proof in PC is a sequence of wffs beginning with one or more wffs as premises; fresh premises may
be added at any point in the course of a proof.

• New wffs are generated by applying "rules" to any wff or a group of wffs that have already occurred in the sequence.

• This means a Natural Deduction system has two aspects: A set of rules and a method for applying the rules.

• Thus it is similar to the procedure of deriving theorems in mathematics.

• So we turn the situation around and say that all mathematics proofs are instances of Natural Deduction.

You might also like