Help:=proc(): print(`BonnSieve(n,k), `): print(` ApplySieve(Se,P,Si)`): end: with(combinat): #{{set}}: A collection of subsests of {1,2, ....n} #such that Sum((-1)^s*ElementsWithProperties[s], s in the #{set} gives a lower or upper bounds (if k is even or odd) #(either resp. or not) BonnSieve:=proc(n,k) local i,N: N:={seq(i,i=1..n)}: {seq(op(choose(N,i)),i=0..k)}: end: #ApplySieve(Se,P,Si): Inputs a universal se Se #and a list of "properties" described explicitly #by a list of subsets of Se P=[P1,P2, ...] #(meaning Pi is the set of objectts having property i #(and possiblly other properties), and it also inputs # a sieve Si. Outputs the "estimate" implied by Si #and the true value of the set of objects that has #none of the properties #For example #ApplySieve({Emilie,Aisha,Daniela}, #[{Emilie,Aisha},{Emilie,Daniela}], {{},{1},{2}}) #should return #TrueValue=0 #Estimate=3-2-2=-1 ApplySieve:=proc(Se,P,Si) local Es, TV,josh,kellen,Si1: if not {} in Si then ERROR(`Bad input`): fi: TV:=nops(Se minus {seq(op(P[i]),i=1..nops(P))}): Si1:=Si minus {{}}: Es:=add((-1)^nops(josh)*nops(`intersect`(seq(P[kellen], kellen in josh))),josh in Si1) + nops(Se): Es,TV: end: #k=Number of ordered properties #BrunSieve(k,N) inputs the number of properties k #and a list N of weakly decrreasing pos. integers #N=[N1,N2,N3, Nr] with r<=k #outputs all subsets of {1, ..., k} written #in dec. order i1>i2>i3>.. such that #i1<=N1 and i2<=N2, ...ir<=Nr BrunSieve:=proc(k,L) end: