![Page 1: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/1.jpg)
CS335 Introduction to AI
Francisco Iacobelli
July 20, 2015
![Page 2: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/2.jpg)
First Order LogicCan intelligent systems deduce stuff?
One Sherlock Holmes
Another Sherlock
BBC One’s Sherlock (2010-) with Benedict Cumberbach and Martin Freeman.
![Page 3: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/3.jpg)
First Order LogicRepresentation Of Language
I Whorf (1956) suggest that communities determine lang.categories
I Wanner (1975) subject remember the content of what theyread better than the actual words.
I Mitchell et al. (2008) could predict –with above chanceaccuracy– the areas of the brain that would activate withcertain words(fMRI)
![Page 4: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/4.jpg)
First Order LogicFormal/Natural Languages
I Objects (cat, dog, house, John, etc.)I Relations (has color, bigger than, comes between, etc.)I Facts: (One value for a given input: has father, has head,
can swim)
Facts have a truth value. true or false
![Page 5: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/5.jpg)
Formal LanguagesOntological and Epistemological Commitments
Language Ontological Commitment1 Epistemological Commitment2
Propositional Logic facts true/false/unknownFirst-Order Logic facts, objects, relations true/false/unknownTemporal Logic facts,objects, relations, time true/false/unknownProbability Theory facts degree of belief ∈ [0, 1]Fuzzy Logic facts with degree of truth known interval value
1What exists in the world2Agent’s beliefs about facts
![Page 6: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/6.jpg)
RelationshipsModels for first order logic
94 Chapter 8. First-Order Logic
R J$
left leg
on headbrother
brother
person personking
crown
left leg
Figure 8.2 FILES: figures/fol-model.eps (Tue Nov 3 16:22:52 2009). A model containing fiveobjects, two binary relations, three unary relations (indicated by labels on the objects), and one unaryfunction, left-leg.
Relations are just tuples:brotherhood = {< Richard , John >,< John,Richard >};on − head : {< crown, John >}
![Page 7: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/7.jpg)
First-Order-LogicSyntax
Sentence → AtomicSentence|ComplexSentenceAtomicSentence → 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 |Left leg| . . .
Operator Precedence3 : ¬,∧,∨,⇒,↔3Otherwise the grammar is ambiguous
![Page 8: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/8.jpg)
First Order LogicMore on Syntax
I Three kinds of symbolsI Constant: objectsI Predicate: relationsI Function: funcions (i.e. can return values other than truth
vals.)I Predicate and Function have arity.I Symbols have an interpretationI Terms: LeftLeg(John)I Atomic Sentences state facts: Brother(Richard , John)I Complex Sentence: Brother(R, J) ∧ Brother(J,R) or¬King(Richard)⇒ King(John)
I Universal Quantifiers: ∀King(x)⇒ Person(x)I Existential Quantifiers: ∃Crown(x) ∧OnHead(x , John)
![Page 9: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/9.jpg)
First Order LogicTry this
What is the interpretation for:
I King(Richard) ∨ King(John)I ¬Brother(LeftLeg(Richard), John)I ∀x∀yBrother(x , y)⇒ Sibling(x , y)I In(Paris,France) ∧ In(Marseilles,France)I ∀c Country(c) ∧ Border(c,Ecuador)⇒
In(c,SouthAmerica)I ∃Country(c) ∧ Border(c,Spain) ∧ Border(c, Italy)
![Page 10: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/10.jpg)
First Order LogicMore Facts
• Richard has only two brothers, John and Geoffrey:
Brother(John,Richard) ∧ Brother(Geoffrey ,Richard) ∧ John 6= Geoffrey∧∀xBrother(x ,Richard)⇒ (x = John ∨ x = Geoffrey)
• No Region in South America borders any region in Europe
∀c,d In(c,SouthAmerica) ∧ In(d ,Europe)⇒ ¬Border(c,d)
• No two adjacent countries have the same map color
∀x , y Country(x) ∧ Country(y) ∧ Border(x , y)⇒¬(Color(x) = Color(y)) ∧ ¬(x = y)
![Page 11: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/11.jpg)
First Order LogicMore Facts
• Richard has only two brothers, John and Geoffrey:
Brother(John,Richard) ∧ Brother(Geoffrey ,Richard) ∧ John 6= Geoffrey∧∀xBrother(x ,Richard)⇒ (x = John ∨ x = Geoffrey)
• No Region in South America borders any region in Europe
∀c,d In(c,SouthAmerica) ∧ In(d ,Europe)⇒ ¬Border(c,d)
• No two adjacent countries have the same map color
∀x , y Country(x) ∧ Country(y) ∧ Border(x , y)⇒¬(Color(x) = Color(y)) ∧ ¬(x = y)
![Page 12: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/12.jpg)
First Order LogicMore Facts
• Richard has only two brothers, John and Geoffrey:
Brother(John,Richard) ∧ Brother(Geoffrey ,Richard) ∧ John 6= Geoffrey∧∀xBrother(x ,Richard)⇒ (x = John ∨ x = Geoffrey)
• No Region in South America borders any region in Europe
∀c,d In(c,SouthAmerica) ∧ In(d ,Europe)⇒ ¬Border(c,d)
• No two adjacent countries have the same map color
∀x , y Country(x) ∧ Country(y) ∧ Border(x , y)⇒¬(Color(x) = Color(y)) ∧ ¬(x = y)
![Page 13: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/13.jpg)
First Order LogicMore Facts
• Richard has only two brothers, John and Geoffrey:
Brother(John,Richard) ∧ Brother(Geoffrey ,Richard) ∧ John 6= Geoffrey∧∀xBrother(x ,Richard)⇒ (x = John ∨ x = Geoffrey)
• No Region in South America borders any region in Europe
∀c,d In(c,SouthAmerica) ∧ In(d ,Europe)⇒ ¬Border(c,d)
• No two adjacent countries have the same map color
∀x , y Country(x) ∧ Country(y) ∧ Border(x , y)⇒¬(Color(x) = Color(y)) ∧ ¬(x = y)
![Page 14: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/14.jpg)
First Order LogicMore Facts
• Richard has only two brothers, John and Geoffrey:
Brother(John,Richard) ∧ Brother(Geoffrey ,Richard) ∧ John 6= Geoffrey∧∀xBrother(x ,Richard)⇒ (x = John ∨ x = Geoffrey)
• No Region in South America borders any region in Europe
∀c,d In(c,SouthAmerica) ∧ In(d ,Europe)⇒ ¬Border(c,d)
• No two adjacent countries have the same map color
∀x , y Country(x) ∧ Country(y) ∧ Border(x , y)⇒¬(Color(x) = Color(y)) ∧ ¬(x = y)
![Page 15: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/15.jpg)
First Order LogicMore Facts
• Richard has only two brothers, John and Geoffrey:
Brother(John,Richard) ∧ Brother(Geoffrey ,Richard) ∧ John 6= Geoffrey∧∀xBrother(x ,Richard)⇒ (x = John ∨ x = Geoffrey)
• No Region in South America borders any region in Europe
∀c,d In(c,SouthAmerica) ∧ In(d ,Europe)⇒ ¬Border(c,d)
• No two adjacent countries have the same map color
∀x , y Country(x) ∧ Country(y) ∧ Border(x , y)⇒¬(Color(x) = Color(y)) ∧ ¬(x = y)
![Page 16: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/16.jpg)
Assertions and Queries in FOLASK and TELL
I TELL(KB,King(John))I TELL(KB, ∀x King(x)⇒ Person(x))
I ASK (KB,King(John)) return TrueI ASK (KB,∃x Person(x)) return True
I ASKVARS(KB,Person(x)) yields {x/John, x/Richard}, abinding list
![Page 17: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/17.jpg)
First Order LogicKinship
“The son of my father is my brother”; “One’s grandmother is themother of one’s parent”; etc.
I Domain: People.I Unary predicates: Male,FemaleI Relations:
Parent ,Sibling,Brother ,Sister ,Child ,Daughter ,Son,Spouse,Wife,Husband ,Grandparent ,Grandchild ,Cousin,Aunt ,Uncle
I Functions: Mother ,Father
![Page 18: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/18.jpg)
First Order LogicKinship
“One’s mother is one’s female parent”∀m, c Mother(c) = m↔ Female(m) ∧ Parent(m, c)
“A sibling is another child of one’s parents”∀x , y Sibling(x , y)↔ x 6= y ∧ ∃p Parent(p, x) ∧ Parent(p, y)
“Wendy is female”
Female(wendy)
These are axioms
![Page 19: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/19.jpg)
First Order LogicKinship
“One’s mother is one’s female parent”∀m, c Mother(c) = m↔ Female(m) ∧ Parent(m, c)
“A sibling is another child of one’s parents”∀x , y Sibling(x , y)↔ x 6= y ∧ ∃p Parent(p, x) ∧ Parent(p, y)
“Wendy is female”
Female(wendy)
These are axioms
![Page 20: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/20.jpg)
First Order LogicKinship
“One’s mother is one’s female parent”∀m, c Mother(c) = m↔ Female(m) ∧ Parent(m, c)
“A sibling is another child of one’s parents”∀x , y Sibling(x , y)↔ x 6= y ∧ ∃p Parent(p, x) ∧ Parent(p, y)
“Wendy is female”
Female(wendy)
These are axioms
![Page 21: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/21.jpg)
First Order LogicKinship
“One’s mother is one’s female parent”∀m, c Mother(c) = m↔ Female(m) ∧ Parent(m, c)
“A sibling is another child of one’s parents”∀x , y Sibling(x , y)↔ x 6= y ∧ ∃p Parent(p, x) ∧ Parent(p, y)
“Wendy is female”
Female(wendy)
These are axioms
![Page 22: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/22.jpg)
First Order LogicKinship
“One’s mother is one’s female parent”∀m, c Mother(c) = m↔ Female(m) ∧ Parent(m, c)
“A sibling is another child of one’s parents”∀x , y Sibling(x , y)↔ x 6= y ∧ ∃p Parent(p, x) ∧ Parent(p, y)
“Wendy is female”
Female(wendy)
These are axioms
![Page 23: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/23.jpg)
First Order LogicWumpus: Time domain included
Can be represented more concisely
I at time step3:Percept([Stench,Breeze,Glitter ,None,None],3)
I at time step6:Percept([None,Breeze,None,None,Scream],6)
I Actions can be:Turn(Right),Turn(Left),Forward ,Shoot ,Grab,Climb
And we can ASK the best action at time step 5ASKVARS(∃a BestAction(a,5))
![Page 24: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/24.jpg)
FOL: WumpusEncoding complex rules
Can encode:I Raw percepts:∀t , s,g,m, c Percept([s,b,Glitter ,m, c], t)⇒ Glitter(t)
I Reflex actions: ∀t Glitter(t)⇒ BestAction(Grab, t)
Instead of encoding stuff like:
Adjacent(Square1,2,Square1,1)Adjacent(Square3,4,Square4,4)
Encode:∀x , y ,a,b Adjacent([x , y ], [a,b])⇔
(x = a∧(y = b−1∨y = b+1))∨(y = b∧(x = a−1∨x = a+1))
![Page 25: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/25.jpg)
First Order LogicLegos
I Define pieces: Long(p),Short(p),etc.I and restrictions: ∀p Long(p)↔ ¬(Long(p) ∧ Short(p))I Define rules: ∀x , y , z CanConnectWithOverlap(x , y , z)↔
x 6= y ∧ Piece(x) ∧ Piece(y) ∧ Number(z) ∧ Value(z) ≤Overlap(x , y)...
I ∀x , y Short(x) ∧ Short(y) ∧Overlap(x , y) < 1⇒WeakLink(x , y)
![Page 26: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/26.jpg)
PrologExample
Alain Colmerauer (1972)
Download SWI Prolog
And a quick tutorial
![Page 27: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/27.jpg)
Creating a Knowledge Base
I Identify the TaskI Assemble the relevant knowledgeI Decide on a vocabulary of predicates, functions and
constantsI Encode general knowledge about the domain (rules)I Encode a description of the problemI Pose queries to the inference procedure and get answersI Debug the KB
![Page 28: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/28.jpg)
Inferencein First Order Logic
Given ∀x King(x) ∧Greedy(x)⇒ Evil(x)
One can infer
I King(John) ∧Greedy(John)⇒ Evil(John)I King(Richard) ∧Greedy(Richard)⇒ Evil(Richard)I King(Father(John)) ∧Greedy(Father(John))⇒
Evil(Father(John))
![Page 29: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/29.jpg)
Inferencein First Order Logic
I Universal Instantiation (in a ∀ rule, substitute all symbols)I Existential Instantiation (in a ∃ rule, substitute one symbol,
use the rule and discard)I Skolem Constants is a new variable that represents a new
inference.
![Page 30: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/30.jpg)
Inferencein First Order Logic
Suppose KB:I ∀x King(x) ∧Greedy(x)⇒ Evil(x)I King(John)I Greedy(John)I Brother(Richard , John)
Apply UI using {x/John}and{x/Richard}I King(John) ∧Greedy(John)⇒ Evil(John)I King(Richard) ∧Greedy(Richard)⇒ Evil(Richard)
And discard the Universally quantified sentence. We can getthe KB to be propositions.
![Page 31: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/31.jpg)
Inferencein First Order Logic
Suppose KB:I ∀x King(x) ∧Greedy(x)⇒ Evil(x)I King(John)I ∀y Greedy(y)
Apply UI using {x/John}and{y/John}
![Page 32: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/32.jpg)
InferenceGeneralized Modus Ponens
for atomic sentences pi ,p′
i and q, where there is a substitutionθ such that SUBST (θ,p
′
i ) = SUBST (θ,pi), for all i
p′
1,p′
2, . . . ,p′n, (p1 ∧ p2 ∧ . . . ∧ pn ⇒ q)SUBST (θ,q)
p′
1 = King(John) p1 = King(x)p
′
2 = Greedy(y) p2 = Greedy(x)θ = {x/John, y/John} q = Evil(x)SUBST (θ,q) .
![Page 33: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/33.jpg)
InferenceUnification
UNIFY (p,q) = θ Where SUBST (θ,p) = SUBST (θ,q)
For example:I We ask ASKVARS(Knows(John, x)) (Whom does John
know?)I UNIFY (Knows(John, x),Knows(John, Jane)) = {x/Jane}I UNIFY (Knows(John, x),Knows(y ,Bill)) ={y/John, x/Bill}
I UNIFY (Knows(John, x),Knows(y ,Mother(y))) ={y/John, x/Mother(John)}
Algorithm in the book (goes variable by variable recursively unifying)
![Page 34: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/34.jpg)
InferencePutting it all together
“The Law says that it is a crime for an American to sellweapons to hostile nations. The country Nono, and enemy ofAmerica, has some missiles , and all of its missiles were sold toit by Colonel West, who is American”
Prove that Colonel Wes is a Criminal
![Page 35: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/35.jpg)
InferenceThe KB
“The Law says that it is a crime for an American to sellweapons to hostile nations. The country Nono, and enemy ofAmerica, has some missiles , and all of its missiles were sold toit by Colonel West, who is American”
I R1:American(x) ∧ Weapon(y) ∧ Sells(x , y .z) ∧ Hostile(z) ⇒ Criminal(x)
I R2: Owns(Nono,M1) Nono has some missilesI R3: Missile(M1)
I R4: Missile(x) ⇒ Weapon(x) A missile is a weaponI R5: Missile(x) ∧ Owns(Nono, x) ⇒ Sells(West , x ,Nono) All missiles
sold by westI R6: Enemy(x ,America) ⇒ Hostile(x) Enemies of America are hostileI R7: American(West) West is americanI R8: Enemy(Nono,America)
![Page 36: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/36.jpg)
InferenceGraph
102 Chapter 9. Inference in First-Order Logic
Hostile(Nono)
Enemy(Nono,America)Owns(Nono,M1)Missile(M1)American(West)
Weapon(M1)
Criminal(West)
Sells(West,M1,Nono)
Figure 9.4 FILES: figures/crime-fc.eps (Tue Nov 3 16:22:35 2009). The proof tree generated byforward chaining on the crime example. The initial facts appear at the bottom level, facts inferred onthe first iteration in the middle level, and facts inferred on the second iteration at the top level.
![Page 37: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/37.jpg)
Forward Chaining ASKIterations
Iteration 1:I R5 satisfied with {x/M1} and R9: Sells(West ,M1,Nono) is
addedI R4 satisfied with {x/M1} and R10: Weapon(M1) is addedI R6 satisfied with {x/Nono} and R11: Hostile(Nono) is
added
Iteration 2:I R1 is satisfied with {x/West , y/M1, z/Nono} and
Criminal(West) is added.
![Page 38: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/38.jpg)
Forward Chaining ASKIterations
Iteration 1:I R5 satisfied with {x/M1} and R9: Sells(West ,M1,Nono) is
addedI R4 satisfied with {x/M1} and R10: Weapon(M1) is addedI R6 satisfied with {x/Nono} and R11: Hostile(Nono) is
added
Iteration 2:I R1 is satisfied with {x/West , y/M1, z/Nono} and
Criminal(West) is added.
![Page 39: CS335 Introduction to AIfid.cl/courses/ai/firstOrderLogic/slides_firstOrderLogic.pdfFirst Order Logic Representation Of Language I Whorf (1956) suggest that communities determine lang](https://reader033.vdocuments.mx/reader033/viewer/2022041808/5e55cdbbc5879e31e4273fd4/html5/thumbnails/39.jpg)
Inference in First Order LogicDiscussion
I Once we have facts that evaluate to T or FI We can apply Forward Chaining, Backwards Chaining and
ResolutionI The key is to understand UnificationI Very similar to Logical agents.