a java library for boolean algebra that supports infinite variables
| operator | grammar |
|---|---|
| and | expression = expression ( and , & , * , . ) expression |
| or | expression = expression ( or , | , + ) expression |
| xor | expression = expression ( xor , ^) expression |
| nor | expression = expression ( nor ) expression |
| nand | expression = expression ( nand ) expression |
| xnor | expression = expression ( xnor ) expression |
| not/invert | expression = expression ' |
| not/invert | expression = ~ expression |
full adder
func sum = func.parse("(a xor b) xor c");
func carry_out = func.parse("(c and (a xor b)) or (b and a)");
System.out.println(new TruthTable(sum, carry_out).toString());output:
F1=(a xor b) xor c
F2=(c and (a xor b)) or (b and a)
a b c | F1 F2
------------
0 0 0 | 0 0
0 0 1 | 1 0
0 1 0 | 1 0
0 1 1 | 0 1
1 0 0 | 1 0
1 0 1 | 0 1
1 1 0 | 0 1
1 1 1 | 1 1
invert
func f = func.parse("a and (b xor c)");
System.out.println(f.not());output:
a nand (b xor c)
print with only and , or gates
System.out.println(f.alternate());output:
a and ((b and c') or (b' and c))