Tim Keal's Comprehensive Guide to Boolean Logic

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Tim Keal's Comprehensive Guide to Boolean Logic
by on (#35897)
---Tim Keal's Comprehensive Guide to Boolean Logic---

Reference Material for this lesson:

Code:
----------------------------------------------------+
Boolean Beakers (plain/text version)                |
(c) Copyright Mon, 2007 12/17 Timothy Robert Keal   |
-----+----------------------------------------------+
pop3 | jargon juno com                              |
http | mediaplague.com                              |
icq  | 41981241                                     |
yim  | stereotypicalhacker                          |
yim  | stereotypicalhacker2pt0                      |
aim  | alias jargon                                 |
msn  | timkeal hotmail com                          |
skype| trkeal                                       |
-----+----------------------------------------------+
3 2 1 0  Truth Table Power Of 2 Bit Index           |
----------------------------------------------------+
0 0 0 1  Neither  A,B                               |
0 0 1 0  Just       B                               |
0 1 0 0  Just     A                                 |
1 0 0 0  Both     A,B                               |
----------------------------------------------------+
1 1 0 0  Input    A                                 |
1 0 1 0  Input      B                               |
----------------------+---------+---------+---------+
0 0 0 0    NOT TRUE   |FALSE    |NULL     |         |
0 0 0 1  A NOT   OR B |NOR   A,B|         |         |
0 0 1 0  A NOT LIMP B |NLIMP A,B|Just    B|         |
0 0 1 1  A NOT        |NOT   A  |         |         |
0 1 0 0  A NOT RIMP B |NRIMP A,B|NIMP  A,B|Just  A  |
0 1 0 1    NOT      B |NOT     B|         |         |
0 1 1 0  A NOT  EQV B |NEQV  A,B|XOR   A,B|EOR   A,B|
0 1 1 1  A NOT  AND B |NAND  A,B|         |         |
- - - - - - - - - - - + - - - - + - - - - + - - - - +
1 0 0 0  A      AND B |AND   A,B|         |         |
1 0 0 1  A      EQV B |EQV   A,B|XNOR  A,B|ENOR  A,B|
1 0 1 0             B |        B|         |         |
1 0 1 1  A     RIMP B |RIMP  A,B|IMP   A,B|         |
1 1 0 0  A            |      A  |         |         |
1 1 0 1  A     LIMP B |LIMP  A,B|         |         |
1 1 1 0  A       OR B |OR    A,B|         |         |
1 1 1 1        TRUE   |TRUE     |Identity |         |
----------------------+---------+---------+---------+


Image

0, 1, 2 input "Boolean Beakers" overview thumbnail
Image

0 input "Boolean Beakers" poster
Image

1 input "Boolean Beakers" poster
Image

2 input "Boolean Beakers" poster
Image
Magic Faerie-Godmother "Eureka" Dust
by on (#35899)
And now... THE LESSON:

In the "Boolean Beakers Posters", notice the amount of inputs progressively does a doubling 'n' interval with each iteration of 'n'-ary splits through Boolean Space.

Look here:
Code:
0000   False   | 1111   Truth 
n/a              n/a
n/a              n/a
n/a              n/a
n/a              n/a
n/a              n/a
n/a              n/a
n/a              n/a

Notice, two ends of a Unit Segment for zero input Boolean Space.

Code:
0000   False   | 1111   Truth 
n/a              n/a
n/a              n/a
0011 A Not     | 1100 A     
n/a              n/a
n/a              n/a
n/a              n/a
n/a              n/a

Notice, 4 corners of a Unit Square for one input Boolean Space.
Notice 'X' is equivalent to 'XX'.
Notice the n/a gaps are quadrupling.

The formula for the amount of gates is 2^2^(AmountOfInputs).

0 inputs has 2^2^0 gates. (2)
1 inputs has 2^2^1 gates. (4)
2 inputs has 2^2^2 gates. (16)
3 inputs would therefore have 2^2^3 gates. (256)

Each bit3 bit2 bit1 bit0 is a truth table for 2 inputs.
The truth table itself being left-endian, meaning the highest bit is the first bit in the series.
The lowest bit is always zero.

for 0 inputs:
bit0 is a constant (whether it is set or not.)

for 1 input:
bit1 is just a
bit0 is neither a,etcetera

for 2 inputs:
bit3 is (just all) both a,b (but nothing else being set)
bit2 is just a (only a is set, and nothing else)
bit1 is just b (only b is set, and nothing else)
bit0 is neither a,b(,etcetera,...) (nothing is set)

Remember that nothing else only pertains to the actual inputs within the amount included within the boolean operand.

for 3 inputs:
bit7 all a,b,c
bit6 both a,b
bit5 both a,b
bit4 both a,c
bit3 both b,c
bit2 just b
bit1 just c
bit0 none

By now you prolly see the pattern of permutation, that is the ordered series of possible match-ups between the inputs.

Since if the result of the boolean operand is if any entry is bit expression holds its ground, therefore:
If any bit in the truth table filters through, the result is set as well, otherwise the result is not set.
for unknowns, the table simply collapses to the simplest table as already outlined below:

Code:
0000   False   | 1111   Truth 
0001 A NOr   B | 1110 A Or    B
0010 A NLimp B | 1101 A LImp  B
0011 A Not     | 1100 A       
0100 A NRImp B | 1011 A Rimp  B
0101   Not   B | 1010         B
0110 A NEqv  B | 1001 A Eqv   B
0111 A Nand  B | 1000 A And   B


Notice, 16 vertices of a Unit Hypercube for two input Boolean Space.
Notice 'LR' is equivalent to 'LLRR'.
Also Notice, 'X' is equivalent to 'XXXX'

Therfore: 'HiLo' is equivalent to 'HiHiLoLo'

Thus you can reverse this behavior on either end of the series for so long as the unknowns do not fill that capacity.
Yes, I realize this last statement is very confusing, even I forget why that part is important in simplifying the overall expression.
I will come back to that later when I re-download my notes.

Code:
0000   False   | 1111   Truth 
0001 A NOr   B | 1110 A Or    B
0010 A NLimp B | 1101 A LImp  B
0011 A Not     | 1100 A       
0100 A NRImp B | 1011 A Rimp  B
0101   Not   B | 1010         B
0110 A NEqv  B | 1001 A Eqv   B
0111 A Nand  B | 1000 A And   B


Notice the left side is the reverse of the right side of the table!
The left side is 'Not' of the right side!
Also notice the bitmasks, that is, the series of bits, are the opposite setting from each side!
Thus the full set of possible truth tables counts upwards down the left side, then wraps 180 degrees around the rosie bush, and counts upwards back up the other side!

Now refer to this again:

Code:
----------------------+---------+---------+---------+
0 0 0 0    NOT TRUE   |FALSE    |NULL     |         |
0 0 0 1  A NOT   OR B |NOR   A,B|         |         |
0 0 1 0  A NOT LIMP B |NLIMP A,B|Just    B|         |
0 0 1 1  A NOT        |NOT   A  |         |         |
0 1 0 0  A NOT RIMP B |NRIMP A,B|NIMP  A,B|Just  A  |
0 1 0 1    NOT      B |NOT     B|         |         |
0 1 1 0  A NOT  EQV B |NEQV  A,B|XOR   A,B|EOR   A,B|
0 1 1 1  A NOT  AND B |NAND  A,B|         |         |
- - - - - - - - - - - + - - - - + - - - - + - - - - +
1 0 0 0  A      AND B |AND   A,B|         |         |
1 0 0 1  A      EQV B |EQV   A,B|XNOR  A,B|ENOR  A,B|
1 0 1 0             B |        B|         |         |
1 0 1 1  A     RIMP B |RIMP  A,B|IMP   A,B|         |
1 1 0 0  A            |      A  |         |         |
1 1 0 1  A     LIMP B |LIMP  A,B|         |         |
1 1 1 0  A       OR B |OR    A,B|         |         |
1 1 1 1        TRUE   |TRUE     |Identity |         |
----------------------+---------+---------+---------+


Notice all the aliases for operands and constants from left to right.

EOR means exclusive OR, this means either, but not both.
LIMP means Left Implied, while RIMP means Right Implied.

A RIMP B is A IMP B, a standard Implication.
However, A LIMP B, is B IMP A. notice the order of the inputs reverses!

Also notice EQV (Eqivalence) is the opposite of XOR (another common mnemonic device of EOR.)
Thus, NEQV (Not Equivalent) is the same result as XOR (Exclusive Or!)
Thus, XNOR also known by the mnemonic ENOR (Neither) is the opposite output of EQV (Equivalent!)

This concludes the lesson, I am hell-ass tired and want to drive 50 miles home and go to bed.

I don't have the money for a damn lear jet from this airport to that one so I have to drive.
(Plus I would need a cargo jet anyways because I can't just leave my car at my damned friend's house.)

I now smack you on the skull with the rod of holy virginity. You are now a super-geek. (once, you assimilate this tutorial completely.)

END OF LESSON.

(Just because I moulded you into a super-geek doesn't make me one, i lost my virginity a thousand plus times over, and I damn well am a steampunk industrial/grunge rocker with a 14 inch mohawk; possibly dyed, maybe even pigmented checker board; half the time anyways.)

Plus I am hot as hell to chicks, did I ever tell the time I had to drive on two side wheels for 5000ft while disobeying Johnny Law and wrecklessly driving in order to defy certain death? Well maybe I share that story some other damn well time.

Good luck in your Boolean Adventures.

Now piss off and GO MAKE YOUR CREATOR PROUD.

by on (#35997)
I'm leaving this up long enough for you to copy this to your own blog or wiki.

by on (#36003)
tepples wrote:
I'm leaving this up long enough for you to copy this to your own blog or wiki.


um that was the rough draft, it is incomplete.

btw i screwed up and listed RImp twice, the second time it was supposed to be Just B, that is prolly part of the confusion. (Fixed now.)

plus i was awake for over 72 hours when i posted that. obviously, it is hard to comprehend.

This is a comprehensive Boolean Logic Tutorial. It applies to everything logic related, btw I have not outlined the difference between logical boolean operators and bitwise boolean operators.

Bitwise just means it applies to every digit of bits in the bitmask individually, logical means if any bit in a mask is set the entire mask is considered as Truth (set). Meaning -1 is 2's compliment mask 11111111 when using a "Signed Char". -2 would be 11111110. For, Unsigned Char 11111111 is 255, also under Unsigned Char 11111110 is 254. However in both, 00000001 is 1 and 00000010 is 2.

this means when using logical boolean operands:

if A is any of 111111111, 11111110, 00000001, 00000010; A is treated as
1. (Truth, Set)
However, if A is 00000000, A is treated as 0. (False, Unset)

Same goes for B for it's own input as how it is treated.

the output would then be either 11111111 (Truth, Set) or otherwise 00000000 (False, Unset)

This is how logical Boolean operands work.

Bitwise Operands work as if each bit in the masks A, B were their own pair of inputs and bit in the mask of output.

Thus 00000011 And 00001010 result is 0000010 when using Bitwise And,
but 00000011 And 00001010 result is 11111111 when using Logical And.
Some languages the result is 00000001 for logical for Truth, but I think NES uses the 11111111 (1 Byte) Logical Boolean Operand Truth (Set) mask.

I haven't got to the actual Morysl Algorithm 100% yet.

Also I haven't yet outlined the following, which I will do how:

Code:
3,2,1,0 applies to:

Input1
n+-+-+
p|0|1|
u+-+-+
t|2|3|
2+-+-+

where:

left side us input 1 unset and right side is input 1 set. (A)

-and-

top half is input 2 unset and bottom half is input 2 set. (B)


for example:
Code:
False
+-+-+
|0|0|
+-+-+
|0|0|
+-+-+

Truth
+-+-+
|1|1|
+-+-+
|1|1|
+-+-+

A And B
+-+-+
|0|0|
+-+-+
|0|1|
+-+-+

A Nand B
+-+-+
|1|1|
+-+-+
|1|0|
+-+-+

A Or B
+-+-+
|0|1|
+-+-+
|1|1|
+-+-+

A Nor B
+-+-+
|1|0|
+-+-+
|0|0|
+-+-+

A Xor B (NEqv)
+-+-+
|0|1|
+-+-+
|1|0|
+-+-+

A Xnor B (Eqv)
+-+-+
|1|0|
+-+-+
|0|1|
+-+-+

A Nor B
+-+-+
|1|0|
+-+-+
|0|0|
+-+-+

A (Input 1)
+-+-+
|0|0|
+-+-+
|1|1|
+-+-+

B (Input 2)
+-+-+
|0|1|
+-+-+
|0|1|
+-+-+

A Nand B
+-+-+
|1|1|
+-+-+
|1|0|
+-+-+

A Imp B (RImp)
+-+-+
|1|1|
+-+-+
|0|1|
+-+-+

B Imp A (LImp)
+-+-+
|1|0|
+-+-+
|1|1|
+-+-+

A NImp B (NRImp)
+-+-+
|0|0|
+-+-+
|1|0|
+-+-+

B NImp A (NLImp)
+-+-+
|0|1|
+-+-+
|0|0|
+-+-+



Thus:
Code:
0000   False   | 1111   Truth
0001 A NOr   B | 1110 A Or    B
0010 A NLimp B | 1101 A LImp  B
0011 A Not     | 1100 A     
0100 A NRImp B | 1011 A RImp  B
0101   Not   B | 1010         B
0110 A NEqv  B | 1001 A Eqv   B
0111 A Nand  B | 1000 A And   B

by on (#36004)
Are these the plans for Nature's harmonic simultaneous 4-day timecube?

by on (#36006)
Dwedit wrote:
Are these the plans for Nature's harmonic simultaneous 4-day timecube?


No, this is a comprehensive guide to Boolean Logic.

All "The Logic Cube" is, is a unique way to organize an illustration of the 16 basic Boolean operands.

All "The Morsyl Algorithm" is, is a way to dynamically dump the Boolean expression which is analogous to the logical gates on a printed circuit board for any MOSFET-based memory chip to demultiplex data in RAM or ROM, also known as an obsolete way to address data in memory physically.

by on (#36009)
Dwedit wrote:
Are these the plans for Nature's harmonic simultaneous 4-day timecube?
Hm. I suspect it would be more like the Synchronious 6-position Rubik's Cube's time-travelling breakdown ability, but I'm not sure.

by on (#36014)
Dwedit wrote:
Are these the plans for Nature's harmonic simultaneous 4-day timecube?

I prefer Nintendo's portable simultaneous 4-player GameCube myself.

by on (#36020)
jargon wrote:
tepples wrote:
I'm leaving this up long enough for you to copy this to your own blog or wiki.


um that was the rough draft, it is incomplete.

btw i screwed up and listed RImp twice, the second time it was supposed to be Just B, that is prolly part of the confusion. (Fixed now.)

(junk)


He said about you taking out this junk and putting in your blog. He's NOT requesting more details about this junk.

by on (#36030)
Fx3 wrote:
jargon wrote:
tepples wrote:
I'm leaving this up long enough for you to copy this to your own blog or wiki.


um that was the rough draft, it is incomplete.

btw i screwed up and listed RImp twice, the second time it was supposed to be Just B, that is prolly part of the confusion. (Fixed now.)

(junk)


He said about you taking out this junk and putting in your blog. He's NOT requesting more details about this junk.


How is it junk? I haven't even gotten to the part where I show the op code list as 6502/2A03 machine code equivalents and their 2A03/6502 Assembly Mnemonic identifiers.

(Btw, I meant 'B', not 'Just B'... fixed.)