##################################################################### ##ResPar.txt: Save this file as ResPar.txt # ## To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read ResPar.txt # ##Then follow the instructions given there # ## # ##Written by Mingjia Yang and Doron Zeilberger, Rutgers University # ###################################################################### #Created: print(`Created: April 2019`): print(` This is ResPar.txt `): print(`It is one of the packages that accompany the article `): print(`Counting Restriced Partitions Bounded in a square using the Goulden-Jackson method`): print(`by Mingjia Yang and Doron Zeilberger`): print(`and also available from Zeilberger's website`): print(``): print(`Please report bugs to DoronZeil at gmail dot com `): print(``): print(`The most current version of this package and paper`): print(` are available from`): print(`http://sites.math.rutgers.edu/~zeilberg/ .`): print(`---------------------------------------`): print(`For a list FindRec procedures type ezraFindRec();, for help with`): print(`a specific procedure, type ezraFindRec(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the Supporting procedures type ezra1();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the MAIN procedures type ezra();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): with(combinat): ezra1:=proc() if args=NULL then print(` The supporting procedures are: Avem, Box, CheckGFx, CheckGFxE, GFxE, GJgf, IsBad, IsBad1, SubW1,SubW, WalksG1 `): print(``): else ezra(args): fi: end: ezra:=proc() if args=NULL then print(`The main procedures are: Av, GFx, Pars, ParsE, ParsEG, ParsG, SeqRP, Walks, WtoP `): print(` `): elif nops([args])=1 and op(1,[args])=Av then print(`Av(pa): inputs a partition pattern pa=[a1,a2,..., ak] indicating that there is a sub-partition of the form`): print(` [i,i-a1,i-a1-a2, ...,i-a1-...-ak] outputs the word in {0,1} that the corresponding word has to avoid. `): print(` Try: `): print(` Av([1,1]); `): elif nops([args])=1 and op(1,[args])=Avem then print(`Avem(pa,M,N): inputs a partition pattern, outputs the corresponding word to avoid, using `): print(`WalksG1(M,N,pa) as a data set. Try:`): print(`Avem([0],5,5);`): elif nops([args])=1 and op(1,[args])=Box then print(`Box(n): all the words in {0,1} of length n. Try:`): print(`Box(3);`): elif nops([args])=1 and op(1,[args])=CheckGFx then print(`CheckGFx(P,K): checks procedure GFx(P,x) against brute-force counting up to partitions into at most K parts and largest part<=K.`): print(`Try: `): print(`CheckGFx({[0],[1]},6);`): elif nops([args])=1 and op(1,[args])=CheckGFxE then print(`CheckGFxE(P,K): checks procedure GFxE(P,x) against brute-force counting up to partitions into at most K parts and largest part<=K.`): print(`Try: `): print(`CheckGFxE({[0],[1]},6);`): elif nops([args])=1 and op(1,[args])=GFx then print(`GFx(P,x): inputs a set of partition patterns P and a symbol x, outputs the rational function`): print(`in x[0],x[1], whose coefficeient of x[0]^m*x[1]^n is the number of integer partitions with`): print(` <= m parts and largest part<=n avoiding all the pattterns in P. Try:`): print(`GFx({[0],[1]},x);`): elif nops([args])=1 and op(1,[args])=GFxE then print(`GFxE(P,x): inputs a set of partition patterns P and a symbol x, outputs the rational function`): print(`in x[0],x[1], whose coefficeient of x[0]^m*x[1]^n is the number of integer partitions with`): print(` exactly m parts and largest part<=n avoiding all the pattterns in P. Try:`): print(`GFxE({[0],[1]},x);`): elif nops([args])=1 and op(1,[args])=GJgf then print(`GJgf(alphabet,MISTAKES,x) finds the generating function`): print(`F(x[l_1],x[l_2],...,x[l_r]), the weight enumerator of `): print(`of all words in the alphabet=[l_1,..,l_r], avodoiding the members of MISTAKES as consecutive subwords. The`): print(`the weight of a word is the product of x[its letters] times`): print(`the set of mistakes, MISTAKES should be such that if it contains`): print(` a word, it cannot contain any of its proper subwords`): print(`For example to get the g.f. for the set of words`): print(`in the alphabet {1,2,3}, avoiding 123,231,312, type:`): print(` GJgf({1,2,3},{[1,2,3],[2,3,1],[3,1,2]},x); `): elif nops([args])=1 and op(1,[args])=IsBad then print(`IsBad(p,S) given a partition p decides whether it contains at least one one of the patterns S. Try: `): print(`IsBad([4,3,2,2],{[0],[1]});` ): elif nops([args])=1 and op(1,[args])=IsBad1 then print(`IsBad1(p,pa) given a partition p decides whether it contains the pattern pa. Try: `): print(` IsBad1([3,3,2,2,2],[0,1]); `): elif nops([args])=1 and op(1,[args])=Pars then print(`Pars(M,N): the set of partitions with at most M parts and largest part N. Try:`): print(`Pars(4,4);`): elif nops([args])=1 and op(1,[args])=ParsE then print(`ParsE(M,N): the set of partitions with Exactly M parts and largest part N. Try:`): print(`ParsE(4,4);`): elif nops([args])=1 and op(1,[args])=ParsEG then print(`ParsEG(M,N,S): inputs non-nega. integers M and N, and a set of patterns S outputs the set partitions into EXACTLY M parts`): print(`with largest part at most N that avoid the patterns in S. Try:`): print(`ParsEG(5,5,{[0],[1]});`): elif nops([args])=1 and op(1,[args])=ParsG then print(`ParsG(M,N,S): inputs non-nega. integers M and N, and a set of patterns S outputs the set partitions into at most M parts`): print(`with largest part at most N that avoid the patterns in S. Try:`): print(`ParsG(5,5,{[0],[1]});`): elif nops([args])=1 and op(1,[args])=SeqRP then print(`SeqRP(P,K): Given a set of restrictions P, and a positive integer K, outputs the first K terms of the integer sequence`): print(`"number of partitions with largest part <=n and number of parts<=n avoiding the patterns in P. For example, to`): print(`get the first 20 terms of the sequence enumerating partitions with distict parts, try:`): print(`SeqRP({[0]},20);`): elif nops([args])=1 and op(1,[args])=SubW then print(`SubW(S,k): all the consecutive subwords (factors) of the words in S of length k. Try:`): print(`SubW({[a,b,c,d]},2);`): elif nops([args])=1 and op(1,[args])=SubW1 then print(`SubW1(w,k): all the consecutive subwords (factors) of the word w of length k. Try:`): print(`SubW1([a,b,c,d],2);`): elif nops([args])=1 and op(1,[args])=Walks then print(`Walks(M,N): the set of vectors with M 0's and N 1's. Try:`): print(`Walks(4,2);`): elif nops([args])=1 and op(1,[args])=WalksG1 then print(`WalksG1(M,N,pa): inputs non-nega. integers M and N, and a a pattern pa, outputs the set of words with M 0s and N 1s`): print(`which that their corresponding partition avodis the partition pattern pa. Try:`): print(`Walks1(5,5,[0]);`): elif nops([args])=1 and op(1,[args])=WtoP then print(`WtoP(w): inputs a word w in the alphabet {0,1} and outputs the corresponding partitions. Try: `): print(`WtoP([0,0,1,1]); `): else print(`There is no ezra for`,args): fi: end: #######From Findrec.txt ###################################################################### ## FindRec.txt: Save this file as FindRec.txt To use it, stay in the # ## same directory, get into Maple (by typing: maple ) # ## and then type: read FindRec.txt # ## Then follow the instructions given there # ## # ## Written by Doron Zeilberger, Rutgers University , # ## zeilberg@math.rutgers.edu. # ###################################################################### ezraFindRec:=proc() if args=NULL then print(`The Findrec procedures: are `): print(` findrec, Findrec, FindrecF,SeqFromRec `): print(): elif nargs=1 and args[1]=findrec then print(`findrec(f,DEGREE,ORDER,n,N): guesses a recurrence operator annihilating`): print(`the sequence f of degree DEGREE and order ORDER.`): print(`For example, try: findrec([seq(i,i=1..10)],0,2,n,N);`): elif nargs=1 and args[1]=Findrec then print(`Findrec(f,n,N,MaxC): Given a list f tries to find a linear recurrence equation with`): print(`poly coffs. ope(n,N), where n is the discrete variable, and N is the shift operator `): print(`of maximum DEGREE+ORDER<=MaxC`): print(`e.g. try Findrec([1,1,2,3,5,8,13,21,34,55,89],n,N,2);`): elif nargs=1 and args[1]=FindrecF then print(`FindrecF(f,n,N): Given a function f of a single variable tries to find a linear recurrence equation with`): print(`poly coffs. .g. try FindrecF(i->i!,n,N);`): elif nargs=1 and args[1]=SeqFromRec then print(`SeqFromRec(ope,n,N,Ini,K): Given the first L-1`): print(`terms of the sequence Ini=[f(1), ..., f(L-1)]`): print(`satisfied by the recurrence ope(n,N)f(n)=0`): print(`extends it to the first K values`): print(`For example, try:`): print(`SeqFromRec(N-n-1,n,N,[1],10);`): fi: end: ###Findrec #findrec(f,DEGREE,ORDER,n,N): guesses a recurrence operator annihilating #the sequence f of degree DEGREE and order ORDER #For example, try: findrec([seq(i,i=1..10)],0,2,n,N); findrecVerbose:=proc(f,DEGREE,ORDER,n,N) local ope,var,eq,i,j,n0,kv,var1,eq1,mu,a: if (1+DEGREE)*(1+ORDER)+3+ORDER>nops(f) then ERROR(`Insufficient data for a recurrence of order`,ORDER, `degree`,DEGREE): fi: ope:=0: var:={}: for i from 0 to ORDER do for j from 0 to DEGREE do ope:=ope+a[i,j]*n^j*N^i: var:=var union {a[i,j]}: od: od: eq:={}: for n0 from 1 to (1+DEGREE)*(1+ORDER)+2 do eq1:=0: for i from 0 to ORDER do eq1:=eq1+subs(n=n0,coeff(ope,N,i))*op(n0+i,f): od: eq:= eq union {eq1}: od: var1:=solve(eq,var): kv:={}: for i from 1 to nops(var1) do mu:=op(i,var1): if op(1,mu)=op(2,mu) then kv:= kv union {op(1,mu)}: fi: od: ope:=subs(var1,ope): if ope=0 then RETURN(FAIL): fi: ope:={seq(coeff(expand(ope),kv[i],1),i=1..nops(kv))} minus {0}: if nops(ope)>1 then print(`There is some slack, there are `, nops(ope)): print(ope): RETURN(Yafe(ope[1],N)[2]): elif nops(ope)=1 then RETURN(Yafe(ope[1],N)[2]): else RETURN(FAIL): fi: end: #findrec(f,DEGREE,ORDER,n,N): guesses a recurrence operator annihilating #the sequence f of degree DEGREE and order ORDER #For example, try: findrec([seq(i,i=1..10)],0,2,n,N); findrec:=proc(f,DEGREE,ORDER,n,N) local ope,var,eq,i,j,n0,kv,var1,eq1,mu,a: option remember: if not findrecEx(f,DEGREE,ORDER,ithprime(20)) then RETURN(FAIL): fi: if not findrecEx(f,DEGREE,ORDER,ithprime(40)) then RETURN(FAIL): fi: if not findrecEx(f,DEGREE,ORDER,ithprime(80)) then RETURN(FAIL): fi: if (1+DEGREE)*(1+ORDER)+5+ORDER>nops(f) then ERROR(`Insufficient data for a recurrence of order`,ORDER, `degree`,DEGREE): fi: ope:=0: var:={}: for i from 0 to ORDER do for j from 0 to DEGREE do ope:=ope+a[i,j]*n^j*N^i: var:=var union {a[i,j]}: od: od: eq:={}: for n0 from 1 to (1+DEGREE)*(1+ORDER)+4 do eq1:=0: for i from 0 to ORDER do eq1:=eq1+subs(n=n0,coeff(ope,N,i))*op(n0+i,f): od: eq:= eq union {eq1}: od: var1:=solve(eq,var): kv:={}: for i from 1 to nops(var1) do mu:=op(i,var1): if op(1,mu)=op(2,mu) then kv:= kv union {op(1,mu)}: fi: od: ope:=subs(var1,ope): if ope=0 then RETURN(FAIL): fi: ope:={seq(coeff(expand(ope),kv[i],1),i=1..nops(kv))} minus {0}: if nops(ope)>1 then RETURN(Yafe(ope[1],N)[2]): elif nops(ope)=1 then RETURN(Yafe(ope[1],N)[2]): else RETURN(FAIL): fi: end: Yafe:=proc(ope,N) local i,ope1,coe1,L: if ope=0 then RETURN(1,0): fi: ope1:=expand(ope): L:=degree(ope1,N): coe1:=coeff(ope1,N,L): ope1:=normal(ope1/coe1): ope1:=normal(ope1): ope1:= convert( [seq(factor(coeff(ope1,N,i))*N^i,i=ldegree(ope1,N)..degree(ope1,N))],`+`): factor(coe1),ope1: end: #Findrec(f,n,N,MaxC): Given a list f tries to find a linear recurrence equation with #poly coffs. #of maximum DEGREE+ORDER<=MaxC #e.g. try Findrec([1,1,2,3,5,8,13,21,34,55,89],n,N,2); Findrec:=proc(f,n,N,MaxC) local DEGREE, ORDER,ope,L: for L from 0 to MaxC do for ORDER from 0 to L do DEGREE:=L-ORDER: if (2+DEGREE)*(1+ORDER)+4>=nops(f) then print(`Insufficient data for degree`, DEGREE, `and order `,ORDER): RETURN(FAIL): fi: ope:=findrec([op(1..(2+DEGREE)*(1+ORDER)+4,f)],DEGREE,ORDER,n,N): if ope<>FAIL then RETURN(ope): fi: od: od: FAIL: end: #SeqFromRec(ope,n,N,Ini,K): Given the first L-1 #terms of the sequence Ini=[f(1), ..., f(L-1)] #satisfied by the recurrence ope(n,N)f(n)=0 #extends it to the first K values SeqFromRec:=proc(ope,n,N,Ini,K) local ope1,gu,L,n1,j1: ope1:=Yafe(ope,N)[2]: L:=degree(ope1,N): if nops(Ini)<>L then ERROR(`Ini should be of length`, L): fi: ope1:=expand(subs(n=n-L,ope1)/N^L): gu:=Ini: for n1 from nops(Ini)+1 to K do gu:=[op(gu), -add(gu[nops(gu)+1-j1]*subs(n=n1,coeff(ope1,N,-j1)), j1=1..L)]: od: gu: end: #end Findrec with(linalg): #findrecEx(f,DEGREE,ORDER,m1): Explores whether thre #is a good chance that there is a recurrence of degree DEGREE #and order ORDER, using the prime m1 #For example, try: findrecEx([seq(i,i=1..10)],0,2,n,N,1003); findrecEx:=proc(f,DEGREE,ORDER,m1) local ope,var,eq,i,j,n0,eq1,a,A1, D1,E1,Eq,Var,f1,n,N: option remember: f1:=f mod m1: if (1+DEGREE)*(1+ORDER)+5+ORDER>nops(f) then ERROR(`Insufficient data for a recurrence of order`,ORDER, `degree`,DEGREE): fi: ope:=0: var:={}: for i from 0 to ORDER do for j from 0 to DEGREE do ope:=ope+a[i,j]*n^j*N^i: var:=var union {a[i,j]}: od: od: eq:={}: for n0 from 1 to (1+DEGREE)*(1+ORDER)+4 do eq1:=0: for i from 0 to ORDER do eq1:=eq1+subs(n=n0,coeff(ope,N,i))*op(n0+i,f1) mod m1: od: eq:= eq union {eq1}: od: Eq:= convert(eq,list): Var:= convert(var,list): D1:=nops(Var): E1:=nops(Eq): if E10 then RETURN(false): fi: if E1-D1>=1 then for j from 1 to nops(Var) do A1[D1,j]:=coeff(Eq[D1+1],Var[j]): od: if det(A1) mod m1 <>0 then RETURN(false): fi: fi: if E1-D1>=2 then for j from 1 to nops(Var) do A1[D1,j]:=coeff(Eq[D1+2],Var[j]): od: if det(A1) mod m1 <>0 then RETURN(false): fi: fi: true: end: #######End From Findrec.txt ####### From David_Ian #issubword(u,v) returns 1 if v is a subword of u, otherwise 0 issubword:=proc(u,v) local i,j: for i from 1 to nops(u) do for j from i to nops(u) while (j-i+1<=nops(v) and op(j,u)=op(j-i+1,v)) do : od: if j-i=nops(v) then RETURN(1): fi: od: 0: end: #superflous(B,w) given a set of bad words, and one of its #members, finds whether it is superflous, #that is, whether it is a factor of another one, and deletes the larger one superflous:=proc(B,w) local i,v: if not type(B,set) or not type(w,list) then ERROR(`Bad input`): fi: if not member(w,B) then ERROR(`Second argument must belong to first arg.`): fi: for i from 1 to nops(B) do v:=op(i,B): if v<>w and issubword(w,v)=1 then RETURN(1): fi: od: 0: end: hakten:=proc(B) local w,i: for i from 1 to nops(B) do w:=op(i,B): if superflous(B,w)=1 then RETURN(B minus {w}): fi: od: B: end: #Hakten(B) removes all superflous words Hakten:=proc(B) local B1,B2: B1:=B: B2:=hakten(B1): while B1<>B2 do B1:=B2: B2:=hakten(B2): od: B2: end: #A program to find the gen. fun. of all words in an alphabet #given in a list alphabet, according to the number of mistakes #where the list of mistakes is MISTAKES, a list of lists #where each element is given in as a list. It is based on #Goulden-Jackson-Zeilberger, see Stanley's book, #Enumerative combinatorics I, ex. 14.a in #chapter 4, pp. 266-267 #overlap is a procedure that given two words u and v #computes the weight-enumerator of all v\suffix(u), #for all suffixes of u that are prefixes of v. overlap:=proc(u,v,x) local i,j,k,lu,gug: lu:=0: for i from 2 to nops(u) do for j from i to nops(u) while (j-i+1<=nops(v) and op(j,u)=op(j-i+1,v)) do : od: if j-i=nops(v) and u<>v then ERROR(v,`is a subword of`,u,`illegal input`): fi: if j=nops(u)+1 and (i>1 or j>2) then gug:=1: for k from j-i+1 to nops(v) do gug:=gug*x[op(k,v)]: od: lu:=lu+gug: fi: od: lu: end: #findeq sets up the equ C[v]= x[v]+t*Sum_u overlap(u,v,x) *C[u] findeq:=proc(v,MISTAKES,C,t,x) local eq,i,u: eq:=t: for i from 1 to nops(v) do eq:=eq*x[op(i,v)]: od: for i from 1 to nops(MISTAKES) do u:=op(i,MISTAKES): eq:=eq+t*overlap(u,v,x)*C[op(u)]: od: C[op(v)]-eq=0: end: GJgf0:=proc(alphabet,MISTAKES,x,t) local v,eq, var,i,lu,C: if Hakten(MISTAKES)<>MISTAKES then ERROR(`The set of mistakes is not minimal, use another package`): fi: eq:={}: var:={}: for i from 1 to nops(MISTAKES) do v:=op(i,MISTAKES): eq:= eq union {findeq(v,MISTAKES,C,t,x)}: var:=var union {C[op(v)]}: od: var:=solve(eq,var): lu:=1: for i from 1 to nops(alphabet) do lu:=lu-x[op(i,alphabet)]: od: for i from 1 to nops(MISTAKES) do v:=op(i,MISTAKES): lu:=lu-subs(var,C[op(v)]): od: lu:=normal(1/lu): subs(t=t-1,lu): end: GJgf:=proc(alphabet,MISTAKES,x) local t: factor(subs(t=0,GJgf0(alphabet,MISTAKES,x,t))): end: ####### End from David_Ian #Walks(M,N): the set of walks from [0,0] to [M,N]. Try: #Walks(4,4); Walks:=proc(M,N) local gu1,gu2,g: option remember: if M<0 or N<0 then RETURN({}): fi: if M=0 and N=0 then RETURN({[]}): fi: gu1:=Walks(M-1,N): gu2:=Walks(M,N-1): {seq([0,op(g)],g in gu1)} union {seq([1,op(g)],g in gu2)} : end: #WtoP(w): inputs a word w in the alphabet {0,1} and outputs the corresponding partitions. Try #WtoP([0,0,1,1]); WtoP:=proc(w) local m,x,i,gu : option remember: if w=[] then RETURN([]): fi: if w=[1$(nops(w))] or w=[0$(nops(w))] then RETURN([]): fi: m:=coeff(add(x[w[i]],i=1..nops(w)),x[0],1); gu:=WtoP([op(1..nops(w)-1,w)]): if w[-1]=1 then [m,op(gu)]: else gu: fi: end: #Pars(M,N): the set of partitions into at most N parts with largest part <=M Pars:=proc(M,N) local gu,gu1: gu:=Walks(M,N): {seq(WtoP(gu1),gu1 in gu)}: end: #IsBad1(p,pa) given a partition p decides whether it contains the pattern pa. Try #IsBad1 IsBad1:=proc(p,pa) local i,i1,gu: if nops(p)=0 )then print(`bad input`): RETURN(FAIL): fi: k:=nops(pa): [1,seq(op([0$pa[k+1-i],1]),i=1..k)]: end: #GFxE(P,x): inputs a set of partition patterns P and a symbol x, outputs the rational function #in x[0],x[1], whose coefficeient of x[0]^m*x[1]^n is the number of integer partitions with #exactly m parts and largest part<=n avoiding all the pattterns in P. Try #GFxE({[0],[1]},x); GFxE:=proc(P,x) local pa: x[0]*GJgf({0,1},{seq(Av(pa),pa in P)},x): end: #CheckGFxE(P,K): checks procedure GFxE(P,x) against brute-force counting up to partitions into at most K parts and largest part<=K. #Try: #CheckGFxE({[0],[1]},6); CheckGFxE:=proc(P,K) local gu,x,L,gu1,i,j,M: gu:=GFxE(P,x): L:=[]: gu:=taylor(gu,x[0],K+1): for i from 1 to K do gu1:=coeff(gu,x[0],i): gu1:=taylor(gu1,x[1],K+1): L:=[op(L),[seq(coeff(gu1,x[1],j),j=1..K)]]: od: L: M:=[seq([seq(nops(ParsEG(i,j,P)),j=1..K)],i=1..K)]: evalb(L=M): end: #ParsE(M,N): the set of partitions into exactly N parts with largest part <=M ParsE:=proc(M,N) local gu,gu1: if M=1 then RETURN({[1$N]}): fi: gu:=Walks(M-1,N): gu:={seq([0,op(gu1)],gu1 in gu)}: {seq(WtoP(gu1),gu1 in gu)}: end: #ParsEG(M,N,S): inputs non-nega. integers M and N, and a set of patterns S outputs the set partitions into EXACTLY N parts #with largest part at most M that avoid the patterns in S. Try: #ParsEG(5,5,{[0],[1]}); ParsEG:=proc(M,N,S) local mu,gu,mu1: gu:={}: mu:=ParsE(M,N): for mu1 in mu do if not IsBad(mu1,S) then gu:=gu union {mu1}: fi: od: gu: end: #GFx(P,x): inputs a set of partition patterns P and a symbol x, outputs the rational function #in x[0],x[1], whose coefficeient of x[0]^m*x[1]^n is the number of integer partitions with #<=m parts and largest part<=n avoiding all the pattterns in P. Try #GFx({[0],[1]},x); GFx:=proc(P,x) GFxE(P,x)/(1-x[1]): end: #CheckGFx(P,K): checks procedure GFx(P,x) against brute-force counting up to partitions into at most K parts and largest part<=K. #Try: #CheckGFx({[0],[1]},6); CheckGFx:=proc(P,K) local gu,x,L,gu1,i,j,M: gu:=GFx(P,x): L:=[]: gu:=taylor(gu,x[0],K+1): for i from 1 to K do gu1:=coeff(gu,x[0],i): gu1:=taylor(gu1,x[1],K+1): L:=[op(L),[seq(coeff(gu1,x[1],j),j=1..K)]]: od: L: M:=[seq([seq(nops(ParsG(i,j,P)),j=1..K)],i=1..K)]: L,M: end: #SeqRP(P,K): Given a set of restrictions P, and a positive integer K, outputs the first K terms of the integer sequence #"number of partitions with largest part <=n and number of parts<=n avoiding the patterns in P. For example, to #get the first 20 terms of the sequence enumerating partitions with distict parts, try: #SeqRP({[0]},20); SeqRP:=proc(P,K) local gu,gu1,x,L,i: gu:=GFx(P,x): L:=[]: gu:=taylor(gu,x[0],K+1): for i from 1 to K do gu1:=coeff(gu,x[0],i): gu1:=taylor(gu1,x[1],K+1): L:=[op(L),coeff(gu1,x[1],i)]: od: L: end: