Help:=proc(): print(`Adn(d,n), IsBad(d,S),adnS(d,n)`): print(`NdnS(d,n) `): end: #Dedicated to Endre Szemeredi on the occaison of the Abel Prize 2012 with(combinat): #Let a_d(n) be the largest size of a subset of {1, ...,n} #avoiding arthmetical pogressions of length d #(Szemeredi's famous theorem says that a_d(n)/n->0) #d=3 is it the already deep Roth theorem who proved that #a_3(n)/n<=C/log(log(n)) #Adn(d,n): Inputs positive integers d and n and outputs #the set of all subsets of {1, ...,n} that DO NOT have #an arithmetical progression of length d Adn:=proc(d,n) local S,s1,i,T: S:=powerset(n): T:={}: for s1 in S do if not IsBad(d,s1) then #T:=T union {s1}: T:={op(T), s1}: fi: od: T: end: #IsBad(d,S): Does the set of pos. integers S contain #an AP of length d? IsBad:=proc(d,S) local m,S1,dif,PTM,j: option remember: if nops(S)