Boolean Logic, Logic Gates, Truth Tables

advertisement
Boolean Logic, Logic Gates, Truth
Tables
J. Dimitrov
jordan@dmu.ac.uk
Software Technology Research Laboratory (STRL)
De Montfort University
Leicester, UK.
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 1
Overview
Boolean logic (algebra)
Gates implementing boolean operators
Some expressions
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 2
Boolean logic
Named after the nineteenth-century
mathematician George Boole
Allows us to reason and draw conclusions by
calculating thruth values.
It models the world by assuming atomic
sentences and assigning truth values to those.
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 3
Why logic?
Couldn’t we do without logic?
Example: If John loves Mary then he gives her
flowers. John gives Mary flowers.
What could we say about John and Mary?
Example: What is the opposite statement of “If
it rains, I take an umbrella”?
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 4
Why logic?
John may not love Mary!
The opposite of “If it rains, I take an umbrella”
is “It rains and I don’t have an umbrella”.
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 5
Basics
As we said, we’ll have a collection of atomic
sentences.
They will model our world.
They will include statements like “John loves
Mary”, “John gives Mary flowers”, “It rains” and
“I have an umbrella”.
These statements will be represented by
letters A, B, C , etc.
From the atomic statements we will build
complex statements such as “If John loves
Mary then he gives her flowers”.
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 6
Basics
The World (Universe)
An atomic sentence
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 7
Basics
D
A
B
C
The World (Universe)
An atomic sentence
A set
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 8
Boolean opertations
Not
Inverts the truth value of the argument.
Denoted as A, Not(A), ¬A.
A = true, iffA = false
And
Logical and
Denoted as A.B, A And B, A ∧ B .
A.B = true, iffA = true and B = true.
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 9
Boolean operations
Or
Logical or
Denoted as A + B, A Or B, A ∨ B .
A + B = true, iffA = true or B = true.
Implication
Logical implication
Denoted as A ⇒ B .
A ⇒ B = true, iffA = true implies B = true.
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 10
Truth tables and gates
Thinking now about true =1 and false=0.
Not
A
0
1
A
1
0
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 11
Truth tables and gates
And
A
0
0
1
1
B
0
1
0
1
A.B
0
0
0
1
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 12
Truth tables and gates
Or
A
0
0
1
1
B
0
1
0
1
A+B
0
1
1
1
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 13
Truth tables and gates
Implication
A B A⇒B
0 0
1
1
0 1
1 0
0
1
1 1
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 14
More operations and gates
Some abreviations
is the same as
Nand, Nor, Xor, XNor, etc
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 15
Boolean algebra
A.A = 0
A+A=1
A.1 = A
A.0 = 0
A.A = A
A+1=1
A+0=A
A+A=A
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 16
Boolean algebra
A.B = B.A
A+B =B+A
A.B.C = (A.B).C = A.(B.C)
A + B + C = (A + B) + C = A + (B + C)
A.(B + C) = A.B + A.C= (A.B) + (A.C)
A + (B.C) = (A + B).(A + C)6= A + (B.A) + C
A + B = A.B
A.B = A + B
A=A
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 17
De Morgan’s law
A + B = A.B
Why this will be the case?
A + B = A.B
A + B = A + B = A.B
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 18
Other forms of De Morgan’s law
A.B = A + B
A Xor B = A XNor B
J.Dimitorv, STRL, DMU, jordan@dmu.ac.uk – p. 19
Download