# Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.

## Presentation on theme: "Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean."— Presentation transcript:

Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean Logic and Computer Logic

Review: Boolean algebra Definition A Boolean algebra consists of a set of elements B two binary operations and one unary operation two distinct elements 0 and 1 such that the following properties hold for all x, y, z  B  (Idempotency can be derived from these properties) x + x = x x * x = x Properties 1. x + y = y + x (commutative properties) 2. (x + y) + z = x + (y + z) (associative properties) 3. x + (y * z) = (x + y) * (x + z) (distributive properties) 4. x + 0 = x (identity properties) 5. x + x = 1 (complement properties) And 1. x * y = y * x (commutative properties) 2. (x* y) * z = x * (y * z) (associative properties) 3. x * (y + z) = (x * y) + (x * z) (distributive properties) 4. x * 1 = x (identity properties) 5. x * x = 0 (complement properties) Section 7.2Logic Networks1

Example Let B = {0, 1} and define + by x + y = max(x, y), * by x * y = min(x, y), and ′ as follows: 0′ = 1, 1′ = 0. It is possible to verify all of the properties in the definition of a Boolean algebra using brute force. For example for property 2, associativity of *: (0*0)*0 = 0*(0*0) = 0 (0*0)*1 = 0*(0*1) = 0 (0*1)*0 = 0*(1*0) = 0... (1*1)*1 = 1*(1*1) = 1 Property 4, identity for addition: x + 0 = x For x = 0, 0 + 0 = 0 For x = 1, 1 + 0 = 1 Although it is tedious you can use this approach to show that [{0, 1}, max, min, (0′ = 1, 1′ = 0), 0, 1] satisfies the requirements of a Boolean algebra. Section 7.2Logic Networks2

Tautological Equivalences in Propositional Logic Example: Let  be disjunction (or) and  be conjunction (and); A′ is the negation of A, 0 is a contradiction, 1 is a tautology. then A  B = B  A, A  B = B  A (commutative), A  0 = A, A  1 = A (identity property) A  A′ = 1, A  A′ = 0 (complement property) Associative and distributive properties can also be shown Thus Propositional Logic has all the properties of a Boolean algebra Equivalences Among the Subsets of a Universal Set S Example: Let  and  be set union and inter- section, A′ is the complement of a set,  is the empty set, S is the universal set. Then A  B = B  A, A  B = B  A (commutative), A   = A, A  S = A (identity property) A  A′ = 1, A  A′ =  (complement property) Associative & distributive properties can also be shown Set identities have the properties of a Boolean algebra. Section 7.2Logic Networks3 Review

Examples of Boolean Algebras Propositional Logic [B = {statements}, + and * =  and , the unary operator contradicts (changes truth value of) a statement, and contradiction and tautology are equivalent of 0 and 1]. (0 is a statement that is always false, 1 is a statement that is always true.) Subsets of some set S also are the elements that form a Boolean algebra under the operations , , and set complementation, with 0/1 elements being  and S. Section 7.2Logic Networks4

Section 7.2Logic Networks5 Combinational Networks Basic logic elements Imagine that the electrical voltages carried along wires fall into one of two ranges, high or low, which we shall represent by 1 and 0, respectively. Voltage fluctuations within these ranges are ignored, so we are forcing a binary mask on an analog phenomenon. Also suppose that switches can be wired so that a signal of 1 causes the switch to be closed and a signal of 0 causes the switch to be open as seen in figure below. Combine two such switches, controlled by lines x 1 and x 2, in parallel. The figure below illustrates the various cases. Fig. 7.6

Combinational Networks Table 7.2 summarizes the behavior of the circuit in figure 7.6 x 1 x 2 Output 1 1 1 1 0 1 0 1 1 0 0 0 If you interpret 1 as True and 0 as False (as most programming languages do) then this is the truth table for disjunction (logical or). Section 7.2Logic Networks6

Section 7.2Logic Networks7 Basic Logic Elements The OR gate, Figure (a), behaves like the Boolean operation +. (x + 0 = x, x + x = x) The AND gate, Figure (b), represents the Boolean operation *. (x * 1 = x, x * x = x) Figure (c) shows an inverter, corresponding to the unary Boolean operation. Because of the associativity property for and, the OR and AND gates can have more than two inputs.

Section 7.2Logic Networks8 Boolean Expressions DEFINITION: BOOLEAN EXPRESSION A Boolean expression in n variables, x 1, x 2,..., x n, is any finite string of symbols formed by applying the following rules: 1. x 1, x 2,..., x n are Boolean expressions. 2. If P and Q are Boolean expressions, so are (P + Q), (P  Q), and (P). x 3, (x 1 + x 2 )x 3, (x 1 x 3 + x 4 )x 2, and (x 1 x 2 )x 1 are all Boolean expressions. In propositional logic, the logical connectives , , and are instances of the operations of a Boolean algebra.

Section 7.2Logic Networks9 Truth Functions DEFINITION: TRUTH FUNCTION A truth function is a function f such that f:{0,1} n  {0,1} for some integer n  1. The notation {0,1} n denotes the set of all n-tuples of 0s and 1s. A truth function thus associates a value of 0 or 1 with each such n-tuple. Example: The Boolean expression x 1 x 2 + x 3 defines the truth function given in Table 7.3 below:

Section 7.2Logic Networks10 Networks and Expressions By combining AND gates, OR gates, and inverters, we can construct a logic network representing a given Boolean expression that produces the same truth function as that expression. Example: Logic network for Boolean expression x 1 x 2 + x 3 is shown in the figure below: Example: Logic network for Boolean expression (x 1 x 2 + x 3 ) + x 3 is shown in the figure below:

Download ppt "Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean."

Similar presentations