CSE 473 Propositional Logic SAT Algorithms Dan Weld (With some slides from Mausam, Stuart Russell, Dieter Fox, Henry Kautz, Min-Yen Kan…) Irrationally.

Slides:



Advertisements
Similar presentations
Russell and Norvig Chapter 7
Advertisements

Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Effective Propositional Reasoning CSE 473 – Autumn 2003.
Artificial Intelligence Knowledge-based Agents Russell and Norvig, Ch. 6, 7.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Computing & Information Sciences Kansas State University Lecture 11 of 42 CIS 530 / 730 Artificial Intelligence Lecture 11 of 42 William H. Hsu Department.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Knowledge Representation I (Propositional Logic) CSE 473.
Logical Agents Chapter 7.
Methods of Proof Chapter 7, second half.
Logical Agents Chapter 7 Feb 26, Knowledge and Reasoning Knowledge of action outcome enables problem solving –a reflex agent can only find way from.
Logic in AI CSE 573. © Daniel S. Weld 2 Logistics Monday? Reading Ch 8 Ch 9 thru p 278 Section 10.3 Projects Due 11/10 Teams and project plan due by this.
Knowledge Representation II (Inference in Propositional Logic) CSE 473.
Knowledge Representation II (Inference in Propositional Logic) CSE 473 Continued…
Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip )
Logic - Part 2 CSE 573. © Daniel S. Weld 2 Reading Already assigned R&N ch 5, 7, 8, 11 thru 11.2 For next time R&N 9.1, 9.2, 11.4 [optional 11.5]
To do Check slides for next lecture and move some to this lecture. Consider eliminating resolution Simplify discussion of inference – just talk about SAT.
Logical Agents Chapter 7 (based on slides from Stuart Russell and Hwee Tou Ng)
Logical Agents. Knowledge bases Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system): 
Logical Agents (NUS) Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
CHAPTERS 7, 8 Oliver Schulte Logical Inference: Through Proof to Truth.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
1 Problems in AI Problem Formulation Uninformed Search Heuristic Search Adversarial Search (Multi-agents) Knowledge RepresentationKnowledge Representation.
Logic in AI CSE 573. © Daniel S. Weld 2 Logistics Monday? Reading Ch 8 Ch 9 thru p 278 Section 10.3 Projects Due 11/10 Teams and project plan due by this.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
S P Vimal, Department of CSIS, BITS, Pilani
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 Logical Agents Chapter 7. 2 A simple knowledge-based agent The agent must be able to: –Represent states, actions, etc. –Incorporate new percepts –Update.
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
© Daniel S. Weld 1 Logistics Problem Set 2 Due Wed A few KR problems Robocode 1.Form teams of 2 people 2.Write design document.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Computing & Information Sciences Kansas State University Wednesday, 13 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 10 of 42 Wednesday, 13 September.
1 Logical Agents Chapter 7. 2 Logical Agents What are we talking about, “logical?” –Aren’t search-based chess programs logical Yes, but knowledge is used.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Logical Agents Russell & Norvig Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean)
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Inference in Propositional Logic (and Intro to SAT) CSE 473.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7 Part I. 2 Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents. Inference : Example 1 How many variables? 3 variables A,B,C How many models? 2 3 = 8 models.
CS666 AI P. T. Chung Logic Logical Agents Chapter 7.
Propositional Logic: Logical Agents (Part I)
Notes 7: Knowledge Representation, The Propositional Calculus
Inference in Propositional Logic (and Intro to SAT)
EA C461 – Artificial Intelligence Logical Agent
EA C461 – Artificial Intelligence Logical Agent
Notes 7: Knowledge Representation, The Propositional Calculus
Local Search Strategies: From N-Queens to Walksat
Logical Agents Chapter 7.
EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS
Logical Agents Chapter 7 Selected and slightly modified slides from
Logical Agents Reading: Russell’s Chapter 7
Logical Agents Chapter 7.
Artificial Intelligence
Artificial Intelligence: Agents and Propositional Logic.
Logical Agents Chapter 7.
Knowledge Representation I (Propositional Logic)
Methods of Proof Chapter 7, second half.
Problems in AI Problem Formulation Uninformed Search Heuristic Search
Logical Agents Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

CSE 473 Propositional Logic SAT Algorithms Dan Weld (With some slides from Mausam, Stuart Russell, Dieter Fox, Henry Kautz, Min-Yen Kan…) Irrationally held truths may be more harmful than reasoned errors. - Thomas Huxley ( )

Overview – Introduction & Agents – Search, Heuristics & CSPs – Adversarial Search – Logical Knowledge Representation – Planning & MDPs – Reinforcement Learning – Uncertainty & Bayesian Networks – Machine Learning – NLP & Special Topics

Propositional Logic Syntax – Atomic sentences: P, Q, … – Connectives: , , ,  Semantics – Truth Tables Inference – Modus Ponens – Resolution – DPLL – GSAT Complexity © Daniel S. Weld3

Semantics Syntax: which arrangements of symbols are legal – (Def “sentences”) Semantics: what the symbols mean in the world – (Mapping between symbols and worlds) © Daniel S. Weld4 Sentences Facts Sentences Representation World Semantics Inference

5 Truth tables for connectives

6 Models Logicians often think in terms of models, which are formally structured worlds with respect to which truth can be evaluated – In propositional case, each model = truth assignment – Set of models can be enumerated in a truth table We say m is a model of a sentence α if α is true in m M(α) is the set of all models of α Then KB ╞ α iff M(KB)  M(α) – E.g. KB = (P  Q)  (  P  R) α = (P  R) How to check? – One way is to enumerate all elements in the truth table – slow 

Satisfiability, Validity, & Entailment S is satisfiable if it is true in some world S is unsatisfiable if it is false all worlds S is valid if it is true in all worlds S1 entails S2 if wherever S1 is true S2 is also true © Daniel S. Weld7

Types of Reasoning (Inference) Deduction (showing entailment, |=) S = question Prove that KB |= S Two approaches: Rules to derive new formulas from old (inference) Show (KB   S) is unsatisfiable Model Finding (showing satisfiability) S = description of problem Show S is satisfiable A kind of constraint satisfaction 8

Propositional Logic: Inference Algorithms 1.Backward & Forward Chaining 2.Resolution (Proof by Contradiction) 3.Exhaustive Enumeration 4.DPLL (Davis, Putnam Loveland & Logemann) 5.GSAT © Daniel S. Weld9 } } Deduction Model Finding

10 Wumpus World Performance measure – Gold: +1000, death: – -1 per step, -10 for using the arrow Environment – Squares adjacent to wumpus are smelly – Squares adjacent to pit are breezy – Glitter iff gold is in the same square – Shooting kills wumpus if you are facing it – Shooting uses up the only arrow – Grabbing picks up gold if in same square – Releasing drops the gold in same square Sensors: Stench, Breeze, Glitter, Bump, Scream Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot

11 Exploring a wumpus world [1,2]

12 Exploring a wumpus world [1,2]

13 Exploring a wumpus world [1,2]

14 Exploring a wumpus world [1,2]

15 Exploring a wumpus world [1,2]

16 Exploring a wumpus world [1,2]

17 Exploring a wumpus world [1,2]

18 Exploring a wumpus world [1,2]

19 Wumpus world sentences: KB Let P i,j be true if there is a pit in [i, j]. Let B i,j be true if there is a breeze in [i, j]. KB:  P 1,1  B 1,1 "Pits cause breezes in adjacent squares" B 1,1  (P 1,2  P 2,1 ) B 2,1  (P 1,1  P 2,2  P 3,1 )

20 Full Encoding of Wumpus World In propositional logic:  P 1,1  W 1,1 B x,y  (P x,y+1  P x,y-1  P x+1,y  P x-1,y ) S x,y  (W x,y+1  W x,y-1  W x+1,y  W x-1,y ) W 1,1  W 1,2  …  W 4,4  W 1,1   W 1,2  W 1,1   W 1,3 …  64 distinct proposition symbols, 155 sentences

Model Finding Find an assignments to variables that makes a formula true Note: this is a kind of CSP, right?  =  P 12 (ie “[1,2] is safe”)

State Estimation Maintaining a KB which records what you know about the (partially observed) world state – Prop logic – First order logic – Probabilistic encodings

23

Propositional Logic: Inference Algorithms 1.Backward & Forward Chaining 2.Resolution (Proof by Contradiction) 3.Exhaustive Enumeration 4.DPLL (Davis, Putnam Loveland & Logemann) 5.GSAT © Daniel S. Weld24 } } Deduction Model Finding

Inference 3: Model Enumeration for (m in truth assignments){ if (m makes  true) then return “Sat!” } return “Unsat!” © Daniel S. Weld25

26 Model Checking : Truth tables for inference alpha_1 = not P_{12} (“[1,2] is safe”)

Inference 4: DPLL (Enumeration of Partial Models) [Davis, Putnam, Loveland & Logemann 1962] Version 1 dpll_1(pa){ if (pa makes F false) return false; if (pa makes F true) return true; choose P in F; if (dpll_1(pa  {P=0})) return true; return dpll_1(pa  {P=1}); } Returns true if F is satisfiable, false otherwise © Daniel S. Weld27

DPLL Version 1 © Daniel S. Weld28 (a  b  c) (a  ¬b) (a  ¬c) (¬a  c)

DPLL Version 1 © Daniel S. Weld29 a (a  b  c) (a  ¬b) (a  ¬c) (¬a  c)

DPLL Version 1 © Daniel S. Weld30 a (F  b  c) (F  ¬b) (F  ¬c) (T  c) F

DPLL Version 1 © Daniel S. Weld31 a (F  F  c) (F  T) (F  ¬c) (T  c) F b F

DPLL Version 1 © Daniel S. Weld32 a (F  F  F) (F  T) (T  F) F b c F F

DPLL Version 1 © Daniel S. Weld33 a F T T T F b c F F

DPLL Version 1 © Daniel S. Weld34 a b c (a  b  c) (a  ¬b) (a  ¬c) (¬a  c) F F F

DPLL Version 1 © Daniel S. Weld35 a b b c c (a  b  c) (a  ¬b) (a  ¬c) (¬a  c)

DPLL as Search Search Space? Algorithm? © Daniel S. Weld36

Improving DPLL © Daniel S. Weld37

Improving DPLL © Daniel S. Weld38

Improving DPLL © Daniel S. Weld39

Representing Formulae CNF = Conjunctive Normal Form – Conjunction (  ) of Disjunctions (  ) Represent as set of sets – ((A, B), (  A, C), (  C)) – ((  A), (A)) – (()) – ((A)) – ()

DPLL version 2 dpll_2(F, literal){ remove clauses containing literal if (F contains no clauses)return true; shorten clauses containing  literal if (F contains empty clause) return false; choose V in F; if (dpll_2(F,  V))return true; return dpll_2(F, V); } Partial assignment corresponding to a node is the set of chosen literals on the path from the root to the node © Daniel S. Weld41

DPLL Version 2 © Daniel S. Weld42 a (a  b  c) (a  ¬b) (a  ¬c) (a  c)(a  c)

DPLL Version 2 © Daniel S. Weld43 a (F  b  c) (F  ¬b) (F  ¬c) (T  c) F

DPLL Version 2 © Daniel S. Weld44 a (b  c)(b  c) (¬b) (¬c) F

DPLL Version 2 © Daniel S. Weld45 a (F  c) (T) (¬c) b F F

DPLL Version 2 © Daniel S. Weld46 a (c)(c) (¬c) b F F

DPLL Version 2 © Daniel S. Weld47 a (F) (T) b c F F F

DPLL Version 2 © Daniel S. Weld48 a () b c Empty clause! F F F

DPLL Version 2 © Daniel S. Weld49 a (F  F  F) (F  T) (T  F) F b c

DPLL Version 2 © Daniel S. Weld50 a F T T T F b c

DPLL Version 2 © Daniel S. Weld51 a b c (a  b  c) (a  ¬b) (a  ¬c) (¬a  c)

Benefit Can backtrack before getting to leaf © Daniel S. Weld52

Structure in Clauses Pure Literals – A symbol that always appears with same sign – {{a  b c} {  c d  e} {  a  b e}{d b} {e a  c}} © Daniel S. Weld53 Unit Literals A literal that appears in a singleton clause {{  b c}{  c}{a  b e}{d b}{e a  c}} Might as well set it true! And simplify {{a  b c} {  a  b e} {e a  c}} Might as well set it true! And simplify {{  b} {a  b e}{d b}} {{d}}

In Other Words © Daniel S. Weld54 May view this as adding constraint propagation techniques into play

In Other Words © Daniel S. Weld55 May view this as adding constraint propagation techniques into play

DPLL (previous version) Davis – Putnam – Loveland – Logemann dpll(F, literal){ remove clauses containing literal if (F contains no clauses) return true; shorten clauses containing  literal if (F contains empty clause) return false; if (F contains a unit or pure L) return dpll(F, L); choose V in F; if (dpll(F,  V))return true; return dpll(F, V); } © Daniel S. Weld56

DPLL (for real!) Davis – Putnam – Loveland – Logemann dpll(F, literal){ remove clauses containing literal if (F contains no clauses) return true; shorten clauses containing  literal if (F contains empty clause) return false; if (F contains a unit or pure L) return dpll(F, L); choose V in F; if (dpll(F,  V))return true; return dpll(F, V); } © Daniel S. Weld57

DPLL (for real) © Daniel S. Weld58 a b c c (a  b  c) (a  ¬b) (a  ¬c) (¬a  c)

Compare with DPLL Version 1 © Daniel S. Weld59 a b b c c (a  b  c) (a  ¬b) (a  ¬c) (¬a  c)

DPLL (for real!) Davis – Putnam – Loveland – Logemann dpll(F, literal){ remove clauses containing literal if (F contains no clauses) return true; shorten clauses containing  literal if (F contains empty clause) return false; if (F contains a unit or pure L) return dpll(F, L); choose V in F; if (dpll(F,  V))return true; return dpll(F, V); } © Daniel S. Weld60 Where could we use a heuristic to further improve performance?

Heuristic Search in DPLL Heuristics are used in DPLL to select a (non- unit, non-pure) proposition for branching Idea: identify a most constrained variable – Likely to create many unit clauses MOM’s heuristic: – Most occurrences in clauses of minimum length © Daniel S. Weld61

Success of DPLL 1962 – DPLL invented 1992 – 300 propositions 1997 – 600 propositions (satz) Additional techniques: – Learning conflict clauses at backtrack points – Randomized restarts – 2002 (zChaff) 1,000,000 propositions – encodings of hardware verification problems © Daniel S. Weld62

Other Ideas? How else could we solve SAT problems?

WalkSat (Take 1) Local search (Hill Climbing + Random Walk) over space of complete truth assignments – With prob p: flip any variable in any unsatisfied clause – With prob (1-p): flip best variable in any unsat clause best = one which minimizes #unsatisfied clauses © Daniel S. Weld64

Refining Greedy Random Walk Each flip – makes some false clauses become true – breaks some true clauses, that become false Suppose s1  s2 by flipping x. Then: #unsat(s2) = #unsat(s1) – make(s1,x) + break(s1,x) Idea 1: if a choice breaks nothing, it’s likely good! Idea 2: near the solution, only the break count matters – the make count is usually 1

Walksat (Take 2) state = random truth assignment; while ! GoalTest(state) do clause := random member { C | C is false in state }; for each x in clause do compute break[x]; if exists x with break[x]=0 then var := x; else with probability p do var := random member { x | x is in clause }; else var := arg x min { break[x] | x is in clause }; endif state[var] := 1 – state[var]; end return state; Put everything inside of a restart loop. Parameters: p, max_flips, max_runs

Random 3-SAT – sample uniformly from space of all possible 3- clauses – n variables, l clauses Which are the hard instances? – around l/n =

Random 3-SAT Varying problem size, n Complexity peak appears to be largely invariant of algorithm – backtracking algorithms like Davis-Putnam – local search procedures like GSAT What’s so special about 4.3? 68

Random 3-SAT Complexity peak coincides with solubility transition – l/n < 4.3 problems under- constrained and SAT – l/n > 4.3 problems over- constrained and UNSAT – l/n=4.3, problems on “knife- edge” between SAT and UNSAT 69

Special Syntactic Forms General Form: ((q  r)  s))   (s  t) Conjunction Normal Form (CNF) (  q  r  s )  (  s   t) Set notation: { (  q, r, s ), (  s,  t) } empty clause () = false Binary clauses: 1 or 2 literals per clause (  q  r) (  s   t) Horn clauses: 0 or 1 positive literal per clause (  q   r  s ) (  s   t) (q  r)  s (s  t)  false © Daniel S. Weld70

Prop. Logic Themes Expressiveness © Daniel S. Weld71 NP in general Completeness / speed tradeoff Horn clauses, binary clauses Tractability Expressive but awkward No notion of objects, properties, or relations Number of propositions is fixed