Presentation is loading. Please wait.

Presentation is loading. Please wait.

Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson.

Similar presentations


Presentation on theme: "Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson."— Presentation transcript:

1 Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson

2 Objective  To review disjunctive normal form (dnf) and present an algorithm to convert an arbitrary Boolean expression to an equivalent one in dnf  Equivalence of any particular Boolean expression and the one returned can be proven with natural deduction, but the correctness for all possible inputs requires additional proof techniques (induction)

3 3 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 0 1 0 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1

4 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.

5 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 DeMorgan’s Law and Double Negation Law  Then convert to DNF  Distribute and over or

6 DeMorgan’s Law  (E  F)   E   F  EF    E F

7 Double Negation  E  E  E E 

8 NNF Example  a  bc  

9  a  bc   

10  a  bc   

11  a  bc 

12  a  bc 

13 Conversion to NNF Define NNF(expr) Input: expr is a Boolean Expression, Output: an equivalent Boolean Expression in NNF if isConstant(expr) return expr if isVariable(expr) return expr if isNegation(expr) return NNF_Not(expr) if isDisjunction(expr) return NNF(op1(expr))  NNF(op2(expr)) if isConjunction(expr) return NNF(op1(expr))  NNF(op2(expr))

14 NNF_Not Define NNF_Not(expr) Input: is a Boolean Expression with expr =  expr1 Output: an equivalent Boolean Expression in NNF expr1 = op(expr) if isConstant(expr1) return expr if isVariable(expr1) return expr if isNegation(expr1) return NNF(op(expr1)) [remove double negation] if isDisjunction(expr1) return NNF(  op1(expr1)  NNF(  op2(expr1)) [DeMorgan’s Law] if isConjunction(expr1) return NNF(  op1(expr1))  NNF(  op2(expr1)) [DeMorgan’s Law]

15 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 DeMorgan’s Law and Double Negation Law  Then convert to DNF  Distribute and over or

16 Distribute And over Or 1.E  (F1  F2)  (E  F1)  (E  F2) 2.(E1  E2)  F  (E1  F)  (E2  F)   F1F2 E   E  EF1

17 DNF Example   c  ab

18     ab  ab

19     a  ab  b

20    a  b   a  b

21 Conversion to DNF Define DNF(expr) Input: expr is a Boolean Expression in NNF Output: an equivalent Boolean Expression in DNF if isConstant(expr) return expr if isVariable(expr) return expr if isNegation(expr) return expr if isDisjunction(expr) return DNF(op1(expr))  DNF(op2(expr)) if isConjunction(expr) return DistributeAndOverOr (DNF(op1(expr))  DNF(op2(expr)))

22 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 )    (x n  y n )  (x 1    x n )    (y 1    y n )


Download ppt "Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson."

Similar presentations


Ads by Google