-- Define the ring of Boolean functions on 5 nodes Q = ZZ/2[x1,x2,x3,x4,x5] / ideal(x1^2-x1,x2^2-x2,x3^2-x3,x4^2-x4,x5^2-x5); -- Shortcut for AND and OR functions RingElement | RingElement :=(x,y)->x+y+x*y; RingElement & RingElement :=(x,y)->x*y; -- Define the Boolean functions f1 = x5 | (1+x2) | x4; f2 = (1+x1) & (1+x3); f3 = 1+x2; f4 = 1+x2; f5 = x1 | x4; -- Eliminate x5. It only appears in f1. f1=sub(f1,{x5=>f5}); -- Eliminate x4. It only appears in f1. f1=sub(f1,{x4=>f4}); -- Eliminate x3, which appears in f1 and f2. f1=sub(f1,{x3=>f3}); f2=sub(f2,{x3=>f3}); -- We can't eliminate further; f1 contains x1 and f2 contains x2. (f1, f2)