100x more cursed + Zig
do not read the source code
Features:
- supports logical not, and, or, xor
- (new in v2) proper polynomial ordering (greatest degree first + lexicographic but i'm not really sure if i know what that word means)
Truth tables for the utterly deranged
Polynomial form, and everything must evaluate to 0 or 1. 0=false, 1=true. A valid booleanomial evaluates to 0 or 1 for all inputs that are 0 or 1.
zig build run
requires Zig v0.10 probably (for std.bit_set.IntegerBitSet.setRangeValue
)
asked
a = a
b = b
c = c
not a = -a + 1
a and b = ab
a or b = -ab + a + b
a xor b = -2ab + a + b
true = 1
false = 0
not true = 0
not false = 1
a or true = 1
a and true = a
a xor true = -a + 1
a or false = a
a and false = 0
a xor false = a
c and (a or b) = -abc + ac + bc
a and b and c and d = abcd
a or b or c or d = -abcd + abc + abd + acd + bcd - ab - ac - bc - ad - bd - cd + a + b + c + d
a xor b xor c xor d = -8abcd + 4abc + 4abd + 4acd + 4bcd - 2ab - 2ac - 2bc - 2ad - 2bd - 2cd + a + b + c + d
(a and b) or (c and (a xor b)) = -2abc + ab + ac + bc
comptime compilre