## Monday, September 03, 2012

### Electronics Lessons: Boolean Algebra

There is nothing that would turn a person off a subject more than the mention of algebra.

But, do bear with me.

As with ordinary algebra we'er using letter to represent something, but in this case we're using it to represent states on inputs compared to what ew want our output to be.

I introduced notation in the last post that describes how to write logical expressions.

So lets just straight in.

In real maths we know that 1 + 2 = 2 + 1, both are equal to three.
The same is true in boolean algebra,

1 + 0 = 0 + 1
1 . 0 = 0 . 1

Also it's pretty obvious that if I say A and A, that's just A, if I give you a choice A or A, that's not really a choice.

A . A = A
A + A = A

We can use brackets in boolean algebra just like we do in regular algebra.

That means that:
(A + B) + C = A + (B + C)
(A . B) . C = A . (B . C)

Brackets can be expanded out the same wat that they are in regular maths
So:
A . (B + C) = A . B + A . C
A + (B . C) = (A + B) . (A + C)

Then we have terms that just don't matter.
A + (A . B)
A or A and B.
well in either case for the given output A has to be high and the state of B does not matter.
so:
A + A . B = A
A . (A + B) = A

We use 0 to represent a logic low, and a to represent a logic 1.
0 + A = A
0 . A = 0

1 + A = 1
1 . A = A

/A + A = 1
/A . A = 0

Not only are terms that are the same redundant. (Like A or A)
But terms that have all the same terms, but include a NOT statement are also redundant.

A and B, OR A and NOT B.

A .B + A . /B = A
(A + B) . (A + /B) = A

(A + B) . (A + /B) => A . A + A . /B + A . B + B . /B
B . /B is equal to 0
A . A + A . /B + A . B + B . /B => A + A . /B + A . B + 0
And just as A + 0 = A the same is true of a complex expression.
A + A . /B + A . B + 0 => A + A . /B + A . B
As said earlier A and A or A and NOT B is just as good as saying A
A + A . /B + A . B => A + A => A

Some more rules are:
A + /A . B = A + B

To prove this let's look at a table showing the outputs.
first lets look at /A . B
A => /A B | Q
===========
0 => 1  0 | 0
0 => 1  1 | 1
1 => 0  0 | 0
1 => 0  1 | 0

Now we'll put that into a new table so that we can look at A + /A . B

A Q | Out
=======
0 0 | 0
0 1 | 1
1 0 | 1
1 0 | 1

and compare that to A OR B
A B | Q
======
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 1

it's the same (weird looking rule proven!)

we also have
A ( /A + B) = A . B

The last two rules are a special set called DeMorgans Theorem.

/(A + B) = /A . /B
and
/(A. B) = /A + /B