Download presentation
Presentation is loading. Please wait.
Published byKellie Cornelia Green Modified over 6 years ago
1
Propositional Calculus: Boolean Algebra and Simplification
CS 270: Mathematical Foundations of Computer Science Jeremy Johnson
2
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
3
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
4
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
5
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.
6
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 6 6
7
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:
8
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
9
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
10
September 4, 1997 Logic Circuits Here is the circuit for the simplified multiplexor expression x0 x1 s 10 10
11
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
12
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 12 12
13
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 x y x y x y x y implication equivalence xor 13
14
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 14
15
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
16
Solution Derive the tautology x y x y 𝑥→𝑦 ≡(𝑥∧𝑦)∨ 𝑥∧𝑦 ∨ 𝑥∧𝑦
Derive the tautology x y x y 𝑥→𝑦 ≡(𝑥∧𝑦)∨ 𝑥∧𝑦 ∨ 𝑥∧𝑦 ≡ (𝑥∧𝑦)∨ (𝑥∧𝑦)∨ 𝑥∧𝑦 ∨ 𝑥∧𝑦 ≡ 𝑥∧(𝑦∨𝑦)∨ 𝑥∨𝑥 ∧𝑦 ≡ (𝑥∧𝑇)∨(𝑇∧𝑦) ≡ 𝑥∨𝑦 16
17
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
18
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)
19
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
20
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
21
Arguments and Formulas
An argument 1,…,n is valid if and only if the formula (1 … n) is a tautology
22
Truth Tree Construction
( ) ( ) ( )
23
Truth Tree Construction
( ) ( ) ( ) ( ) ( ) ( )
24
Example Truth Tree
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.