print(`This is PIE, a Maple package written by the`); print(`Experimental Math class taught by Dr. Z during`); print(`Spring 2011.`); with(combinat): #==================================================================== Help := proc() if nargs=0 then print(`contains the following procedures:`); print(`PIE(L),AND1(C1,C2,n)`); elif nargs=1 and args[1]=PIE then print(`PIE(L):`); print(`Inputs a list of sets, L, and outputs the number`); print(`of elements in their union `); print(`For example, try:`); print(`PIE([{1,3},{2,3}])`); elif nargs=1 and args[1]=AND1 then print(`AND1(C1,C2,n):`); print(`Inputs two clauses, C1 and C2, in n variables (expressed`); print(`as sets of integers from the set {-n,...,-1,1,...,n}) finds`); print(`their AND`); fi; end: #==================================================================== PIE := proc(L) local co,i,S,s,m; m := nops(L); co := add(nops(L[i]),i=1..m); for i from 2 to m do S := choose(L,i); #print(S); co := co + (-1)^(i-1)*add(nops(`intersect`(op(s))),s in S); od; RETURN(co); end: #==================================================================== AND1 := proc(C1,C2,n) local C,i; C := C1 union C2; for i from 1 to n do if member(i,C) and member(-i,C) then RETURN(0); fi; od; RETURN(C); end: