15-780: graduate ai lecture 3. logic and sat · 15-780: graduate ai lecture 3. logic and sat ......
TRANSCRIPT
![Page 1: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/1.jpg)
15-780: Graduate AILecture 3. Logic and SAT
Geoff Gordon (this lecture)Ziv Bar-Joseph
TAs Geoff Hollinger, Henry Lin
![Page 2: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/2.jpg)
Admin
HW1 out today!On course websiteDue Thu 10/4
Reminder: Matlab tutorial todayNSH 1507, 5PM
![Page 3: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/3.jpg)
Working together
Working together on HW, looking on web, etc.: great idea!
but each person must write up and submit his/her own solution, without reference to written/electronic materials from web or other students
Last year’s HWs are on course web site
![Page 4: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/4.jpg)
Late policy
If you need to hand a HW in late: contact us before due dateUnless agreed otherwise, HW is worth 75% credit up to 24 hrs late, 50% credit up to 48 hrs late, 0% credit afterwardsEven if for 0% credit, must hand in all assignments to pass
![Page 5: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/5.jpg)
Review
![Page 6: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/6.jpg)
Topics covered
C-spaceWays of splitting up C-space
Visibility graphVoronoiExact, approximate cell decompositionAdaptive cells (quadtree, parti-game)
RRTs
![Page 7: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/7.jpg)
8/15 puzzle applet
http://www.cs.ualberta.ca/~aixplore/search/IDA/Applet/SearchApplet.html
![Page 8: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/8.jpg)
Project ideas
![Page 9: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/9.jpg)
Poker
![Page 10: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/10.jpg)
Poker
Minimax strategy for heads-up poker = solving linear program1-card hands, 13-card deck: 52 vars, instantaneousRI Hold’Em: ~1,000,000 vars
2 weeks / 30GB (exact sol, CPLEX)40 min / 1.5GB (approx sol)
TX Hold’Em: ??? (up to 1017 vars or so)
![Page 11: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/11.jpg)
ScrabbleTM
Can buy a hand-tweaked, very good computer Scrabble player for $30 or soCan we learn to beat it?
![Page 12: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/12.jpg)
Learning models for control
Most of this course, we’ll assume we have a good model of the world when we’re trying to planUsually not true in practice—must learn itProject: learn a model for an interesting system, write a planner for learned model, make planner work on original system
![Page 13: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/13.jpg)
Learning models for control
R/C car
![Page 14: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/14.jpg)
Learning models for control
Model airplane
![Page 15: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/15.jpg)
Citation
“Using Inaccurate Models in Reinforcement Learning.” Pieter Abbeel, Morgan Quigley, Andrew Y. Nghttp://www.icml2006.org/icml_documents/camera-ready/001_Using_Inaccurate_Mod.pdf
![Page 16: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/16.jpg)
Logic
![Page 17: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/17.jpg)
Why logic?
Search: for problems like 8-puzzle, can write compact description of rulesReasoning: figure out consequences of the knowledge we’ve given our agentForeshadowing: logical inference is a special case of probabilistic inference (Part II)
![Page 18: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/18.jpg)
Propositional logic
Constants: T or FVariables: x, y (values T or F)Connectives: ∧, ∨, ¬
Can get by w/ just NANDSometimes also add others: ⊕, ⇒, ⇔, …
George Boole1815–1864
![Page 19: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/19.jpg)
Propositional logic
Build up expressions like ¬x ⇒ y
Precedence: ¬, ∧, ∨, ⇒
Terminology: variable or constant with or w/o negation = literalWhole thing = formula or sentence
![Page 20: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/20.jpg)
Expressive variable names
Rather than variable names like x, y, may use names like “rains” or “happy(John)”For now, “happy(John)” is just a string with no internal structure
there is no “John”happy(John) ⇒ ¬happy(Jack) means the same as x ⇒ ¬y
![Page 21: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/21.jpg)
But what does it mean?
A formula defines a mapping(assignment to variables) ↦ {T, F}
Assignment to variables = modelFor example, formula ¬x yields mapping:
x ¬x
T F
F T
![Page 22: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/22.jpg)
More truth tables
x y x ∧ y
T T T
T F F
F T F
F F F
x y x ∨ y
T T T
T F T
F T T
F F F
![Page 23: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/23.jpg)
Truth table for implication
(a ⇒ b) is logically equivalent to (¬a ∨ b)
If a is True, b must be True too
If a False, no requirement on b
E.g., “if I go to the movie I will have popcorn”: if no movie, may or may not have popcorn
a b a ⇒ b
T T T
T F F
F T T
F F T
![Page 24: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/24.jpg)
Complex formulas
To evaluate a bigger formula(x ∨ y) ∧ (x ∨ ¬y) when x = F, y = F
Build a parse treeFill in variables at leaves using modelWork upwards using truth tables for connectives
![Page 25: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/25.jpg)
Example
(x ∨ y) ∧ (x ∨ ¬y) when x = F, y = F
![Page 26: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/26.jpg)
Bigger truth tables
x y z (x ∨ y) ⇒ zT T TT T FT F TT F FF T TF T FF F TF F F
![Page 27: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/27.jpg)
Working with formulas
![Page 28: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/28.jpg)
Definitions
Two sentences are equivalent, A ≡ B, if they have same truth value in every model
(rains ⇒ pours) ≡ (¬rains ∨ pours)
reflexive, transitive, commutativeSimplifying = transforming a formula into a shorter*, equivalent formula
![Page 29: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/29.jpg)
Transformation rules210 Chapter 7. Logical Agents
(! ! ") " (" ! !) commutativity of !(! # ") " (" # !) commutativity of #
((! ! ") ! #) " (! ! (" ! #)) associativity of !((! # ") # #) " (! # (" # #)) associativity of #
¬(¬!) " ! double-negation elimination
(! $ ") " (¬" $ ¬!) contraposition
(! $ ") " (¬! # ") implication elimination
(! % ") " ((! $ ") ! (" $ !)) biconditional elimination
¬(! ! ") " (¬! # ¬") de Morgan
¬(! # ") " (¬! ! ¬") de Morgan
(! ! (" # #)) " ((! ! ") # (! ! #)) distributivity of ! over #(! # (" ! #)) " ((! # ") ! (! # #)) distributivity of # over !
Figure 7.11 Standard logical equivalences. The symbols !, ", and # stand for arbitrarysentences of propositional logic.
chapter, we will see algorithms that are much more efficient in practice. Unfortunately, every
known inference algorithm for propositional logic has a worst-case complexity that is expo-
nential in the size of the input. We do not expect to do better than this because propositional
entailment is co-NP-complete. (See Appendix A.)
Equivalence, validity, and satisfiability
Before we plunge into the details of logical inference algorithms, we will need some addi-
tional concepts related to entailment. Like entailment, these concepts apply to all forms of
logic, but they are best illustrated for a particular logic, such as propositional logic.
The first concept is logical equivalence: two sentences ! and " are logically equivalentLOGICALEQUIVALENCE
if they are true in the same set of models. We write this as ! % ". For example, wecan easily show (using truth tables) that P ! Q and Q ! P are logically equivalent; other
equivalences are shown in Figure 7.11. They play much the same role in logic as arithmetic
identities do in ordinary mathematics. An alternative definition of equivalence is as follows:
for any two sentences ! and ",
! " " if and only if ! |= " and " |= ! .
(Recall that |= means entailment.)
The second concept we will need is validity. A sentence is valid if it is true in allVALIDITY
models. For example, the sentence P # ¬P is valid. Valid sentences are also known as
tautologies—they are necessarily true and hence vacuous. Because the sentence True is trueTAUTOLOGY
in all models, every valid sentence is logically equivalent to True.What good are valid sentences? From our definition of entailment, we can derive the
deduction theorem, which was known to the ancient Greeks:DEDUCTIONTHEOREM
For any sentences ! and ", ! |= " if and only if the sentence (! $ ") is valid.
(Exercise 7.4 asks for a proof.) We can think of the inference algorithm in Figure 7.10 as
α, β, γ are arbitrary formulas
210 Chapter 7. Logical Agents
(α ∧ β) ≡ (β ∧ α) commutativity of ∧(α ∨ β) ≡ (β ∨ α) commutativity of ∨
((α ∧ β) ∧ γ) ≡ (α ∧ (β ∧ γ)) associativity of ∧((α ∨ β) ∨ γ) ≡ (α ∨ (β ∨ γ)) associativity of ∨
¬(¬α) ≡ α double-negation elimination
(α ⇒ β) ≡ (¬β ⇒ ¬α) contraposition
(α ⇒ β) ≡ (¬α ∨ β) implication elimination
(α ⇔ β) ≡ ((α ⇒ β) ∧ (β ⇒ α)) biconditional elimination
¬(α ∧ β) ≡ (¬α ∨ ¬β) de Morgan
¬(α ∨ β) ≡ (¬α ∧ ¬β) de Morgan
(α ∧ (β ∨ γ)) ≡ ((α ∧ β) ∨ (α ∧ γ)) distributivity of ∧ over ∨(α ∨ (β ∧ γ)) ≡ ((α ∨ β) ∧ (α ∨ γ)) distributivity of ∨ over ∧
Figure 7.11 Standard logical equivalences. The symbols !, ", and # stand for arbitrarysentences of propositional logic.
chapter, we will see algorithms that are much more efficient in practice. Unfortunately, every
known inference algorithm for propositional logic has a worst-case complexity that is expo-
nential in the size of the input. We do not expect to do better than this because propositional
entailment is co-NP-complete. (See Appendix A.)
Equivalence, validity, and satisfiability
Before we plunge into the details of logical inference algorithms, we will need some addi-
tional concepts related to entailment. Like entailment, these concepts apply to all forms of
logic, but they are best illustrated for a particular logic, such as propositional logic.
The first concept is logical equivalence: two sentences α and β are logically equivalentLOGICALEQUIVALENCE
if they are true in the same set of models. We write this as α ⇔ β. For example, wecan easily show (using truth tables) that P ∧ Q and Q ∧ P are logically equivalent; other
equivalences are shown in Figure 7.11. They play much the same role in logic as arithmetic
identities do in ordinary mathematics. An alternative definition of equivalence is as follows:
for any two sentences α and β,
α ≡ β if and only if α |= β and β |= α .
(Recall that |= means entailment.)
The second concept we will need is validity. A sentence is valid if it is true in allVALIDITY
models. For example, the sentence P ∨ ¬P is valid. Valid sentences are also known as
tautologies—they are necessarily true and hence vacuous. Because the sentence True is trueTAUTOLOGY
in all models, every valid sentence is logically equivalent to True.What good are valid sentences? From our definition of entailment, we can derive the
deduction theorem, which was known to the ancient Greeks:DEDUCTIONTHEOREM
For any sentences α and β, α |= β if and only if the sentence (α ⇒ β) is valid.
(Exercise 7.4 asks for a proof.) We can think of the inference algorithm in Figure 7.10 as
![Page 30: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/30.jpg)
More rules
210 Chapter 7. Logical Agents
(α ! β) " (β ! α) commutativity of !(α # β) " (β # α) commutativity of #
((α ! β) ! γ) " (α ! (β ! γ)) associativity of !((α # β) # γ) " (α # (β # γ)) associativity of #
¬(¬α) " α double-negation elimination
(α $ β) " (¬β $ ¬α) contraposition
(α $ β) " (¬α # β) implication elimination
(α % β) " ((α $ β) ! (β $ α)) biconditional elimination
¬(α ! β) " (¬α # ¬β) de Morgan
¬(α # β) " (¬α ! ¬β) de Morgan
(α ! (β # γ)) " ((α ! β) # (α ! γ)) distributivity of ! over #(α # (β ! γ)) " ((α # β) ! (α # γ)) distributivity of # over !
Figure 7.11 Standard logical equivalences. The symbols !, ", and # stand for arbitrarysentences of propositional logic.
chapter, we will see algorithms that are much more efficient in practice. Unfortunately, every
known inference algorithm for propositional logic has a worst-case complexity that is expo-
nential in the size of the input. We do not expect to do better than this because propositional
entailment is co-NP-complete. (See Appendix A.)
Equivalence, validity, and satisfiability
Before we plunge into the details of logical inference algorithms, we will need some addi-
tional concepts related to entailment. Like entailment, these concepts apply to all forms of
logic, but they are best illustrated for a particular logic, such as propositional logic.
The first concept is logical equivalence: two sentences α and β are logically equivalentLOGICALEQUIVALENCE
if they are true in the same set of models. We write this as α % β. For example, wecan easily show (using truth tables) that P ! Q and Q ! P are logically equivalent; other
equivalences are shown in Figure 7.11. They play much the same role in logic as arithmetic
identities do in ordinary mathematics. An alternative definition of equivalence is as follows:
for any two sentences α and β,
α " β if and only if α |= β and β |= α .
(Recall that |= means entailment.)
The second concept we will need is validity. A sentence is valid if it is true in allVALIDITY
models. For example, the sentence P # ¬P is valid. Valid sentences are also known as
tautologies—they are necessarily true and hence vacuous. Because the sentence True is trueTAUTOLOGY
in all models, every valid sentence is logically equivalent to True.What good are valid sentences? From our definition of entailment, we can derive the
deduction theorem, which was known to the ancient Greeks:DEDUCTIONTHEOREM
For any sentences α and β, α |= β if and only if the sentence (α $ β) is valid.
(Exercise 7.4 asks for a proof.) We can think of the inference algorithm in Figure 7.10 as
α, β are arbitrary formulas
![Page 31: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/31.jpg)
Still more rules…
… can be derived from truth tablesFor example:
(a ∨ ¬a) ≡ True
(True ∨ a) ≡ True
(False ∧ a) ≡ False
![Page 32: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/32.jpg)
Example
![Page 33: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/33.jpg)
Normal Forms
![Page 34: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/34.jpg)
Normal forms
A normal form is a standard way of writing a formulaE.g., conjunctive normal form (CNF)
conjunction of disjunctions of literals(x ∨ y ∨ ¬z) ∧ (x ∨ ¬y) ∧ (z)
Each disjunct called a clauseAny formula can be transformed into CNF w/o changing meaning
![Page 35: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/35.jpg)
CNF cont’d
Often used for storage of knowledge databasecalled knowledge base or KB
Can add new clauses as we find them outEach clause in KB is separately true (if KB is)
happy(John) ∧ (¬happy(Bill) ∨ happy(Sue)) ∧man(Socrates) ∧(¬man(Socrates) ∨ mortal(Socrates))
![Page 36: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/36.jpg)
Another normal form: DNF
DNF = disjunctive normal form = disjunction of conjunctions of literalsDoesn’t compose the way CNF does: can’t just add new conjuncts w/o changing meaning of KBExample:
(rains ∨ ¬pours) ∧ fishing≡
(rains ∧ fishing) ∨ (¬pours ∧ fishing)
![Page 37: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/37.jpg)
Transforming to CNF or DNF
Naive algorithm:replace all connectives with ∧∨¬
move negations inward using De Morgan’s laws and double-negationrepeatedly distribute over ∧ over ∨ for DNF (∨ over ∧ for CNF)
![Page 38: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/38.jpg)
Example
Put the following formula in CNF
(a ∨ b ∨ ¬c) ∧ ¬(d ∨ (e ∧ f)) ∧ (c ∨ d ∨ e)
![Page 39: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/39.jpg)
Example
Now try DNF
(a ∨ b ∨ ¬c) ∧ ¬(d ∨ (e ∧ f)) ∧ (c ∨ d ∨ e)
![Page 40: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/40.jpg)
Discussion
Problem with naive algorithm: it’s exponential! (Space, time, size of result.)Each use of distributivity can almost double the size of a subformula
![Page 41: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/41.jpg)
A smarter transformation
Can we avoid exponential blowup in CNF?Yes, if we’re willing to introduce new variablesG. Tseitin. On the complexity of derivation in propositional calculus. Studies in Constrained Mathematics and Mathematical Logic, 1968.
![Page 42: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/42.jpg)
Example
Put the following formula in CNF:
(a ∧ b) ∨ (c ∧ d)
![Page 43: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/43.jpg)
Proofs
![Page 44: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/44.jpg)
Entailment
Sentence A entails sentence B, A ⊨ B, if B is True in every model where A is
same as saying that (A ⇒ B) is valid
![Page 45: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/45.jpg)
Proof tree
A tree with a formula at each nodeAt each internal node, children ⊨ parent
Leaves: assumptions or premisesRoot: consequenceIf we believe assumptions, we should also believe consequence
![Page 46: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/46.jpg)
Proof tree example
![Page 47: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/47.jpg)
Proof tree example
![Page 48: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/48.jpg)
Proof tree example
![Page 49: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/49.jpg)
Proof by contradiction
Assume opposite of what we want to prove, show it leads to a contradiction Suppose we want to show KB ⊨ S
Write KB’ for (KB ∧ ¬S)
Build a proof tree withassumptions drawn from clauses of KB’conclusion = Fso, (KB ∧ ¬S) ⊨ F (contradiction)
![Page 50: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/50.jpg)
Proof by contradiction
![Page 51: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/51.jpg)
Proof by contradiction
![Page 52: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/52.jpg)
Inference rules
![Page 53: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/53.jpg)
Inference rule
To make a proof tree, we need to be able to figure out new formulas entailed by KBMethod for finding entailed formulas = inference ruleWe’ve implicitly been using one already
![Page 54: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/54.jpg)
Modus ponens
Probably most famous inference rule: all men are mortal, Socrates is a man, therefore Socrates is mortalQuantifier-free version: man(Socrates) ∧
(man(Socrates) ⇒ mortal(Socrates))
d(a ∧ b ∧ c ⇒ d) a b c
![Page 55: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/55.jpg)
Another inference rule
Modus tollensIf it’s raining the grass is wet; the grass is not wet, so it’s not raining
¬a(a ⇒ b) ¬b
![Page 56: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/56.jpg)
One more…
(a ∨ b ∨ c) (¬c ∨ d ∨ e)a ∨ b ∨ d ∨ e
ResolutionCombines two sentences that contain a literal and its negationNot as commonly known as modus ponens / tollens
![Page 57: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/57.jpg)
Resolution example
Modus ponens / tollens are special casesModus tollens:(¬raining ∨ grass-wet) ∧ ¬grass-wet ⊨ ¬raining
![Page 58: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/58.jpg)
Resolution
Simple proof by case analysisConsider separately cases where we assign c = True and c = False
(a ∨ b ∨ c) (¬c ∨ d ∨ e)a ∨ b ∨ d ∨ e
![Page 59: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/59.jpg)
Resolution
Case c = True(a ∨ b ∨ T) ∧ (F ∨ d ∨ e)
= (T) ∧ (d ∨ e)
= (d ∨ e)
(a ∨ b ∨ c) ∧ (¬c ∨ d ∨ e)
![Page 60: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/60.jpg)
Resolution
Case c = False(a ∨ b ∨ F) ∧ (T ∨ d ∨ e)
= (a ∨ b) ∧ (T)
= (a ∨ b)
(a ∨ b ∨ c) ∧ (¬c ∨ d ∨ e)
![Page 61: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/61.jpg)
Resolution
Since c must be True or False, conclude(d ∨ e) ∨ (a ∨ b)
as desired
(a ∨ b ∨ c) ∧ (¬c ∨ d ∨ e)
![Page 62: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/62.jpg)
Theorem provers
![Page 63: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/63.jpg)
Theorem prover
Theorem prover = mechanical system for finding a proof treeAn application of search techniques from earlier lecture
Search node = KB (including whatever we’ve proven so far)Neighbor: (KB ∧ S) if KB ⊨ S
![Page 64: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/64.jpg)
A basic theorem prover
Given KB, want to conclude SLet KB’ = CNF(KB ∧ ¬S)
Repeat:add new clause to KB’ using resolution
Until we add empty clause (False) and conclude KB ⊨ S
Or run out of new clauses and conclude KB ⊭ S
![Page 65: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/65.jpg)
Soundness and completeness
An inference procedure is sound if it can only conclude things entailed by KB
common sense; haven’t discussed anything unsound
A set of rules is complete if it can conclude everything entailed by KB
![Page 66: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/66.jpg)
Completeness
Theorem provers based on modus ponens by itself are incompleteSimple resolution theorem prover from above is complete for propositional logic
![Page 67: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/67.jpg)
Variations
Later
Horn clause inference (faster)Ways of handling uncertainty (slower)CSPs (sometimes more convenient)Quantifiers / first-order logic
![Page 68: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/68.jpg)
Horn clauses
Horn clause: (a ∧ b ∧ c ⇒ d)
Equivalently, (¬a ∨ ¬b ∨ ¬c ∨ d)
Disjunction of literals, at most one of which is positivePositive literal = head, rest = body
![Page 69: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/69.jpg)
Use of Horn clauses
People find it easy to write Horn clauses (listing out conditions under which we can conclude head)
happy(John) ∧ happy(Mary) ⇒ happy(Sue)
No negative literals in above formula; again, easier to think about
![Page 70: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/70.jpg)
Why are Horn clauses important
Inference in a KB of propositional Horn clauses is linearE.g., by forward chaining
![Page 71: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/71.jpg)
Forward chaining
Look for a clause with all body literals satisfiedAdd its head to KBRepeatSee RN for more details
![Page 72: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/72.jpg)
Handling uncertainty
Fuzzy logic / certainty factorssimple, but don’t scale
Nonmonotonic logicalso doesn’t scale
Probabilitiesmay or may not scale—more in Part II
![Page 73: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/73.jpg)
Certainty factors
KB assigns a certainty factor in [0, 1] to each propositionInterpret as “degree of belief”When applying an inference rule, certainty factor for consequent is a function of certainty factors for antecedents (e.g., minimum)
![Page 74: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/74.jpg)
Problems w/ certainty factors
Hard to separate a large KB into mostly-independent chunks that interact only through a well-defined interfaceCertainty factors are not probabilities (i.e., do not obey Bayes’ Rule)
![Page 75: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/75.jpg)
Nonmonotonic logic
Suppose we believe all birds can flyMight add a set of sentences to KB
bird(Polly) ⇒ flies(Polly)
bird(Tweety) ⇒ flies(Tweety)
bird(Tux) ⇒ flies(Tux)bird(John) ⇒ flies(John)
…
![Page 76: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/76.jpg)
Nonmonotonic logic
Fails if there are penguins in the KBFix: instead, add
bird(Polly) ∧ ¬ab(Polly) ⇒ flies(Polly)
bird(Tux) ∧ ¬ab(Tux) ⇒ flies(Tux)
…ab(Tux) is an “abnormality predicate”Need separate abi(x) for each type of rule
![Page 77: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/77.jpg)
Nonmonotonic logic
Now set as few abnormality predicates as possibleCan prove flies(Polly) or flies(Tux) with no ab(x) assumptionsIf we assert ¬flies(Tux), must now assume ab(Tux) to maintain consistencyCan’t prove flies(Tux) any more, but can still prove flies(Polly)
![Page 78: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/78.jpg)
Nonmonotonic logic
Works well as long as we don’t have to choose between big sets of abnormalities
is it better to have 3 flightless birds or 5 professors that don’t wear jackets with elbow-patches?even worse with nested abnormalities: birds fly, but penguins don’t, but superhero penguins do, but …
![Page 79: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/79.jpg)
SAT
![Page 80: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/80.jpg)
Definitions
A sentence is satisfiable if it is True in some modelIf not satisfiable, it is a contradiction (False in every model)A sentence is valid if it is True in every model (a valid sentence is a tautology)
![Page 81: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/81.jpg)
Satisfiability
SAT is the problem of determining whether a given propositional logic sentence is satisfiableA decision problem: given an instance, answer yes or noA fundamental problem in CS
![Page 82: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/82.jpg)
SAT is a search problem
(At least) two ways to write itsearch nodes are (full or partial) models, neighbors differ in assignment for a single variablesearch nodes are formulas, neighbors by entailment
And hybrids (node = model + formula)
![Page 83: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/83.jpg)
SAT is a general search problem
Many other search problems reduce to SATInformally, if we can solve SAT, can solve these other problemsSo a good SAT solver is a good AI building block
![Page 84: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/84.jpg)
Example search problem
3-coloring: can we color a map using only 3 colors in a way that keeps neighboring regions from being the same color?
![Page 85: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/85.jpg)
Reduction
Loosely, “A reduces to B” means that if we can solve B then we can solve AMore formally, A, B are decision problems (instances ↦ truth values)
A reduction is a poly-time function f such that, given an instance a of A
f(a) is an instance of B, and A(a) = B(f(a))
![Page 86: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/86.jpg)
Reduction picture
![Page 87: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/87.jpg)
Reduction picture
![Page 88: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/88.jpg)
Reduction picture
![Page 89: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/89.jpg)
Example reduction
Each square must be red, green, or blueAdjacent squares can’t both be red (similarly, green or blue)
![Page 90: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/90.jpg)
Example reduction
(ar ∨ ag ∨ ab) ∧ (br ∨ bg ∨ bb) ∧ (cr ∨ cg ∨ cb) ∧ (dr ∨ dg ∨ db) ∧ (er ∨ eg ∨ eb) ∧ (zr ∨ zg ∨ zb)(¬ar ∨ ¬br) ∧ (¬ag ∨ ¬bg) ∧ (¬ab ∨ ¬bb)
(¬ar ∨ ¬zr) ∧ (¬ag ∨ ¬zg) ∧ (¬ab ∨ ¬zb)
…
![Page 91: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/91.jpg)
Search and reduction
S. A. Cook in 1971 proved that many useful search problems reduce back and forth to SAT
showed how to simulate poly-size-memory computer w/ (very complicated, but still poly-size) SAT problem
Equivalently, SAT is exactly as hard (in theory at least) as these other problems
![Page 92: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/92.jpg)
Cost of reduction
Complexity theorists often ignore little things like constant factors (or even polynomial factors!)So, is it a good idea to reduce your search problem to SAT?Answer: sometimes…
![Page 93: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/93.jpg)
Cost of reduction
SAT is well studied ⇒ fast solversSo, if there is an efficient reduction, ability to use fast SAT solvers can be a win
e.g., 3-coloringanother example later (SATplan)
Other times, cost of reduction is too highusu. because instance gets biggerwill also see example later (MILP)
![Page 94: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/94.jpg)
Choosing a reduction
May be many reductions from problem A to problem BMay have wildly different properties
e.g., search on transformed instance may take seconds vs. days
![Page 95: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/95.jpg)
Direction of reduction
If A reduces to B thenif we can solve B, we can solve Aso B must be at least as hard as A
Trivially, can take an easy problem and reduce it to a hard one
![Page 96: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/96.jpg)
Not-so-useful reduction
Path planning reduces to SATVariables: is edge e in path?Constraints:
exactly 1 path-edge touches startexactly 1 path-edge touches goaleither 0 or 2 touch each other node
![Page 97: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/97.jpg)
Reduction to 3SAT
We saw that search problems can be reduced to SAT
is CNF formula satisfiable?Can reduce even further, to 3SAT
is 3CNF formula satisfiable?Useful if reducing SAT/3SAT to another problem (to show other problem hard)
![Page 98: 15-780: Graduate AI Lecture 3. Logic and SAT · 15-780: Graduate AI Lecture 3. Logic and SAT ... Poker Minimax strategy for ... known inference algorithm for propositional logic has](https://reader035.vdocuments.us/reader035/viewer/2022070611/5b1442017f8b9a347c8c2854/html5/thumbnails/98.jpg)
Reduction to 3SAT
Must get rid of long clausesE.g., (a ∨ ¬b ∨ c ∨ d ∨ e ∨ ¬f)
Replace with(a ∨ ¬b ∨ x) ∧ (¬x ∨ c ∨ y) ∧ (¬y ∨ d ∨ z) ∧ (¬z ∨ e ∨ ¬f)