Help:=proc(): print(`Mchoose(S,k),Prk(F,r,k) `): print(`NCP(A,B) , gNCP(L)`): end: #Mchoose(S,k): inputs a set S and a pos. integer #k and outputs the set of MULTI-SETS with exactly #k elements written in the format {[a1,i1],[a2,i2], ...} Mchoose:=proc(S,k) local S1,b,i,F,F1,f1: option remember: if k=0 then RETURN({{}}): fi: if S={} then RETURN({}): fi: b:=S[nops(S)]: S1:=S minus {b}: F:=Mchoose(S1,k): for i from 1 to k do F1:=Mchoose(S1,k-i): F:=F union {seq({op(f1), [b,i]}, f1 in F1)}: od: F: end: #Prk(F,r,k): inputs a collection of sets of integers #F, and pos. integers k and r, and outputs true of false #according to whether F has so-called property P(r,k) #in p. 5 of Alon-Boppana Combinatorica 7(1)(1987) 1-22 Prk:=proc(F,r,k) local ju,f,Ju,j,ListW,j1,U: if {seq( evalb(nops(f)<=k), f in F)}<>{true} then RETURN(false): fi: Ju:=Mchoose(F,r): for ju in Ju do ListW:=[seq(j1[1]$j1[2],j1 in ju)]: U:=`union`(seq(seq(ListW[i] intersect ListW[j],j=i+1..r ) ,i=1..r)): for f in F do if U intersect f=U and f<>U then RETURN(false): fi: od: od: true: end: #{Soup,Salad,CheeseFingers}x{VegLas,Falafel, VegiBurger}x #{IceCream,FruitSalad,Moose} #NCP(A,B): The set of sets {{a1,b1}, ...}, a in A and b in B NCP:=proc(A,B) local a,b: {seq(seq({a,b}, a in A),b in B)}: end: #gNCP(L): gNCP(L) given a list of sets L, constructs #all the "menues" (picking exactly ONE element from each #set in L gNCP:=proc(L) local i,L1,brian,baxter,F1,f1: if nops(L)=1 then RETURN({seq({brian}, brian in L[1])}): fi: baxter:=L[nops(L)]: L1:=[op(1..nops(L)-1,L)]: F1:=gNCP(L1): {seq(seq(f1 union {baxter1}, baxter1 in baxter), f1 in F1)}: end: