boolean logic, de morgan’s laws,computing.ermysteds.co.uk/.../booleanlogicnoanswers_0_0.pdf ·...

49
Boolean logic, De Morgan’s laws, and lots of other mind-bending stuff You need your brain for this. Also I can’t believe that I used Paint to make some images. You should shoot me now.

Upload: tranthuy

Post on 09-Sep-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Boolean logic, De Morgan’s laws, and lots of other mind-bending

stuff

You need your brain for this. Also I can’t believe that I used Paint to make some images.

You should shoot me now.

Some revision first (nicked from Wikipedia)

http://www.humorsoffice.com/img/android-logo-logic-gates/

Some weird symbols

NOT A = A

A OR B = A + B

A AND B = A . B

De Morgan came up with two rules

(NOT A) AND (NOT B) = NOT (A OR B)

&

NOT (A AND B) = (NOT A) OR (NOT B)

First law…

U

A B

(NOT A) is in pink

(NOT B) is in yellow

NOT A AND NOT B – which bits are in pink and yellow?

(A OR B) is in pink

NOT (A OR B) is in blue

NOT (A OR B)

A+B

(NOT A) AND (NOT B)

A . B

is the same as

So we have proved that

(A + B)

is equal to

A . B

Second Law

Trying to prove that

NOT (A AND B) = (NOT A) OR (NOT B)

(A AND B) in pink

NOT (A AND B) in yellow

NOT A in tan

NOT B in green

(NOT A) OR (NOT B) – which bits are in tan or green?

NOT (A AND B)

A . B

is the same as

(NOT A) OR (NOT B)

A+B

So we have proved that

A . B

is equal to

A + B

Remember NAND and NOR?

NOT AND

&

NOT OR

We have a logic circuit, it uses 2 gates

A

B

A.B A.B

We could replace two gates with a single NAND gate and know that our

program’s logic would not change

NOT (A AND B)

A

B

A.B A.B

A

B

A.B

same as (A NAND B)

NOT (A OR B)

A

B

A+B A+B

A

B

A+B

same as (A NOR B)

So what?

When designing programs or logic gates (chips) we can use De Morgan’s laws to save some logic gates, and to make our logic operations simpler

Using only NAND and NOR gates and with the aid of De Morgan’s laws, draw

circuits for:

i) Q = A + B

ii) Q = A . B

i) (NOT A) OR (NOT B)

We know that this is the same as NOT(A AND B)

So:

A

B

A.B Q

ii) (NOT A) AND (NOT B)

We know this is the same as NOT(A OR B)

So:

A

B

A+B Q

A rule to remember:

Borrowed from http://www.csus.edu/indiv/p/pangj/class/cpe64/ademo/L1_Demo_Demorgan.pdf - It’s probably worth you grabbing that as it’s another person’s take on this lesson

Other Boolean laws to remember (0 = False, 1 = True)

1. X AND 0 = 0 2. X AND 1 = X 3. X AND X = X 4. X AND (NOT X) = 0 5. X OR 0 = X 6. X OR 1 = 1 7. X OR X = X 8. X OR (NOT X) = 1 9. NOT (NOT X) = X

Commutative Law: X+Y = Y+X X.Y = Y.X

(the order of AND or OR operations doesn’t matter)

Associative Law: X.(Y.Z) = (X.Y).Z

X+(Y+Z) = (X+Y)+Z (the order of AND or OR operations for several variables doesn’t matter)

Distributive Law:

X.(Y+Z) = (X.Y) + (X.Z)

(X + Y) . (W + Z) = X.W + X.Z + Y.W + Y.Z

Want some more confusion?

A.B

Is the same as

AB And as geeks are lazy the . often goes walkies but you need to remember that AB is A AND B

Print out and keep card

http://www.tpub.com/neets/book13/NF130220.GIF

Simply this

Q = (X.Y).(Y+Z)

BREAK THE LINE, CHANGE THE SIGN

Q = (X.Y).(Y+Z)

Q = (X.Y)+(Y+Z)

Q = (X.Y)+(Y+Z)

Q = (X.Y)+(Y+Z)

Two negatives are a positive (see basic rule number 9)

Q = (X.Y)+(Y+Z) BREAK THE LINE, CHANGE THE SIGN

Q = (X.Y)+(Y.Z)

Q = (X.Y)+(Y.Z) Two negatives are a positive (see basic rule number 9)

Q = (X.Y)+(Y.Z)

Or put simply

Q = (X.Y).(Y+Z) is the same as

Q = XY+YZ

That was fun!! Another, another!

Use De Morgan’s laws to simply

AB + A + B

AB + A + B BREAK THE LINE, CHANGE THE SIGN reversed is

JOIN THE LINE CHANGE THE SIGN

= AB + A . B

= AB + AB

=1 (i.e. it’s always true!)

You want more? Simplify :

A + B + (A + B)

Simplify

A + B + (A + B)

= A.B + (A + B) (lhs join line / flip sign)

= (A.B).(A+B) (swap sign / join line)

=(A.B.A)+(A.B.B) (distributive a(b+c)=ab+ac)

=A.B + A.B (basic rules a and a = a)

= A.B (basic rules a or a = a )

(= AB (or A NAND B))

Other ways you may see online when you Google to see what on earth was

being talked about today

NOT A is also A’ and also ¬A and also ~A and known as the complement of A

A OR B is also A \/ B and also A | B and known as A union B

A AND B is and also A /\ B and also A & B

The nice thing about standards is that there are so many to choose from – Andrew Tannenbaum

Exercises – Simplify:

1. A.B+A

2. B.(A+A)

3. A.B+B

4. B.(A+B)

Answers

links

http://www.electrical4u.com/boolean-algebra-theorems-and-laws-of-boolean-algebra/

http://www.csus.edu/indiv/p/pangj/class/cpe64/ademo/L1_Demo_Demorgan.pdf

And use Wolfram Alpha to evaluate any Boolean expressions and check your simplification