(written long time ago, publish or languish)
These are some notes I made for Davide Radaelli for the first section of Schuller’s lectures on physics.
Let’s turn Boolean algebra into something we know better: arithmetic.
First we’ll set False to 0 and True to 1. To handle overflow, any arithmetic is
mod 2. So even numbers are
There are 4 unary operators:
- 2 constant functions:
, - identity:
. I like to write it as - negation:
. I like to write it as or .
Now for binary operators: and
and or
.
and
can be represented as multiplication. But or
cannot be represented as
addition. True or True is True, but
The annihilation properties of and
and or
suggest a way out.
True or \_
is always True, False or x
is the identity function on x.
False and _
is always False, True and x
is the identity function on x.
Notice the duality between these properties. It’ll come in handy in a moment.
The solution for how to represent these popped into my head randomly, which I dislike intensely, since that’s not a reliable problem solving method. But my subconscious doesn’t care.
We can use min and max.
and
is interesting because it can be represented 2 ways, as min or as multiplication.
But what’s +
then? Thinking categorically, sums are coproducts, which are on
the side of math that encodes the idea of single choices, any rather than all.
Closest match is exclusive or
. Turns out that works (check the truth table
yourself to be sure).
The last big boolean operator to handle is implication. It’s exponentiation.
Here’s some Julia code to test it out. I manually checked the basic implication truth table.
using RandomizedPropertyTest
@quickcheck (c^(a * b) == (c^a)^b == (c^b)^a) ((a, b, c)::Bool)
@quickcheck (c^(a ⊻ b) == (c^a * c^b) == (c^b * c^a)) ((a, b, c)::Bool)
@quickcheck (c^(a | b) == (c^a * c^b) == (c^b * c^a)) ((a, b, c)::Bool)
@quickcheck (a * (b | c) == (a * b) | (a * c)) ((a, b, c)::Bool)
@quickcheck (a | b == max(a, b)) ((a, b, c)::Bool)
@quickcheck (a & b == min(a, b) == a * b) ((a, b, c)::Bool)
@quickcheck (a * (b ⊻ c) == (a * b) ⊻ (a * c)) ((a, b, c)::Bool) # doesn't hold in all cases, such as a,b,c=1,1,0
Predicate Logic
Let’s explore
Dually,
Example: Consider a set we’re quantifying over is
Example: If the set we’re quantifying over is