SlideShare a Scribd company logo
Knowledge representationKnowledge representation
using Predicate logicusing Predicate logic
Dr.V.Manjula ,
Prof/CSE,
VEL TECH HIGH TECH Dr. RANGARAJAN Dr. SAKUNTHALA
ENGINEERING COLLEGE.
LogicLogic
2
Formal Language and their ontological and epistemological commitments
3
Review of PropositionalReview of Propositional
LogicLogic
Let P: Today is Sunday
Q: We have guests
P ∧ Q : Today is Sunday and We have guests
P ∨ Q : Today is Sunday or We have guests
¬P : Today is not Sunday.
P → Q : if today is Sunday then we have guests.
P ↔ Q : Today is Sunday if and only if we have guests.
Propositional variables
Propositional constants: T, F
Logical connectives
4
SemanticsSemantics
Propositions and expressions have
truth values: can be true or false.
The truth value of an expression is
determined by truth tables, e.g.:
P Q P v Q
T T T
T F T
F T T
F F F
5
Propositional Proof TheoryPropositional Proof Theory
Propositional proof theory: A set of axioms
(logical identities) and inference rules used to
manipulate expressions and to obtain true
expressions out of other true expressions.
Inference rules: give a mechanical procedure to
obtain true expressions out of other true
expressions.
Modus ponens: P, P → Q |= Q
6
Knowledge representationKnowledge representation
using predicate logicusing predicate logic
Some books are interesting.
∃ x (book(x) Λ interesting(x))
Anybody that has a friend is not lonely
(If someone has a friend, they are not lonely)
∀x (∃ y friend(x,y)  ~lonely(x))
7
Predicate LogicPredicate Logic
Represents properties and relations by
using predicates with arguments.
likes(mary,apples) ∧ ¬likes(mary,grapes)
Quantifiers: indicate the scope of the predicate
Universal quantifier:
∀ X likes ( mary , X) Mary likes everything
Existential quantifier
∃ X likes ( mary , X)
there is something which Mary likes.
8
Proof Theory for Predicate LogicProof Theory for Predicate Logic
Based on the resolution procedure.
Unification: matching predicates with variables
to atomic sentences (matching variables to
constants.)
Example: Is Socrates mortal?
∀ X (human(X)  mortal(X))
human(socrates)
human(plato)
alien(spock)
Inferencing in Predicate LogicInferencing in Predicate Logic
 Forward chainingForward chaining
 Given P,Given P, , to infer Q, to infer Q
 P, matchP, match L.H.SL.H.S ofof
 Assert Q fromAssert Q from R.H.SR.H.S
 Backward chainingBackward chaining
 Q, MatchQ, Match R.H.SR.H.S ofof
 assert Passert P
 Check if P existsCheck if P exists
 Resolution – RefutationResolution – Refutation
 Negate goalNegate goal
 Convert all pieces of knowledge into clausal form (disjunction ofConvert all pieces of knowledge into clausal form (disjunction of
literals)literals)
 See if contradiction indicated by null clause can be derivedSee if contradiction indicated by null clause can be derived
QP →
QP →
10
ResolutionResolution
A ∨ B, ¬B ∨ C |= A ∨ C
compare with: B, ¬B ∨ C |= C
(B →C = ¬B ∨ C)
If B is true, then C must be true, if B is false
than A must be true.
This means that WHENEVER the conjunction
(A ∨ B) ∧ (¬B ∨ C) is true, A ∨ C is also true.
11
How resolution worksHow resolution works
¬P1 v P2 ¬P2
¬P1 P1 v P3 v P4
P3 v P4 This is the conclusion
Eliminate opposite literals and rewrite two
expressions as one
12
Proof by refutationProof by refutation
P4 v ¬P6 P6
P4 ¬P4
Add the negation of the
statement to be proved
contradiction
Resolution in First-Order LogicResolution in First-Order Logic
13
Basic steps for proving a conclusion S given premises
Premise1, …, Premisen
(all expressed in FOL):
1. Convert all sentences to CNF
2. Negate conclusion S & convert result to CNF
3. Add negated conclusion S to the premise clauses
4. Repeat until contradiction or no progress is made:
a. Select 2 clauses (call them parent clauses)
b. Resolve them together, performing all required
unifications
c. If resolvent is the empty clause, a contradiction
has been found (i.e., S follows from the premises)
d. If not, add resolvent to the premises
If we succeed in Step 4, we have proved the conclusion
March 14, 2006
AI: Chapter 9: Inference in
First-Order Logic14
UnificationUnification
 UnificationUnification: The process of finding all legal: The process of finding all legal
substitutions that make logical expressions looksubstitutions that make logical expressions look
identicalidentical
 This is a recursive algorithmThis is a recursive algorithm
March 14, 2006
AI: Chapter 9: Inference in
First-Order Logic15
UnificationUnification
 We can get the inference immediately if we canWe can get the inference immediately if we can
find a substitutionfind a substitution θθ such that King(x) andsuch that King(x) and
Greedy(x) match King(John) and Greedy(y)Greedy(x) match King(John) and Greedy(y)
 θθ = {x/John, y/John} works= {x/John, y/John} works
 Unify(Unify(αα,,ββ) =) = θθ ifif αα θθ == ββ θθ
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Resolution ExamplesResolution Examples
30
31
Resolution ExamplesResolution Examples
32
33
Predicate CalculusPredicate Calculus
 Introduction through an exampleIntroduction through an example (Zohar Manna, 1974):(Zohar Manna, 1974):
 Problem: A, B and C belong to the Himalayan club. EveryProblem: A, B and C belong to the Himalayan club. Every
member in the club is either a mountain climber or a skier ormember in the club is either a mountain climber or a skier or
both. A likes whatever B dislikes and dislikes whatever Bboth. A likes whatever B dislikes and dislikes whatever B
likes. A likes rain and snow. No mountain climber likes rain.likes. A likes rain and snow. No mountain climber likes rain.
Every skier likes snow.Every skier likes snow. Is there a member who is a mountain climberIs there a member who is a mountain climber
and not a skier?and not a skier?
 Given knowledge has:Given knowledge has:
 FactsFacts
 RulesRules
Predicate Calculus: ExamplePredicate Calculus: Example
contd.contd.
 LetLet mcmc denote mountain climber anddenote mountain climber and sksk denotes skier. Knowledgedenotes skier. Knowledge
representation in the given problem is as follows:representation in the given problem is as follows:
1.1. member(A)member(A)
2.2. member(B)member(B)
3.3. member(C)member(C)
4.4. ∀∀x[member(x) → (mc(x) sk(x))]∨x[member(x) → (mc(x) sk(x))]∨
5.5. ∀∀x[mc(x) → ~like(x,rain)]x[mc(x) → ~like(x,rain)]
6.6. ∀∀x[sk(x) → like(x, snow)]x[sk(x) → like(x, snow)]
7.7. ∀∀x[like(B, x) → ~like(A, x)]x[like(B, x) → ~like(A, x)]
8.8. ∀∀x[~like(B, x) → like(A, x)]x[~like(B, x) → like(A, x)]
9.9. like(A, rain)like(A, rain)
10.10. like(A, snow)like(A, snow)
11.11. Question: x[member(x) mc(x) ~sk(x)]∃ ∧ ∧Question: x[member(x) mc(x) ~sk(x)]∃ ∧ ∧
 We have to infer the 11We have to infer the 11thth
expression from the given 10.expression from the given 10.
 Done through Resolution Refutation.Done through Resolution Refutation.
1.1. PP
2.2. converted toconverted to
3.3.
Draw the resolution tree (actually an invertedDraw the resolution tree (actually an inverted
tree). Every node is a clausal form andtree). Every node is a clausal form and
branches are intermediate inference steps.branches are intermediate inference steps.
QP → QP ∨~
Q~
Q~
QP ∨~
P~ P
TerminologyTerminology
 Pair of clauses beingPair of clauses being resolvedresolved is called theis called the
ResolventsResolvents. The resulting clause is called the. The resulting clause is called the
ResoluteResolute..
 Choosing the correct pair of resolvents is aChoosing the correct pair of resolvents is a
matter of search.matter of search.
Club example revisitedClub example revisited
1. member(A)
2. member(B)
3. member(C)
4.
– Can be written as
–
5.
–
6.
–
7.
–
))]()(()([ xskxmcxmemberx ∨→∀
))]()(()([ xskxmcxmember ∨→
)()()(~ xskxmcxmember ∨∨
)],()([ snowxlkxskx →∀
),()(~ snowxlkxsk ∨
)],(~)([ rainxlkxmcx →∀
),(~)(~ rainxlkxmc ∨
)],(~),([ xBlkxAlkx →∀
),(~),(~ xBlkxAlk ∨
8.8.
–
9.9.
10.10.
11.11.
– Negate–Negate–
)],(),([~ xBlkxAlkx →∀
),(),( xBlkxAlk ∨
),( rainAlk
),( snowAlk
)](~)()([ xskxmcxmemberx ∧∧∃
)]()(~)([~ xskxmcxmemberx ∨∨∀
 Now standardize the variables apart whichNow standardize the variables apart which
results in the followingresults in the following
1. member(A)
2. member(B)
3. member(C)
4.
5.
6.
7.
8.
9.
10.
11.
)()()(~ 111 xskxmcxmember ∨∨
),()(~ 22 snowxlkxsk ∨
),(~)(~ 33 rainxlkxmc ∨
),(~),(~ 44 xBlkxAlk ∨
),(),( 55 xBlkxAlk ∨
),( rainAlk
),( snowAlk
)]()(~)([~ 666 xskxmcxmemberx ∨∨∀
),(~),(~ 44 xBlkxAlk ∨ ),( snowAlk
),(~ snowBlk ),()(~ 22 snowxlkxsk ∨
)()()(~ 111 xskxmcxmember ∨∨)(~ Bsk
)()(~ BmcBmember ∨ )(Bmember
)(Bmc)]()(~)([~ 666 xskxmcxmemberx ∨∨∀
)()(~ BskBmember ∨ )(~ Bsk
)(~ Bmember )(Bmember
7
10
12 5
13 4
14 2
11
15
16 13
17 2
42
Prolog exampleProlog example
Predicate logic representation is used only on paper.
Computational implementation: logic
programming languages
In Logic and in Prolog:
∀ X ∀ Y (father(X,Y) v mother(X,Y)  parent(X,Y))
∀ X ∀ Y( (∃ Z(parent(Z,X) ∧ parent(Z,Y)) 
siblings(X,Y))
parent(X,Y):- father(X,Y).
parent(X,Y):- mother(X,Y).
siblings(X,Y):- parent(Z,X),parent(Z,Y).
Example -2Example -2
43
Converting Statements into Predicate Logic Formulae (WFFs):
1.All employees earning Rs 500000 or more per year pay taxes.
2.Some employees are sick today.
3.No employees earns more than the president.
Let
• E(x) : for x is an employee
• P(x) : for x is a President
• i(x) : for the income of x (lower case – denotes function not
predicate)
• GE(u,v) for u is greater than or equal to v
• S(x) for x is sick today
• T(x) for x pays taxes
Then : Formulae in FOPL are :
1 : x ((E(x)∀ ∧ GE(i(x), 500000)) ⇒T(x))
2 : x(E(y)∃ ⇒ S(x))
3 : x y((E(x)∀ ∀ ∧ P(y)) ⇒ ~GE(i(x), i(y)))
Example -3Example -3
44
i. John likes all kinds of food.
ii. Apples are food.
iii.Chicken is food.
iv.Anything anyone eats and isn’t killed by is
food.
v. Bill eats peanuts, and is still alive.
vi.Sue eats everything that Bill eats.
Prove that “John likes peanuts”
45
John likes all kinds of
food
∀x food (x) ⇒ eats(John, x)
Apples are food. food(apples)
Chicken is food. food(chicken)
Anything anyone eats and
isn’t killed by is food.
∀x,y eats(x,y) ∧ ¬killed(x)
⇒ food(y)
Bill eats peanuts, and is
still alive.
eats(Bill,Peanuts) ∧
¬killed(Bill)
Sue eats everything that
Bill eats.
∀x eats (Bill,x) ⇒
eats(Sue,x)
Another way of writingAnother way of writing
46
(a) Well Formed Formulas
1.  x Food(x) → Likes(John, x)∀
2. Food(Apples)
3. Food(Chicken)
4.  x y Eats(y, x)   ¬KilledBy(y, x) → Food(x)∀ ∃ ∧
5. Eats(Bill, Peanuts)   ¬KilledBy(Bill, Peanuts)∧
6.  x Eats(Bill, x) → Eats(Sue, x)∀
(b) Convert the formulas of part (a) into clause form.
1. ¬Food(x)   Likes(John, x)∨
2. Food(Apples)
3. Food(Chicken)
4. ¬Eats(y, x)   KilledBy(y, x)   Food(x)∨ ∨
5. Eats(Bill, Peanuts)
6. ¬KilledBy(Bill, Peanuts)
7. ¬Eats(Bill, x)   Eats(Sue, x)∨
ResolutionResolution
47
(d) Use resolution to prove that John likes
peanuts.
8. ¬Likes(John, Peanuts) negated conclusion
9. ¬Food(Peanuts) 1 and 8
10. ¬Eats(y, Peanuts)   KilledBy(y, Peanuts) 4 and 9∨
11. KilledBy(Bill, Peanuts) 5 and 10
12.   6 and 11⊥
(e) Use resolution to answer the question, “What
food does Sue eat?”
13. ¬Eats(Sue, x) negated query
14. ¬Eats(Bill, x) 7 and 13
15.   5 and 14, unifying Peanuts/x⊥

More Related Content

PPT
Heuristic Search Techniques Unit -II.ppt
PPT
Predicate logic_2(Artificial Intelligence)
PPTX
Propositional logic
PPTX
Knowledge representation and Predicate logic
PPTX
Truth management system
PPTX
Semantic nets in artificial intelligence
PPTX
Probabilistic Reasoning
PDF
AI_ 3 & 4 Knowledge Representation issues
Heuristic Search Techniques Unit -II.ppt
Predicate logic_2(Artificial Intelligence)
Propositional logic
Knowledge representation and Predicate logic
Truth management system
Semantic nets in artificial intelligence
Probabilistic Reasoning
AI_ 3 & 4 Knowledge Representation issues

What's hot (20)

PPTX
Unification and Lifting
PPTX
Planning in AI(Partial order planning)
PPT
Knowledge Representation in Artificial intelligence
PPTX
Problem Formulation in Artificial Inteligence Projects
PDF
I. AO* SEARCH ALGORITHM
PPTX
knowledge representation using rules
PPT
predicate logic example
PPTX
Dempster shafer theory
PPTX
Knowledge representation in AI
PDF
Bayes Belief Networks
PPT
Propositional And First-Order Logic
PDF
Artificial Intelligence Notes Unit 2
PPT
Planning
PDF
Production System in AI
PPTX
Knowledge representation In Artificial Intelligence
PDF
State Space Search in ai
PPTX
Planning
PPTX
Forward and Backward chaining in AI
PPTX
Fuzzy rules and fuzzy reasoning
Unification and Lifting
Planning in AI(Partial order planning)
Knowledge Representation in Artificial intelligence
Problem Formulation in Artificial Inteligence Projects
I. AO* SEARCH ALGORITHM
knowledge representation using rules
predicate logic example
Dempster shafer theory
Knowledge representation in AI
Bayes Belief Networks
Propositional And First-Order Logic
Artificial Intelligence Notes Unit 2
Planning
Production System in AI
Knowledge representation In Artificial Intelligence
State Space Search in ai
Planning
Forward and Backward chaining in AI
Fuzzy rules and fuzzy reasoning
Ad

Similar to L03 ai - knowledge representation using logic (20)

PPT
Predicate calculus
PPT
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
PDF
16_FirstOrderLogic.p_4_moduleModuleNotespdf
PPT
predicate logic in artificial intelligence for knowledge representation ppt
PPT
Predlogic
PPTX
AIML 7th semester VTU
PPT
3 fol examples v2
PDF
Logic programming (1)
PDF
PPT
01bkb04p.ppt
PPT
knowledge representation in artificial intellegence.ppt
PDF
Formal Logic - Lesson 8 - Predicates and Quantifiers
PPT
1019Lec1.ppt
PPT
Propositional Logic and Pridicate logic
PDF
Chapter 01 - p2.pdf
PPT
PropositionalLogic.ppt
PPT
PredicateLogic or FOL for Computer Science
PPT
Lec8-PredicateLogic knowledge representation.ppt
PPTX
Predicate logic
PPTX
#4 formal methods – predicate logic
Predicate calculus
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
16_FirstOrderLogic.p_4_moduleModuleNotespdf
predicate logic in artificial intelligence for knowledge representation ppt
Predlogic
AIML 7th semester VTU
3 fol examples v2
Logic programming (1)
01bkb04p.ppt
knowledge representation in artificial intellegence.ppt
Formal Logic - Lesson 8 - Predicates and Quantifiers
1019Lec1.ppt
Propositional Logic and Pridicate logic
Chapter 01 - p2.pdf
PropositionalLogic.ppt
PredicateLogic or FOL for Computer Science
Lec8-PredicateLogic knowledge representation.ppt
Predicate logic
#4 formal methods – predicate logic
Ad

Recently uploaded (20)

PDF
Model Code of Practice - Construction Work - 21102022 .pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
composite construction of structures.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
additive manufacturing of ss316l using mig welding
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
DOCX
573137875-Attendance-Management-System-original
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Construction Project Organization Group 2.pptx
PPTX
Geodesy 1.pptx...............................................
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
Model Code of Practice - Construction Work - 21102022 .pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
composite construction of structures.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
OOP with Java - Java Introduction (Basics)
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Fundamentals of safety and accident prevention -final (1).pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
III.4.1.2_The_Space_Environment.p pdffdf
UNIT 4 Total Quality Management .pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
additive manufacturing of ss316l using mig welding
CH1 Production IntroductoryConcepts.pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Automation-in-Manufacturing-Chapter-Introduction.pdf
573137875-Attendance-Management-System-original
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Construction Project Organization Group 2.pptx
Geodesy 1.pptx...............................................
Operating System & Kernel Study Guide-1 - converted.pdf

L03 ai - knowledge representation using logic

  • 1. Knowledge representationKnowledge representation using Predicate logicusing Predicate logic Dr.V.Manjula , Prof/CSE, VEL TECH HIGH TECH Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE.
  • 2. LogicLogic 2 Formal Language and their ontological and epistemological commitments
  • 3. 3 Review of PropositionalReview of Propositional LogicLogic Let P: Today is Sunday Q: We have guests P ∧ Q : Today is Sunday and We have guests P ∨ Q : Today is Sunday or We have guests ¬P : Today is not Sunday. P → Q : if today is Sunday then we have guests. P ↔ Q : Today is Sunday if and only if we have guests. Propositional variables Propositional constants: T, F Logical connectives
  • 4. 4 SemanticsSemantics Propositions and expressions have truth values: can be true or false. The truth value of an expression is determined by truth tables, e.g.: P Q P v Q T T T T F T F T T F F F
  • 5. 5 Propositional Proof TheoryPropositional Proof Theory Propositional proof theory: A set of axioms (logical identities) and inference rules used to manipulate expressions and to obtain true expressions out of other true expressions. Inference rules: give a mechanical procedure to obtain true expressions out of other true expressions. Modus ponens: P, P → Q |= Q
  • 6. 6 Knowledge representationKnowledge representation using predicate logicusing predicate logic Some books are interesting. ∃ x (book(x) Λ interesting(x)) Anybody that has a friend is not lonely (If someone has a friend, they are not lonely) ∀x (∃ y friend(x,y)  ~lonely(x))
  • 7. 7 Predicate LogicPredicate Logic Represents properties and relations by using predicates with arguments. likes(mary,apples) ∧ ¬likes(mary,grapes) Quantifiers: indicate the scope of the predicate Universal quantifier: ∀ X likes ( mary , X) Mary likes everything Existential quantifier ∃ X likes ( mary , X) there is something which Mary likes.
  • 8. 8 Proof Theory for Predicate LogicProof Theory for Predicate Logic Based on the resolution procedure. Unification: matching predicates with variables to atomic sentences (matching variables to constants.) Example: Is Socrates mortal? ∀ X (human(X)  mortal(X)) human(socrates) human(plato) alien(spock)
  • 9. Inferencing in Predicate LogicInferencing in Predicate Logic  Forward chainingForward chaining  Given P,Given P, , to infer Q, to infer Q  P, matchP, match L.H.SL.H.S ofof  Assert Q fromAssert Q from R.H.SR.H.S  Backward chainingBackward chaining  Q, MatchQ, Match R.H.SR.H.S ofof  assert Passert P  Check if P existsCheck if P exists  Resolution – RefutationResolution – Refutation  Negate goalNegate goal  Convert all pieces of knowledge into clausal form (disjunction ofConvert all pieces of knowledge into clausal form (disjunction of literals)literals)  See if contradiction indicated by null clause can be derivedSee if contradiction indicated by null clause can be derived QP → QP →
  • 10. 10 ResolutionResolution A ∨ B, ¬B ∨ C |= A ∨ C compare with: B, ¬B ∨ C |= C (B →C = ¬B ∨ C) If B is true, then C must be true, if B is false than A must be true. This means that WHENEVER the conjunction (A ∨ B) ∧ (¬B ∨ C) is true, A ∨ C is also true.
  • 11. 11 How resolution worksHow resolution works ¬P1 v P2 ¬P2 ¬P1 P1 v P3 v P4 P3 v P4 This is the conclusion Eliminate opposite literals and rewrite two expressions as one
  • 12. 12 Proof by refutationProof by refutation P4 v ¬P6 P6 P4 ¬P4 Add the negation of the statement to be proved contradiction
  • 13. Resolution in First-Order LogicResolution in First-Order Logic 13 Basic steps for proving a conclusion S given premises Premise1, …, Premisen (all expressed in FOL): 1. Convert all sentences to CNF 2. Negate conclusion S & convert result to CNF 3. Add negated conclusion S to the premise clauses 4. Repeat until contradiction or no progress is made: a. Select 2 clauses (call them parent clauses) b. Resolve them together, performing all required unifications c. If resolvent is the empty clause, a contradiction has been found (i.e., S follows from the premises) d. If not, add resolvent to the premises If we succeed in Step 4, we have proved the conclusion
  • 14. March 14, 2006 AI: Chapter 9: Inference in First-Order Logic14 UnificationUnification  UnificationUnification: The process of finding all legal: The process of finding all legal substitutions that make logical expressions looksubstitutions that make logical expressions look identicalidentical  This is a recursive algorithmThis is a recursive algorithm
  • 15. March 14, 2006 AI: Chapter 9: Inference in First-Order Logic15 UnificationUnification  We can get the inference immediately if we canWe can get the inference immediately if we can find a substitutionfind a substitution θθ such that King(x) andsuch that King(x) and Greedy(x) match King(John) and Greedy(y)Greedy(x) match King(John) and Greedy(y)  θθ = {x/John, y/John} works= {x/John, y/John} works  Unify(Unify(αα,,ββ) =) = θθ ifif αα θθ == ββ θθ
  • 16. 16
  • 17. 17
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 31. 31
  • 33. 33
  • 34. Predicate CalculusPredicate Calculus  Introduction through an exampleIntroduction through an example (Zohar Manna, 1974):(Zohar Manna, 1974):  Problem: A, B and C belong to the Himalayan club. EveryProblem: A, B and C belong to the Himalayan club. Every member in the club is either a mountain climber or a skier ormember in the club is either a mountain climber or a skier or both. A likes whatever B dislikes and dislikes whatever Bboth. A likes whatever B dislikes and dislikes whatever B likes. A likes rain and snow. No mountain climber likes rain.likes. A likes rain and snow. No mountain climber likes rain. Every skier likes snow.Every skier likes snow. Is there a member who is a mountain climberIs there a member who is a mountain climber and not a skier?and not a skier?  Given knowledge has:Given knowledge has:  FactsFacts  RulesRules
  • 35. Predicate Calculus: ExamplePredicate Calculus: Example contd.contd.  LetLet mcmc denote mountain climber anddenote mountain climber and sksk denotes skier. Knowledgedenotes skier. Knowledge representation in the given problem is as follows:representation in the given problem is as follows: 1.1. member(A)member(A) 2.2. member(B)member(B) 3.3. member(C)member(C) 4.4. ∀∀x[member(x) → (mc(x) sk(x))]∨x[member(x) → (mc(x) sk(x))]∨ 5.5. ∀∀x[mc(x) → ~like(x,rain)]x[mc(x) → ~like(x,rain)] 6.6. ∀∀x[sk(x) → like(x, snow)]x[sk(x) → like(x, snow)] 7.7. ∀∀x[like(B, x) → ~like(A, x)]x[like(B, x) → ~like(A, x)] 8.8. ∀∀x[~like(B, x) → like(A, x)]x[~like(B, x) → like(A, x)] 9.9. like(A, rain)like(A, rain) 10.10. like(A, snow)like(A, snow) 11.11. Question: x[member(x) mc(x) ~sk(x)]∃ ∧ ∧Question: x[member(x) mc(x) ~sk(x)]∃ ∧ ∧  We have to infer the 11We have to infer the 11thth expression from the given 10.expression from the given 10.  Done through Resolution Refutation.Done through Resolution Refutation.
  • 36. 1.1. PP 2.2. converted toconverted to 3.3. Draw the resolution tree (actually an invertedDraw the resolution tree (actually an inverted tree). Every node is a clausal form andtree). Every node is a clausal form and branches are intermediate inference steps.branches are intermediate inference steps. QP → QP ∨~ Q~ Q~ QP ∨~ P~ P
  • 37. TerminologyTerminology  Pair of clauses beingPair of clauses being resolvedresolved is called theis called the ResolventsResolvents. The resulting clause is called the. The resulting clause is called the ResoluteResolute..  Choosing the correct pair of resolvents is aChoosing the correct pair of resolvents is a matter of search.matter of search.
  • 38. Club example revisitedClub example revisited 1. member(A) 2. member(B) 3. member(C) 4. – Can be written as – 5. – 6. – 7. – ))]()(()([ xskxmcxmemberx ∨→∀ ))]()(()([ xskxmcxmember ∨→ )()()(~ xskxmcxmember ∨∨ )],()([ snowxlkxskx →∀ ),()(~ snowxlkxsk ∨ )],(~)([ rainxlkxmcx →∀ ),(~)(~ rainxlkxmc ∨ )],(~),([ xBlkxAlkx →∀ ),(~),(~ xBlkxAlk ∨
  • 39. 8.8. – 9.9. 10.10. 11.11. – Negate–Negate– )],(),([~ xBlkxAlkx →∀ ),(),( xBlkxAlk ∨ ),( rainAlk ),( snowAlk )](~)()([ xskxmcxmemberx ∧∧∃ )]()(~)([~ xskxmcxmemberx ∨∨∀
  • 40.  Now standardize the variables apart whichNow standardize the variables apart which results in the followingresults in the following 1. member(A) 2. member(B) 3. member(C) 4. 5. 6. 7. 8. 9. 10. 11. )()()(~ 111 xskxmcxmember ∨∨ ),()(~ 22 snowxlkxsk ∨ ),(~)(~ 33 rainxlkxmc ∨ ),(~),(~ 44 xBlkxAlk ∨ ),(),( 55 xBlkxAlk ∨ ),( rainAlk ),( snowAlk )]()(~)([~ 666 xskxmcxmemberx ∨∨∀
  • 41. ),(~),(~ 44 xBlkxAlk ∨ ),( snowAlk ),(~ snowBlk ),()(~ 22 snowxlkxsk ∨ )()()(~ 111 xskxmcxmember ∨∨)(~ Bsk )()(~ BmcBmember ∨ )(Bmember )(Bmc)]()(~)([~ 666 xskxmcxmemberx ∨∨∀ )()(~ BskBmember ∨ )(~ Bsk )(~ Bmember )(Bmember 7 10 12 5 13 4 14 2 11 15 16 13 17 2
  • 42. 42 Prolog exampleProlog example Predicate logic representation is used only on paper. Computational implementation: logic programming languages In Logic and in Prolog: ∀ X ∀ Y (father(X,Y) v mother(X,Y)  parent(X,Y)) ∀ X ∀ Y( (∃ Z(parent(Z,X) ∧ parent(Z,Y))  siblings(X,Y)) parent(X,Y):- father(X,Y). parent(X,Y):- mother(X,Y). siblings(X,Y):- parent(Z,X),parent(Z,Y).
  • 43. Example -2Example -2 43 Converting Statements into Predicate Logic Formulae (WFFs): 1.All employees earning Rs 500000 or more per year pay taxes. 2.Some employees are sick today. 3.No employees earns more than the president. Let • E(x) : for x is an employee • P(x) : for x is a President • i(x) : for the income of x (lower case – denotes function not predicate) • GE(u,v) for u is greater than or equal to v • S(x) for x is sick today • T(x) for x pays taxes Then : Formulae in FOPL are : 1 : x ((E(x)∀ ∧ GE(i(x), 500000)) ⇒T(x)) 2 : x(E(y)∃ ⇒ S(x)) 3 : x y((E(x)∀ ∀ ∧ P(y)) ⇒ ~GE(i(x), i(y)))
  • 44. Example -3Example -3 44 i. John likes all kinds of food. ii. Apples are food. iii.Chicken is food. iv.Anything anyone eats and isn’t killed by is food. v. Bill eats peanuts, and is still alive. vi.Sue eats everything that Bill eats. Prove that “John likes peanuts”
  • 45. 45 John likes all kinds of food ∀x food (x) ⇒ eats(John, x) Apples are food. food(apples) Chicken is food. food(chicken) Anything anyone eats and isn’t killed by is food. ∀x,y eats(x,y) ∧ ¬killed(x) ⇒ food(y) Bill eats peanuts, and is still alive. eats(Bill,Peanuts) ∧ ¬killed(Bill) Sue eats everything that Bill eats. ∀x eats (Bill,x) ⇒ eats(Sue,x)
  • 46. Another way of writingAnother way of writing 46 (a) Well Formed Formulas 1.  x Food(x) → Likes(John, x)∀ 2. Food(Apples) 3. Food(Chicken) 4.  x y Eats(y, x)   ¬KilledBy(y, x) → Food(x)∀ ∃ ∧ 5. Eats(Bill, Peanuts)   ¬KilledBy(Bill, Peanuts)∧ 6.  x Eats(Bill, x) → Eats(Sue, x)∀ (b) Convert the formulas of part (a) into clause form. 1. ¬Food(x)   Likes(John, x)∨ 2. Food(Apples) 3. Food(Chicken) 4. ¬Eats(y, x)   KilledBy(y, x)   Food(x)∨ ∨ 5. Eats(Bill, Peanuts) 6. ¬KilledBy(Bill, Peanuts) 7. ¬Eats(Bill, x)   Eats(Sue, x)∨
  • 47. ResolutionResolution 47 (d) Use resolution to prove that John likes peanuts. 8. ¬Likes(John, Peanuts) negated conclusion 9. ¬Food(Peanuts) 1 and 8 10. ¬Eats(y, Peanuts)   KilledBy(y, Peanuts) 4 and 9∨ 11. KilledBy(Bill, Peanuts) 5 and 10 12.   6 and 11⊥ (e) Use resolution to answer the question, “What food does Sue eat?” 13. ¬Eats(Sue, x) negated query 14. ¬Eats(Bill, x) 7 and 13 15.   5 and 14, unifying Peanuts/x⊥