Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson.

Slides:



Advertisements
Similar presentations
Exercises for CS1512 Weeks 7 and 8 Propositional Logic 1 (questions + solutions)
Advertisements

SAT Solver CS 680 Formal Methods Jeremy Johnson. 2 Disjunctive Normal Form  A Boolean expression is a Boolean function  Any Boolean function can be.
Logical Systems Synthesis.
Logic Use mathematical deduction to derive new knowledge.
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
Logic Gate Level Part 2. Constructing Boolean expression from truth table First method: write nonparenthesized OR of ANDs Each AND is a 1 in the result.
1 Inference Rules and Proofs Z: Inference Rules and Proofs.
Chapter 9: Boolean Algebra
IT University of Copenhagen Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary.
Discussion #10 1/16 Discussion #10 Logical Equivalences.
Propositional Calculus Math Foundations of Computer Science.
Propositional Equivalence Goal: Show how propositional equivalences are established & introduce the most important such equivalences.
Propositional Calculus Math Foundations of Computer Science.
Propositional Calculus CS 680: Formal Methods in Verification Computer Systems Jeremy Johnson.
CS1502 Formal Methods in Computer Science Lecture Notes 10 Resolution and Horn Sentences.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Normal or Canonical Forms Rosen 1.2 (exercises). Logical Operators  - Disjunction  - Conjunction  - Negation  - Implication p  q   p  q  - Exclusive.
Satisfiability Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Copyright © Curt Hill Truth Tables A way to show Boolean Operations.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
Normal Forms, Tautology and Satisfiability 2/3/121.
CS1502 Formal Methods in Computer Science
Propositional Equivalences
Apr. 3, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 3: Review of Digital Circuits and Logic Design Jeremy R. Johnson Mon. Apr.
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Circuit Design.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
Exercises for CS3511 Week 31 (first week of practical) Propositional Logic.
Discrete Mathematics CS 2610 September Equal Boolean Functions Two Boolean functions F and G of degree n are equal iff for all (x 1,..x n )  B.
CS6133 Software Specification and Verification
Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson.
BOOLEAN ALGEBRA AND LOGIC SIMPLIFICATION
Proof by Contradiction CS 270 Math Foundations of CS Jeremy Johnson.
1 Section 6.2 Propositional Calculus Propositional calculus is the language of propositions (statements that are true or false). We represent propositions.
Boolean Expression Evaluation CS 270: Math Foundations of CS Jeremy Johnson.
CHAPTER 1 INTRODUCTION TO DIGITAL LOGIC. De Morgan’s Theorem De Morgan’s Theorem.
DE MORGAN’S THEOREM. De Morgan’s Theorem De Morgan’s Theorem.
The Logic of Boolean Connectives Chapter 4 Language, Proof and Logic.
1 Proving Properties of Recursive Functions and Data Structures CS 270 Math Foundations of CS Jeremy Johnson.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
CS-7081 Application - 1. CS-7082 Example - 2 CS-7083 Simplifying a Statement – 3.
Truth Table to Statement Form
De Morgan’s Theorem,.
DeMorgan’s Theorem DeMorgan’s 2nd Theorem
Propositional Equivalence
Propositional Calculus: Boolean Functions and Expressions
Thinking Mathematically
CHAPTER 2 Boolean Algebra
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Discussion #10 Logical Equivalences
Disjunctive Normal Form
Jeremy R. Johnson Wed. Sept. 29, 1999
Propositional Calculus: Boolean Functions and Expressions
Proving Properties of Recursive Functions and Data Structures
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Propositional Calculus: Boolean Algebra and Simplification
Elementary Metamathematics
Discrete Mathematics CS 2610
CSE 370 – Winter Combinational Logic - 1
Logic Use mathematical deduction to derive new knowledge.
Propositional Equivalences
Formal Methods in software development
Simplification of Boolean Expressions
Disjunctive Normal Form
PROPOSITIONAL LOGIC - SYNTAX-
Laws & Rules of Boolean Algebra
The Foundations: Logic and Proofs
Presentation transcript:

Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson

2 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

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

Is-NNF (defun is-nnf (expr) (cond ( (is-constant expr) t) ( (is-variable expr) t ) ( (is-not expr) (is-variable (op1 expr)) ) ( (is-or expr) (and (is-nnf (op1 expr)) (is-nnf (op2 expr))) ) ( (is-and expr) (and (is-nnf (op1 expr)) (is-nnf (op2 expr))) ) )

NNF (mutual-recursion (defun nnf-not (expr) (cond ( (is-constant (op1 expr)) expr ) ( (is-variable (op1 expr)) expr ) ( (is-not (op1 expr)) (nnf (op1 (op1 expr))) ) ( (is-or (op1 expr)) (list 'and (nnf (list 'not (op1 (op1 expr)))) (nnf (list 'not (op2 (op1 expr))))) ) ( (is-and (op1 expr)) (list 'or (nnf (list 'not (op1 (op1 expr)))) (nnf (list 'not (op2 (op1 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 (op1 expr)) (nnf (op2 expr))) ) ( (is-and expr) (list 'and (nnf (op1 expr)) (nnf (op2 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 (not p))  p  Base case. Expr = var or (not var)  Assume true for expr1 and expr2 and show for (not expr), (or expr1 expr2), and (and expr1 expr2)  and and or are trivial

Correctness for (not expr)  (is-nnf (nnf ‘(not expr))  (nnf ‘(not expr))  (nnf-not ‘(not expr))  Case 1. (nnf-not ‘(not (not expr))) = (nnf expr)) which is correct by induction and double negation  Case 2. (nnf-not ‘(not (and expr1 expr2))) = (nnf ‘(or (not expr1) (not expr2))) = (list ‘or (nnf ‘(not expr1)) (nnf ‘(not expr2))) which is correct by induction and De Morgan  Case 3. (nnf-not ‘(not (or expr1 expr2)))

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 (op1 expr)) ) ( (is-or expr) (and (no-andor (op1 expr)) (no-andor (op2 expr))) ) ( (is-and expr) (and (no-or (op1 expr)) (no-or (op2 expr))) ) )

Is-DNF (defun no-or (expr) (cond ( (is-constant expr) t) ( (is-variable expr) t ) ( (is-not expr) (no-or (op1 expr)) ) ( (is-or expr) nil ) ( (is-and expr) (and (no-or (op1 expr)) (no-or (op2 expr))) ) )

DNF (defun dnf (expr) (nnf2dnf (nnf expr)) ) ; assume (is-nnf expr) (defun nnf2dnf (expr) (cond ( (is-constant expr) expr ) ( (is-variable expr) expr ) ( (is-not expr) expr ) ( (is-or expr) (list 'or (nnf2dnf (op1 expr)) (nnf2dnf (op2 expr))) ) ( (is-and expr) (distrib-andor (nnf2dnf (op1 expr)) (nnf2dnf (op2 expr))) ) )

Distribute And over Or 1.(and E (or F1 F2))  (or (and E F1) (and E F2)) 2.(and (or E1 E2) F)  (or (and E1 F) (and E2 F)) 3.(and (or E1 E2) (or (F1 F2))   (or (and E1 F1) (and E1 F2) (and E2 F1) (and E2 F2))  (or (and E1 F1) (or (and E1 F2) (or (and E2 F1) (and E2 F2))))

DNF ; assume (and (is-dnf expr1) (is-dnf expr2)) ; distribute and over or in (and expr1 expr2) (defun distrib-andor (expr1 expr2) (cond ( (and (not (is-or expr1)) (not (is-or expr2))) (list 'and expr1 expr2) ) ( (and (not (is-or expr1)) (is-or expr2)) (list 'or (distrib-andor expr1 (op1 expr2)) (distrib-andor expr1 (op2 expr2))) ) ( (and (is-or expr1) (not (is-or expr2))) (list 'or (distrib-andor (op1 expr1) expr2) (distrib-andor (op2 expr1) expr2)) ) ( (and (is-or expr1) (is-or expr2)) (list 'or (distrib-andor (op1 expr1) (op1 expr2)) (list 'or (distrib-andor (op1 expr1) (op2 expr2)) (list 'or (distrib-andor (op2 expr1) (op1 expr2)) (distrib-andor (op2 expr1) (op2 expr2))))) ) ) )

Simplified DNF ; assume (and (is-dnf expr1) (is-dnf expr2)) ; distribute and over or in (and expr1 expr2) (defun distrib-andor (expr1 expr2) (cond ( (is-or expr1) (list 'or (distrib-andor (op1 expr1) expr2) (distrib-andor (op2 expr1) expr2)) ) ( (is-or expr2) (list 'or (distrib-andor expr1 (op1 expr2)) (distrib-andor expr1 (op2 expr2))) ) ( (and (not (is-or expr1)) (not (is-or expr2))) (list 'and expr1 expr2) ) ) )

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 )

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, 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