Decision Procedures for Satisfiability and Validity in Propositional Logic Meghdad Ghari Institute for Research in Fundamental Sciences (IPM) School of Mathematics-Isfahan Branch Logic Group http://math.ipm.ac.ir/Isfahan/Logic-Group.htm Logic Short Course I, Computational Propositional Logic November 24, 2016 Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 1 / 57
Outline Conjunctive Normal Form 1 Disjunctive Normal Form 2 Horn formulas 3 A linear SAT solver 4 Binary Decision Diagrams 5 Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 2 / 57
Logical reasoning Is the following argument logically valid? A 1 A 2 . . . A n B Various Semantics Artificial Language = ⇒ Various Proof systems Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 3 / 57
Language Formulas of propositional logic are defined by the following grammar: Formula ::= Atomic Formula | TRUE | FALSE | ( ¬ Formula) | (Formula ∧ Formula) | (Formula ∨ Formula) | (Formula → Formula). In Backus Naur form (BNF): φ ::= p | ⊤ | ⊥ | ( ¬ φ ) | ( φ ∧ φ ) | ( φ ∨ φ ) | ( φ → φ ) , p ∈ Atom Atom denotes a non-empty (finite or infinite) set of atomic propositions (or propositional variables). Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 4 / 57
Language Formulas of propositional logic are defined by the following grammar: Formula ::= Atomic Formula | TRUE | FALSE | ( ¬ Formula) | (Formula ∧ Formula) | (Formula ∨ Formula) | (Formula → Formula). In Backus Naur form (BNF): φ ::= p | ⊤ | ⊥ | ( ¬ φ ) | ( φ ∧ φ ) | ( φ ∨ φ ) | ( φ → φ ) , p ∈ Atom Atom denotes a non-empty (finite or infinite) set of atomic propositions (or propositional variables). Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 4 / 57
Semantics Valuations: v : Atom → { T , F } Valuations can be extended to the set of all formulas as follows: ¬ φ ⊤ ⊥ φ T F T F F T φ ∧ ψ φ ∨ ψ φ → ψ φ ψ φ ψ φ ψ T T T T T T T T T T F F T F T T F F F T F F T T F T T F F F F F F F F T Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 5 / 57
Principle of compositionality The meaning of a complex expression is determined by the meanings of its constituent expressions and the rules used to combine them. v ( ⊤ ) = T v ( ⊥ ) = F v ( ¬ φ ) = 1 − v ( φ ) v ( φ ∧ ψ ) = min ( v ( φ ) , v ( ψ )) v ( φ ∨ ψ ) = max ( v ( φ ) , v ( ψ )) v ( φ → ψ ) = min ( 1 , 1 − v ( φ ) + v ( ψ )) Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 6 / 57
Semantic consequence Definition If for all valuations in which all φ 1 , φ 2 , . . . , φ n evaluate to T , ψ evaluates to T as well, we say that φ 1 , φ 2 , . . . , φ n | = ψ holds and call | = the semantic entailment relation. Example p ∨ q , ¬ p | = q Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 7 / 57
Syntactic consequence Definition If ψ is provable (in a proof system) from premises φ 1 , φ 2 , . . . , φ n , we say that the sequent φ 1 , φ 2 , . . . , φ n ⊢ ψ is valid. Example p ∨ q , ¬ p ⊢ q Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 8 / 57
Logical consequence A 1 Two approaches to logical consequence: A 2 . Semantic: φ 1 , φ 2 , . . . , φ n | = ψ . . . Syntactic: φ 1 , φ 2 , . . . , φ n ⊢ ψ . A n B Theorem (Soundness) φ 1 , φ 2 , . . . , φ n ⊢ ψ ⇒ φ 1 , φ 2 , . . . , φ n | = ψ Theorem (Completeness) φ 1 , φ 2 , . . . , φ n | = ψ ⇒ φ 1 , φ 2 , . . . , φ n ⊢ ψ Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 9 / 57
Logic in Computer Science Two approaches: Semantic: ◮ M. Huth and M. Ryan, Logic in Computer Science modelling and reasoning about systems, Cambridge University Press, 2004 Syntactic: ◮ M. Fitting, First-Order Logic and Automated Theorem Proving , Springer, 1996. ◮ J. H. Gallier, Logic for Computer Science Foundations of Automatic Theorem Proving , John Wiley, 1987. Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 10 / 57
Satisfiability, validity, equivalence Definition (Satisfiable) Given a formula φ in propositional logic, we say that φ is satisfiable (has a model) if it has a valuation in which it evaluates to true. Definition (Valid) Given a formula φ in propositional logic, we say that φ is valid if under every valuation it evaluates to true. In that case we write | = φ . Definition (Equivalence) Let φ and ψ be formulas of propositional logic. We say that φ and ψ are semantically equivalent iff φ | = ψ and φ | = ψ hold. In that case we write φ ≡ ψ . Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 11 / 57
Decision procedures Definition A decision problem is a question in some formal system with a yes-or-no answer, depending on the values of some input parameters. Definition A decision procedure is an algorithm that, given a decision problem, terminates with a correct yes/no answer. Definition A computer program that searches for a model for a propositional formula is called a SAT Solver. Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 12 / 57
Some applications of SAT solvers Test for the functional equivalence of two circuits. Identifying defects of integrated circuits. Model checking of hardware and software systems. Planning in artificial intelligence. Joao Marques-Silva, Practical Applications of Boolean Satisfiability , In Workshop on Discrete Event Systems (WODES), IEEE Press, 2008. Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 13 / 57
Boolean functions Definition A boolean variable x is a variable ranging over the values 0 and 1. A boolean function f of n arguments is a function from { 0 , 1 } n to { 0 , 1 } . Example 0 def 1 def ¯ = 1 and ¯ = 0; x · y def = 1 if x = y = 1; otherwise x · y def = 0; x + y def = 0 if x = y = 0; otherwise x + y def = 1. Various representations of boolean functions: Truth tables Propositional formulas. Binary decision diagrams. Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 14 / 57
Boolean functions Definition A boolean variable x is a variable ranging over the values 0 and 1. A boolean function f of n arguments is a function from { 0 , 1 } n to { 0 , 1 } . Example 0 def 1 def ¯ = 1 and ¯ = 0; x · y def = 1 if x = y = 1; otherwise x · y def = 0; x + y def = 0 if x = y = 0; otherwise x + y def = 1. Various representations of boolean functions: Truth tables Propositional formulas. Binary decision diagrams. Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 14 / 57
Truth tables Truth tables are very space-inefficient. Once you have computed a truth table, it is easy to see whether the boolean function represented is satisfiable or valid. Once you have computed a truth table, comparing whether two ordered truth tables represent the same boolean function also seems easy. Checking satisfiability of a function with n atoms requires of the order of 2 n operations if the function is represented as a truth table. We conclude that checking satisfiability, validity and equivalence is highly inefficient with the truth-table representation. Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 15 / 57
Propositional formulas Propositional formulas often provide a compact and efficient presentation of boolean functions. Deciding whether two arbitrary propositional formulas f and g denote the same boolean function is suspected to be exponentially expensive. Deciding whether an arbitrary propositional formula is satisfiable is a famous problem in computer science: No efficient algorithms for SAT are known, and it is strongly suspected that there aren’t any. P ? = NP NP ? = co - NP Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 16 / 57
Theorem Let φ be a formula of propositional logic. Then φ is satisfiable iff ¬ φ is not valid. Theorem Given formulas φ 1 , φ 2 , . . . , φ n and ψ of propositional logic, φ 1 , φ 2 , . . . , φ n | = ψ iff | = φ 1 → ( φ 2 → . . . ( φ n → ψ )) Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 17 / 57
Theorem Let φ be a formula of propositional logic. Then φ is satisfiable iff ¬ φ is not valid. Theorem Given formulas φ 1 , φ 2 , . . . , φ n and ψ of propositional logic, φ 1 , φ 2 , . . . , φ n | = ψ iff | = φ 1 → ( φ 2 → . . . ( φ n → ψ )) Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 17 / 57
Conjunctive Normal Form (CNF) L ::= p | ¬ p , p ∈ Atom Literal D ::= L | L ∨ D Clause C ::= D | D ∧ C Conjunctive normal form Example ( ¬ q ∨ p ∨ r ) ∧ ( ¬ p ∨ r ) ∧ q . � ( ¬ q ∨ p ∨ r ∨ q ) ∧ ( ¬ p ∨ p ) . � ( p ∧ r ) ∧ ( ¬ p → r ) . × ¬ ( q ∨ p ∨ r ) ∧ ( ¬ q ∨ p ) . × Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 18 / 57
Conjunctive Normal Form (CNF) L ::= p | ¬ p , p ∈ Atom Literal D ::= L | L ∨ D Clause C ::= D | D ∧ C Conjunctive normal form Example ( ¬ q ∨ p ∨ r ) ∧ ( ¬ p ∨ r ) ∧ q . � ( ¬ q ∨ p ∨ r ∨ q ) ∧ ( ¬ p ∨ p ) . � ( p ∧ r ) ∧ ( ¬ p → r ) . × ¬ ( q ∨ p ∨ r ) ∧ ( ¬ q ∨ p ) . × Meghdad Ghari (IPM) SAT Solvers Logic Short Course 2016 18 / 57
Recommend
More recommend