#OK to post homework #Natalya Ter-Saakov, March 6, Assignment 12 read "C12.txt": with(combinat): #Problem 2 #CheckBMFM(n,K) inputs a random function, call it f, defined on subests of {1,...,n} # and checkes that BM(FM(f,n))=f, viewed as tables, by checking that you always get the same value if you evaluate it at any subset of {1,...n} CheckBMFM:=proc(f,n) local BMFM: BMFM:=BM(FM(f,n),n): EqualEntries(f,BMFM): end: #CheckFMBM(n,K) inputs a random function, call it f, defined on subests of {1,...,n} # and checkes that FM(BM(f,n))=f, viewed as tables, by checking that you always get the same value if you evaluate it at any subset of {1,...n} CheckFMBM:=proc(f,n) local FMBM: FMBM:=BM(FM(f,n),n): EqualEntries(f,FMBM): end: #Problem 4 #CheckSuperAdditivity(f,n): inputs a function on the set of subsets of {1, ...,n} and outputs true iff for every two disjoint subsets S and T of {1,...,n}, you have # f[S union T] ≥ f[S] + f[T] CheckSuperAdditivity:=proc(f,n) local PN, PS, S, T: PN:=powerset(n): for S in PN do PS:=powerset(S): for T in PS do if f[S]