1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For...
-
date post
19-Dec-2015 -
Category
Documents
-
view
214 -
download
2
Transcript of 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For...
![Page 1: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/1.jpg)
CS 331 Dr M M Awais 1
FOL
Inferencing
Finding solution to queries
• Propositionalization – (For reference only, may leave slides 2 to 7)
• Unification– Forward Chaining– Backward Chaining
• Resolution
![Page 2: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/2.jpg)
Luger’s Book:
Chapter 2and
Chapter 12(upto 12.2)
![Page 3: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/3.jpg)
CS 331 Dr M M Awais 3
FOL
Propositionalization
1. Brute Force Approach
2. Apply all possible bindings to the variables.
3. Add every clause in the sentence as a proposition to the knowledge base.
4. Search for the required proposition (Goal proposition)
![Page 4: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/4.jpg)
CS 331 Dr M M Awais 4
FOL Reduction to propositional inferenceSuppose the KB contains just the following:
X wealthy(X) greedy(X) bad(X)wealthy(arif)greedy(arif)cousins(shahid,arif)
• Instantiating the universal sentence in all possible ways, we have:wealthy(arif) greedy(arif) bad(arif)wealthy(shahid) greedy(shahid) bad(shahid)wealthy(arif)greedy(arif)cousins(shahid,arif)
Universal Instantiation
•The new KB is propositionalized: proposition symbols are
wealthy(arif), greedy(arif), bad(arif), wealthy(shahid), greedy(shahid), bad(shahid), cousins(shahid,arif).
![Page 5: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/5.jpg)
CS 331 Dr M M Awais 5
FOL
Reduction contd.
• Every FOL KB can be propositionalized so as to preserve entailment (entailments are dependencies)
• (A ground sentence is entailed by new KB iff entailed by original KB)
• Idea: propositionalize KB and query, apply resolution, return result
• Problem: with function symbols, there are infinitely many ground terms,– e.g., Father(Father(Father(John)))
–•
•
•
![Page 6: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/6.jpg)
CS 331 Dr M M Awais 6
FOL
Reduction contd.
Theorem: Herbrand (1930). If a sentence α is entailed by an FOL KB, it is entailed by a finite subset of the propositionalized KB
Idea: For n = 0 to ∞ do create a propositional KB by instantiating with depth-$n$ terms see if α is entailed by this KB
Problem: works if α is entailed, loops if α is not entailed
Theorem: Turing (1936), Church (1936) Entailment for FOL is
semidecidable (algorithms exist that say yes to every entailed sentence, but no algorithm exists that also says no to every nonentailed sentence.)
•
![Page 7: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/7.jpg)
CS 331 Dr M M Awais 7
FOL
Problems with propositionalization
• Propositionalization seems to generate lots of irrelevant sentences.
• E.g., from:x King(x) Greedy(x) Evil(x)King(John)y Greedy(y)Brother(Richard,John)
• it seems obvious that Evil(John), but propositionalization produces lots of facts such as Greedy(Richard) that are irrelevant
• With p k-ary predicates and n constants, there are p·nk instantiations.
••
••
![Page 8: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/8.jpg)
CS 331 Dr M M Awais 8
FOL
Unification
“It is an algorithm for determining the substitutions needed to make two predicate
calculus expressions match”
The process of universal/existential instantiation require substitutions
![Page 9: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/9.jpg)
CS 331 Dr M M Awais 9
FOL
Unification
• Unify(α,β) = θ if αθ = βθ p q θ knows(ali,X) knows(ali,sana) knows(ali,X) knows(Y,hira) knows(ali,X) knows(Y,mother(Y))knows(ali,X) knows(X,hira)
• Standardizing apart eliminates overlap of variables, e.g., the fourth sentence can have knows(Z,hira)
•
•
![Page 10: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/10.jpg)
CS 331 Dr M M Awais 10
FOL
Unification
• Unify(α,β) = θ if αθ = βθ
p q θ
knows(ali,X) knows(ali,sana) {sana/X}
knows(ali,X) knows(Y,hira)
knows(ali,X) knows(Y,mother(Y))
knows(ali,X) knows(X,hira)
• Standardizing apart eliminates overlap of variables, e.g., the fourth sentence can have knows(Z,hira)
•
•
![Page 11: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/11.jpg)
CS 331 Dr M M Awais 11
FOL
Unification
• Unify(α,β) = θ if αθ = βθ
p q θ
knows(ali,X) knows(ali,sana) {sana/X}
knows(ali,X) knows(Y,hira) {hira/X,ali/Y}
knows(ali,X) knows(Y,mother(Y))
knows(ali,X) knows(X,hira)
• Standardizing apart eliminates overlap of variables, e.g., the fourth sentence can have knows(Z,hira)
•
![Page 12: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/12.jpg)
CS 331 Dr M M Awais 12
FOL
Unification
• Unify(α,β) = θ if αθ = βθ
p q θ
knows(ali,X) knows(ali,sana) {sana/X}
knows(ali,X) knows(Y,hira) {hira/X,ali/Y}
knows(ali,X) knows(Y,mother(Y)) {ali/Y,mother(ali)}
knows(ali,X) knows(X,hira)
• Standardizing apart eliminates overlap of variables, e.g., the fourth sentence can have knows(Z,hira)
•
![Page 13: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/13.jpg)
CS 331 Dr M M Awais 13
FOL
Unification
• Unify(α,β) = θ if αθ = βθ
p q θ
knows(ali,X) knows(ali,sana) {sana/X}
knows(ali,X) knows(Y,hira) {hira/X,ali/Y}
knows(ali,X) knows(Y,mother(Y)) {ali/Y,mother(ali)}
knows(ali,X) knows(X,hira) {fail}
• Standardizing apart eliminates overlap of variables, e.g., the fourth sentence can have knows(Z,hira)
•
![Page 14: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/14.jpg)
CS 331 Dr M M Awais 14
FOL
Unification - MGU
• To unify knows(ali,X) and knows(Y,Z)θ = {ali/Y, Z/X } or θ = {ali/Y, ali/X, ali/Z}
(if only ali is present in the data base of facts)
• The first unifier is more general than the second.
• There is a single Most General Unifier (MGU) that is unique up to renaming of variables.
MGU = { ali/Y, Z/X}••
![Page 15: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/15.jpg)
CS 331 Dr M M Awais 15
FOL
Implementation of Unification
Using“List format”
PC Syntax List Syntax
p(a,b) (p a b)
p(f(a), g(X,Y)) (p(f a)(g X Y))
p(x) ^ q(y) ((p x) ^ (q y))
![Page 16: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/16.jpg)
CS 331 Dr M M Awais 16
FOL
Unification Examples
Unify((parents X(father X) (mother bill)), (parents bill (father bill)Y)).
Complete Substitution
{bill/X, mother (bill)/Y}
![Page 17: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/17.jpg)
CS 331 Dr M M Awais 17
FOL
![Page 18: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/18.jpg)
CS 331 Dr M M Awais 18
FOL
![Page 19: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/19.jpg)
CS 331 Dr M M Awais 19
FOL
![Page 20: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/20.jpg)
CS 331 Dr M M Awais 20
FOL
Logic – Based Financial Advisor
To help a user decide whether to invest in a saving A/C or the stock market or both
![Page 21: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/21.jpg)
CS 331 Dr M M Awais 21
FOL
Policy:
Saving inadequate - should invest in saving A/c regardless of income
Saving adequateand adequate income - More profitable option of stock investment
Low Income& adequate savings - Split surplus between saving and stock investment
![Page 22: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/22.jpg)
CS 331 Dr M M Awais 22
FOL
Defining ConstraintsDefining Constraints
Adequate Savings/Income:
Income: Rs 15000/month
extra Rs 4000/ dependent/month
Saving: Rs 25,000/year
extra Rs 5000/dependent/year
![Page 23: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/23.jpg)
CS 331 Dr M M Awais 23
FOL
Calculating AdequacyDefine Functions to calculate the minimum income and
savings
Minimum Savings: min_saving(X)
min_saving(X)=25000+5000*X
where X are the number of dependents
Minimum Income: min_income(X)
min_income(X)=15000+4000*X
![Page 24: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/24.jpg)
CS 331 Dr M M Awais 24
FOL
Outputs
Investment (savings)Investment (stocks)Investment (combination)
How can we represent outputs?
![Page 25: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/25.jpg)
CS 331 Dr M M Awais 25
FOL
Rules saving_acc (inadequate) investment (savings)
saving_acc(adequate) ^ income(adequate) investment(stocks)
saving_acc (adequate) ^ income (inadequate) investment (combination)
![Page 26: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/26.jpg)
CS 331 Dr M M Awais 26
FOL
What next?
• Define Saving adequate
• Define saving inadequate
• Define income adequate
• Define income inadequate
![Page 27: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/27.jpg)
CS 331 Dr M M Awais 27
FOL
Savings
Check if saved amount is greater than the minimum saving required
)(_
))(min_,(^)((^)(_
adequateaccsaving
YsavingXgreaterYdependantsYXsavedamtX
)(_
))(min_,(^)((^)(_
inadequateaccsaving
YsavingXgreaterYdependantsYXsavedamtX
![Page 28: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/28.jpg)
CS 331 Dr M M Awais 28
FOL
Income
Check if the income is greater than the minimum income
)(
))(_,(^)((^),(
adequateincome
YincomemixgreaterYdependantsYsteadyXearningsX
)(
))(_,(^)((^),(
inadequateincome
YincomemixgreaterYdependantsYsteadyXearningsX
)(),( inadequateincomeunsteadyXearningsX
![Page 29: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/29.jpg)
CS 331 Dr M M Awais 29
FOL
Try firing rules with 9, 10, 11
![Page 30: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/30.jpg)
CS 331 Dr M M Awais 30
FOL
Example knowledge base
The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.
Prove that Col. West is a criminalProve that Col. West is a criminal•
•
![Page 31: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/31.jpg)
CS 331 Dr M M Awais 31
FOL
Example knowledge base contd.... it is a crime for an American to sell weapons to hostile nations:
american(X) weapon(Y) sells(X,Y,z) hostile(z) criminal(X)Nono … has some missiles, i.e., X Owns(Nono,X) Missile(X):
owns(nono,m1) and missile(m1)… all of its missiles were sold to it by Colonel West
missile(X) owns(nono,X) sells(west,X,nono)Missiles are weapons:
missile(X) weapon(X)An enemy of America counts as "hostile“:
enemy(X,america) hostile(X)West, who is American …
american(west)The country Nono, an enemy of America …
enemy(nono,america)
–••••
![Page 32: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/32.jpg)
CS 331 Dr M M Awais 32
FOL
Example knowledge base contd.Rule Base:Rule Base:... it is a crime for an American to sell weapons to hostile nations:
R1: american(X) weapon(Y) sells(X,Y,z) hostile(z) criminal(X)Nono … has some missiles, i.e.,
R2R2: X owns(nono,X) missile(X):… all of its missiles were sold to it by Colonel West
R3R3: missile(X) owns(nono,X) sells(west,X,nono)Missiles are weapons:
R4:R4: missile(X) weapon(X)An enemy of America counts as "hostile“:
R5R5: enemy(X,america) hostile(X)
•Database of Facts:Database of Facts:owns(nono,m1) and missile(m1)
West, who is American …american(west)
The country Nono, an enemy of America …enemy(nono,america)
•••
![Page 33: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/33.jpg)
CS 331 Dr M M Awais 33
FOL
•START FROM THE FACTS•THINK WHICH RULES APPLY
Be careful about the convention constants start with capital letters and variables with small
(applicable to next few slides)
R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
1. FORWARD CHAINING
![Page 34: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/34.jpg)
CS 331 Dr M M Awais 34
FOL R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
R4{m1/X}
R3{m1/X}
R5{nono/X}
![Page 35: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/35.jpg)
CS 331 Dr M M Awais 35
FOL
R1{west/X , m1/Y , nono/Z}
R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4:: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
![Page 36: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/36.jpg)
CS 331 Dr M M Awais 36
FOL
2. BACKWARD CHAINING
•START FROM THE CONCLUSION•THINK IS THE RULE SUPPORT AVAILABLE
R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
![Page 37: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/37.jpg)
CS 331 Dr M M Awais 37
FOL R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
Backward chaining example
![Page 38: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/38.jpg)
CS 331 Dr M M Awais 38
FOL R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
Backward chaining example
![Page 39: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/39.jpg)
CS 331 Dr M M Awais 39
FOL R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
Backward chaining example
![Page 40: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/40.jpg)
CS 331 Dr M M Awais 40
FOL R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
Backward chaining example
![Page 41: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/41.jpg)
CS 331 Dr M M Awais 41
FOL R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
Backward chaining example
![Page 42: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/42.jpg)
CS 331 Dr M M Awais 42
FOL R1: american(X) weapon(Y) sells(X,Y,Z) hostile(Z) criminal(X) R2: X owns(nono,X) missile(X):R3: missile(X) owns(nono,X) sells(west,X,nono)R4: missile(X) weapon(X)R5: enemy(X,america) hostile(X)
•
Backward chaining example
![Page 43: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/43.jpg)
CS 331 Dr M M Awais 43
FOL
3. Modus Ponen Based Solution
1. 6 with 3 suggests, through Modus Ponens:
weapons(m1) :{m1/X}
2. From 4 and 9
hostile(nono) : {nono/X}
3. From 2, 5, 6, Modus Ponens
sells(west,nono,m1):m1/X
4. From 2,3,4,5,6, and 9
criminal(west):criminal(west):
{west/X, m1/Y, nono/Z}{west/X, m1/Y, nono/Z}
1. X,Y,Z[american(X)^weapon(Y)^nation(Z)^hostile(Z)^sells(X,Z,Y) criminal(X)]
2. X owns(nono,X)^missiles(X) sells(west,nono,X)
3. X missiles(X) weapons (X)4. X enemy(X,america) hostile(X)5. owns(nono,m1)6. missiles(m1)7. american(west)8. nation(nono)9. enemy(nono,america)10. nation(america)
![Page 44: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/44.jpg)
CS 331 Dr M M Awais 44
FOL
Composition
• Find Overall Substitutions
• Given two or more sets of substitutions
![Page 45: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/45.jpg)
CS 331 Dr M M Awais 45
FOL
Example• S1={A/K}
• S2={a/A, H/J}
What set would represent overall substitutions
• S1.S2={a/K, H/J}
• Algorithm?
![Page 46: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/46.jpg)
CS 331 Dr M M Awais 46
FOL
Example• S1={A/K} S2={a/A, H/J}
• S1.S2={a/K, H/J}
• Algorithm:
1. Apply S2 to S1 (find overall substitution)
2. Add S2 to S1
3. Drop all substitutions in S2 which have common denominators with S1
![Page 47: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/47.jpg)
CS 331 Dr M M Awais 47
FOL
Example• S1={A/K} S2={a/A, H/J}• Algorithm:Apply S2 to S1 (find overall substitution)
Apply a/A to A/K would lead to a/KApply H/J to A/K cannot be appliedS1.S2={a/K}
Add S2 to S1S1.S2={a/K a/A,H/J}
Drop all substitutions in S2 which have common denominators with S1nothing gets dropped, hence the answer is {a/K,a/A,H/J}
![Page 48: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/48.jpg)
CS 331 Dr M M Awais 48
FOL
Example
• S1={D/A}• S2={a/D}• S12={a/A, a/D}
• S1={D/A,S/G}• S2={x/X, f/D, q/S,w/A}• S1.S2={f/A,q/G, x/X, f/D, q/S,w/A}• S1.S2={f/A,q/G,x/X,q/S} (w/A gets dropped)S1.S2={f/A,q/G, x/X,q/S}
![Page 49: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/49.jpg)
CS 331 Dr M M Awais 49
FOL
Is S1.S2 same as S2.S1
• S1={D/A}• S2={a/D}• S21={a/A, D/A}{a/A} where as S12={a/A, a/D}
• S1={D/A,S/G}• S2={x/X, f/D, q/S,w/A}• S2.S1={x/X, f/D, q/S, w/A D/A,S/G}• S2.S1={x/X, f/D, q/S, w/A, S/G} (D/A gets
dropped)
Hence generally speaking S1.S2 not equal to S2.S1
![Page 50: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/50.jpg)
CS 331 Dr M M Awais 50
FOL
Is S12 same as S21• S1={D/A}
• S2={X/A}
• S12={D/A, X/A}
• S12={D/A}
• S21={X/A,D/A}
• S21={X/A}
![Page 51: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/51.jpg)
CS 331 Dr M M Awais 51
FOL
Example• S1={D/A, d/F,S/E}
• S2={g/D}
• S12={g/A, d/F,S/E, g/D}
• S12={g/A, d/F,S/E, g/D}
• S21={g/D, D/A, d/F,S/E}
![Page 52: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/52.jpg)
CS 331 Dr M M Awais 52
FOLSubstitution: Discussion
• Domain: Variables in the substitution together form the domain (denominators)
• Replacements: Terms are the replacements (numerators)
• Pure Vs Impure Substitutions:
– A pure substitution is if all replacements are free of the variables in the domain of the substitution. Otherwise impure
– {s/X, t/I, j/G} (pure)
– The composition of pure substitutions may be impure and vice versa
• Composability:
– A substitution S1 and S2 are composable if and only if the variables in the domain of S1 do not appear among the replacements of S2, otherwise they are noncomposable.
– S1={a/X,b/Y,z/V} S2={U/X,b/V} composable
– S1={a/X,b/Y,z/V} S2={X/U, b/V} noncomposable
![Page 53: 1 FOL CS 331 Dr M M Awais Inferencing Finding solution to queries Propositionalization –(For reference only, may leave slides 2 to 7) Unification –Forward.](https://reader037.fdocuments.us/reader037/viewer/2022110322/56649d3a5503460f94a150bb/html5/thumbnails/53.jpg)
CS 331 Dr M M Awais 53
FOL Application ExampleKnowledge base:
knows(ali,sana) knows(X,shahid) knows(X,Y)
We also know
knows(ali,X) hates(ali,X)
Unify the conditions to find ali hates whom
unify(knows(ali,X) , knows(ali,sana)) = {sana/X}Using the binding and the rule: ali hates sana
unify(knows(ali,X) , knows(X,shahid)) = {ali/X,shahid/X} This would fail as X cannot have two values at the same time
As the composition of {ali/X} with {shahid/X} or vice versa will result in only one valid substitution
unify(knows(ali,X) , knows(X,Y)) = {ali/X,X/Y}This would mean that ali knows everyone including himself, therefore hates everyone.