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

Preview:

Citation preview

Disjunctive Normal Form

CS 270: Math Foundation of CSJeremy Johnson

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

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 x0 x1 f

0 0 0 0

0 0 1 0

0 1 0 1

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 1

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 DeMorgan’s Law and Double Negation Law

Then convert to DNF Distribute and over or

DeMorgan’s Law

(E F) E F

E F

E F

Double Negation

E E

E

E

NNF Example

a

b c

NNF Example

[DeMorgan’s Law]

a

b c

NNF Example

[DeMorgan’s Law]Recursively convert operands

a

b c

NNF Example

[DeMorgan’s Law] [Double Negation Law]

a

b c

NNF Example

[DeMorgan’s Law] [Double Negation Law]

) [DeMorgan’s Law]

a

b c

Conversion to NNFDefine 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))

NNF_NotDefine 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]

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

Distribute And over Or

1. E (F1 F2)º (E F1) (E F2)

2. (E1 E2) Fº (E1 F) (E2 F)

F1 F2

E

E F2

E F1

DNF Example

c 𝑑

a b

DNF Example

( ))

𝑑

𝑐

a b

a b

DNF Example

( )) ( ) )

𝑑

a 𝑐

a b

b 𝑐

DNF Example

( )) ( ) ) ( )

a 𝑐

b 𝑐

a 𝑑

b 𝑑

Conversion to DNFDefine 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)))

Exponential Blowup

Converting the following expression shows that an exponential increase in the size of the DNF form of a boolean expression is possible

(x1 y1) (xn yn)

(x1 xn) (y1 yn)

Recommended