15-780: Graduate AI Lecture 5. Logic, Planning
Transcript of 15-780: Graduate AI Lecture 5. Logic, Planning
![Page 1: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/1.jpg)
15-780: Graduate AILecture 5. Logic, Planning
Geoff Gordon (this lecture)Ziv Bar-Joseph
TAs Geoff Hollinger, Henry Lin
![Page 2: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/2.jpg)
Review
![Page 3: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/3.jpg)
Review
CSPs (definition, examples)Sudoku, jobshop scheduling
Over-, under-, critically-constrainedBasic search for SAT & CSPs
![Page 4: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/4.jpg)
Search in SAT, CSPs
Constraint propagation / unit resolutionConstraint learning from conflict clausesVariable ordering
activity, most-constrained variableValue ordering
least-constraining value
![Page 5: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/5.jpg)
Citation for MiniSAT
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/cgi/MiniSat.ps.gz.cgi
Also, the map-coloring applet that I linked last class appears to be offline
![Page 6: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/6.jpg)
Randomization
Random restarts for DFS-based (DPLL) search
avoiding doldrumsWalkSAT
![Page 7: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/7.jpg)
Tseitin transformation
Put the following formula in CNF:(a ∧ b) ∨ ((c ∨ d) ∧ e)
Parse tree:
![Page 8: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/8.jpg)
Tseitin transformation
Introduce temporary variablesx = (a ∧ b)
y = (c ∨ d)
z = (y ∧ e)
![Page 9: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/9.jpg)
Tseitin transformation
To ensure x = (a ∧ b), want
x ⇒ (a ∧ b)
(a ∧ b) ⇒ x
![Page 10: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/10.jpg)
Tseitin transformation
x ⇒ (a ∧ b)
(¬x ∨ (a ∧ b))
(¬x ∨ a) ∧ (¬x ∨ b)
![Page 11: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/11.jpg)
Tseitin transformation
(a ∧ b) ⇒ x
(¬(a ∧ b) ∨ x)
(¬a ∨ ¬b ∨ x)
![Page 12: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/12.jpg)
Tseitin transformation
To ensure y = (c ∨ d), want
y ⇒ (c ∨ d)
(c ∨ d) ⇒ y
![Page 13: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/13.jpg)
Tseitin transformation
y ⇒ (c ∨ d)
(¬y ∨ c ∨ d)
(c ∨ d) ⇒ y((¬c ∧ ¬d) ∨ y)
(¬c ∨ y) ∧ (¬d ∨ y)
![Page 14: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/14.jpg)
Tseitin transformation
Finally, z = (y ∧ e)
z ⇒ (y ∧ e) ≡ (¬z ∨ y) ∧ (¬z ∨ e)
(y ∧ e) ⇒ z ≡ (¬y ∨ ¬e ∨ z)
![Page 15: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/15.jpg)
Tseitin end result
(a ∧ b) ∨ ((c ∨ d) ∧ e) ≡
(¬x ∨ a) ∧ (¬x ∨ b) ∧ (¬a ∨ ¬b ∨ x) ∧
(¬y ∨ c ∨ d) ∧ (¬c ∨ y) ∧ (¬d ∨ y) ∧(¬z ∨ y) ∧ (¬z ∨ e) ∧ (¬y ∨ ¬e ∨ z) ∧
(x ∨ z)
![Page 16: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/16.jpg)
HW questions
3(a) asks you to implement an “opaque” data structure for nodesThis just means that there is a well-defined interface, and data structure is accessed only through interfaceE.g., definitions of pq_init, pq_set, pq_pop, pq_test are such an interface, so the priqueue we gave is opaque
![Page 17: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/17.jpg)
State numbering in maze
\ x 1 2 3 4 5
y \ ___________________________
1 | 1 6 11 16 21
2 | 2 7 12 17 22
3 | 3 8 13 18 23
4 | 4 9 14 19 24
5 | 5 10 15 20 25
This contradicts description in the text, but matches the code—updated text on web
![Page 18: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/18.jpg)
HW questions
Storing backpointers in A*, BFS, etc.
![Page 19: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/19.jpg)
Generic search
S = { start } M = ∅
While (S ≠ ∅)
x ← some element of S, S ← S \ xCheckSolution(x)For y ∈ neighbors(x) \ M
S ← S ∪ {y} , backpointer(y) ← x
M = M ∪ {x}
![Page 20: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/20.jpg)
HW questions
More questions?
![Page 21: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/21.jpg)
First-order logic
![Page 22: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/22.jpg)
Predicates and objects
Interpret happy(John) or likes(Joe, pizza) as a predicate applied to some objectsObject = an object in the worldPredicate = boolean-valued function of objectsZero-argument predicate plays same role that Boolean variable did before
![Page 23: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/23.jpg)
Functions
Functions map zero or more objects to another object
e.g., professor(15-780), last-common-ancestor(John, Mary)
Zero-argument function is the same as an object—John v. John()
![Page 24: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/24.jpg)
Definitions
Term = expression referring to an objectJohnleft-leg-of(father-of(president-of(USA)))
Atom = predicate applied to objectshappy(John)rainingat(robot, Wean-5409, 11AM-Wed)
![Page 25: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/25.jpg)
Definitions
Literal = possibly-negated atomhappy(John), ¬happy(John)
Sentence = literals joined by connectives like ∧∨¬⇒
rainingdone(slides(780)) ⇒ happy(professor)
![Page 26: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/26.jpg)
Models
Meaning of sentence: model ↦ {T, F}
Models are now much more complicatedList of objectsTable of function values for each function mentioned in formulaTable of predicate values for each predicate mentioned in formula
![Page 27: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/27.jpg)
For example
![Page 28: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/28.jpg)
KB describing example
alive(cat)ear-of(cat) = earin(cat, box) ∧ in(ear, box)
¬in(box, cat) ∧ ¬in(cat, nil) …
ear-of(box) = ear-of(ear) = ear-of(nil) = nilcat ≠ box ∧ cat ≠ ear ∧ cat ≠ nil …
![Page 29: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/29.jpg)
Model of example
Objects: C, B, E, NAssignments:
cat: C, box: B, ear: E, nil: Near-of(C): E, ear-of(B): N, ear-of(E): N, ear-of(N): N
Predicate values:in(C, B), ¬in(C, C), ¬in(C, N), …
![Page 30: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/30.jpg)
Failed model
Objects: C, E, NFails because there’s no way to satisfy inequality constraints with only 3 objects
![Page 31: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/31.jpg)
Another possible model
Objects: C, B, E, N, XExtra object X could have arbitrary properties since it’s not mentioned in KBE.g., X could be its own ear
![Page 32: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/32.jpg)
An embarrassment of models
In general, can be infinitely many modelsunless KB limits number somehow
Job of KB is to rule out models that don’t match our idea of the world
![Page 33: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/33.jpg)
Aside: typed variables
KB illustrates need for data typesDon’t want to have to specify ear-of(box) or ¬in(cat, nil)
Could design a type systemargument of happy() is of type animate
Function instances which disobey type rules have value nil
![Page 34: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/34.jpg)
Quantifiers
So far, still can’t say “all men are mortal”Add quantifiers and object variables∀x. man(x) ⇒ mortal(x)
¬∃x. lunch(x) ∧ free(x)
∀: no matter how we fill in object variables, formula is still true∃: there is some way to fill in object variables to make formula true
![Page 35: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/35.jpg)
Quantification
Now we have atoms with free variablesAdding quantifier for x is called binding x
In (∀x. likes(x, y)), x is bound, y is free
Can add quantifiers and apply logical operations like ∧∨¬ in any order
But must wind up with ground formula (no free variables)
![Page 36: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/36.jpg)
Scoping rules
Portion of formula where quantifier applies = scopeVariable is bound by innermost enclosing scope with matching nameTwo variables in different scopes can have same name—they are still different vars
![Page 37: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/37.jpg)
Scoping examples
(∀x. happy(x)) ∨ (∃x. ¬happy(x))
Either everyone’s happy, or someone’s unhappy
∀x. (raining ∧ outside(x) ⇒ (∃x. wet(x)))
The x who is outside may not be the one who is wet
![Page 38: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/38.jpg)
Semantics of ∀
Write (M / x: obj) for the model which is just like M except that variable x is assigned to the object objM / x: obj is a refinement of MA sentence (∀x. S) is true in M if S is true in (M / x: obj) for any object obj in M
![Page 39: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/39.jpg)
Example
M has objects (A, B, C) and predicate happy(x) which is true for A, B, CSentence ∀x. happy(x) is satisfied in M
since happy(A) is satisfied in M/x:A, happy(B) in M/x:B, happy(C) in M:x/C
![Page 40: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/40.jpg)
Semantics of ∃
A sentence (∃x. S) is true in M if there is some object obj in M such that S is true in model (M / x: obj)
![Page 41: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/41.jpg)
Example
M has objects (A, B, C) and predicatehappy(A) = happy(B) = Truehappy(C) = False
Sentence ∃x. happy(x) is satisfied in M
Since happy(x) is satisfied in, e.g., M/x:B
![Page 42: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/42.jpg)
Quantifier nesting
English sentence “everybody loves somebody” is ambiguousTranslates to logical sentences∀x. ∃y. loves(x, y)
∃y. ∀x. loves(x, y)
![Page 43: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/43.jpg)
Reasoning in FOL
![Page 44: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/44.jpg)
Entailment, etc.
As before, entailment, unsatisfiability, validity, etc. refer to all possible modelsSo, can’t in general determine entailment or validity by enumerating models
since there could be infinitely manyPossible to search for satisfying assignment, but can’t show unsatisfiable
![Page 45: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/45.jpg)
Propositionalization
However, people do use SAT-checkers for reasoning in FOLTurn FOL KB into one or more finite, propositional KBs, search for models in eachMore later
![Page 46: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/46.jpg)
Theorem provers
Theorem provers (formula-based search) also generalize to FOLBoth model-based and formula-based searches generally work from KB in CNFCNF for FOL also called clause form
![Page 47: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/47.jpg)
Generalizing CNF
All transformation rules for propositional logic still holdIn addition, there is a “De Morgan’s Law” for moving negations through quantifiers
¬∀x. S ≡ ∃x. ¬S
¬∃x. S ≡ ∀x. ¬S
And, rules for getting rid of quantifiers
![Page 48: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/48.jpg)
Putting FOL KB in CNF
Eliminate ⇒, move ¬ in w/ De Morgan
but ¬ moves through quantifiers too
Get rid of quantifiers (see below)Distribute ∧∨, or use Tseitin
![Page 49: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/49.jpg)
Do we really need ∃?
(∃x) happy(x)
happy(happy_person())
(∀y) (∃x) loves(y, x)
(∀y) loves(y, loved_one_of(y))
![Page 50: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/50.jpg)
Skolemization
Eliminate ∃ using function of arguments of all enclosing ∀ quantifiers
Called Skolemization (after Thoraf Albert Skolem) Thoraf Albert Skolem
1887–1963
![Page 51: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/51.jpg)
Getting rid of quantifiers
Standardize apart (avoid name collisions)SkolemizeDrop ∀ (free variables implicitly universally quantified)Terminology: still called “free” even though quantification is implicit
![Page 52: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/52.jpg)
For example
(∀x) man(x) ⇒ mortal(x)
(¬man(x) ∨ mortal(x))
(∀x) (honest(x) ⇒ happy(Diogenes))(¬honest(x) ∨ happy(Diogenes))
(∀y) (∃x) loves(y, x)
loves(y, f(y))
![Page 53: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/53.jpg)
Exercise
((∀x) honest(x)) ⇒ happy(Diogenes)
![Page 54: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/54.jpg)
Exercise
((∀x) honest(x)) ⇒ happy(Diogenes)
¬((∀x) honest(x)) ∨ happy(Diogenes)
((∃x) ¬honest(x)) ∨ happy(Diogenes)¬honest(foo()) ∨ happy(Diogenes)
foo() = “the guy who might not be honest”
![Page 55: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/55.jpg)
Theorem provers
![Page 56: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/56.jpg)
Theorem provers
Theorem provers work as before:add ¬S to KB
put in CNFrun resolutionif we get an empty clause, we’ve proven S by contradiction
But, CNF and resolution have changed
![Page 57: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/57.jpg)
Generalizing resolution
Propositional: (¬a ∨ b) ∧ a ⊨ b
FOL: (¬man(x) ∨ mortal(x)) ∧ man(Socrates)
⊨ mortal(Socrates)
Difference: had to substitute x = Socrates
![Page 58: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/58.jpg)
Unification
Two FOL sentences unify with each other if there is a way to set their variables so that they are identicalman(x), man(Socrates) unify using the substitution x = Socrates
![Page 59: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/59.jpg)
Unification examples
loves(x, x), loves(John, y) unify using x = y = Johnloves(x, x), loves(John, Mary) can’t unifyloves(uncle(x), y), loves(z, aunt(z)):
![Page 60: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/60.jpg)
Unification examples
loves(x, x), loves(John, y) unify using x = y = Johnloves(x, x), loves(John, Mary) can’t unifyloves(uncle(x), y), loves(z, aunt(z)):
z = uncle(x), y = aunt(uncle(x))loves(uncle(x), aunt(uncle(x)))
![Page 61: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/61.jpg)
Most general unifier
May be many substitutions that unify two formulasMGU is unique (up to renaming)Finding it takes quadratic time
because of “occur check”does a variable occur inside the formula that it’s trying to unify with?
![Page 62: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/62.jpg)
First-order resolution
Given clauses (a ∨ b ∨ c), (¬c’ ∨ d ∨ e)
And a variable substitution VIf c / V and c’ / V are the sameThen we can conclude(a ∨ b ∨ d ∨ e) / V
![Page 63: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/63.jpg)
Proof by SAT
![Page 64: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/64.jpg)
Proof by SAT
To prove S, put KB ∧ ¬S in clause form
Turn FOL KB into propositional KBsin general, infinitely many
Check each one in orderWill turn out that, if any one is unsatisfiable, we have our proof
![Page 65: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/65.jpg)
Propositionalization
Given a FOL KB in clause formAnd a set of objects U (for universe)We can propositionalize KB under U by substituting elements of U for free variables in all combinations
![Page 66: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/66.jpg)
Propositionalization example
(¬man(x) ∨ mortal(x))
mortal(Socrates)favorite_drink(Socrates, hemlock)drinks(x, favorite_drink(x))
U = (Socrates, hemlock, Fred)
![Page 67: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/67.jpg)
Propositionalization example
(¬man(Socrates) ∨ mortal(Socrates)) (¬man(Fred) ∨ mortal(Fred)) (¬man(hemlock) ∨ mortal(hemlock))drinks(Socrates, favorite_drink(Socrates)) drinks(hemlock, favorite_drink(hemlock)) drinks(Fred, favorite_drink(Fred))mortal(Socrates) ∧ favorite_drink(Socrates, hemlock)
![Page 68: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/68.jpg)
Choosing a universe
To check a FOL KB, propositionalize it using some universe UWhich universe?
![Page 69: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/69.jpg)
Herbrand Universe
Herbrand universe H of formula S:start with all objects mentioned in Sor synthetic object X if none mentionedapply all functions mentioned in S to all combinations of objects in H, add to Hrepeat
![Page 70: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/70.jpg)
Herbrand Universe
E.g., loves(uncle(John), Mary)H = {John, Mary, uncle(John), uncle(Mary), uncle(uncle(John)), uncle(uncle(Mary)), … }
![Page 71: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/71.jpg)
Herbrand’s theorem
If a FOL KB in clause form is unsatisfiableAnd H is its Herbrand universeThen the propositionalized KB is unsatisfiable for some finite U ⊆ H
![Page 72: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/72.jpg)
Converse of Herbrand
A. J. Robinson proved “lifting lemma”Write PKB for a propositionalization of KBAny resolution proof in PKB corresponds to a resolution proof in KB… so, if PKB is unsatisfiable, so is KB
![Page 73: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/73.jpg)
Proofs w/ Herbrand & Robinson
So, FOL KB is unsatisfiable if and only if there is a subset of Herbrand universe making PKB unsatisfiable
![Page 74: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/74.jpg)
Proofs w/ Herbrand & Robinson
To prove S, put KB ∧ ¬S in clause form
Build subsets of Herbrand universe in increasing order of size: U1, U2, …Propositionalize KB with Ui, check SATIf Ui unsatisfiable, we have our contradictionIf Ui satisfiable, move on to Ui+1
![Page 75: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/75.jpg)
Making it faster
Restrict semantics so we only need to check one finite propositional KBUnique names: objects with different names are different (John ≠ Mary)
Domain closure: objects without names given in KB don’t existRestrictions also make entailment, validity feasible
![Page 76: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/76.jpg)
Planning
![Page 77: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/77.jpg)
Time
So far, have not modeled a changing worldFor KBs that evolve, add extra argument to each predicate saying when it was true
at(Robot, Wean5409) at(Robot, Wean5409, 17)
![Page 78: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/78.jpg)
Operators
Given a representation like this, can define operators that change stateE.g., given
at(Robot, Wean5409, 17)moves(Robot, Wean5409, corridor, 17)
could define an operator that impliesat(Robot, corridor, 18)¬at(Robot, Wean5409, 18)
![Page 79: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/79.jpg)
Goals
Want our robot to, e.g., get sandwichSearch for proof of has(Geoff, Sandwich, t)Analyze proof tree to find sequence of operators that make goal true
![Page 80: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/80.jpg)
Complications
This strategy yields lots of complicationsneed axioms describing natural numbers (for time)frame axioms (facts don’t appear or disappear unless we used an operator)unique names, exactly one action per step, …
Result is slow inference
![Page 81: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/81.jpg)
Planning
Alternate solution: define a subset of FOL especially for planningE.g., STRIPS language
no functions, limited quantification, …STanford Research Institute Problem Solver
![Page 82: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/82.jpg)
STRIPS
State of world at each time = { propositions }Each proposition is ground literalFor brevity, list only true literalsTime is implicit
![Page 83: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/83.jpg)
STRIPS state example
![Page 84: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/84.jpg)
STRIPS state example
food(N)hungry(M)at(N, W)at(M, X)at(B1, Y)at(B2, Y)
at(B3, Z)on(B2, B1)clear(B2)clear(B3)height(M, Low)height(N, High)
![Page 85: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/85.jpg)
STRIPS operators
Operator = { preconditions }, { effects }If preconditions are true at time t,
can apply operator at time teffects will be true at time t+1rest of state unaffected
Basic STRIPS: one operator per step
![Page 86: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/86.jpg)
Quantification in operators
Preconditions of operator may contain variables (implicit ∀)
Operator can apply if preconditions unify with state t (using binding X)state t+1 has e / X for each e in effects
![Page 87: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/87.jpg)
Operator example
Eat(target, p, l)hungry(M), food(target), at(M, p), at(target, p), level(M, l), level(target, l)¬hungry(M), full(M), ¬at(target, p), ¬level(target, l)
![Page 88: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/88.jpg)
Operator example
Move(from, to)at(M, from), level(M, Low)at(M, to), ¬at(M, from)
Push(object, from, to)at(object, from), at(M, from), clear(object)at(M, to), at(object, to), ¬at(object, from), ¬at(M, from)
![Page 89: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/89.jpg)
Operator example
Climb(object, p)at(M, p), at(object, p), level(M, Low), clear(object)level(M, High), ¬level(M, Low)
ClimbDown()level(M, High)¬level(M, High), level(M, Low)
![Page 90: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/90.jpg)
Plan search
![Page 91: 15-780: Graduate AI Lecture 5. Logic, Planning](https://reader033.fdocuments.net/reader033/viewer/2022050520/627291cdca34ba72b6651a48/html5/thumbnails/91.jpg)
Plan search
Given a planning problem (start state, operator descriptions, goal)Run standard search algorithms to find planDecisions: search state representation, neighborhood, search algorithm