#Hey Dr. Z, # My program now works! # #---Phil ########################### # class10_SCD.mpl # # simple chain decomposition.... SCD:=proc(n) local C1l,C2l,c,cn,sn,i,j,S,le: if n <= 0 then return FAIL: fi: # base case n=1 if n =1 then return {[{},{1}]}: fi: C1l:=convert(SCD(n-1),list): C2l:=[]: # append the n to each element in the lattice for C2 for i from 1 to nops(C1l) do c:=C1l[i]: cn:=[]: for j from 1 to nops(c) do sn:= c[j] union {n}: cn:= [op(cn),sn]: od: C2l:= [op(C2l),cn]: od: #print(C1l,C2l): S:={}: for i from 1 to nops(C1l) do le:= nops(C1l[i]): S:= S union {[op(C1l[i]),C2l[i][le]],[op(1..le-1,C2l[i])]}: od: S minus {[]}: end: ## HOMEWORK: do this, but do it lexicographically (greedy) as per last class. ## then check that the two of them give the same thing.