Propositional Calculus: Boolean Algebra and Simplification

Slides:



Advertisements
Similar presentations
CSE 311: Foundations of Computing Fall 2013 Lecture 3: Logic and Boolean algebra.
Advertisements

Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson.
1 Section 10.1 Boolean Functions. 2 Computers & Boolean Algebra Circuits in computers have inputs whose values are either 0 or 1 Mathematician George.
From Chapter 4 Formal Specification using Z David Lightfoot
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.
11.1 Boolean Functions. Boolean Algebra An algebra is a set with one or more operations defined on it. A boolean algebra has three main operations, and,
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Boolean Algebra Computer Organization 1 © McQuain Boolean Algebra A Boolean algebra is a set B of values together with: -two binary operations,
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
1 Fundamentals of Computer Science Propositional Logic (Boolean Algebra)
BOOLEAN ALGEBRA Saras M. Srivastava PGT (Computer Science)
Lecture 7 Topics –Boolean Algebra 1. Logic and Bits Operation Computers represent information by bit A bit has two possible values, namely zero and one.
CS1502 Formal Methods in Computer Science
Apr. 3, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 3: Review of Digital Circuits and Logic Design Jeremy R. Johnson Mon. Apr.
Combinational Logic 1.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
Lecture 22: 11/19/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Logic Design CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Extra slides for Chapter 3: Propositional Calculus & Normal Forms Based on Prof. Lila Kari’s slides For CS2209A, 2009 By Dr. Charles Ling;
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.
Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson.
Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 9 Boolean Algebras and Combinatorial Circuits.
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.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Module Code MA0003NI: Computing mathematics Lecture for Week Autumn.
Boolean Algebra & Logic Gates
Morgan Kaufmann Publishers
2. The Logic of Compound Statements Summary
Department of Preparatory Year, Umm Al Qura University
Chapter 11 (Part 1): Boolean Algebra
Propositional Equivalence
Unit 2 Boolean Algebra.
ECE 20B, Winter 2003 Introduction to Electrical Engineering, II LECTURE NOTES #2 Instructor: Andrew B. Kahng (lecture)
Propositional Calculus: Boolean Functions and Expressions
CS 105 Digital Logic Design
CHAPTER 2 Boolean Algebra
Discussion #10 Logical Equivalences
Proposition & Predicates
Boolean Algebra.
Boolean Algebra A Boolean algebra is a set B of values together with:
Boolean Algebra A Boolean algebra is a set B of values together with:
Disjunctive Normal Form
Boolean algebra Last time we talked about Boolean functions, Boolean expressions, and truth tables. Today we’ll learn how to how use Boolean algebra to.
Jeremy R. Johnson Wed. Sept. 29, 1999
Propositional Calculus: Boolean Functions and Expressions
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Elementary Metamathematics
Discrete Mathematics CS 2610
Information Technology Department
Chapter 1 The Foundations: Logic and Proof, Sets, and Functions
NP-Completeness Proofs
CS201: Data Structures and Discrete Mathematics I
Functions Computers take inputs and produce outputs, just like functions in math! Mathematical functions can be expressed in two ways: We can represent.
Propositional Equivalences
CSE 311 Foundations of Computing I
Boolean Algebra.
A Brief Summary for Exam 1
Disjunctive Normal Form
From now on: Combinatorial Circuits:
Foundations of Discrete Mathematics
Design of Digital Circuits Lab 1 Supplement: Drawing Basic Circuits
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Laws & Rules of Boolean Algebra
CS201: Data Structures and Discrete Mathematics I
Presentation transcript:

Propositional Calculus: Boolean Algebra and Simplification CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus Topics Motivation: Simplifying Conditional Expressions Rules of Boolean Algebra Equational Reasoning Proofs Using Truth Tables Tautologies and Automatic Verification of Tautologies Arguments, Satisfiability and Truth Trees

Programming Example Boolean expressions arise in conditional statements. It is possible to abstract the relations with boolean variables (propositions that are either true or false). Using this abstraction one can reason and simplify conditional statements. if ((a < b) || ((a >= b) && (c == d))) then { … } else { … } Let p denote the relation (a<b) and q denote the relation (c == d). The above expression is then equal to p || !p && q 3

Programming Example (cont) The previous expression is equivalent (two expressions are equivalent if they are true for the same values of the variables occurring in the expressions) to a simpler expression (p || !p && q)  p || q We can see this since if p is true both expressions are true, and if p is false, then !p is true and (!p && q) is true exactly when q is true. 4

Boolean Algebra The Boolean operators  and  are analogous to addition and multiplication with true and false playing the roles of 1 and 0. Complement is used for negation. This provides a compact notation and suggests appropriate algebraic simplification Similar properties hold such as the associative, commutative, and distributive identities.

September 4, 1997 Sums of Products Disjunctive normal form, using the notation of Boolean Algebra, corresponds to a sum of products 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 6 6

Properties of Boolean Algebra Boolean expressions can be simplified using rules of Boolean algebra Identity law: A + 0 = A and A ● 1 = A. Zero and One laws: A + 1 = 1 and A ● 0 = 0 Inverse laws: Idempotent laws: A + A = A = A ● A Commutative laws: A + B = B + A and A ● B = B ● A. Associative laws: A + (B + C) = (A + B) + C and A ● (B ● C) = (A ● B) ● C. Distributive laws: A ● (B + C) = (A ● B) + (A ● C) and A + (B ● C) = (A + B) ● (A + C) Double Negation: 𝐴 =𝐴 DeMorgan’s laws:

Simplification of Boolean Expressions September 4, 1997 Simplification of Boolean Expressions Simplifying multiplexor expression using Boolean algebra Equational reasoning: replace subexpressions by equivalent expressions Reflexive, Symmetric, Transitive Verify that the boolean function corresponding to this expression as the same truth table as the original function. 8 8

September 4, 1997 Logic Circuits Given a boolean expression it is easy to write down the corresponding logic circuit Here is the circuit for the original multiplexor expression x0 x1 s 9 9

September 4, 1997 Logic Circuits Here is the circuit for the simplified multiplexor expression x0 x1 s 10 10

Nand is functionally complete Using DeMorgan’s Law,  and  are enough to generate all Boolean functions All boolean functions can be implemented using nand gates (and, or and not can be implemented using nand) not: and: or: x y x | y 0 0 1 0 1 1 1 0 1 1 1 0

Conjunctive Normal Form September 4, 1997 Conjunctive Normal Form Conjunctive normal form (products of sums) Conjunction of clauses (disjunction of literals) For each row in the truth table where the output is false, write a sum such that the corresponding input not in that row Alternatively use Demorgan’s law for the negation of dnf for f (zero rows) Duality (swap and/or true/false) E.G. (multiplexor function) (𝑠+ 𝑥 0 + 𝑥 1 )(𝑠+ 𝑥 0 + 𝑥 1 )( 𝑠 + 𝑥 0 + 𝑥 1 ) ( 𝑠 + 𝑥 0 + 𝑥 1 ) 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 12 12

Additional Notation Several additional Boolean functions of two variables have special meaning and are given special notation. By our previous results we know that all boolean functions can be expressed with not, and, and or; so the additional notation is simply a convenience. x y x  y 0 0 1 0 1 1 1 0 0 1 1 1 x y x  y 0 0 1 0 1 0 1 0 0 1 1 1 x y x  y 0 0 0 0 1 1 1 0 1 1 1 0 implication equivalence xor 13

Tautologies A tautology is a boolean expression that is always true, independent of the values of the variables occurring in the expression. The properties of Boolean Algebra are examples of tautologies. Tautologies can be verified using truth tables. The truth table below shows that x  y   x  y x y x  y  x  y 0 0 1 1 0 1 1 1 1 0 0 0 1 1 1 1 14

Exercise Derive the tautology x  y   x  y from the sum of products expression obtained from the truth table for x  y. You will need to use properties of Boolean algebra to simplify the sum of products expression to obtain the desired equivalence. 15

Solution Derive the tautology x  y   x  y 𝑥→𝑦 ≡(𝑥∧𝑦)∨ 𝑥∧𝑦 ∨ 𝑥∧𝑦 0 0 1 0 1 1 1 0 0 1 1 1 Derive the tautology x  y   x  y 𝑥→𝑦 ≡(𝑥∧𝑦)∨ 𝑥∧𝑦 ∨ 𝑥∧𝑦 ≡ (𝑥∧𝑦)∨ (𝑥∧𝑦)∨ 𝑥∧𝑦 ∨ 𝑥∧𝑦 ≡ 𝑥∧(𝑦∨𝑦)∨ 𝑥∨𝑥 ∧𝑦 ≡ (𝑥∧𝑇)∨(𝑇∧𝑦) ≡ 𝑥∨𝑦 16

Tautology Checker A program can be written to check to see if a Boolean expression is a tautology. Simply generate all possible truth assignments for the variables occurring in the expression and evaluate the expression with its variables set to each of these assignments. If the evaluated expressions are always true, then the given Boolean expression is a tautology. A similar program can be written to check if any two Boolean expressions E1 and E2 are equivalent, i.e. if E1  E2. Such a program will be written later in the term. 17

Satisfiability A formula is satisfiable if there is an assignment to the variables that make the formula true A formula is falsifiable if there is an assignment to the variables that make the formula false A formula is contradictory if all assignments to variables eval to false A formula is valid if all assignments to variables eval to true (a valid formula is a tautology) The negation of a valid formula is not satisfiable A formula is invalid if there is an assignment to variables that eval to false (counterexample)

Satisfiability Checking to see if a formula f is satisfiable can be done by searching a truth table for a true entry or truth tree construction Exponential in the number of variables Does not appear to be a polynomial time algorithm (satisfiability is NP-complete) There are efficient satisfiability checkers that work well on many practical problems Checking whether f is invalid can be done by checking if  f is satisfiable. An assignment that makes  f satisfiable provides a counterexample

Arguments An argument is a list of premises followed by a conclusion An argument is valid if any assignment that makes the premises true also makes the conclusion true An argument is invalid if there is some assignment that makes the premises true but does not make the conclusion true If we negate the conclusion we can search for counterexamples by looking for an assignment that makes the premises and negated conclusion true

Arguments and Formulas An argument 1,…,n   is valid if and only if the formula (1  …  n)   is a tautology

Truth Tree Construction          (  )    (  )    (  )   

Truth Tree Construction (  ) (  ) (  )    (  )    (  )    (  )      

Example Truth Tree