
6.825 Techniques in Artificial Intelligence Satisfiability Problems Many problems can be expressed as a list of constraints. Satisfiability and Validity Answer is assignment to variables that satisfy all the constraints. Satisfiable sentence: there exists a truth value Examples: assignment for the variables that makes the • Scheduling people to work in shifts at a hospital sentence true (truth value = t). – Some people don’t work at night • Algorithm? – No one can work more than x hours a week • Try all the possible assignments to see if one – Some pairs of people can’t be on the same shift works. – Is there assignment of people to shifts that satisfy all constraints? Valid sentence: all truth value assignments for the • Finding bugs in programs [Daniel Jackson, MIT] variables make the sentence true. – Write logical specification of, e.g. air traffic controller • Algorithm? – Write assertion “two airplanes on same runway at • Try all possible assignments and check that they same time” all work. – Can these be satisfied simultaneously? Are there better algorithms than these? Lecture 4 • 1 Lecture 4 • 2 Conjunctive Normal Form Converting to CNF Satisfiability problems are written as conjunctive 1. Eliminate arrows using definitions normal form (CNF) formulas: 2. Drive in negations using De Morgan’s Laws (A ⁄ B ⁄ÿC)Ÿ(B ⁄ D)Ÿ(ÿA) Ÿ(B ⁄C) ÿ(f ⁄ j) ≡ ÿf Ÿ ÿj ÿ(f Ÿ j) ≡ ÿf ⁄ ÿj • ( A ⁄ B ⁄ ÿ C ) is a clause, which is a disjunction of literals 3. Distribute or over and • A, B, and C are literals, each of which is a : A ⁄(B ŸC) ≡ (A ⁄ B)Ÿ(A ⁄C) variable or the negation of a variable. • Each clause is a requirement which must be satisfied and it has different ways of being satisfied. 4. Every sentence can be converted to CNF, but it may grow exponentially in size • Every sentence in propositional logic can be written in CNF Lecture 4 • 3 Lecture 4 • 4 CNF Conversion Example Simplifying CNF (A ⁄ B) Æ (C Æ D) • An empty clause is false (no options to satisfy) 1. Eliminate arrows • A sentence with no clauses is true (no requirements) ÿ(A⁄ B) ⁄ (ÿC ⁄ D) † • A sentence containing an empty clause is false 2. Drive in negations (there is an impossible requirement) † (ÿA†Ÿ ÿB) ⁄(ÿC ⁄ D) 3. Distribute (ÿA ⁄ÿC ⁄ D)Ÿ(ÿB ⁄ÿC ⁄ D) Lecture 4 • 5 Lecture 4 • 6 1 † † † Recitation Problems - I Algorithms for Satisfiability Convert to CNF Given a sentence in CNF, how can we prove it is 1. (A Æ B) Æ C satisfiable? Enumerate all possible assignments and see if 2. A Æ (B Æ C) sentence is true for any of them. But, the number of possible assignments grows exponentially in the 3. (A Æ B) ⁄(B Æ A) number of variables. Consider a search tree where at each level we 4. ÿ(ÿP Æ (P Æ Q)) consider the possible assignments to one variable, say P. On one branch, we assume P is f and on the 5. other that it is t. (P Æ (Q Æ R)) Æ (P Æ (R Æ Q)) 6. Given an assignment for a variable, we can simplify the sentence and then repeat the process for (P Æ Q) Æ ((Q Æ R) Æ (P Æ R)) another variable. Lecture 4 • 7 Lecture 4 • 8 Assign and Simplify Example Assign and Simplify (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) Given a CNF sentence f and a literal U Ÿ(P ⁄ S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) • Delete all clauses containing U (they’re satisfied) • Delete :U from all remaining clauses (because U If we assign P=f, we get simpler set of constraints † is not an option) P ⁄Q Q † • simplifies to • P ⁄ ÿ Q ⁄ R simplifies to ÿQ⁄ R We denote the simplified sentence by f(U) • ÿ P ⁄ ÿ T is satisfied and can be removed Works for positive and negative literals U † • P ⁄ S simplifies to S † † Result is (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR)Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) † Lecture 4 • 9 Lecture 4 • 10 Search Example Search Example (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) Ÿ(P ⁄ S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(P ⁄ S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:P) f(P) f(:P) f(P) (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR) † Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) † † † † † † † Lecture 4 • 11 Lecture 4 • 12 † † 2 † Search Example Search Example (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) Ÿ(P ⁄ S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(P ⁄ S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:P) f(P) f(:P) f(P) (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR) (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR) Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:Q) f(Q) f(:Q) f(Q) ()Ÿ(T ⁄ÿR) Ÿ(S) (R) Ÿ(T ⁄ÿR) Ÿ(S) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Lecture 4 • 13 Lecture 4 • 14 † † Search Example Search Example (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) † Ÿ(P ⁄ S)Ÿ†(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(P ⁄ S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:P) f(P) f(:P) f(P) (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR) (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR) † Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:Q) f(Q) † f(:Q) f(Q) ()Ÿ(T ⁄ÿR) Ÿ(S) (R) Ÿ(T ⁄ÿR) Ÿ(S) ()Ÿ(T ⁄ÿR) Ÿ(S) (R) Ÿ(T ⁄ÿR) Ÿ(S) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:R) f(R) f(:R) f(R) ()Ÿ(S)Ÿ(T ⁄ S)Ÿ(ÿS ⁄T) (T)Ÿ(S)Ÿ(ÿS ⁄T) Lecture 4 • 15 Lecture 4 • 16 † † Search Example Search Example (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) (P ⁄Q)Ÿ(P ⁄ÿQ⁄ R) Ÿ(T ⁄ÿR) Ÿ(ÿP ⁄ÿT) † Ÿ(P ⁄ S)Ÿ†(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(P ⁄ S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:P) f(P) f(:P) f(P) (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR) (Q)Ÿ(ÿQ⁄ R)Ÿ(T ⁄ÿR) † † Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(S)Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) † f(:Q) f(Q) † f(:Q) f(Q) ()Ÿ(T ⁄ÿR) Ÿ(S) (R) Ÿ(T ⁄ÿR) Ÿ(S) ()Ÿ(T ⁄ÿR) Ÿ(S) (R) Ÿ(T ⁄ÿR) Ÿ(S) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) Ÿ(T ⁄ R ⁄ S)Ÿ(ÿS ⁄T) f(:R) f(R) f(:R) f(R) † ()Ÿ(S)Ÿ(T ⁄ S)Ÿ(ÿS ⁄T) (T)Ÿ(S)Ÿ(ÿS ⁄†T ) ()Ÿ(S)Ÿ(T ⁄ S)Ÿ(ÿS ⁄T) (T)Ÿ(S)Ÿ(ÿS ⁄T) f(S) f(S) The assignment for a literal (T)Ÿ(T) The assignment for a literal (T)Ÿ(T) appearing by itself in a clause appearing by itself in a clause is forced: true for a positive f(T) is forced: true for a positive f(T) literal, false for a negative literal, false for a negative True True literal. Lecture 4 • 17 literal. Lecture 4 • 18 † † 3 † † † † † † † † † † † † Another Example DPLL(f) • If f is empty, return true (T ⁄ X)Ÿ(ÿS ⁄T)Ÿ(S ⁄ X) (embrace truth) • If there is an empty clause in f, return false f(T) (reject falsity) (S ⁄ X) • If there is a unit clause U in f, return DPLL(f(U)) (accept the inevitable) f(S) • If there is a pure literal U in f, return DPLL(f(U)) True (go with the flow) • For some variable v Since T occurs only (take a guess) positively, it might – If DPLL(f(v)) then return true as well be assigned – Else return DPLL(f(: v)) to true Unit clause has only one literal Pure literal only occurs positively or negatively Lecture 4 • 19 Lecture 4 • 20 Recitation Problems - II Making good guesses How would you modify DPLL so it: • returns a satisfying assignment if there is one, MOMS heuristic for choosing variable v: and false otherwise † • returns all satisfying assignments Maximum number of Occurrences, Minimum Sized clauses Would using DPLL to return all satisfying assignments † be any more efficient than simply listing all the • Choose highly constrained variables assignments and checking to see whether they’re satisfying? Why or why not? • If you’re going to fail, fail early Lecture 4 • 21 Lecture 4 • 22 Soundness and Completeness GSAT Properties of satisfiability algorithms: Hill climbing in the space of total assignments • Sound – if it gives you an answer, it’s correct • Starts with random assignment for all variables • Complete – it always gives you an answer • Moves to “neighboring” assignment with least cost (flip a single bit) DPLL is sound and complete Cost(assignment) = number of unsatisfied clauses We will now consider some algorithms for Loop n times satisfiability that are sound but not complete.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-