Disjunctive Normal Form CS 680 Formal Methods Jeremy
- Slides: 17
Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson
Boolean Expressions A Boolean expression is a Boolean function Any Boolean function can be written as a Boolean expression Disjunctive normal form (sums of products) For each row in the truth table where the output is true, write a product such that the corresponding input is the only input combination that is true Not unique E. G. (multiplexor function) s x 0 x 1 f 0 0 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 1 2
Disjunctive Normal Form Theorem. Any boolean expression can be converted to an equivalent boolean exprssion in DNF. Proof. Any boolean expression defines a boolean function. Construct the truth table for the boolean expression and use the procedure on the previous slide to construct a boolean expression in DNF for the function defined by the truth table.
Alternative Proof A recursive conversion algorithm with corresponding inductive proof of correctness. Assume that implications and equivalences have been removed Assume that constants have been eliminated First convert to Negative Normal Form (NNF) (not expr) only occurs when expr is a variable Use De. Morgan’s Law and Double Negation Law Then convert to DNF Distribute and over or
Is-NNF (defun is-nnf (expr) (cond ( (is-constant expr) t) ( (is-variable expr) t ) ( (is-not expr) (is-variable (op 1 expr)) ) ( (is-or expr) (and (is-nnf (op 1 expr)) (is-nnf (op 2 expr))) ) ( (is-and expr) (and (is-nnf (op 1 expr)) (is-nnf (op 2 expr))) )
NNF (mutual-recursion (defun nnf-not (expr) (cond ( (is-constant (op 1 expr)) expr ) ( (is-variable (op 1 expr)) expr ) ( (is-not (op 1 expr)) (nnf (op 1 expr))) ) ( (is-or (op 1 expr)) (list 'and (nnf (list 'not (op 1 expr)))) (nnf (list 'not (op 2 (op 1 expr))))) ) ( (is-and (op 1 expr)) (list 'or (nnf (list 'not (op 1 expr)))) (nnf (list 'not (op 2 (op 1 expr))))) )
NNF (defun nnf (expr) (cond ( (is-constant expr) expr ) ( (is-variable expr) expr ) ( (is-not expr) (nnf-not expr) ) ( (is-or expr) (list 'or (nnf (op 1 expr)) (nnf (op 2 expr))) ) ( (is-and expr) (list 'and (nnf (op 1 expr)) (nnf (op 2 expr))) ) )
Correctness (is-nnf (nnf expr) Structural induction on expr using De Morgan’s laws and Double Negation law (not (and p q)) (or (not p) (not q)) (not (or p q)) (and (not p) (not q)) (not p)) p Base case. Expr = var or (not var) Assume true for expr 1 and expr 2 and show for (not expr), (or expr 1 expr 2), and (and expr 1 expr 2) and or are trivial
Correctness for (not expr) (is-nnf (nnf ‘(not expr)) = (nnf-not ‘(not expr)) Case 1. (nnf-not ‘(not expr))) = (nnf expr)) which is correct by induction and double negation Case 2. (nnf-not ‘(not (and expr 1 expr 2))) = (nnf ‘(or (not expr 1) (not expr 2))) = (list ‘or (nnf ‘(not expr 1)) (nnf ‘(not expr 2))) which is correct by induction and De Morgan Case 3. (nnf-not ‘(not (or expr 1 expr 2)))
Is-DNF (defun is-dnf (expr) (and (is-nnf expr) (no-andor expr)) ) ; no and above or (defun no-andor (expr) (cond ( (is-constant expr) t ) ( (is-variable expr) t ) ( (is-not expr) (no-andor (op 1 expr)) ) ( (is-or expr) (and (no-andor (op 1 expr)) (no-andor (op 2 expr))) ) ( (is-and expr) (and (no-or (op 1 expr)) (no-or (op 2 expr))) )
Is-DNF (defun no-or (expr) (cond ( (is-constant expr) t) ( (is-variable expr) t ) ( (is-not expr) (no-or (op 1 expr)) ) ( (is-or expr) nil ) ( (is-and expr) (and (no-or (op 1 expr)) (no-or (op 2 expr))) )
DNF (defun dnf (expr) (nnf 2 dnf (nnf expr)) ) ; assume (is-nnf expr) (defun nnf 2 dnf (expr) (cond ( (is-constant expr) expr ) ( (is-variable expr) expr ) ( (is-not expr) expr ) ( (is-or expr) (list 'or (nnf 2 dnf (op 1 expr)) (nnf 2 dnf (op 2 expr))) ) ( (is-and expr) (distrib-andor (nnf 2 dnf (op 1 expr)) (nnf 2 dnf (op 2 expr))) )
Distribute And over Or 1. (and E (or F 1 F 2)) (or (and E F 1) (and E F 2)) 2. (and (or E 1 E 2) F) (or (and E 1 F) (and E 2 F)) 3. (and (or E 1 E 2) (or (F 1 F 2)) (or (and E 1 F 1) (and E 1 F 2) (and E 2 F 1) (and E 2 F 2)) (or (and E 1 F 1) (or (and E 1 F 2) (or (and E 2 F 1) (and E 2 F 2))))
DNF ; assume (and (is-dnf expr 1) (is-dnf expr 2)) ; distribute and over or in (and expr 1 expr 2) (defun distrib-andor (expr 1 expr 2) (cond ( (and (not (is-or expr 1)) (not (is-or expr 2))) (list 'and expr 1 expr 2) ) ( (and (not (is-or expr 1)) (is-or expr 2)) (list 'or (distrib-andor expr 1 (op 1 expr 2)) (distrib-andor expr 1 (op 2 expr 2))) ) ( (and (is-or expr 1) (not (is-or expr 2))) (list 'or (distrib-andor (op 1 expr 1) expr 2) (distrib-andor (op 2 expr 1) expr 2)) ) ( (and (is-or expr 1) (is-or expr 2)) (list 'or (distrib-andor (op 1 expr 1) (op 1 expr 2)) (list 'or (distrib-andor (op 1 expr 1) (op 2 expr 2)) (list 'or (distrib-andor (op 2 expr 1) (op 1 expr 2)) (distrib-andor (op 2 expr 1) (op 2 expr 2))))) )
Simplified DNF ; assume (and (is-dnf expr 1) (is-dnf expr 2)) ; distribute and over or in (and expr 1 expr 2) (defun distrib-andor (expr 1 expr 2) (cond ( (is-or expr 1) (list 'or (distrib-andor (op 1 expr 1) expr 2) (distrib-andor (op 2 expr 1) expr 2)) ) ( (is-or expr 2) (list 'or (distrib-andor expr 1 (op 1 expr 2)) (distrib-andor expr 1 (op 2 expr 2))) ) ( (and (not (is-or expr 1)) (not (is-or expr 2))) (list 'and expr 1 expr 2) )
Exponential Blowup Converting the following expression shows that an exponential increase in the size of the dnf form of a boolean expression is possible (x 1 y 1) (xn yn) (x 1 xn) (y 1 yn)
Exercise Prove that (dnf expr) terminates Hint show that the size of expr decreases in all recursive calls and that the base case must eventually be reached, where size of an expr is the number of not, and or operations. Use induction to prove (is-dnf (dnf expr)) Modify (dnf expr) to compute the conjunctive normal form (cnf expr). Hint cnf is duel to dnf
- P q r p q truth table
- Conjunctive normal form
- Convert to disjunctive normal form
- Equivalent disjunctive form example
- Define disjunctive normal form
- En la basura
- 680 705 in expanded form
- Altair 680
- Talk 680
- F tag 680
- Bme 680
- Ese 680
- Nur 680
- Christina 680 pounds
- Ese 680
- A 680 newton student runs up a flight of stairs
- Ese 680
- Disjunctive syllogism