Boolean logic

Preview:

DESCRIPTION

detailed study on Boolean logic and its application by Cornelius saiki

Citation preview

Boolean algebra (or Boolean logic) is a logical calculus of

truth values, developed by George Boole in the 1840s.

It resembles the algebra of real numbers but the numerical

operators

• Multiplication AB

• Addition A + B

• Negation ¬A

Been replaced by respective logical operator’s

• Conjunction (AND) AɅB

• Disjunction (OR) AVB

• Complement (NOT) ¬A

These are the basic Boolean operators and all other are built from these.

A Ʌ ( BV C)

Example:

Boolean Logic

Boolean Algebra Laws

Boolean algebra, like regular algebra, has certain rules.

• Associativity

• Distributivity

• Commutativity

Associativity, Commutativity and Distributivity only apply to the AND

and OR operators.

• ASSOCIATIVITY

Associativity is the property of algebra that the order of evaluation

of the terms is immaterial.

A V (B V C)=(A V B) V C

A Ʌ (B Ʌ C)=(A Ʌ B) Ʌ C

A + (B + C)=(A + B) + C

A . (B . C)=(A . B) . C

or

Distributivity

Distributivity is the property that an operator can be

applied to the terms within the brackets.

A Ʌ (B V C) =(A Ʌ B) V (A Ʌ C)

A. (B + C) =(A . B) + (A . C)

or

Commutativity

Commutativity is the property that order of application of

an operator is immaterial.

A Ʌ B = B Ʌ A

A V B = B V A or

A . B = B . A

A + B = B + A

De Morgan's Law

De Morgan's Law is a consequence of the fact that the NOT or

negation operator is not distributive.

¬(P Ʌ Q)= (¬P) V (¬Q)

¬(P V Q)= (¬P) Ʌ (¬Q)

or P . Q =P +Q

P + Q =P . Q

Rule 1: A +0=A Rule 7: A.A=A

Rule 2: A + 1=1 Rule 8: A.¬A=0

Rule 3: A.0=0 Rule 9: ¬ ¬A=0

Rule 4: A.1=A Rule 10: A+AB=A

Rule 5: A+A=A Rule 11: A+ ¬AB=A+B

Rule 6: A+¬A=1 Rule 12: (A+B)(A+C)=A+BC

These laws of Boolean results in a number of rules which then used

for Boolean algebra.

There are 12 basic rules of Boolean algebra

Examples

Simplify the following Expressions.

B Ʌ A Ʌ ¬A

Using rule 8. We get.

B Ʌ 0 = 0

A Ʌ ¬B V A Ʌ B

Taking out A.

A Ʌ (¬B V B )

This gives use A

1.

2

THEOREMS OF ALGEBRA AND TRUTH TABLE

There are several operators used in Boolean algebra (logics)

Conjunction (AND):

It is the closest of these three to its numerical counterpart, in

fact on 0 and 1 it is multiplication.

As a logical operation the conjunction of two propositions is

true when both propositions are true, and otherwise is false.

Boolean expression: X=A∩B

A B X=A∩B

F F F

F T F

T F F

T T T

A B C=A∩B

0 0 0

0 1 0

1 0 0

1 1 1

0 * 0 = 0

0 * 1 = 0

1 * 0 = 0

1 * 1 = 1

A B C X=A∩B∩C

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 0

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 1

Using three inputs

Boolean expression : X=A∩B∩C

0 * 0 * 0 = 0

0 * 0 * 1 = 0

0 * 1 * 0 = 0

0 * 1 * 1 = 0

1 * 0 * 0 = 0

1 * 0 * 1 = 0

1 * 1 * 0 = 0

1 * 1 * 1 = 1

Try other combinations of the input levels

Disjunction:

It operates almost like addition, with one

exception:

The disjunction of 1 and 1 is neither 2 nor 0 but

1.

Thus the disjunction of two propositions is false

when both propositions are false, and otherwise

is true.

Boolean expression: X=A∪B

A B X=A∪B

F F F

F T T

T F T

T T T

A B C=A∪B

0 0 0

0 1 1

1 0 1

1 1 1

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 1

Using three inputs

Boolean expression : X=A∩B∩C

A B C X=A∪B∪C

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 1

1 1 0 1

1 1 1 1

0 +0 + 0 = 0

0 + 0 + 1 = 0

0 + 1 + 0 = 0

0 + 1 + 1 = 0

1 + 0 + 0 = 0

1 + 0 + 1 = 0

1 + 1 + 0 = 0

1 + 1 + 1 = 1

Logical Negation (NOT):

Also called complement

Since we have only two numbers in Boolean algebra, If we know the value of

one, then we automatically know the value of the other.

Thus this number is the complement of the variable.

1 is the complement of 0

0 is the compliment of 1

Complement of A=¬A

A ¬A

0 1

1 0

A ¬A

F T

T F

NAND AND NOR LOGIC OPERATORS

NAND LOGIC OPERATORS

• This comes from two operators

NOT & AND

• It is made up from the compliment of their respective functions

A B X

F F T

F T T

T F T

T T F

A B X

0 0 1

0 1 1

1 0 1

1 1 0

• This comes from two operators NOT & AND

• It is made up from the compliment of their respective functions

NOR LOGIC OPERATORS

NAND AND NOR LOGIC OPERATORS

A B X=A∪B

F F F

F T T

T F T

T T T

A B C=A∪B

0 0 0

0 1 1

1 0 1

1 1 1

A B X

0 0 0

0 1 1

1 0 1

1 1 0

Exclusive OR & NOR OPERATORS (XOR & XNOR)

• Gives false if both inputs are true or both are

false .

• Gives true if we have different input levels

EXCLUSIVE OR (XOR)

It is the negative complement of XOR operator

Exclusive NOR (XNOR)

A B X

0 0 1

0 1 0

1 0 0

1 1 1

Boolean logic and Electronics Circuits

Boolean algebra is devised for dealing mathematically with philosophical

propositions which have ONLY TWO possible values: TRUE or FALSE,

Light ON or OFF.

SW1 Open >> Lamp is OFF

SW1 Closed >> Lamp is ON

The truth table for these conditions is stated below

SW1 Lamp

OPEN OFF

CLOSED ON

SW1 Lamp

0 0

1 1

Electronic Systems:

Analogue >> Continuous System

Digital >> Discrete System

Boolean logic and Electronics Circuits In Boolean algebra the TWO possible conditions can

be represented by the DIGITS

“0” and “1”.

Binary Digits – Bits.

Light ON = “1” = +5V = HIGH

Light OFF = “0” = 0V = LOW

Open = “0”, CLOSED = “1”

“AND” operation: Describes events which can

occur IF and only IF 2 or more other events are

TRUE

Consider the circuit below A B C

OPEN OPEN OFF

OPEN CLOSED OFF

CLOSED OPEN OPEN

CLOSED CLOSED ON

A B L

0 0 0

0 1 0

1 0 0

1 1 1

Lamp will light ONLY when the switches A and B are

CLOSED, i.e. A and B both “1”

NOTATION: C = A.B

C = AB Boolean Equation

The symbol for AND gate is shown below

Application of AND Gate

• The AND gate on this drill press

provides a safety feature which

prevent the operator from placing

a hand between the drill bit and

stock.

• To activate the drive, both

buttons must be pushed

simultaneously

“OR” Operation:

Describes events which can occur IF at LEAST

ONE of the other events is TRUE.

Since the Switches are in

parallel, the lamp will light

when A

OR B are closed, i.e. A or B =

“1” or Both “1”

A B L

OPEN OPEN OFF

OPEN CLOSE

D

ON

CLOSE

D

OPEN ON

CLOSE

D

CLOSE

D

ON

A B L

0 0 0

0 1 1

1 0 1

1 1 1

Application of OR Gates:

Here OR gate is used to detect an

exceed of temperature or pressure,

and then produce a command signal

for the system to take necessary

actions

“NOT” operation: Changes a statement from TRUE

to FALSE and vice–versa, i.e. inversion

The truth table for this operation

A L

OPEN ON

CLOSED OFF

A L

0 1

1 0

Application of NOT Gates:

A NOT GATE can be used to generate build a

square wave oscillator

Most times a NOT Gate gates ARE

not used on its own to perform a

function, rather its usually connected

to other gates to perform a function.

NOR GATE

A B C=A∪B

0 0 0

0 1 1

1 0 1

1 1 1

A B X

0 0 1

0 1 1

1 0 1

1 1 0

NAND GATE

XOR GATE A B X

0 0 0

0 1 1

1 0 1

1 1 0

XNOR GATE

A B X

0 0 1

0 1 0

1 0 0

1 1 1

BOOLEAN LOGIC IN PROGRAMMING

Boolean logic is fundamental to the design of computer hardware even if it isn’t the whole story.

The same holds true for programming.

In decision making, Boolean expression are applied while writing our programs

For example, a common task is making a decision using an IF statement

IF (A>0 AND A<10)

THEN do something

end

Recommended