Firstorderlogic JSN
Firstorderlogic JSN
Chapter 8
Outline
• Why FOL?
• Syntax and semantics of FOL
• Using FOL
• Wumpus world in FOL
• Knowledge engineering in FOL
Pros and cons of propositional
logic
Propositional logic is declarative
Propositional logic allows partial/disjunctive/negated
information
– (unlike most data structures and databases)
Propositional logic is compositional:
– meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,2
Meaning in propositional logic is context-independent
(unlike natural language, where meaning depends on context)
Propositional logic has very limited expressive power
(unlike natural language)
– E.g., cannot say "pits cause breezes in adjacent squares“
• except by writing one sentence for each square
Propositional logic is a weak language
E.g.
Sibling(KingJohn,Richard) Sibling(Richard,KingJohn)
>(1,2) ≤ (1,2)
>(1,2) >(1,2)
Backus–Naur form for FOL
• Sentence → AtomicSentence | ComplexSentence
• AtomicSentence → Predicate | Predicate(Term,...) | Term = Term
• ComplexSentence → ( Sentence ) | [ Sentence ] | ¬ Sentence | Sentence ∧
Sentence | Sentence ∨ Sentence | Sentence ⇒ Sentence | Sentence ⇔
Sentence | Quantifier Variable,... Sentence
• Term → Function(Term,...) | Constant | Variable
• Quantifier → ∀| ∃
• Constant → A | X1 | John | ···
• Variable → a | x | s | ···
• Predicate → True | False | After | Loves | Raining | ···
• Function → Mother | LeftLeg | ···
• OPERATOR PRECEDENCE : ¬, =, ∧, ∨, ⇒, ⇔
Truth in first-order logic
• Sentences are true with respect to a model and an interpretation
• x y is the same as y x
• x y Loves(x,y)
– “There is a person who loves everyone in the world”
• y x Loves(x,y)
– “Everyone in the world is loved by at least one person”
Tell(KB,Percept([Smell,Breeze,None],5))
Ask(KB,a BestAction(a,5))
• Reflex
– t Glitter(t) BestAction(Grab,t)
Deducing hidden properties
• x,y,a,b Adjacent([x,y],[a,b])
[a,b] {[x+1,y], [x-1,y],[x,y+1],[x,y-1]}
Properties of squares:
• s,t At(Agent,s,t) Breeze(t) Breezy(s)
Squares are breezy near a pit:
Diagnostic rule---infer cause from effect
s Breezy(s) ∃{r} Adjacent(r,s) Pit(r)