###################################################################### ##RPpos.txt: Save this file as RPpos.txt # ## To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read RPpos.txt # ##Then follow the instructions given there # ## # ##Written by Mingjia Yang and Doron Zeilberger, Rutgers University # #DoronZeil at gmail dot com # ###################################################################### #Created: May 2019 print(`Created: May 2019`): print(` This is RPpos.txt `): print(`It is one of the packages that accompany the article `): print(` Systematic Counting of Restricted Partitions`): 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(`For a list of the qFindRec procedures type ezraF();, for help with`): print(`a specific procedure, type ezraF(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the Story procedures type ezraS();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the Guessing procedures type ezraG();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the Cluster procedures type ezraC();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the Scheme procedures type ezraSc();, for help with`): print(`a specific procedure, type ezra(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): ezraS:=proc() if args=NULL then print(` The Story procedures are: Mamar11, Mamar111`): print(``): else ezra(args): fi: end: ezraSc:=proc() if args=NULL then print(` The Schemes procedures are: ApplySc, ApplySc1, CheckGFseq, MakeSc, Mish, Mish1, Yeled, Yeled1 `): print(``): else ezra(args): fi: end: ezraG:=proc() if args=NULL then print(` The Guessing procedures are: GuessPq, GuessPq1 `): print(``): else ezra(args): fi: end: ezraC:=proc() if args=NULL then print(` The Cluster procedures are: Amn, C, C1, IsComp `): print(``): else ezra(args): fi: end: ezra1:=proc() if args=NULL then print(` The supporting procedures are: Child, Child1, DiagSeqB, Fmn1, FmnB, IsBadP, IsBadP1, GenF1a, GPmnB, GuP, Pmn, xmn, xmn1,xn, xnB, xnSeqB `): print(``): else ezra(args): fi: end: ezra:=proc() if args=NULL then print(`The main procedures are: DiagSeq, Fmn, GFseq, GPmn, SeqGenF1, xnSeq, xnSeq_mod, GxnSeq, GP `): print(` `): elif nops([args])=1 and op(1,[args])=xnSeq_mod then print(`xnSeq_mod(N,A,M,r): the first N terms of the sequence "number of `): print(` partitions of n avoiding the set of patterns A, and with parts mod r in M (that is, the remainders are in the set M)". Try: `): print(`xnSeq_mod(50,{},{1,4},5);`): print(`xnSeq_mod(50,{},{2,3},5);`): print(`xnSeq_mod(50,{[0]},{0,1,3,5},6); `): elif nops([args])=1 and op(1,[args])=GxnSeq then print(`GxnSeq(N,A,Mod,B,IC): the first N terms of the sequence "number of `): print(` partitions of n avoiding the partition patterns A globally,`): print(`patterns in Mod locally (according to mod conditions),and patterns in B at the beginning,`): print(` in addition to having no sub-partitions in IC (initial conditions)". Try: `): print(`GxnSeq(50,{[0],[1]},[],{},[]);`): print(`GxnSeq(50,{[0],[1]},[],{},[[1]]);`): print(`GxnSeq(50,{[0],[1]},[{[2]},{[3]},{[2],[3]}],{},[[2]]);`): print(`For the Schur 1926 sequence, type`): print(`GxnSeq(50,{[0],[1],[2]},[{[3]},{},{}],{},[]);`): print(`For the Kanade-Russell sequence, mentioned in the paper, type`): print(`GxnSeq(50,{[1]},[{[0,0],[0,3],[2,0],[0,2]},{[0],[3,0]}],{},[[2,2]]);`): elif nops([args])=1 and op(1,[args])=GP then print(`GP(m,n,A,Mod,B,IC): the number of `): print(` partitions of n with the largest part m, avoiding the partition patterns A globally,`): print(`patterns in Mod locally (according to mod conditions),and patterns in B at the beginning,`): print(` in addition to having no sub-partitions in IC (initial conditions)". Try: `): print(`GP(8,50,{[0],[1]},[{[2]},{[3]},{[2],[3]}],{},[[2]])`): elif nops([args])=1 and op(1,[args])=Amn then print(`Amn(m,n,S,q): the weigt-enumerator of the`): print(`set of partitions with largest part=m and number of parts=n avoiding the partition patterns S, using the Cluster method. Try`): print(`Amn(5,5,{[0,0]},q);`): elif nops([args])=1 and op(1,[args])=ApplySc then print(`ApplySc(Sc,q,z,L): given a scheme Sc, variables q and z, and a list L, applies the scheme to L`): print(`Try: `): print(`ApplySc({[1/(1-q*z),1]},q,z,[1/(1-q*z)]);`): elif nops([args])=1 and op(1,[args])=ApplySc1 then print(`ApplySc1(L,S1,q,z): inputs a current list,L, or rational functions L, and a set S1 reprending an operator`): print(`applies S1 to L. Try:`): print(`ApplySc1([q*z,1/(1-q*z)], {[q,1],[q/(1-q*z),2]},q,z);`): elif nops([args])=1 and op(1,[args])=C then print(`C(m,m1,l,w,S,q): the weight-enumerator of the set of clusters that start at m, end at m1, have length l, depth w, with set of forbiddedn patterns S `): print(`C(5,5,3,1,{[0]},q);`): elif nops([args])=1 and op(1,[args])=C1 then print(`C1(m,m1,l,w,S,s,q): the weight-enumerator of the set of clusters that start at m, end at m1, have length l, depth w, with set of forbiddedn patterns S that start with s (a member of S)`): prnt(`Try: `): print(`C1(5,5,3,1,{[0]},[0],q);`): elif nops([args])=1 and op(1,[args])=CheckGFseq then print(`CheckGFseq(S,N): Checks GFseq(S,q,z,N): . Try:`): print(`CheckGFseq({[0,0,0]},10);`): elif nops([args])=1 and op(1,[args])=Child then print(`Child(m,m1,S): the set of children of the set of patterns S. Try:`): print(`Child(5,4,{[0],[1,2],[1,3],[2]});`): elif nops([args])=1 and op(1,[args])=Child1 then print(`Child1(m,m1,p): given positive integers m and m1 such that m>=m1 outputs the implied pattern at the beginning obtained by deleting m`): print(`in partition whose largest part is m, and second-largest part is m1, where the original partition aviods p at the beginning. Try:`): print(`Child1(5,3,[2,1]);`): elif nops([args])=1 and op(1,[args])=DiagSeq then print(`DiagSeq(P,q,N): Given a set of patterns, outputs the first N terms of the sequence of`): print(`weight-enumerators of the set of partitions with largest part=i and number of parts=i. Try:`): print(`DiagSeq({[0,0,0]},q,30);`): elif nops([args])=1 and op(1,[args])=DiagSeqB then print(`DiagSeqB(P,q,N): Like DiagSeq(P,q,N), but by brute force. For checking purposes only. Try: `): print(`DiagSeqB({[0,0,0]},q,30);`): elif nops([args])=1 and op(1,[args])=Fmn then print(`Fmn(m,n,S,q): the weigt-enumerator of the`): print(`set of partitions with largest part=m and number of parts=n avoiding the partition patterns S. Try: `): print(`Fmn(5,5,{[0,0]},q); `): elif nops([args])=1 and op(1,[args])=Fmn1 then print(`Fmn1(m,n,S,S1,q): the weigt-enumerator of the`): print(`set of partitions with largest part=m and number of parts=n avoiding the partition patterns S and in addition S1 at the beginning. Try: `): print(`Fmn1(5,5,{[0,0]},{[0]}); `): elif nops([args])=1 and op(1,[args])=FmnB then print(`FmnB(m,n,S,q): the weigt-enumerator of the`): print(`set of partitions with largest part=m and number of parts=n avoiding the partition patterns S. By brute force. FOR CHECKING ONLY. Try: `): print(`FmnB(5,5,{[0,0]},q); `): elif nops([args])=1 and op(1,[args])=GenF1a then print(`GenF1a(m,S,q,T): Inputs a positive integer,m, a set of restrictions, S, and a variable name q, and a buffer T, a fairly large pos. integer.`): print(` Outputs`): print(`the generating function of the sequence: number of partitions of n with largest m obeying the restictions of`): print(`S. For example, try:`): print(`GenF1a(4,{[0,0],[0,1]},q,10); `): elif nops([args])=1 and op(1,[args])=GFseq then print(`GFseq(S,q,z,N): Inputs a list of restrictions S, variables q and z, and a positive integer N outputs`): print(`the list of length N whose n-th term is the rational function in z and q whose coefficient of z^m is`): print(`the weight-enumerator of the set of partitions with exactly n parts, largest part m, and obeying the`): print(`restrictions of S. Try:`): print(`GFseq({[0]},q,z,6);`): elif nops([args])=1 and op(1,[args])=GPmn1 then print(`GPmn1(m,n,S,S1): the set of partitions with largest part=m and number of parts=n avoiding the partition patterns S `): print(`and in addition S1 at the beginning. Try`): print(`GPmn1(5,5,{[0,0]},{[0]});`): elif nops([args])=1 and op(1,[args])=GPmn then print(`GPmn(m,n,S): the set of partitions with largest part=m and number of parts=n avoiding the partition patterns S. Try: `): print(`GPmn(5,3,{[0,0]});`): elif nops([args])=1 and op(1,[args])=GPmnB then print(`GPmnB(m,n,S): the set of partitions with largest part=m and number of parts=n avoiding the partition patterns S. Using BRUTE FORCE`): print(`(only for checking purposes). Try: `): print(`GPmnB(5,3,{[0,0]});`): elif nops([args])=1 and op(1,[args])=GuessPq then print(`GuessPq(L,q,Q,d): guesses a polynomial of degree<=nops(L)-3 in Q=q^n P(q^n) (with coefficients that are rational functions in q)`): print(`such that Pol(q^n)=L[n]. If none exists, it returns FAIL. Try:`): print(`GuessPq([seq(q^(2*i)+q*q^i+q^2,i=1..5)],q,Q);`): elif nops([args])=1 and op(1,[args])=GuessPq1 then print(`GuessPq1(L,q,Q,d): guesses a polynomial of degree d in Q=q^n P(q^n) (with coefficients that are rational functions in q)`): print(`such that Pol(q^n)=L[n]. Try:`): print(`GuessPq1([seq(q^(2*i)+q*q^i+q^2,i=1..5)],q,Q,2);`): elif nops([args])=1 and op(1,[args])=GuP then print(`GuP(L,q): inputs a list of integers L and outputs, if possible the list [a1,b1],...[ak,bk] that agrees with it`): print(`such that the g.f. is (1-q^a1)^b1*(1-q^a2)^b2*....`): print(`Warning: You always get an answer! If the length of the output is close to the input and the exponents are high it is`): print(`probably.nonsense, i.e. does not generalize. Try:`): print(`GuP(xnSeq(20,{[0],[1]}),q); `): elif nops([args])=1 and op(1,[args])=IsBadP1 then print(`IsBadP(L,S): inputs an integer partition L, and a set of partition "patterns" S, decides whether L contains any member of S. Try:`): print(`IsBadP([5,4,3],{[1,1],[0]});`): elif nops([args])=1 and op(1,[args])=IsBadP1 then print(`IsBadP1(L,p): inputs an integer partition L, and a partition "pattern" p, decides whether L contains p. Try:`): print(`IsBadP1([5,4,3],[1,1]);`): elif nops([args])=1 and op(1,[args])=IsComp then print(`IsComp(s,k,s1): In a cluster, can pattern s1 come after pattern s, starting at the k-th place of s. Try`): print(`IsComp([0],2,[0]);`): elif nops([args])=1 and op(1,[args])=MakeSc then print(`MakeSc(S,q,z): inputs a set of restrictions, outputs a scheme for computing the sequence of generating functions `): print(`whose n-th entry is the rational function in z whose coefficient of z^m is the weight-enumerator of`): print(` the weight-enumerator of the set of partitions with n parts, largest part m, that avoid the patterns in S. `): print(` Try: `): print(` MakeSc({[0,0],[1,1]},q,z); `): elif nops([args])=1 and op(1,[args])=Mamar11 then print(`Mamar11(K,L,s,M): Inputs a positive integer K, another positive integer L, yet another positive integer s and a fairly large positive integer M`): print(`outputs the first M terms from n=1 to n=M of the eunumerating sequence for partitions of n that avoid sets of patterns containing`): print(`s1 restrictions of the form [a1,a2,.., al], with l<=L with 0<=a1, ...,al<=K and s<=s1. Try:`): print(`Mamar11(2,2,2,100);`): elif nops([args])=1 and op(1,[args])=Mamar111 then print(`Mamar111(K,L,s,M): Inputs a positive integer K, another positive integer L, yet another positive integer s and a fairly large positive integer M`): print(`outputs the first M terms from n=1 to n=M of the eunumerating sequence for partitions of n that avoid sets of patterns containing`): print(`s restrictions of the form [a1,a2,.., aL] with 0<=a1, ...,aL<=K. Try:`): print(`Mamar111(2,2,2,100);`): elif nops([args])=1 and op(1,[args])=Mish then print(`Mish(S,S1,q,Q,z): Inputs a set of global restrictions S, and a set of starting restrictions, S1, and variable symbols`): print(`q and z, and shift operator Q, for indexing, where Q[S] means that A[S] should be replaced by Q(A[S](qz))`): print(`Mish({[0,0,0]},{[0,0]},q,Q,z);`): elif nops([args])=1 and op(1,[args])=Mish1 then print(`Mish1(S,S1,q,z): Like Mish(S,S1,q,Q,z) but with more compact format, the Q is implied. Try: `): print(`Mish1({[0,0,0]},{[0,0]},q,z);`): elif nops([args])=1 and op(1,[args])=Pmn then print(`Pmn(m,n): the set of partitions with largest part=m and number of parts=n. Try: `): print(` Pmn(4,2); `): elif nops([args])=1 and op(1,[args])=SeqGenF1 then print(`SeqGenF1(M,S,q,T): Inputs a positive integer,m, a set of restrictions, S, and a variable name q.`): print(`It also inputs a buffer variable T.`): print(` Outputs`): print(`The list of generating functions of the sequence: number of partitions of n with largest m obeying the restictions of`): print(`S, for m from 1 to M. For example, try:`): print(`SeqGenF1(4,{[0,0],[0,1]},q,10);`): elif nops([args])=1 and op(1,[args])=Yeled then print(`Yeled(d,S): The child of the set of patterns D when the difference between the largest and second-largest part is d.`): print(`Try: `): print(`Yeled(2,{[2,1]}); `): elif nops([args])=1 and op(1,[args])=Yeled1 then print(`Yeled1(d,p): The child of the pattern p when the difference between the largest and second-largest part is d.`): print(`Try: `): print(`Yeled1(2,[2,1]); `): elif nops([args])=1 and op(1,[args])=xmn then print(`xmn(m,n,S): the number of `): print(` partitions of n with largest part=m avoiding the partition patterns S. Try: `): print(`xmn(10,5,{[0,0]}); `): elif nops([args])=1 and op(1,[args])=xn then print(`xn(n,S): the number of `): print(` partitions of n avoiding the set of patterns S. Try: `): print(`xn(10,{[0,0]}); `): elif nops([args])=1 and op(1,[args])=xnB then print(`xnB(m,n,S): the number of `): print(` partitions of n avoiding the set of patterns S, by brute force, for checking purposes only. Try: `): print(`xnB(10,{[0,0]}); `): elif nops([args])=1 and op(1,[args])=xnSeq then print(`xnSeq(N,S): the first N terms of the sequence "number of `): print(` partitions of n avoiding the set of patterns S". Try: `): print(`xnSeq(10,{[0,0]}); `): elif nops([args])=1 and op(1,[args])=xnSeqB then print(`xnSeqB(N,S): the first N terms of the sequence "number of `): print(` partitions of n avoiding the set of patterns S". By brute force. Only for checking. Try: `): print(`xnSeqB(10,{[0,0]}); `): else print(`There is no ezra for`,args): fi: end: ##########From qFindRec.txt ###################################################################### ##qFindRec.txt: Save this file as qFindRec.txt # ## To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read qFindRec.txt # ##Then follow the instructions given there # ## # ##Written by Doron Zeilberger, Rutgers University , # #DoronZeil at gmail dot com # ###################################################################### #Created: March , 2017 with(combinat): ezraF1:=proc() if args=NULL then print(` The supporting procedures are: qbin, qfac, qFR1 `): print(``): else ezra(args): fi: end: ezraF:=proc() if args=NULL then print(`The main procedures are: qFR, SumSeq, SumSeqBi `): print(` `): elif nops([args])=1 and op(1,[args])=qbin then print(`qbin(a1,b1,q): the q-binomial coefficient for numeric a1 and b1. Try:`): print(` qbin(6,3,q); `): elif nops([args])=1 and op(1,[args])=qfac then print(`qfac(n1,q): (1-q)*...*(1-q^n1)/(1-q)^n1. Try:`): print(`qfac(5,q);`): elif nops([args])=1 and op(1,[args])=qFR then print(`qFR(L,q,n,N,C): inputs a list L of polynomials (or rational functions) in q, and non-negative integers`): print(` tries to find an operator ope(q,q^n,N) of degree deg1 and order ord1 such that deg1+ord1<=C`): print(`annihilating L. or returns FAIL. L must be at least of length (C+3)^2/4+4. Try`): print(`qFR([seq(q^(i1^2),i1=1..15)],q,n,N,3);`): elif nops([args])=1 and op(1,[args])=qFR1 then print(`qFR1(L,deg1,ord1,q,n,N): inputs a list L of polynomials (or rational functions) in q, and non-negative integers`): print(`deg1 and ord1 tries to find an operator ope(q,q^n,N) annihilating L. Try:`): print(` qFR1([seq(q^(i1^2),i1=1..20)],2,1,q,n,N); `): elif nops([args])=1 and op(1,[args])=SumSeq then print(`SumSeq(F,N0): inputs a summand F phrased in terms of the qbinomial coefficients (called qbin), or q-factorial (called qfac), that`): print(`depends on k and n, outputs the first N0 terms (starting at n=1) of the Sum(F,k=0..n). Try: `): print(`SumSeq((n,k)->q^(k*(k-1)/2)*qbin(n,k,q),10); `): print(`SumSeq((n,k)->q^(k^2)/qfac(k,q)/qfac(n-k,q),10); `): elif nops([args])=1 and op(1,[args])=SumSeqBi then print(`SumSeqBi(F,N0): inputs a summand F phrased in terms of the qbinomial coefficients (called qbin) or q-factorial (called qfac) that`): print(`depends on k and n, outputs the first N0 terms (starting at n=1) of the Sum(F,k=-n..n). Try: `): print(`SumSeqBi((n,k)->(-1)^k*q^((5*k^2+k)/2)/qfac(n-k,q)/qfac(n+k,q),10); `): else print(`There is no ezra for`,args): fi: end: #qFR1(L,deg1,ord1,q,n,N): inputs a list L of polynomials (or rational functions) in q, and non-negative integers #deg1 and ord1 tries to find an operator ope(q,q^n,N) annihilating L. Try #qFR1([seq(q^(i1^2),i1=1..10)],1,2,q,n,N); qFR1:=proc(L,deg1,ord1,q,n,N) local a,ope,var,i,j,eq,eq1,hal,i1,n1,lu,hal1,lu1,Q: if nops(L)<= (ord1+1)*(deg1+2)+3 then print(`The list is too short, it has `, nops(L), `terms but it should have at least`, (ord1+1)*(deg1+2)+3, `terms .` ): RETURN(FAIL): fi: ope:=add(add(a[i,j]*Q^i*N^j,i=0..deg1),j=0..ord1): var:={seq(seq(a[i,j],i=0..deg1),j=0..ord1)}: eq:=expand({seq(add(subs(Q=q^n1,coeff(ope,N,i1))*L[n1+i1],i1=0..ord1),n1=1..(ord1+1)*(deg1+1)+3 ) }): eq1:=subs(q=2,eq): hal:=solve(eq1,var): if expand(subs(hal,ope))=0 then RETURN(FAIL): else print(`There is hope for a recurrence of order`, ord1, `and degree`, deg1): fi: hal:=solve(eq,var): if expand(subs(hal,ope))=0 then RETURN(FAIL): fi: lu:={}: for hal1 in hal do if op(1,hal1)=op(2,hal1) then lu:=lu union {op(1,hal1)}: fi: od: if nops(lu)>1 then print(`Non unique solution`): RETURN({seq(coeff(ope,lu1,1),lu1 in lu)}): fi: ope:=subs(hal,ope): ope:=subs(lu[1]=1,ope): if normal(expand({seq(add(subs(Q=q^n1,coeff(ope,N,i1))*L[n1+i1],i1=0..ord1),n1=(ord1+1)*(deg1+1)+3..nops(L)-ord1 ) }))<>{0} then print(ope, `did not work out`): RETURN(FAIL): fi: ope:=add(factor(coeff(ope,N,i1))*N^i1,i1=0..ord1): subs(Q=q^n,ope): end: #qFR(L,q,n,N,C): inputs a list L of polynomials (or rational functions) in q, and non-negative integers # tries to find an operator ope(q,q^n,N) of degree deg1 and order ord1 such that deg1+ord1<=C #annihilating L. or returns FAIL. L must be at least of length (C+3)^2/4+4. Try #qFR([seq(q^(i1^2),i1=1..10)],q,n,N,3); qFR:=proc(L,q,n,N,C) local ope, ord1,deg1,C1: if nops(L)< (C+3)^2/4+4 then print(`L must be at least of length`, trunc((C+3)^2/4+4)): RETURN(FAIL): fi: for C1 from 1 to C do for ord1 from 1 to C1 do deg1:=C1-ord1: ope:=qFR1(L,deg1,ord1,q,n,N): if ope<>FAIL then RETURN(ope): fi: od: od: FAIL: end: #qfac(n1,q): (1-q)*...*(1-q^n1)/(1-q)^n1. Try: #qfac(5,q); qfac:=proc(n1,q) local i: expand(mul(1-q^i,i=1..n1)): end: #qbin(a1,b1,q): the q-binomial coefficient for numeric a1 and b1. try: #qbin(6,3,q); qbin:=proc(a1,b1,q) local i: expand(normal(mul(1-q^(a1-i+1),i=1..b1)/mul(1-q^i,i=1..b1))): end: #SumSeq(F,N0): inputs a summand F phrased in terms of the qbinomial coefficients (called qbin) or q-factorial (called qfac) that #depends on k and n, outputs the first N0 terms (starting at n=1) of the Sum(F,k=0..n). Try #SumSeq((n,k)->q^(k*(k-1)/2)*qbin(n,k,q),10); SumSeq:=proc(F,N0) local n1,k1: normal([seq(expand(add(F(n1,k1),k1=0..n1)),n1=1..N0)]): end: #SumSeqBi(F,N0): inputs a summand F phrased in terms of the qbinomial coefficients (called qbin) or q-factorial (called qfac) that #depends on k and n, outputs the first N0 terms (starting at n=1) of the Sum(F,k=-n..n). Try #SumSeqBi((n,k)->(-1)^k*q^((5*k^2+k)/2)/qfac(n-k,q)/qfac(n+k,q),10); SumSeqBi:=proc(F,N0) local n1,k1: normal([seq(expand(add(F(n1,k1),k1=-n1..n1)),n1=1..N0)]): end: ###end from qFindRec.txt #Rev(L): the reverse of list L. Try: Rev([4,5,7]); Rev:=proc(L) local i: [seq(L[nops(L)+1-i],i=1..nops(L))]: end: #IsBadP1(L,p): inputs an integer partition L, and a partition "pattern" p, decides whether L contains p. Try #IsBadP1([5,4,3],[1,1]); IsBadP1:=proc(L,p) local i,L1: L1:=[seq(L[i]-L[i+1],i=1..nops(L)-1)]: if nops(L1)=m1 outputs the implied pattern at the beginning obtained by deleting m #in partition whose largest part is m, and second-largest part is m1, where the original partition aviods p at the beginning. Try: #Child1(5,3,[2,1]); Child1:=proc(m,m1,p) local d: option remember: d:=m-m1: if d<0 or p=[] then RETURN(FAIL): fi: if p[1]=d then RETURN({[op(2..nops(p),p)]}): else RETURN({}): fi: end: #Child(m,m1,S): the set of children of the set of patterns S. Try: #Child(5,4,{[0],[1,2],[1,3],[2]}); Child:=proc(m,m1,S) local p: option remember: {seq(op(Child1(m,m1,p)), p in S)}: end: #GPmn1(m,n,S,S1): the set of partitions with largest part=m and number of parts=n avoiding the partition patterns S and in addition S1 at the beginning. Try #GPmn1(5,5,{[0,0]},{[0]}); GPmn1:=proc(m,n,S,S1) local gu,m1, S2,mu,mu1: option remember: if member([],S1) then RETURN({}): fi: if n=1 then RETURN({[m]}): fi: gu:={}: for m1 from 1 to m do S2:=Child(m,m1,S union S1): mu:=GPmn1(m1,n-1,S,S2): gu:=gu union {seq([m,op(mu1)],mu1 in mu)}: od: gu: end: #GPmn(m,n,S): the set of partitions with largest part=m and number of parts=n avoiding the partition patterns S. Try: #GPmn(5,3,{[0,0]}); GPmn:=proc(m,n,S) option remember: GPmn1(m,n,S,{}): end: #Fmn1(m,n,S,S1,q): the weigt-enumerator of the #set of partitions with largest part=m and number of parts=n avoiding the partition patterns S and in addition S1 at the beginning. Try #Fmn1(5,5,{[0,0]},{[0]}); Fmn1:=proc(m,n,S,S1,q) local gu,m1: option remember: if member([],S1) then RETURN(0): fi: if n=1 then RETURN(q^m): fi: gu:=0: for m1 from 1 to m do gu:=gu+Fmn1(m1,n-1,S, Yeled(m-m1,S union S1), q): od: expand(q^m*gu): end: #FmnB(m,n,S,q): the weigt-enumerator of the #set of partitions with largest part=m and number of parts=n avoiding the partition patterns S, but brute force. For checking only. Try #FmnB(5,5,{[0,0]},q); FmnB:=proc(m,n,S,q) local gu,gu1: option remember: gu:=GPmnB(m,n,S): add(q^convert(gu1,`+`),gu1 in gu): end: #Fmn(m,n,S,q): the weigt-enumerator of the #set of partitions with largest part=m and number of parts=n avoiding the partition patterns S. Try #Fmn(5,5,{[0,0]},q); Fmn:=proc(m,n,S,q) option remember: Fmn1(m,n,S,{},q): end: #C(m,m1,l,w,S,q): the weight-enumerator of the set of clusters that start at m, end at m1, have length l, depth w, with set of forbiddedn patterns S #C(5,5,3,1,{[0]},q); C:=proc(m,m1,l,w,S,q) local s: option remember: add(C1(m,m1,l,w,S,s,q), s in S): end: #IsComp(s,k,s1): In a cluster, can pattern s1 come after pattern s, starting at the k-th place of s. Try #IsComp([0],k,[0]); IsComp:=proc(s,k,s1) local gu1,gu2,i,i1,m,m1,m10: if k=1 or k>nops(s)+1 then RETURN(FAIL): fi: if k=nops(s)+1 then RETURN(true): fi: gu1:=[m,seq(m-add(s[i1],i1=1..i-1),i=2..nops(s)+1)]: gu2:=[m1,seq(m1-add(s1[i1],i1=1..i-1),i=2..nops(s1)+1)]: m10:=solve(gu1[k]=gu2[1],m1): gu2:=subs(m1=m10,gu2): if [op(k..nops(s)+1,gu1)]=[op(1..nops(s)+2-k,gu2)] then RETURN(true): else RETURN(false): fi: end: #C1(m,m1,l,w,S,s,q): the weight-enumerator of the set of clusters that start at m, end at m1, have length l, depth w, with set of forbiddedn patterns S that start with s (a member of S) #Try: #C1(5,5,3,1,{[0]},[0],q); C1:=proc(m,m1,l,w,S,s,q) local gu,i,j,s1,lu,ma,k,i1: option remember: if (m<1 or m1>m or l<1 or w<1) then RETURN(0): fi: if w=1 then if not ( l=nops(s)+1 and m-m1=convert(s,`+`)) then RETURN(0): else RETURN( (-1)*q^(m*l-add(add(s[j],j=1..i-1),i=2..l)) ): fi: fi: gu:=0: for s1 in S do for k from 2 to nops(s)+1 do if IsComp(s,k,s1) then lu:=[m,seq(m-add(s[i1],i1=1..i-1),i=2..k)]: ma:=lu[k]: gu:=expand(gu-q^(add(lu[i],i=1..k-1))*C1(ma,m1,l-(k-1),w-1,S,s1,q)): fi: od: od: gu: end: #Amn(m,n,S,q): the weight-enumerator of the #set of partitions with largest part=m and number of parts=n avoiding the partition patterns S, using the Cluster method. Try #Amn(5,5,{[0,0]}); Amn:=proc(m,n,S,q) local m1,l,w,m2: option remember: #if n=0 then #RETURN(1): #fi: if n=1 then RETURN(q^m): fi: expand( q^m*add(Amn(m1,n-1,S,q),m1=1..m) +add(add(add(add(C(m,m1,l,w,S,q)*Amn(m2,n-l,S,q),m2=1..m1), w=1..n) ,l=1..n-1),m1=1..m) +add(add(C(m,m1,n,w,S,q), w=1..n),m1=1..m) ) : end: #GuessPq1(L,q,Q,d): guesses a polynomial of degree d in Q=q^n P(q^n) (with coefficients that are rational functions in q) #such that Pol(q^n)=L[n]. Try: #GuessPq1([seq(q^(2*i)+q*q^i+q^2,i=1..5)],Q,2); GuessPq1:=proc(L,q,Q,d) local a,i,P,eq,var: if nops(L)<=d+2 then print(L, `must be of length at least `, d+3): RETURN(FAIL): fi: P:=add(a[i]*Q^i,i=0..d): var:={seq(a[i],i=0..d)}: eq:={seq(L[i]-subs(Q=q^i,P),i=1..nops(L))}: if solve(subs(q=2,eq), var)=NULL then RETURN(FAIL): fi: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: factor(subs(var,P)): end: #GuessPq(L,q,Q): guesses a polynomial of degree<=nops(L)-3 in Q=q^n P(q^n) (with coefficients that are rational functions in q) #such that Pol(q^n)=L[n]. Try: #GuessPq([seq(q^(2*i)+q*q^i+q^2,i=1..7)],Q); GuessPq:=proc(L,q,Q) local d,gu: for d from 1 to nops(L)-3 do gu:=GuessPq1(L,q,Q,d): if gu<>FAIL then RETURN(gu): fi: od: FAIL: end: #DiagSeq(P,q,N): Given a set of patterns, outputs the first N terms of the sequence of #weight-enumerators of the set of partitions with largest part=i and number of parts=i. Try: #DiagSeq({[0,0,0]},q,30); DiagSeq:=proc(P,q,N) local i: [seq(Fmn(i,i,P,q),i=1..N)]: end: #DiagSeqB(P,q,N): Given a set of patterns, outputs the first N terms of the sequence of #weight-enumerators of the set of partitions with largest part=i and number of parts=i. By brute froce (for checking). Try: #DiagSeqB{[0,0,0]},q,30); DiagSeqB:=proc(P,q,N) local i: [seq(FmnB(i,i,P,q),i=1..N)]: end: #IsKickable(p,S): given a list of prefix patterns S and p a member, can p be kicked out? IsKickable:=proc(p,S) local p1: for p1 in S minus {p} do if nops(p1)<=nops(p) and [op(1..nops(p1),p)]=p1 then RETURN(true): fi: od: false: end: #CleanUp1(S): One step of cleaning up CleanUp1:=proc(S) local p,S1: S1:=S: for p in S do if IsKickable(p,S) then S1:=S1 minus {p}: fi: od: S1: end: CleanUp:=proc(S) local S1,S2,S3: S1:=S: S2:=CleanUp1(S1): while S1<>S2 do S3:=CleanUp1(S2): S2:=S3: S1:=S2: od: S2: end: #Yeled1(d,p): The child of the pattern p when the difference between the largest and second-largest part is d. #Try: #Yeled1(2,[2,1]); Yeled1:=proc(d,p) option remember: if d<0 or p=[] then RETURN(FAIL): fi: if p[1]=d then RETURN({[op(2..nops(p),p)]}): else RETURN({}): fi: end: #Yeled(d,S): the set of children of the set of patterns S when the difference between the largest and second-largest terms is d. Try: #Yeled(1,{[0],[1,2],[1,3],[2]}); Yeled:=proc(d,S) local p,gu,mu: option remember: gu:={}: for p in S do mu:=Yeled1(d,p): if mu<>FAIL then gu:=gu union mu: fi: od: CleanUp(gu): end: #Mish(S,S1,q,Q,z): Inputs a set of global restrictions S, and a set of starting restrictions, S1, and variable symbols #q and z, and shift operator Q, for indexing, where Q[S] means that A[S] should be replaced by Q[S](qz) #Mish({[0,0,0]},{[0,0]},q,Q,z); Mish:=proc(S,S1,q,Q,z) local gu,lu,gad,ku,i: option remember: if member([],S1) then RETURN(0): fi: lu:=S union S1: gad:=max(seq(lu[i][1],i=1..nops(lu)))+1: gu:=(q*z)^gad*Q[{}]/(1-q*z): for i from 0 to gad-1 do ku:=Yeled(i,lu): if not member([],ku) then gu:=gu+q^i*z^i*Q[ku]: fi: od: gu: end: #Mish1(S,S1,q,z): Inputs a set of global restrictions S, and a set of starting restrictions, S1, and variable symbols #q and z, and shift operator Q, for indexing, where Q[S] means that A[S] should be replaced by Q[S](qz) #Mish1({[0,0,0]},{[0,0]},q,z); Mish1:=proc(S,S1,q,z) local gu,lu,gad,ku,i: option remember: if member([],S1) then RETURN(0): fi: lu:=S union S1: gad:=max(seq(lu[i][1],i=1..nops(lu)))+1: gu:={[(q*z)^gad/(1-q*z),{}]}: for i from 0 to gad-1 do ku:=Yeled(i,lu): if not member([],ku) then gu:=gu union {[q^i*z^i,ku]}: fi: od: gu: end: #MakeSc(S,q,z): inputs a set of restrictions, outputs a scheme for computing the sequence of generating functions #whose n-th entry is the rational function in z whose coefficient of z^m is the weight-enumerator of #the weight-enumerator of the set of partitions with n parts, largest part m, that avoid the patterns in S. #Try: #MakeSc({[0,0],[1,1]},q,z); MakeSc:=proc(S,q,z) local s,gu, gu1,gu2, T,gad,d,S1,K1,K2,i,mu,GU,i1: gad:=max(seq(op(s), s in S)): gu:={{}}: gu1:= gu union {seq(seq(Yeled(d,S union S1),d=0..gad), S1 in gu)}: while gu<>gu1 do gu2:= gu1 union {seq(seq(Yeled(d,S union S1), d=0..gad), S1 in gu1)}: gu:=gu1: gu1:=gu2: od: gu:=gu1: gu1:={}: for S1 in gu do if not member([],S1) then gu1:=gu1 union {S1}: fi: od: gu:=gu1: for S1 in gu do T[S1]:=Mish1(S,S1,q,z): od: K1[1]:={}: K2[{}]:=1: mu:=gu minus {{}}: for i from 2 to nops(mu)+1 do K1[i]:=mu[i-1]: K2[mu[i-1]]:=i: od: op(K1),op(K2): GU:=[]: for i from 1 to nops(gu) do GU:=[op(GU),subs({seq(gu[i1]=K2[gu[i1]],i1=1..nops(gu))},T[K1[i]])]: od: GU: end: #ApplySc1(L,S1,q,z): inputs a current list,L, or rational functions L, and a set S1 reprending an operator #applies S1 to L. Try: #ApplySc1([q*z,1/(1-q*z)], {[q,1],[q/(1-q*z,2]},q,z); ApplySc1:=proc(L,S1,q,z) local s1,gu: gu:=0: for s1 in S1 do gu:=normal(gu+s1[1]*subs(z=q*z,L[s1[2]])): od: gu: end: #ApplySc(Sc,q,z,L): given a scheme Sc, variables q and z, and a list L, applies the scheme to L #Try: #ApplySc([1/(1-q*z)],q,z,[1/(1-q*z)]); ApplySc:=proc(Sc,q,z,L) local i: if nops(Sc)<>nops(L) then RETURN(FAIL): fi: [seq(ApplySc1(L,Sc[i],q,z),i=1..nops(L))]: end: #GFseq(S,q,z,N): Inputs a list of restrictions S, variables q and z, and a positive integer N outputs #the list of length N whose n-th term is the rational function in z and q whose coefficient of z^m is #the weight-enumerator of the set of partitions with exactly n parts, largest part m, and obeying the #restrictions of S. Try: #GFseq({[0]},q,z,6); GFseq:=proc(S,q,z,N) local Sc,L,gu,i,n: Sc:=MakeSc(S,q,z): L:=[seq(q*z/(1-q*z),i=1..nops(Sc))]: gu:=[]: for n from 1 to N do gu:=[op(gu),L[1]]: L:=ApplySc(Sc,q,z,L): od: gu: end: CheckGFseq1:=proc(S,q,N) local z,lu1,m,n,Lu1,Lu2,ku: lu1:=GFseq(S,q,z,N): Lu1:=[]: for n from 1 to N do ku:=taylor(lu1[n],z=0,N+1): ku:=[seq(expand(coeff(ku,z,m)),m=1..N)]: Lu1:=[op(Lu1),ku]: od: Lu1: end: CheckGFseq2:=proc(S,q,N) local m,n: [seq([seq(Fmn(m,n,S,q),m=1..N)],n=1..N)]: end: #CheckGFseq(S,N): Checks GFseq(S,q,z,N): . Try: #CheckGFseq({[0,0,0]},10); CheckGFseq:=proc(S,N) local q: evalb(CheckGFseq1(S,q,N)=CheckGFseq2(S,q,N)): end: #IsBadP1_mod(L,p,M,N): inputs an integer partition L, and a partition "pattern" p, decides whether L contains p. #Also, decides if parts mod N are in M--if some part mod N is not in M then return true. Try #IsBadP1_mod([5,4,3],[1,1],{0,1},3); IsBadP1_mod:=proc(L,p,M,N) local i,L1,l: L1:=[seq(L[i]-L[i+1],i=1..nops(L)-1)]: for l in L do if not evalb(l mod N in M) then RETURN(true): fi: od: if nops(L1)n then RETURN(0): fi: if m=n then RETURN(1): fi: gu:=0: for m1 from 1 to m do gu:=gu+xmn1(m1,n-m,S, Yeled(m-m1,S union S1)): od: gu: end: #xmn(m,n,S): the number of #partitions of n with largest part=m avoiding the partition patterns S. Try #xmn(5,5,{[0,0]}); xmn:=proc(m,n,S) option remember: xmn1(m,n,S,{}): end: #xn(n,S): The number of partitions of n avoiding the set of patterns S. Try: #xn(10,{[0,0]}); xn:=proc(n,S) local m: option remember: add(xmn(m,n,S),m=1..n): end: #xnB(n,S): The number of partitions of n avoiding the set of patterns S, by brute force, for checking purposes only. Try: #xnB(10,{[0,0]}); xnB:=proc(n,S) local gu,gu1,c: gu:=partition(n): gu:={seq(Rev(gu1),gu1 in gu)}: c:=0: for gu1 in gu do if not IsBadP(gu1,S) then c:=c+1: fi: od: c: end: #xnSeq(N,S): The list of the first N entries of xn(n,S). Try: #xnSeq(20,{[0]}); xnSeq:=proc(N,S) local n: [seq(xn(n,S),n=1..N)]: end: #xnSeqB(N,S): The list of the first N entries of xn(n,S). By brute force. For checking only. Try: #xnSeqB(10,{[0]}); xnSeqB:=proc(N,S) local n: [seq(xnB(n,S),n=1..N)]: end: #GuP(L,q): inputs a list of integers L and outputs, if possible the list [a1,b1],...[ak,bk] that agrees with it #such that the g.f. is (1-q^a1)^b1*(1-q^a2)^b2*.... #Warning: You always get an answer! If the length of the output is close to the input and the exponents are high it is #probably.nonsense. Try: #GuP(xnSeq(20,{[0],[1]}); GuP:=proc(L,q) local K,f,i,f1,mu,a,b,j,L1: K:=nops(L): f:=1+add(L[i]*q^i,i=1..nops(L)): f1:=taylor(log(f),q=0,K+1): f1:=add(coeff(f1,q,i)*q^i,i=0..K): mu:=[]: while f1<>0 do a:=ldegree(f1,q): b:=coeff(f1,q,a): if not type(b,integer) then RETURN(FAIL): else mu:=[op(mu),[a,-b]]: f1:=f1-b*add(q^(a*j)/j,j=1..trunc(K/a)): fi: od: f1:=mul( (1-q^mu[i][1])^mu[i][2],i=1..nops(mu)): f1:=taylor(f1,q=0,K+1): L1:=[seq(coeff(f1,q,i),i=1..K)]: if L1<>L then print(mu, `did not work out`): RETURN(FAIL): fi: mu: end: #GenF1a(m,S,q,T): Inputs a positive integer,m, a set of restrictions, S, and a variable name q. Outputs #The generating function of the sequence: number of partitions of n with largest m obeying the restictions of #, using T. For example, try: #GenF1a(4,{[0,0],[0,1]},q,10); GenF1a:=proc(m,S,q,T) local i,lu,n,gu1,gu2,gu,mu: if {seq(xmn(m,n,S)*q^n,n=T*m..3*T*m)}={0} then RETURN(add(xmn(m,n,S)*q^n,n=0..T*m-1)): fi: lu:=mul(1-q^i,i=1..m): gu1:=expand(add(xmn(m,n,S)*q^n,n=0..T*m)*lu): gu1:=add(coeff(gu1,q,i)*q^i,i=0..T*m-1): gu2:=expand(add(xmn(m,n,S)*q^n,n=0..2*T*m)*lu): gu2:=add(coeff(gu2,q,i)*q^i,i=0..2*T*m-1): if gu1<>gu2 then RETURN(FAIL): fi: gu:=normal(gu1/lu): mu:=taylor(gu,q=0,25*m+1): mu:=[seq(coeff(mu,q,i),i=1..25*m)]: if mu<>[seq(xmn(m,i,S),i=1..25*m)] then RETURN(FAIL): else RETURN(gu): fi: end: #SeqGenF1(M,S,q,T): Inputs a positive integer,m, a set of restrictions, S, and a variable name q. #It also inputs a buffer variable T. #Outputs #The list of generating functions of the sequence: number of partitions of n with largest m obeying the restictions of #S, for m from 1 to M. For example, try: #SeqGenF1(4,{[0,0],[0,1]},q,10); SeqGenF1:=proc(M,S,q,T) local gu,m,gu1: gu:=[]: for m from 1 to M do gu1:=GenF1a(m,S,q,T): if gu1=FAIL then print(` Make `, T, ` bigger `): print(gu): RETURN(FAIL): else gu:=[op(gu),gu1]: fi: od: gu: end: #Vecs(K,L): the set of vectors [a1,.., aL] where every entry is between 0 and K. Try: #Vecs(2,2); Vecs:=proc(K,L) local gu,gu1,i: option remember: if L=0 then RETURN({[]}): fi: gu:=Vecs(K,L-1): {seq(seq([op(gu1),i],i=0..K),gu1 in gu)}: end: #Mamar111(K,L,s,M): Inputs a positive integer K, another positive integer L, yet another positive integer s and a fairly large positive integer M #outputs the first M terms from n=1 to n=M of the eunumerating sequence for partitions of n that avoid sets of patterns containing #s restrictions of the form [a1,a2,.., aL] with 0<=a1, ...,aL<=K. Try: #Mamar111(2,2,2,100); Mamar111:=proc(K,L,s,M) local gu,gu1: gu:=choose(Vecs(K,L),s): print(`The first`, M, `terms of all the enumerating sequences of partitions avoiding sets of`, s, `patterns each of length`, L, `whose entries are from 0 to`, K): print(``): for gu1 in gu do print(`For the set of patterns`, gu1, `the first`, M, `terms are `): print(``): lprint(xnSeq(M,gu1)): print(``): od: end: #Mamar11(K,L,s,M): Inputs a positive integer K, another positive integer L, yet another positive integer s and a fairly large positive integer M #outputs the first M terms from n=1 to n=M of the eunumerating sequence for partitions of n that avoid sets of patterns containing #s1 restrictions of the form [a1,a2,.., al], with l<=L with 0<=a1, ...,al<=K and s<=s1. Try: #Mamar11(2,2,2,100); Mamar11:=proc(K,L,s,M) local L1,s1,t0: t0:=time(): print(`The first`, M, `terms of all the enumerating sequences of partitions avoiding sets of up to `, s, `patterns each of length up to `, L, `whose entries are from 0 to`, K): print(``): for L1 from 1 to L do for s1 from 1 to min(s,nops(Vecs(K,L1))) do Mamar111(K,L1,s1,M): od: od: print(``): print(`------------------------------------------------------------------------`): print(`This ends this article, that took`, time()-t0, `seconds to generate. `): end: ############################# # New Code # ############################# #GP(m,n,A,Mod,B,IC): the number of # partitions of n with largest part=m avoiding the partition patterns A globally, patterns in Mod locally (according to mod conditions),and patterns in B at the beginning, in addition to having no sub-partitions in IC (initial conditions) GP:=proc(m,n,A,Mod,B,IC) local gu,m1,k,i,j,L1,l,S: option remember: k:=nops(Mod): gu:=0: if m>n then RETURN(0): fi: L1:=[]: for l in IC do L1:=[op(L1),[seq(l[i]-l[i+1],i=1..nops(l)-1)]]: od: S:=B: for i from 1 to nops(IC) do if evalb(m=IC[i][1]) then if evalb(L1[i]=[]) then RETURN(0): else S:=S union {L1[i]}: fi: fi: od: if m=n then RETURN(1): fi: if k=0 then for m1 from 1 to m do if not member([],Yeled(m-m1,A union S)) then gu:=gu+GP(m1,n-m,A,Mod,Yeled(m-m1, A union S),IC): fi: od: RETURN(gu): fi: i:=m mod k: for m1 from 1 to m do if not member([],Yeled(m-m1,A union Mod[i+1] union S)) then gu:=gu+GP(m1,n-m,A,Mod,Yeled(m-m1, S union A union Mod[i+1]),IC): fi: od: gu: end: #Gxn(n,A,Mod,B,IC): the number of # partitions of n avoiding the partition patterns S globally, patterns in S1 locally (according to mod conditions),and patterns in S2 at the beginning, in addition to having no sub-partitions in L (initial conditions) Gxn:=proc(n,A,Mod,B,IC) local m: option remember: add(GP(m,n,A,Mod,B,IC),m=1..n): end: #GxnSeq(N,A,Mod,B,IC): the first N terms of the sequence of numbers of # partitions of n avoiding the partition patterns S globally, patterns in S1 locally (according to mod conditions),and patterns in S2 at the beginning, in addition to having no sub-partitions in L (initial conditions) GxnSeq:=proc(N,A,Mod,B,IC): [seq(Gxn(n,A,Mod,B,IC),n=1..N)]: end: #############The Product Side########### xmn2:=proc(m,n,S,S1,M,r) local gu,m1: option remember: if member([],S1) then RETURN(0): fi: if m>n then RETURN(0): fi: if m=n and evalb(m mod r in M) then RETURN(1): fi: if not evalb(m mod r in M) then RETURN(0): fi: gu:=0: for m1 from 1 to m do gu:=gu+xmn2(m1,n-m,S, Yeled(m-m1,S union S1),M,r): od: gu: end: #xmn_mod(m,n,S,M,r): the number of #partitions of n with largest part=m avoiding the partition patterns S. Parts mod r are in M. Try #xmn_mod(5,5,{[0,0]},{1,2},3); xmn_mod:=proc(m,n,S,M,r) option remember: xmn2(m,n,S,{},M,r): end: #xn_mod(n,S,M,r): The number of partitions of n avoiding the set of patterns S. Parts mod r are in M. Try: #xn_mod(50,{[0,0]},{1,2},3); xn_mod:=proc(n,S,M,r) local m: option remember: add(xmn_mod(m,n,S,M,r),m=1..n): end: #xnB_mod(n,S,M,r): The number of partitions of n avoiding the set of patterns S, by brute force, for checking purposes only. Parts mod r are in M. Try: #xnB_mod(50,{[0,0]},{1,2},3); xnB_mod:=proc(n,S,M,r) local gu,gu1,c: gu:=partition(n): gu:={seq(Rev(gu1),gu1 in gu)}: c:=0: for gu1 in gu do if not IsBadP_mod(gu1,S,M,r) then c:=c+1: fi: od: c: end: xnB_mod1:=proc(n,S,M,r) local gu,gu1,c: gu:=partition(n): gu:={seq(Rev(gu1),gu1 in gu)}: c:={}: for gu1 in gu do if not IsBadP_mod(gu1,S,M,r) then c:=c union {gu1}: fi: od: c: end: #xnSeq_mod(N,S,M,r): The list of the first N entries of xn_mod(n,S,M,N). Parts mod r are in M. Try: #xnSeq_mod(20,{[0]},{1,2},3); xnSeq_mod:=proc(N,S,M,r) local n: [seq(xn_mod(n,S,M,r),n=1..N)]: end: xnSeq_prod:=proc(N,S,M,r,a) local n,i: [seq(coeff(taylor(add(q^n*xn_mod(n,S,M,r),n=1..N+1)*Poch(a,q^r,N+1),q=0,N),q^i),i=1..N-1)]: end: #Poch(a,q,n) : the Pochhammer symbol expression Poch:=proc(a,q,n): product(1-a*q^i,i=0..n-1): end: #xnSeqB(N1,S,M,N): The list of the first N1 entries of xn(n,S). Parts mod N are in M. By brute force. For checking only. Try: #xnSeqB(10,{[0]},{0,1},3); xnSeqB_mod:=proc(N1,S,M,N) local n: [seq(xnB_mod(n,S,M,N),n=1..N1)]: end: