theory of computation chapter 4 boolean logic
play

Theory of Computation Chapter 4: Boolean Logic Guan-Shieng Huang - PowerPoint PPT Presentation

Theory of Computation Chapter 4: Boolean Logic Guan-Shieng Huang Apr. 7, 2003 Feb. 19, 2006 0-0 Boolean Expressions X = { x 1 , x 2 , . . . } a countably infinite variables, each can be true or false . Logical connectivities:


  1. Theory of Computation Chapter 4: Boolean Logic Guan-Shieng Huang Apr. 7, 2003 Feb. 19, 2006 0-0

  2. ✬ ✩ Boolean Expressions • X = { x 1 , x 2 , . . . } a countably infinite variables, each can be true or false . • Logical connectivities: ∨ : logical or; ∧ : logical and; ¬ : logical not. • The syntax: A Boolean expression can be one of 1. a Boolean variable, such as x i ; 2. ¬ φ 1 ; 3. ( φ 1 ∨ φ 2 ); 4. ( φ 1 ∧ φ 2 ); where φ 1 , φ 2 are Boolean expressions. (Inductive definition) ✫ ✪ 1

  3. ✬ ✩ Remarks • ¬ φ 1 : the negation of φ 1 • ( φ 1 ∨ φ 2 ): the disjunction of φ 1 and φ 2 • ( φ 1 ∧ φ 2 ): the conjunction of φ 1 and φ 2 • x i or ¬ x i is called a literal. ✫ ✪ 2

  4. ✬ ✩ The Semantics A truth assignment T is a mapping from a set of variables X ′ ⊂ X to { True , false } . 1. T | = x i if T ( x i ) = true ; 2. T | = ¬ φ if not T | = φ ; 3. T | = ( φ 1 ∨ φ 2 ) if T | = φ 1 or T | = φ 2 ; 4. T | = ( φ 1 ∧ φ 2 ) if T | = φ 1 and T | = φ 2 ; where T is appropriate. ✫ ✪ 3

  5. ✬ ✩ Example φ = (( ¬ x 1 ∨ x 2 ) ∧ x 3 ) and T = { x 1 → true , x 2 → false , x 3 → true } , then T �| = φ . ∵ T �| = ¬ x 1 and T �| = x 2 , ∴ T �| = ( ¬ x 1 ∨ x 2 ). ✫ ✪ 4

  6. ✬ ✩ Remark 1. ( φ 1 ⇒ φ 2 ) as a shorthand of ( ¬ φ 1 ∨ φ 2 ). 2. ( φ 1 ⇔ φ 2 ) as a shorthand of (( φ 1 ⇒ φ 2 ) ∧ ( φ 2 ⇒ φ 1 )). ✫ ✪ 5

  7. ✬ ✩ Two expressions φ 1 and φ 2 are equivalent if T | = φ 1 if and only if T | = φ 2 for all appropriate T . Written as φ 1 ≡ φ 2 . 1. ( φ 1 ∨ φ 2 ) ≡ ( φ 2 ∨ φ 1 ); (commutative law) 2. ( φ 1 ∧ φ 2 ) ≡ ( φ 2 ∧ φ 1 ); 3. ¬¬ φ 1 ≡ φ 1 ; (double-negation law) 4. (( φ 1 ∨ φ 2 ) ∨ φ 3 ) ≡ ( φ 1 ∨ ( φ 2 ∨ φ 3 )); (associative law) 5. (( φ 1 ∧ φ 2 ) ∧ φ 3 ) ≡ ( φ 1 ∧ ( φ 2 ∧ φ 3 )); 6. (( φ 1 ∧ φ 2 ) ∨ φ 3 ) ≡ (( φ 1 ∨ φ 3 ) ∧ ( φ 2 ∨ φ 3 )); ( distributive law) 7. (( φ 1 ∨ φ 2 ) ∧ φ 3 ) ≡ (( φ 1 ∧ φ 3 ) ∨ ( φ 2 ∧ φ 3 )); 8. ¬ ( φ 1 ∨ φ 2 ) ≡ ( ¬ φ 1 ∧ ¬ φ 2 ); (De Morgan’s law) 9. ¬ ( φ 1 ∧ φ 2 ) ≡ ( ¬ φ 1 ∨ ¬ φ 2 ); 10. ( φ 1 ∨ φ 1 ) ≡ φ 1 . (idempotent law) ✫ ✪ 6

  8. ✬ ✩ And ∧ and ∨ are dual. You can interchange all ∧ ’s with all ∨ ’s. Remarks 1. � n i =1 φ i stands for ( φ 1 ∧ φ 2 ∧ · · · ∧ φ n ). 2. � n i =1 φ i stands for ( φ 1 ∨ φ 2 ∨ · · · ∨ φ n ). ✫ ✪ 7

  9. ✬ ✩ Normal Forms Conjunctive-normal form: φ = � n i =1 C i where n ≥ 1 and each C i is the disjunction of literals. C i is called a clause. ( x 1 ∨ ¬ x 2 ) ∧ ( ¬ x 1 ∨ x 2 ) Disjunctive-normal form: φ = � n i =1 D i where n ≥ 1 and each D i is the conjunction of literals. D i is called an implicant. ( x 1 ∧ ¬ x 2 ) ∨ ( ¬ x 1 ∧ x 2 ) ✫ ✪ 8

  10. ✬ ✩ Theorem 4.1 Every Boolean expression is equivalent to one in CNF (also one in DNF). Example ( p ⇒ q ) ∧ ( q ⇒ p ) = ( ¬ p ∨ q ) ∧ ( ¬ q ∨ p ) ( ¬ p ∧ ( ¬ q ∨ p )) ∨ ( q ∧ ( ¬ q ∨ p )) = = ( ¬ p ∧ ¬ q ) ∨ ( ¬ p ∧ p ) ∨ ( q ∧ ¬ q ) ∨ ( q ∧ p ) ( ¬ p ∧ ¬ q ) ∨ ( p ∧ q ) . = ✫ ✪ 9

  11. ✬ ✩ Satisfiability • A Boolean expression φ is satisfiable if there is a truth assignment T such that T | = φ . • An expression φ is valid (or tautology) if T | = φ for all T appropriate to φ . (Written as | = φ ) • φ is unsatisfiable if T �| = φ for all T . Proposition 4.2 A Boolean expression is unsatisfiable if and only if its negation is valid. ( φ is unsatisfiable ⇐ ⇒ | = ¬ φ ) ✫ ✪ 10

  12. ✬ ✩ ✫ ✪ 11

  13. ✬ ✩ Example 4.2 1. ( x 1 ∨ ¬ x 2 ) ∧ ¬ x 1 ; (satisfiable) 2. ( x 1 ∨ x 2 ∨ x 3 ) ∧ ( x 1 ∨¬ x 2 ) ∧ ( x 2 ∨¬ x 3 ) ∧ ( x 3 ∨¬ x 1 ) ∧ ( ¬ x 1 ∨¬ x 2 ∨¬ x 3 ). (unsatisfiable) ✫ ✪ 12

  14. ✬ ✩ SAT Given any Boolean expression φ in conjunctive normal form, is it satisfiable? Remarks 1. SAT ∈ NP . (a) Guess an assignment. (b) Verify it. 2. SAT is NP-complete (Chap. 8). 3. SAT can be easily solved if φ is expressed in disjunctive normal form. (( ¬ p ∧ ¬ q ) ∨ ( p ∧ q )) ✫ ✪ 13

  15. ✬ ✩ Horn A clause is Horn if it has at most one positive Horn clause: literal. x 1 ∧ x 2 · · · ∧ x m ⇒ y could be written as ¬ x 1 ∨ ¬ x 2 ∨ · · · ∨ ¬ x m ∨ y . Given any expression in the conjunction of Horn Horn SAT: clauses, is it satisfiable? ✫ ✪ 14

  16. ✬ ✩ Example: x 1 ∨ ¬ x 2 , x 1 ∨ ¬ x 3 , ¬ x 2 ∨ ¬ x 3 , ¬ x 1 ∨ x 4 , x 1 . x 1 ⇒ x 2 , x 3 ⇒ x 1 , x 2 ∧ x 3 ⇒ false , x 1 ⇒ x 4 , x 1 . Algorithm 1. Initially, T := ∅ . (That is, all variables are set false .) 2. Pick any unsatisfiable implication x 1 ∧ x 2 ∧ · · · ∧ x m ⇒ y and add y to T ; repeat this rule until all implications are satisfied. Try to assign all variables on the premises false. Intuition: ✫ ✪ 15

  17. ✬ ✩ Any assignment T ′ satisfying φ must contain T . Proposition: That is, T is the minimum assignment satisfying φ . HORNSAT is in P . Theorem 4.2 ✫ ✪ 16

  18. ✬ ✩ Boolean Function 1. An n -ary Boolean function is a function from { true , false } n → { true , false } . 2. A Boolean expression φ expresses a Boolean function f if for all truth value t = ( t 1 , . . . , t n ), f ( t ) = true iff T | = φ, where T ( x i ) = t i for 1 ≤ i ≤ n . ✫ ✪ 17

  19. ✬ ✩ Proposition 4.3 Any n -ary Boolean function f can be expressed as a Boolean expression φ f involving variables x 1 , x 2 , . . . , x n . f x 1 x 2 x 3 0 0 0 1 0 0 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 ( ¬ x 1 ∧ ¬ x 2 ∧ ¬ x 3 ) ∨ ( ¬ x 1 ∧ x 2 ∧ ¬ x 3 ) ∨ ( x 1 ∧ ¬ x 2 ∧ x 3 ) ✫ ✪ 18

  20. ✬ ✩ Boolean Circuit 1. no cycle in the graph; 2. the in-degree of each node equals to 0, 1, or 2; 3. each node represents either true , false , ∧ , ∨ , ¬ , or a variable x i . ✫ ✪ 19

  21. ✬ ✩ ✫ ✪ 20

  22. ✬ ✩ Given any circuit C , is there a truth assignment CIRCUIT SAT T appropriate to C such that T ( C ) = true ? When an assignment T is given, ask CIRCUIT VALUE whether T ( C ) is true . ✫ ✪ 21

  23. ✬ ✩ Theorem 4.3 For any n ≥ 2, there is an n -ary Boolean function f such that no Boolean circuit with 2 n 2 n or fewer gates can compute it. ✫ ✪ 22

Recommend


More recommend