boolean logic, logic gates, truth tablesjordan/teaching/elec1099/logicgatestruthtables… ·...

19
Boolean Logic, Logic Gates, Truth Tables J. Dimitrov [email protected] Software Technology Research Laboratory (STRL) De Montfort University Leicester, UK. J.Dimitorv, STRL, DMU, [email protected] – p. 1

Upload: phamliem

Post on 15-Mar-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Boolean Logic, Logic Gates, TruthTablesJ. Dimitrov

[email protected]

Software Technology Research Laboratory (STRL)

De Montfort University

Leicester, UK.

J.Dimitorv, STRL, DMU, [email protected] – p. 1

Page 2: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Overview

Boolean logic (algebra)

Gates implementing boolean operators

Some expressions

J.Dimitorv, STRL, DMU, [email protected] – p. 2

Page 3: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Boolean logic

Named after the nineteenth-centurymathematician George Boole

Allows us to reason and draw conclusions bycalculating thruth values.

It models the world by assuming atomicsentences and assigning truth values to those.

J.Dimitorv, STRL, DMU, [email protected] – p. 3

Page 4: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Why logic?

Couldn’t we do without logic?

Example: If John loves Mary then he gives herflowers. John gives Mary flowers.What could we say about John and Mary?

Example: What is the opposite statement of “Ifit rains, I take an umbrella”?

J.Dimitorv, STRL, DMU, [email protected] – p. 4

Page 5: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

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, [email protected] – p. 5

Page 6: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Basics

As we said, we’ll have a collection of atomicsentences.

They will model our world.

They will include statements like “John lovesMary”, “John gives Mary flowers”, “It rains” and“I have an umbrella”.

These statements will be represented byletters A,B,C, etc.

From the atomic statements we will buildcomplex statements such as “If John lovesMary then he gives her flowers”.

J.Dimitorv, STRL, DMU, [email protected] – p. 6

Page 7: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Basics

An atomic sentence

The World (Universe)

J.Dimitorv, STRL, DMU, [email protected] – p. 7

Page 8: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Basics

A set

D

C

B

A

An atomic sentence

The World (Universe)

J.Dimitorv, STRL, DMU, [email protected] – p. 8

Page 9: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Boolean opertations

NotInverts the truth value of the argument.

Denoted as A, Not(A),¬A.

A = true, iffA = false

AndLogical andDenoted as A.B,A And B,A ∧ B.A.B = true, iffA = true and B = true.

J.Dimitorv, STRL, DMU, [email protected] – p. 9

Page 10: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Boolean operations

OrLogical orDenoted as A + B,A Or B,A ∨ B.A + B = true, iffA = true or B = true.

ImplicationLogical implicationDenoted as A ⇒ B.A ⇒ B = true, iffA = true implies B = true.

J.Dimitorv, STRL, DMU, [email protected] – p. 10

Page 11: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Truth tables and gates

Thinking now about true =1 and false=0.

Not

A A

0 11 0

J.Dimitorv, STRL, DMU, [email protected] – p. 11

Page 12: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Truth tables and gates

And

A B A.B

0 0 00 1 01 0 01 1 1

J.Dimitorv, STRL, DMU, [email protected] – p. 12

Page 13: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Truth tables and gates

Or

A B A + B

0 0 00 1 11 0 11 1 1

J.Dimitorv, STRL, DMU, [email protected] – p. 13

Page 14: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Truth tables and gates

ImplicationA B A ⇒ B

0 0 10 1 11 0 01 1 1

J.Dimitorv, STRL, DMU, [email protected] – p. 14

Page 15: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

More operations and gates

Some abreviations

is the same as

Nand, Nor, Xor, XNor, etc

J.Dimitorv, STRL, DMU, [email protected] – p. 15

Page 16: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

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, [email protected] – p. 16

Page 17: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

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, [email protected] – p. 17

Page 18: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

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, [email protected] – p. 18

Page 19: Boolean Logic, Logic Gates, Truth Tablesjordan/teaching/elec1099/LogicGatesTruthTables… · Boolean Logic, Logic Gates, Truth Tables J. Dimitrov jordan@dmu.ac.uk Software Technology

Other forms of De Morgan’s law

A.B = A + B

A Xor B = A XNor B

J.Dimitorv, STRL, DMU, [email protected] – p. 19