Ai Chapter-4
Ai Chapter-4
Logic
• The logical formalism of a language is useful because it immediately suggests a powerful
way of deriving new knowledge from old using mathematical deduction.
• In this formalism, we can conclude that a new statement is true by proving that it follows
from the statements that are already known.
Proposition
▪ A proposition is a statement, or a simple declarative sentence.
▪ For example, “the book is expensive” is a proposition.
▪ A proposition can be either true or false.
Propositional logic
▪ Logical constants: true, false
▪ Propositional symbols: P, Q, S,... (atomic sentences)
▪ Propositions are combined by connectives:
and [conjunction]
or [disjunction]
implies [implication]
not [negation]
∀ For all
∃ There exists
▪ Propositional logic is a simple language useful for showing key ideas and definitions.
▪ User defines a set of propositional symbols, like P and Q.
▪ User defines the semantics of each propositional symbol:
P means “It is hot”
Q means “It is humid”
R means “It is raining”
• A sentence (well-formed formula) is defined as follows:
➢ A symbol is a sentence.
➢ If S is a sentence, then S is a sentence.
➢ If S is a sentence, then (S) is a sentence.
➢ If S and T are sentences, then (S T), (S T), (S → T), and (S ↔ T) are sentences
➢ A sentence results from a finite number of applications of the above rules.
• Real world facts can be represented by well-formed formulas (wffs) in propositional
logic.
Predicate logic
• First-order Predicate logic (FOPL) models the world in terms of
o Objects, which are things with individual identities
o Properties of objects that distinguish them from other objects
o Relations that hold among sets of objects
o Functions, which are a subset of relations where there is only one “value” for any
given “input”
• First-order Predicate logic (FOPL) provides
o Constants: a, b, dog33. Name a specific object.
o Variables: X, Y. Refer to an object without naming it.
o Functions: Mapping from objects to objects.
o Terms: Refer to objects
o Atomic Sentences: in(dad-of(X), food6) Can be true or false, Correspond to
propositional symbols P, Q.
o A well-formed formula (wff) is a sentence containing no “free” variables. That is, all
variables are “bound” by universal or existential quantifiers.
(x)P(x, y) has x bound as a universally quantified variable, but y is free.
Quantifiers
• Universal quantification
(x)P(x) means that P holds for all values of x in the domain associated with that
Gopi Sanghani, CE Department | 2180703 – Artificial Intelligence 2
4 – Using Predicate Logic
variable
E.g., (x) dolphin(x) → mammal(x)
• Existential quantification
( x)P(x) means that P holds for some value of x in the domain associated with that
variable
E.g., ( x) mammal(x) lays-eggs(x)
• Consider the following example that shows the use of predicate logic as a way of
representing knowledge.
1. Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeians were Romans.
4. Caesar was a ruler.
5. All Pompeians were either loyal to Caesar or hated him.
6. Everyone is loyal to someone.
7. People only try to assassinate rulers they are not loyal to.
8. Marcus tried to assassinate Caesar.
• The facts described by these sentences can be represented as a set of well-formed formulas
(wffs) as follows:
1. Marcus was a man.
man(Marcus)
2. Marcus was a Pompeian.
Pompeian(Marcus)
3. All Pompeians were Romans.
x: Pompeian(x) → Roman(x)
4. Caesar was a ruler.
ruler(Caesar)
5. All Pompeians were either loyal to Caesar or hated him.
inclusive-or
x: Roman(x) → loyalto(x, Caesar) hate(x, Caesar)
exclusive-or
x: Roman(x) → (loyalto(x, Caesar) hate(x, Caesar))
(loyalto(x, Caesar) hate(x, Caesar))
6. Every-one is loyal to someone.
x: y: loyalto(x, y)
7. People only try to assassinate rulers they are not loyal to.
x: y: person(x) ruler(y) tryassassinate(x, y)
→ loyalto(x, y)
8. Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)
• The problem is that, although we know that Marcus was a man, we do not have any way
to conclude from that that Marcus was a person. We need to add the representation of
another fact to our system, namely:
∀ : man(x) → person(x)
• Now we can satisfy the last goal and produce a proof that Marcus was not loyal to
Caesar.
• From this simple example, we see that three important issues must be addressed in the
process of converting English sentences into logical statements and then using those
statements to deduce new ones:
1. Many English sentences are ambiguous (for example, 5, 6, and 7 above).
Choosing the correct interpretation may be difficult.
2. There is often a choice of how to represent the knowledge. Simple
representations are desirable, but they may exclude certain kinds of reasoning.
3. Even in very simple situations, a set of sentences is unlikely to contain all the
information necessary to reason about the topic at hand. In order to be able to
use a set of statements effectively, it is usually necessary to have access to
another set of statements that represent facts that people consider too obvious
to mention.
• 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.
Resolution
• Resolution is a procedure, which gains its efficiency from the fact that it operates on
statements that have been converted to a very convenient standard form.
Example: Consider the following facts. Translate given sentences into formulas in predicate logic.
Prove by resolution the given fact.
• To prove hate (Marcus, Caesar) we start with a negation of it as ¬hate (Marcus, Caesar).
7 loyalto(Marcus, Caesar)
¬tryassassinate(Marcus, Caesar) 8
• Final resolvent is an empty clause means that a contradiction is found in the initial
assumption so, proved hate (Marcus, Caesar).