BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

19
Unit-III Lattices and Boolean algebra Rai University, Ahmedabad LATTICES AND BOOLEAN ALGEBRA COURSE-BCA Subject- Discrete Mathematics Unit-III RAI UNIVERSITY, AHMEDABAD

Transcript of BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Page 1: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

LATTICES AND BOOLEAN ALGEBRA COURSE-BCA

Subject- Discrete Mathematics Unit-III

RAI UNIVERSITY, AHMEDABAD

Page 2: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

Lattices and Boolean algebra

Lattices:

Let L be a non-empty set closed under two binary operations called meet and join denoted respectively by ⋀푎푛푑 ⋁ . Then L is called a lattice if the following axioms hold where, a,b,c are element in L.

[퐿 ] Commutative law:

푎 ∧ 푏 = 푏 ∧ 푎 푎 ∨ 푏 = 푏 ∨ 푎

[퐿 ] Associative law:

(푎 ∧ 푏) ∧ 푐 = 푎 ∧ (푏 ∧ 푐) (푎 ∨ 푏) ∨ 푐 = 푎 ∨ (푏 ∨ 푐)

[퐿 ] Absorption law:

푎 ∧ (푎 ∨ 푏) = 푎 푎 ∨ (푎 ∧ 푏) = 푎

We will sometimes denote the lattice by (퐿,∧,∨). When we want to know which operations are involved.

Properties Of lattice:

1. Completeness:

A poset is called complete lattice if all its subsets have both a join and a meet.

Every complete lattice is bounded.

2. Conditional Completeness:

A conditional complete lattice is a lattice in which every non-empty subset that that has that has an upper bound or has a join. (i.e. a least upper bound)

A conditionally complete lattice is either a complete lattice or a complete lattice without its maximum element 1, its minimum element 0, or both.

Complete Lattice:

A poset is called complete lattice if all subsets have both a join and a meet.

Page 3: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

Bounded Lattice:

A bounded lattice is an algebraic structure of the form (퐿,∨,∧ ,1,0) such that (퐿,∨,∧) is a lattice, 0 (the lattices bottom) is the identity element for the join operation ∨, and 1 (the lattice top) is the identity element for the meet operation ∧.

Identity laws

푎 ∨ 0 = 푎 푎 ∨ 1 = 1

푎 ∧ 1 = 푎 푎 ∧ 0 = 0

The non negative integers with the usual ordering

0 < 1 < 2 < 3…….

Have 0 as a lower bound but have no upper bound.

On the other hand the lattice P(U) of all subsets of any Universal set U is a bounded lattice with U as an upper bound and the empty set ∅ as a lower bound.

Suppose 퐿 = {푎 ,푎 , 푎 , … … 푎 } is a finite lattice.

Then {푎 ∨ 푎 ∨ 푎 ∨ … … ∨ 푎 } are upper and lower bounds for L respectively.

Theorem:

Every finite lattice L is bounded.

Distributive Lattice:

A lattice L is said to be distributive if for any elements a, b, c in L we have the following distributive law:

푎 ∧ (푏 ∨ 푐) = (푎 ∧ 푏) ∨ (푎 ∧ 푐)

&

푎 ∨ (푏 ∧ 푐) = (푎 ∨ 푏) ∧ (푎 ∨ 푐)

Otherwise L is said to be non distributive.

The only non distributive lattices with fewer than 6 elements are called 푀 & 푁 .

Page 4: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

A lattice is distributive if and only if it does not have a sub lattice isomorphic to 푀 표푟 푁 .

Smallest non distributive Smallest non modular (and hence non distributive) lattice N5

(but modular) lattice M3 (and hence non distributive) lattice N5

Complemented Lattice:

Let L be a bounded lattice with lower bound 0 and upper bound 1.Let a be an element of L.

An element 푥 in L is called a complement of 0 if

푎 ∨ 푥 = 퐼 and 푎 ∧ 푥 = 0

Complements need not exist and need not unique.

Example:

Page 5: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

Introduction to Boolean Algebra:

Boolean algebra is the algebra of two-valued logic with only sentential connectives, or equivalently of algebras of sets under union and complementation. The rigorous concept is that of a certain kind of algebra, analogous to the mathematical notion of a group. This concept has roots and applications in logic, set theory , topology, foundations of set theory (Boolean-valued models), measure theory (measure algebras), functional analysis (algebras of projections), and ring theory (Boolean rings). The study of Boolean algebras has several aspects: structure theory, model theory of Boolean algebras, decidability and undesirability questions for the class of Boolean algebras, and the indicated applications. In addition, although not explained here, there are connections to other logics, subsumption as a part of special kinds of algebraic logic, finite Boolean algebras and switching circuit theory and Boolean matrices.

Definition simple properties:

Boolean algebra is one of the most interesting and important algebraic structure which has significant applications in switching circuits, logic and many branches of computer science and engineering. Boolean algebra can be viewed as one of the special type of lattice. A complemented distributive lattice with 0 and 1 is called Boolean algebra. Generally Boolean algebra is denoted by (B, *, , ', 0, 1). Example 1 :

Page 6: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

(P (A), , , ‘ ,) is a Boolean algebra. This is an important example of Boolean algebra [In fact the basic properties of the (P (A), , , ‘) led to define the abstract concept of Boolean algebra]. Further, it can be proved that every finite Boolean algebra must be isomorphic to (P (A), , , ' , A) for a suitably chosen finite set A.

Simple properties of Boolean Algebra:

x + (x · y) = x x · (x + y) = x x + (−x) = 1 x · (−x) = 0 Sub Boolean algebra:

The Boolean algebra (Bn, *, Å , ', 0,1) plays an important role in the construction of switching circuits, electronic circuits and other applications. Also it can be proved that every finite Boolean algebra is isomorphic to the above Boolean algebra (Bn, *, Å , ', 0,1), for some n. Thus, it is interesting to observe that number of elements in any finite Boolean algebra must be always 2n, for some n. Let (B, *, Å , ' , 0,1) be a Boolean algebra and S Í B. If S contains the elements 0 and 1 and is closed under the operation *, Å and ' then (S, *, Å , ', 0,1) is called sub Boolean algebra.

Example : Consider the Boolean algebra (P ({1,2,3}), Ç , È , ' ,f , {1,2,3}) Then (S = {f , {1}, {2,3}, {1,2,3}}, Ç , È , ', f , {1,2,3}) is also sub Boolean algebra. Similarly, S = ({f ,{3},{1,2},{1,2,3}}, Ç , È , ', f , {1,2,3}) is also sub Boolean algebra. But (S = ({f, {1}, {2,3}, {1,2,3}}, Ç , È ,' , f , {1,2,3})) is not a sub Boolean algebra.

Page 7: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

Isomorphic Boolean algebra:

Let < 퐵 ,∗,⊕, , 0,1 > & < 퐵 ,⋂,⋃,−,훼,훽 > be two Boolean algebras.

A mapping 푓:퐵 → 퐵 is called Boolean homomorphism if all the operations of the Boolean algebra are preserved.

It means that for any 푎, 푏 ∈ 퐵

푓(푎 ∗ 푏) = 푓(푎) ∩ 푓(푏)

푓(푎 ⊕ 푏) = 푓(푎) ∪ 푓(푏)

푓(푎 ) = 푓(푎)

푓(0) = 훼

푓(1) = 훽

If the mapping 푓 is one-one also in addition to being homomorphism, then this mapping is called isomorphism.

In particular if 퐵 & 퐵 are two Boolean algebra with respect to the same operation ⊕,∗ ,0,1 then 푓:퐵 → 퐵 is called isomorphism if

1. 푓 is one-one. 2. 푓(푎 ⊕ 푏) = 푓(푎) ⊕푓(푏) 3. 푓(푎 ∗ 푏) = 푓(푎) ∗ 푓(푏) 4. 푓(푎 ) = 푓(푎)

For any 푎, 푏 ∈ 퐵 & 퐵 are said to be isomorphic Boolean algebra.

Definition: Join Irreducible

Let < 퐿,∗,⊕> an element 푥 ∈ 퐿 is called Join-irreducible if it cannot be expressed as the join (LUB) of two distinct elements.

Atom:

Let < 퐿,∗,⊕> be a lattice & 푎 ∈ 퐿, then 푎 is said to be an atom if

a. 푎 is join-irreducible

Page 8: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

b. 푎 is covers of 0-element.

Boolean Expressions and their equivalence:

Boolean algebra uses Boolean variables and Boolean operators. Boolean variables

are binary variables and Boolean operators are logical operators. Some examples

of Boolean variables are A, B, C, a, b, c, X, Y, and Z.

There are three basic logical operators:

AND, OR, and NOT.

A Boolean expression is a combination of Boolean variables and Boolean

operators. There are many Boolean expressions that are logically equivalent to one

another. There are called equivalent expressions.

A Boolean function typically has one or more input variables and produces a result

that is based on these input values. The result can have a value of 0 or 1.

Most of the subsystems of a digital system take the form of a switching network. A

switching network has one or more inputs and can have one or more outputs. Each

output can be represented by a Boolean function with n variables.

2-input AND Gate

For a 2-input AND gate, the output Q is true if BOTH input A “AND” input B are both true, giving the Boolean Expression of: ( Q = A and B ).

AND OR NOT

Page 9: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

Note that the Boolean Expression for a two input AND gate can be written as: A.B or just simply AB without the decimal point.

2-input OR (Inclusive OR) Gate

For a 2-input OR gate, the output Q is true if EITHER input A “OR” input B is true, giving the Boolean Expression of: ( Q = A or B ).

NOT Gate

For a single input NOT gate, the output Q is ONLY true when the input is “NOT” true, the output is the inverse or complement of the input giving the Boolean Expression of: ( Q = NOT A ).

Page 10: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

The NAND and the NOR Gates are a combination of the AND and OR Gates with that of a NOT Gate or inverter.

2-input NAND (Not AND) Gate

For a 2-input NAND gate, the output Q is true if BOTH input A and input B are NOT true, giving the Boolean Expression of: ( Q = not(A and B) ).

2-input NOR (Not OR) Gate

For a 2-input NOR gate, the output Q is true if BOTH input A and input B are NOT true, giving the Boolean Expression of: ( Q = not(A or B) ).

Page 11: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

As well as the standard logic gates there are also two special types of logic gate function called an Exclusive-OR Gate and an Exclusive-NOR Gate. The actions of both of these types of gates can be made using the above standard gates however, as they are widely used functions, they are now available in standard IC form and have been included here as reference.

2-input EX-OR (Exclusive OR) Gate

For a 2-input Ex-OR gate, the output Q is true if EITHER input A or if input B is true, but NOT both giving the Boolean Expression of: ( Q = (A and NOT B) or (NOT A and B) ).

2-input EX-NOR (Exclusive NOR) Gate

Page 12: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

For a 2-input Ex-NOR gate, the output Q is true if BOTH input A and input B are the same, either true or false, giving the Boolean Expression of: ( Q = (A and B) or (NOT A and NOT B) ).

Summary of 2-input Logic Gates

The following Truth Table compares the logical functions of the 2-input logic gates above.

Inputs Truth Table Outputs For Each Gate A B AND NAND OR NOR EX-

OR EX-NOR

0 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 1 0 1 0 0 1

The following table gives a list of the common logic functions and their equivalent Boolean notation.

Logic Function Boolean Notation AND A.B OR A+B NOT A NAND A .B NOR A+B

Page 13: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

EX-OR (A.B) + (A.B) or A B EX-NOR (A.B) + or A B

Example

Find the Boolean algebra expression for the following system.

The system consists of an AND Gate, a NOR Gate and finally an OR Gate. The expression for the AND gate is A.B, and the expression for the NOR gate is A+B. Both these expressions are also separate inputs to the OR gate which is defined as A+B. Thus the final output expression is given as:

The output of the system is given as Q = (A.B) + (A+B), but the notation A+B is the same as the De Morgan´s notation A.B, Then substituting A.B into the output expression gives us a final output notation of Q = (A.B)+(A.B), which is the Boolean notation for an Exclusive-NOR Gate as seen in the previous section.

Inputs Intermediates Output B A A.B A + B Q 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0

Page 14: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

1 1 1 0 1

Then, the whole circuit above can be replaced by just one single Exclusive-NOR Gate and indeed an Exclusive-NOR Gate is made up of these individual gate functions.

Example

Find the Boolean algebra expression for the following system.

This system may look more complicated than the other two to analyse but again, the logic circuit just consists of simple AND, OR and NOT gates connected together.

As with the previous Boolean examples, we can simplify the circuit by writing down the Boolean notation for each logic gate function in turn in order to give us a final expression for the output at Q.

Page 15: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

The output from the 3-input AND gate is only at logic “1” when ALL the gates inputs are HIGH at logic level “1” (A.B.C). The output from the lower OR gate is only a “1” when one or both inputs B or C are at logic level “0”. The output from the 2-input AND gate is a “1” when input A is a “1” and inputs B or C are at “0”. Then the output at Q is only a “1” when inputs A.B.C equal “1” or A is equal to “1” and both inputs B or C equal “0”, A.(B+C).

By using “de Morgan’s theorem” inputs B and input C cancel out as to produce an output at Q they can be either at logic “1” or at logic “0”. Then this just leaves input A as the only input needed to give an output at Q as shown in the table below.

Inputs Intermediates Output C B A A.B.C B C B+C A.(B+C) Q 0 0 0 0 1 1 1 0 0 0 0 1 0 1 1 1 1 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 0 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1

Minterms and Maxterms:

Each row of a truth table can be associated with a minterm, which is a product (AND) of all variables in the function, in direct or complemented form. A minterm has the property that it is equal to 1 on exactly one row of the truth table.

Here is the three-variable truth table and the corresponding minterms:

minterm 0 0 0

0 0 1

Page 16: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

The subscript on the minterm is the number of the row on which it equals 1. (The row numbers are obtained by reading the values of the variables on that row as a binary number.)

Minterms provide a way to represent any Boolean function algebraically, once its truth table is specified. The function is given by the sum (OR) of those minterms corresponding to rows where the function is 1. By the minterm property, the OR will contain a term equal to 1 (making the function 1) on exactly those rows where the function is supposed to be 1.

Example—

Suppose a function is defined by the following truth table:

0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1

Since on rows 1, 2, 4, and 7, we obtain

A compact notation is to write only the numbers of the minterms included in , using the Greek letter capital sigma to indicate a sum:

Page 17: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

This form can be written down immediately by inspection of the truth table.

The foregoing proves that once we have specified a Boolean function by means of its truth table, we are (in principle) able to implement it by means of logic gates that perform the AND, OR, and NOT functions.

Equivalence of two functions:

Two Boolean expressions represent the same function if their truth tables are identical. In form they will be the same.

Each row of a truth table is also associated with a Maxterm, which is a sum (OR) of all the variables in the function, in direct or complemented form. A Maxterm has the property that it is equal to 0 on exactly one row of the truth table.

Here is the three-variable truth table and the corresponding Maxterms:

Maxterms 0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

Like minterms, Maxterms also provide a way to represent any Boolean function algebraically once its truth table is specified. The function is given by the product (AND) of those Maxterms corresponding to rows where the function is 0. By the Maxterms property, the AND will contain a term equal to 0 (making the function 0) on exactly those rows where the function is supposed to be 0.

Page 18: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

Example: for the same function as previously, we observe that it is 0 on rows 0, 3, 5, and 6. So

This form also lends itself to a compact notation: using the Greek letter capital pi to denote a product, we write only the numbers of the Maxterms included in :

Two Boolean functions are equivalent if their forms are the same.

The and notational forms for a given function are related: each form contains all the row numbers omitted in the other form.

Page 19: BCA_Semester-II-Discrete Mathematics_unit-iii_Lattices and boolean algebra

Unit-III Lattices and Boolean algebra

Rai University, Ahmedabad

References:

http://plato.stanford.edu/entries/boolalg-math/#elem

http://venus.cs.qc.cuny.edu/~vivek/csci343_1129/supp/Boolean%20Algebra.pdf

http://www.electronics-tutorials.ws/boolean/bool_7.html

http://www.dsm.fordham.edu/~moniot/Classes/CompOrganization/boolean-outline/node4.html