210 likes | 321 Views
Department of Computer and Information Science, School of Science, IUPUI. CSCI 240. Boolean Algebra. Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu. Boolean Algebra.
E N D
Department of Computer and Information Science,School of Science, IUPUI CSCI 240 Boolean Algebra Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu
Boolean Algebra • We observed in our introduction that early in the development of computer hardware, a decision was made to use binary circuits because it greatly simplified the electronic circuit design. • In order to work with binary circuits, it is helpful to have a conceptual framework to manipulate the circuits algebraically, building only the final “most simple” result. • George Boole (1813-1864) developed a mathematical structure to deal with binary operations with just two values. Today, we call these structures Boolean Algebras.
Boolean Algebra Defined • A Boolean Algebra B is defined as a 5-tuple {B, +, *, ’, 0, 1} • + and * are binary operators; they have two operands • ’ is a unary operator; it has one operand • The following five axioms must hold for any elements a, b, c {0,1}
Boolean Algebra is not regular algebra! • We recognize Form 2 of distributive law:a * (b + c) = (a * b)+(a * c)(Multiplication is distributive over addition) • Is Form 1 of distributive law is true?a + (b * c) = (a + b)*(a + c) 4 + (3 * 2) =? (4 + 3)(4 + 2)4 + 6 =? 7 * 610 ≠ 42
Terminology • Element 0 is called the zero element. In computer science, we’ll call the 0 element “FALSE”. • Element 1 is called the unit element. In computer science, we’ll call the 1 element “TRUE”. • In computer science, we’ll call the + operation “OR”. The result of + is called sum. • In computer science, we’ll call the * operation “AND”. The result of * is called product. • In computer science, we’ll call the ’ operation “NOT”. The result of ’ is called complement. • Juxtaposition implies * operation: ab = a * b • Operator order of precedence is: (), ’, *, +.a+bc = a+(b*c) ≠ (a+b)*cab’ = a(b’) ≠ (a*b)’
Single Bit Boolean Algebra Define a Boolean Algebra where 0 and 1 are bits. • 1’ = 0 and 0’ = 1
Proof by Truth Table • Consider Form 1 of the distributive theorem:a + (b * c) = (a + b)*(a + c). Is it true for a two bit Boolean Algebra? • Can prove using a truth table. How many possible combinations of a, b, and c are there? • Three variables, each with two values: 2*2*2 = 23 = 8
Consider Form 1 of the distributive theorem: a + (b * c) = (a + b)*(a + c). Is it true for a two bit Boolean Algebra? Can prove using a truth table. How many possible combinations of a, b, and c are there? Three variables, each with two values: 2*2*2 = 23 = 8 Proof by Truth Table (cont)
n-bit Boolean Algebra • Single bit Boolean Algebra can be extended to n-bit Boolean Algebra by define sum, product and complement as bit-wise operations • Let a = 1101010, b = 1011011 • a + b = 1101010 + 1011011 = 1111011 • a * b = 1101010 * 1011011 = 1001010 • a’ = 1101010’ = 0010101
Principle Duality • The dual of a statement S is obtained by interchanging * and +; 0 and 1. • Write the dual of (a*1)*(0+a’) = 0. • (a+0)+(1*a’) = 1 • Did you notice that all the original axioms are duals of each other? • Thus, the dual of any theorem in a Boolean Algebra is also a theorem. • This is called the Principle of Duality.
Named Theorems All of the following theorems can be proven based on the axioms. They are used so often that they have names. The theorems can be proven for a two-bit Boolean Algebra using a truth table, but you must use the axioms to prove it in general for all Boolean Algebras.
More Named Theorems DeMorgan’s Laws are particularly important in circuit design. It says that you can get rid of a complemented output by complementing all the inputs and changing ANDs to ORs. (More about circuits coming up…)
Proof using Theorems • Use the properties of Boolean Algebra to reduce (x + y)(x + x) to x. Warning, make sure you use the laws precisely. Unlike truth tables, proofs using Theorems are valid for any boolean algebra, but just bits.
Standard Form • Like regular algebra, Boolean equations can be expressed as a sum of products. Each product is a term of the equation. • Consider the term xyx’z. We define a term to be a Fundamental Product (FP) if it does not repeat any literal. Since our term repeats x, is it not FP. • You call always minimize a term to make it FP.xyx’z = xx’yz = 0yz (which law) = 0 (which law?) • An expression E is sum-of-products form if it is the sum of one ore more FPs, none of which is included in another.
Sum-of-Products Form 1. Consider E=xz’ + y’z + xyz’. This is a sum of products, but is not sum-of-products form because xz’ is contained within xyz’. i.e. it can be reduced. (which law?) 2. Consider E=xz’ + x’yz’ + xy’z. This is already sum-of-products form. Any non-zero Boolean expression can be changed to sum-of-products form. (By duality, there is also a product-of-sums form, but it is used less often.)
Converting to Sum-of-Products Form • Use DeMorgan’s Laws and Involution to move complements inside parenthesis until only variables are complemented. • Use distributive law to transform in to sum of products • Use commutative, idempotent, and complement laws to transform each term into 0 or FP. • Use absorption law to make sum-of-products form.
Example of conversion to sum-of-products form • Consider E=((ab)’c)’((a’+c)(b’+c’))’ • E=((ab)’’+c’)((a’+c)’+(b’+c’)’) – DeMorgan’s Law • E=(ab+c’)(ac’+bc) – DeMorgan’s and Involution Laws • E=abac’ + abbc +ac’c’ + bcc’ – Distributive Law • E=abc’ + abc + ac’ + 0 – Idempotent and Complement • E=ac’ + abc – Absorption Law
Complete Sum-of-Products Form • A complete sum-of-products form is a sum-of-products form where each term involves all the variables. (Each term will have the same number of literals. • You can add missing variables by multiplying by 1, where 1 is of the form x + x’. • Theorem: Every non-zero Boolean expression can be placed in complete sum-of-products form, and it is unique.
Complete Sum-of-Products Example • Express E(x,y,z) = (x’ + y)’ + x’y in complete sum-of-products form. • E = xy’ + x’y – DeMorgan’s Law.If we didn’t know z was involved, we’d think we were done. • E=xy’(z + z’) + x’y(z + z’) • E=xy’z + xy’z’ + x’yz + x’yz’ – Distributive Law(Don’t simplify using Absorption, or you’ll take it back out of Complete S-O-P form)
Sources • Lipschutz, Discrete Mathematics • Mowle, A Systematic Approach to Digital Logic Design