<<

Introduction to the Boolean Problem

Spring 2018 CSCE 235H Introduction to Discrete Structures URL: cse.unl.edu/~cse235h All questions: Piazza Satisfiability Study

• 7 weeks • 30 min lectures in recitation • ~2 hours of homework per week • Goals: – Exposure to fundamental research in CS – Understand how to model problems – Learn to use SAT solver, MiniSAT

CSCE 235 2 Boolean Satisfiability Problem

• Given: – A Boolean formula • Question: – Is there an assignment of values to the Boolean variables such that the formula holds true?

CSCE 235 Logic 3 Boolean Satisfiability Problem a ( a b) _ ¬ ^

(a a) (b b) _ ¬ ! ^ ¬

CSCE 235 Logic 4 Boolean Satisfiability Problem a ( a b) _ ¬ ^ SATISFIABLE a=true, b=true

(a a) (b b) _ ¬ ! ^ ¬

CSCE 235 Logic 5 Boolean Satisfiability Problem a ( a b) _ ¬ ^ SATISFIABLE a=true, b=true

(a a) (b b) _ ¬ ! ^ ¬ UNSATISFIABLE Left side of implication is a tautology. Right side of implication is a . True cannot imply .

CSCE 235 Logic 6 Applications of SAT

• Scheduling • Resource allocation • Hardware/software verification • Planning • Cryptography

CSCE 235 Logic 7

• Variable a, b, p, q, x1,x2 • Literal a, a, q, q, x , x ¬ ¬ 1 ¬ 1 • Clause (a b c) _ ¬ _ • Formula (a b c) _ ¬ _ (b c) ^ _ ( a c) ^ ¬ _ ¬ CSCE 235 Logic 8 Converting to CNF

• All Boolean formulas can be converted to CNF • The operators can be rewritten in , , terms of ! $,, ¬ _ ^ • , , can be rearranged using ¬– De Morgan_ ^ ’s Laws – Distributive Laws – Double Negative • May result in exponential size increase of the formula CSCE 235 Logic 9 Converting to CNF

(a a) (b b) _ ¬ ! ^ ¬ ⌘

CSCE 235 Logic 10 Converting to CNF

(a a) (b b) _ ¬ ! ^ ¬ ⌘ Implication (a a) (b b) ¬ _ ¬ _ ^ ¬ ⌘

CSCE 235 Logic 11 Converting to CNF

(a a) (b b) _ ¬ ! ^ ¬ ⌘ Implication (a a) (b b) ¬ _ ¬ _ ^ ¬ ⌘ DeMorgan’s ( a a) (b b) ¬ ^ _ ^ ¬ ⌘

CSCE 235 Logic 12 Converting to CNF

(a a) (b b) _ ¬ ! ^ ¬ ⌘ Implication (a a) (b b) ¬ _ ¬ _ ^ ¬ ⌘ DeMorgan’s ( a a) (b b) ¬ ^ _ ^ ¬ ⌘ ( a b) ( a b) (a b) (a b) ¬ _ ^ ¬ _ ¬ ^ _ ^ _ ¬ Distributive

CSCE 235 Logic 13 of CNF

• Every clause must be satisfied by at least one true literal • Total possible number of solutions increases as number of variables increases • Clauses constrain the possible solutions • Smaller clauses are more constraining

CSCE 235 Logic 14 Interpretation of CNF

(a b c) a b C _ ¬ _ ¬ 0 0 0 (b c) 0 0 1 ^ _ 0 1 0 ( a) 0 1 1 ^ ¬ 1 0 0 1 0 1 1 1 0 1 1 1

CSCE 235 Logic 15 Interpretation of CNF

(a b c) a b C _ ¬ _ ¬ ( a b c) 0 0 0 (b c) ¬ ¬ ^ ^ 0 0 1 ^ _ 0 1 0 ( a) 0 1 1 ^ ¬ 1 0 0 1 0 1 1 1 0 1 1 1

CSCE 235 Logic 16 Interpretation of CNF

(a b c) a b C _ ¬ _ ¬ ( b c) 0 0 0 (b c) ¬ ¬ ^ ¬ 0 0 1 ^ _ 0 1 0 ( a) 0 1 1 ^ ¬ 1 0 0 1 0 1 1 1 0 1 1 1

CSCE 235 Logic 17 Interpretation of CNF

(a b c) a b C _ ¬ _ ¬ (a) 0 0 0 (b c) ¬ 0 0 1 ^ _ 0 1 0 ( a) 0 1 1 ^ ¬ 1 0 0 1 0 1 1 1 0 1 1 1

CSCE 235 Logic 18 Interpretation of CNF

(a b c) a b C _ ¬ _ ¬ 0 0 0 (b c) 0 0 1 ^ _ 0 1 0 ( a) 0 1 1 ^ ¬ 1 0 0 1 0 1 1 1 0 1 1 1

CSCE 235 Logic 19 Determining SAT/UNSAT

• All that is required to show satisfiability is to find a valid solution • Many techniques available: – Guessing and checking – Systematic search –

CSCE 235 Logic 20 Systematic Search with Backtracking

• Construct a binary tree of all combinations • Proceeds in a depth first manner • Each level corresponds to a variable • Each branch corresponds to a truth assignment • Branches of the tree are ‘pruned’ when the assignment cannot be extended in a satisfiable manner

CSCE 235 Logic 21 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

CSCE 235 Logic 22 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

CSCE 235 Logic 23 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

CSCE 235 Logic 24 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

CSCE 235 Logic 25 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

CSCE 235 Logic 26 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

CSCE 235 Logic 27 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 28 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 29 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 30 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 31 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 32 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 33 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 34 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 35 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 36 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 37 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 38 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 39 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 40 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable

CSCE 235 Logic 41 Systematic Search with Backtracking

(a b c) _ _ ( a b) ^ ¬ _ ¬ ( b c) ^ ¬ _ ¬ ( c a) ^ ¬ _ ¬

Satisfiable 3 solutions total

CSCE 235 Logic 42