4 (load("logic.lisp"), 'done);
7 logic_simp (a or (b or false or (a or b)));
10 logic_simp (b eq a eq false eq true);
13 logic_simp ((a xor true) xor b xor true);
16 characteristic_vector (f(x,y,z), x, y, z);
17 [f(false,false,false),f(false,false,true),f(false,true,false),
18 f(false,true,true),f(true,false,false),f(true,false,true),f(true,true,false),
21 characteristic_vector (true);
24 characteristic_vector (a xor b);
25 [false, true, true, false]$
27 characteristic_vector (a implies b);
28 [true, true, false, true]$
30 characteristic_vector (a implies b, a, b);
31 [true, true, false, true]$
33 characteristic_vector (a implies b, b, a);
34 [true, false, true, true]$
36 zhegalkin_form (a or b or c);
37 a and b and c xor a and b xor a and c xor b and c xor a xor b xor c$
39 zhegalkin_form ((a implies b) or c);
40 a and b and c xor a and b xor a and c xor a xor true$
43 e : ((a or b) xor c) and d, f: zhegalkin_form (e),
44 [logic_equiv (e, f), is(characteristic_vector(e)=characteristic_vector(f))]);
47 logic_equiv (x and y eq x, x implies y);
50 demorgan(dual_function (x or y));
62 closed_under_f (x and y);
65 closed_under_f (x or y);
68 closed_under_t (x and y);
71 closed_under_t (x or y);
80 monotonic (a implies b);
83 characteristic_vector (a or b);
84 [false, true, true, true]$
86 characteristic_vector (a and b);
87 [false, false, false, true]$
89 characteristic_vector (a implies b);
90 [true, true, false, true]$
92 characteristic_vector (a xor b);
93 [false, true, true, false]$
101 zhegalkin_form (a or b);
102 (a and b) xor a xor b$
104 zhegalkin_form (a eq b);
107 functionally_complete (x and y, x xor y);
110 functionally_complete (x and y, x xor y, true);
113 functionally_complete (x and y, x or y, not x);
116 logic_basis (x and y, x or y);
119 logic_basis (x and y, x or y, not x);
122 logic_basis (x and y, not x);
125 logic_basis (x or y, not x);
128 logic_basis (x and y, x xor y, true);
131 block([logic_functions : { not x, x nand y, x nor y,
132 x implies y, x and y, x or y,
133 x eq y, x xor y, true, false }],
134 subset (powerset(logic_functions),
135 lambda ([s], apply ('logic_basis, listify(s)))));
136 {{false, x eq y, x and y}, {false, x eq y, x or y},
137 {false, x implies y}, {true, x xor y, x and y},
138 {true, x xor y, x or y}, {not x, x implies y},
139 {not x, x and y}, {not x, x or y},
140 {x eq y, x xor y, x and y}, {x eq y, x xor y, x or y},
141 {x implies y, x xor y}, {x nand y}, {x nor y}}$
143 logic_diff (a or b or c, a);
144 (b and c) xor b xor c xor true$
146 logic_diff (a and b and c, a);
149 logic_diff (a or (not a), a);
152 demorgan(boolean_form (a implies b implies c));
153 ((not b) and a) or c$
155 logic_equiv (boolean_form (a implies b implies c),
156 zhegalkin_form (a implies b implies c));
159 demorgan (boolean_form (a nor b nor c));
160 (not a) and (not b) and (not c)$
163 (x and y) or ((not x) and y) or ((not x) and (not y))$
169 logic_simplify(((not a) and (not b) and c) or ((not a) and b and c) or (a and (not b) and c) or (a and b and c) or ((not a) and b and (not c)));
170 ((not a) and b) or c$
172 logic_simplify(((not a) and b) or (a and b));
175 logic_simplify (a or (not a) and b);
178 logic_simplify (a or (not a) and (b < 0));