Introduction to Boolean Logic
A boolean value means a value can only take on one of two possibilities,
commonly written as or or false,true.
A proposition is any expression which can be reduced to a boolean value. For
example, the question of whether or can be reduced to the
boolean value true. When it’s clearer to do so, we might also prefer to write
a proposition in plain English, such as by asking whether is a natural
number.
Boolean logic is the study of labeling propositions, circuits, and other objects
as either true or false, and then asking questions about all the things
you’ve just labeled. In this cold way of thinking, true and false are merely
names. To the mathematician, true might refer to whether a proposition is
consistent with the rules they care about; to an engineer, true might refer to
the state of a circuit or a bit of information. To these professions, logic is
merely an accounting machine for manipulating information.
If we think about all the possible boolean functions which consume only one input, there will be possible functions. Additionally, for -input boolean functions, there are unique boolean pairs and thus possible functions.
More generally, for boolean functions accepting inputs, there are possible boolean functions.
Of these, NOT, OR, AND, and XOR are the most well known and they’re
widely implemented in programming languages
| name | math | javascript | julia | python |
|---|---|---|---|---|
NOT | ! | ! | not | |
OR | ⎮⎮ | ⎮⎮ | or | |
AND | && | && | and | |
XOR | ^ | ^ | ^ |
Note that
NOTis a 1-input boolean function, but is listed here due to its popularity.
Logical NOT ()
Logical NOT consumes only one input and it’s written as .
NOT is useful for transforming a proposition to an opposing, contradictory
one. For example, if is the proposition that is natural, then
asks if isn’t natural.
Logical OR, AND, and XOR
ORasks if there exists atrueinput.ANDasks if all inputs aretrue, and is equivalent to multiplication.XORasks if both its inputs are different, and is equivalent to addition.
Implication
Let and be propositions. There are times when knowing is true also means knowing is true. For example, knowing is a natural also means knowing is an integer, although the reverse isn’t always true.
Logical implication is a binary operator represented by the relations table below.
One way of thinking about is as a discussion on what kinds of evidence we would accept for knowing that is true. If we have then we can use the truthiness of to prove . Otherwise, we can just directly prove even if turns out to be false. Both are acceptable ways to prove .
Implication Causality
When we say implies , this doesn’t mean that causes . For example, let’s say that proposition asks if a light switch is turned on, and proposition asks if black holes exist
Since the proposition about black holes is always true, we then have enough to say that implies , but that doesn’t mean we think causes . Instead we say that whenever we observe we also observe .
Universal Functions
NOR and NAND are notable because they’re the only functions that
can individually rebuild all possible boolean functions.
NORcan be written as .NANDcan be written as .
De Morgan’s laws
The One Axiom
Let be booleans, and let be the NAND function. All of boolean
algebra can be summarized with a single axiom:
In 2002, Stephen Wolfram, and separately William McCune and colleagues, independently curated and published this axiom from among over a dozen competing aesthetic choices.
Boolean Field
XOR and AND individually form groups and together they form the smallest
field with only two elements, written as or . Finite fields are
also known as Galois Fields, named after famed mathematician Évariste Galois.
Note the multiplicative group of a field excludes or else multiplication wouldn’t be invertible.
We can see that the functions are equivalent from the truth table below.
Logical Functions represented in
| name | expression | polynomial |
|---|---|---|
NOT | ||
AND | ||
OR | ||
XOR | ||
IMPLY | ||
NAND | ||
NOR |
Higher Order Boolean Logic
The collection of sixteen 2-arity functions closed over the booleans are altogether known as zeroeth order boolean logic.
First order boolean logic allows you to look over “many” boolean propositions
and say whether none, some, or all of the propositions are true, and so
people often say that first order logic “quantifies” over sets.
Second order boolean logic is somewhat controversial. While first order logic allows you to discuss some or all of the objects you care about, it cannot discuss all the relations your objects may have among each other.
So far with zero-order logic we’ve only been evaluating two boolean arguments at a time, but what if we wanted to evaluate many at a time? For example, let’s say I have a set below:
- Are all elements whole numbers? Yes.
- Are some elements bigger than ? Yes: .
- Are no elements smaller than ? Yes.
- Is there a unique element smaller than ? Yes: .
All of the naturals
This statement reads “for all and from we have “.
Some of the naturals
This reads as “there exists an and from such that “.
None of the naturals
The first statement can be read as “there exists no and from such that ”. The second statement can be read as “for all and from we have “.
Saying “never true” is equivalent to saying “always false”.
There is a unique natural
This statement can be read as “there exists a unique element from such that “.