###################################################################### ##GJpats.txt: Save this file as GJpats.txt # ## To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read `GJpats.txt` # ##Then follow the instructions given there # ## # ##Written by Mingjia Yang and Doron Zeilberger, Rutgers University # ###################################################################### #Created: April 2018 print(`Created: April 2018`): print(` This is GJpats.txt `): print(`To use the Goulden-Jackson cluster method for consecutive pattern-avoidance for Words.`): print(`It is one of the packages that accompany the article `): print(` Increasing Consecutive Patterns in Words `): print(`by Mingjia Yang and Doron Zeilberger`): print(`and also available from Yang's and Zeilberger's websites`): 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 of the main Checking procedures type ezraC();, for help with`): print(`For a list of the supporint Checking procedures type ezraC1();, for help with`): print(`a specific procedure, type ezraC(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 (or less important) procedures are: CGFxt, CGFxt1, GFpat, GJGFs, GJGFst, Images1, IsSymm, Mist`): print(` mL, PtoM, Overlapx, SeqGJGFs, SeqGJGFst, SeqGJGFxt `): print(` `): else ezra(args): fi: end: ezra:=proc() if args=NULL then print(`The main procedures are: GJGFxt, GFpats, IncStory, SPtoM `): print(` `): elif nops([args])=1 and op(1,[args])=CGFxt then print(`CGFxt(M,x,t): the cluster generating function with a set of words M according to weight of words and t for keep track `): print(`of number of occurrences of members of M. Try: `): print(`CGFxt({[1,1,1],[0,0,0],[1,0,1]},x,t);`): elif nops([args])=1 and op(1,[args])=CGFxt1 then print(`CGFxt1(M,x,t): the explicit expressions for C[m] with a set of mistakes M. Try:`): print(`CGFxt1({{[1,1,1],[0,0,0],[1,0,1]},x,t);`): elif nops([args])=1 and op(1,[args])=GJGFs then print(`GJGFs(A,M,s): inputs an alphabet A={a1,..., ak}, say, and set of words, M, that are minimal, and a symbol s, and outputs`): print(`the rational function in s whose coefficient of s^n is the number of words`): print(`in the alphabet A of length n with no occurrences of the members of M as COSECUTIVE subwords. Try:`): print(`GJGFs({1,2},{[1,1,1],[2,2,2]},s);`): elif nops([args])=1 and op(1,[args])=GJGFst then print(`GJGFst(A,M,s,t): inputs an alphabet A={a1,..., ak}, say, and set of words, M, that are minimal, and symbols s and t, and outputs`): print(`the rational function in s and t whose coefficient of s^n*t^r is the number of words`): print(`in the alphabet A of length n and r occurrences of the members of M as COSECUTIVE subwords. Try:`): print(`GJGFst({1,2},{[1,1,1],[2,2,2]},s,t);`): elif nops([args])=1 and op(1,[args])=GJGFxt then print(`GJGFxt(A,M,x,t): inputs an alphabet A={a1,..., ak}, say, and set of words, M, that are minimal, and symbols x and t, and outputs`): print(`the rational function in x[a1], ..., x[ak] and t whose coefficient of x[a1]^v1*...*x[ak]^vk*t^r is the number of words`): print(`in the alphabet A with exacty v1 a1-s, ..., vk, ak-s and r occurrences of the members of M as COSECUTIVE subwords. Try:`): print(`GJGFxt({1,2},{[1,1,1],[2,2,2]},x,t);`): elif nops([args])=1 and op(1,[args])=GFpat then print(`GFpat(pi,x,n,t): the generating function in x[1], ..., x[n], of all words in {1, ...,n} according to the weight `): print(`t^(number of occurences of the consecutive pattern pi. Try`): print(`GFpat([1,2,3],x,5,t);`): elif nops([args])=1 and op(1,[args])=GFpats then print(`GFpats(Setpi,x,n,t): the generating function in x[1], ..., x[n], of all words in {1, ...,n} according to the weight `): print(`t^(number of occurences of the consecutive pattern pi in Setpi). Try: `): print(`GFpats({[1,2,3],[1,3,2]},x,5,t); `): elif nops([args])=1 and op(1,[args])=Images1 then print(`Images1(L): all the images of the vector L under permutations. Try:`): print(`Images1([2,1,0,0]);`): elif nops([args])=1 and op(1,[args])=IncStory then print(`IncStory(r,m,R,t): the story of the increasing pattern 1...r by doing it from r letters to R letters. Try: `): print(`IncStory(3,m,6,t);`): elif nops([args])=1 and op(1,[args])=IsSymm then print(`IsSymm(P,x,n): inputs a polynomial P in x[1], ..., x[n], decides whether it is symmetric. Try:`): print(`IsSymm(x[1]+x[2]+x[3],x,3);`): elif nops([args])=1 and op(1,[args])=Mist then print(`Mist(Setpi,n): the set of mistakes implied for n letters from Setpi. Try:`): print(`Mist({[1,2,3]},5);`): elif nops([args])=1 and op(1,[args])=mL then print(`mL(L,x,n): Inputs a partition L, a symbol x, and a positive integer m, outputs the monomial symmetric function m_L(x[1], ..., x[n]);`): print(`Try:`): print(`mL([2,1],x,4);`): elif nops([args])=1 and op(1,[args])=Overlapx then print(`Overlapx(w1,w2,x): the sum of the weights of all the possible overlaps between word w1 and word w2`): print(`where a suffix of w1 coincides with . Try:`): print(`Overlapx([1,1,1,1],[1,1,1,1],x);`): elif nops([args])=1 and op(1,[args])=PtoM then print(`PtoM(P,x,n,M): expresses a symmetric polynomial, P, of x[1], ..., x[n] in terms of the Mononomial symmetric functions. Try:`): print(`PtoM(x[1]+x[2],x,2,M);`): elif nops([args])=1 and op(1,[args])=SeqGJGFs then print(`SeqGJGFs(A,M,N): the first N terms of the Taylor expansion w.r.t. to s of GJGFs(A,M,s) `): print(` Try: `): print(`SeqGJGFs({1,2},{[1,1,1],[2,2,2]},5); `): elif nops([args])=1 and op(1,[args])=SeqGJGFt then print(`SeqGJGFt(A,M,t,N): the first N terms of the Taylor expansion w.r.t. to s of GJGFst(A,M,s,t) `): print(` Try: `): print(`SeqGJGFt({1,2},{[1,1,1],[2,2,2]},t,5); `): elif nops([args])=1 and op(1,[args])=SeqGJGFxt then print(`SeqGJGFxt(A,M,x,t,N): the first N terms of the Taylor expansion w.r.t. to s of GJGFxt(A,M,x,t) where x[i] is replaced by x[i]*s.`): print(` Try: `): print(`SeqGJGFxt({1,2},{[1,1,1],[2,2,2]},x,t,5); `): elif nops([args])=1 and op(1,[args])=SPtoM then print(`SPtoM(P,x,n,m): inputs a symmetric polynomial P in the variables x[1], ..., x[n] (n is a positive integer), and a symbol m,`): print(`expresses it as linear combination of monomial symmetric functions m[lambda]. Try:`): print(`SPtoM(x[1]*x[2],x,2,m);`): elif nops([args])=1 and op(1,[args])=DL then print(`DL(Setpi,x,n,t): convert the denominator of the result of GFpats to a list, according to the i in m[1$i], beginning from i=0 to i=n. Try:`): print(`DL({[1,2,3]},x,6,t);`): elif nops([args])=1 and op(1,[args])=ConjG then print(`ConjG(x,t) conjectures a generating function for the denominator of GFpats({[1,2,3]},x,n,t) (the numerator is 1) Try:`): print(`ConjG(x,t)`): else print(`There is no ezra for`,args): fi: end: ###############################From SF Monom:=proc(lambda,x) local i: convert( [seq(x[i]^lambda[i],i=1..nops(lambda) )], `*`): end: m_lambda:=proc(lambda,x,m) local i,Perms1,lambda1: if m< nops(lambda) then ERROR(`The number of variables should be >= number of parts of lambda`): fi: lambda1:=[op(lambda), seq(0,i=1..m-nops(lambda))]: Perms1:=permute(lambda1): convert( [seq(Monom(Perms1[i],x,m) , i=1..nops(Perms1))] , `+`): end: Chop:=proc(lam) local i: for i from 1 to nops(lam) while lam[i]>0 do od: i:=i-1: [op(1..i,lam)]: end: #Chop RevMM:=proc(P) local i,N: N:=nops(P): [seq(P[N-i+1] , i=1..N)]: end: MonomToPar:=proc(P,x,n) local i1,lam1,coe: lam1:=[seq(degree(P,x[i1]),i1=1..n)] : coe:=normal(P/convert([seq(x[i1]^lam1[i1],i1=1..nops(lam1))],`*`)): coe,Chop(RevMM(sort(lam1))): end: #ApplyPer(f,x,pi1): Applies the permutation pi to the (n=nops(pi)) #function (or expression) f that depends on x[1], ..., x[n] ApplyPer:=proc(f,x,pi1) local i,su: su:={seq(x[i]=x[pi1[i]], i=1.. nops(pi1))}; subs(su,f); end: #Symm(f,x,n): The symmetrizer of the function (or expression) #f(x[1], ..., x[n]) Symm:=proc(f,x,n) local pers,i: pers:=permute(n): convert([seq(ApplyPer(f,x,pers[i]), i=1..nops(pers))], `+`)/nops(pers); end: #SPtoM(P,x,n,m): inputs a symmetric polynomial P in the variables x[1], ..., x[n] (n is a positive integer), and a symbol m, #expresses it as linear combination of monomial symmetric functions m[lambda]. Try: #SPtoM(x[1]*x[2],x,2,m); SPtoM:=proc(P,x,n,m) local P1,Q,mono1,lam1,coe1,gu,NQ: gu:={}: P1:=expand(P): if P1=0 then RETURN(0): fi: if Symm(P1,x,n)<>P1 then RETURN(FAIL): fi: Q:=0: while type(P1,`+`) do mono1:=op(1,P1): lam1:=MonomToPar(mono1,x,n): coe1:=lam1[1]: lam1:=lam1[2]: gu:=gu union {lam1}: Q:=Q+factor(coe1)*m[op(lam1)]: P1:=expand(P1-coe1*m_lambda(lam1,x,n)): od: if P1<>0 then lam1:=MonomToPar(P1,x,n): coe1:=lam1[1]: lam1:=lam1[2]: Q:=Q+factor(coe1)*m[op(lam1)]: P1:=expand(P1-coe1*m_lambda(lam1,x,n)): fi: Q: NQ:=0: for lam1 in gu do NQ:=NQ+factor(coeff(Q,m[op(lam1)],1))*m[op(lam1)]: od: if expand(NQ)<>Q then RETURN(Q): else RETURN(NQ): fi: end: ###############################End From SF #begin checking part ezraC1:=proc() if args=NULL then print(` The supporting procedures are: Coe , NuOc1, NuOc, NuOcC, NuOcC1, WtC, Wt `): print(``): else ezraC(args): fi: end: ezraC:=proc() if args=NULL then print(`The main procedures are: Bdokxt, SeqWt, SeqWtC, Words `): print(` `): elif nops([args])=1 and op(1,[args])=Bdokxt then print(`Bdokxt(A,M,N): checks the Goluden-Jackosn method for alphabet A, set of mistakes M, up to words of length N. Try:`): print(`Bdokxt({0,1},{[0,1,0],[1,1,1]},9);`): elif nops([args])=1 and op(1,[args])=Coe then print(`Coe(P,x,v): the coefficient of x[1]^v[1]*...x[nops(v)]^v[nops(v)] in the polynomial P. Try: `): print(`Coe((x[1]+x[2]+x[3])^6,x,[2,2,2]);`): elif nops([args])=1 and op(1,[args])=NuOcC then print(`NuOcC(w,M): given a word w and a set of words M, finds the number of occurences of members of M in w as a CONSECUTIVE subword.`): print(`Try: `): print(`NuOcC([1,0,1,0,1,1],{[1,0,1],[0,1,1]});`): elif nops([args])=1 and op(1,[args])=NuOc1 then print(`NuOc1(w,m): given a word w and a word m, finds the number of occurences of m in w as ANY subword.`): print(`Try: `): print(` NuOc1([1,0,1,0,1],[1,0,1]); `): elif nops([args])=1 and op(1,[args])=NuOcC1 then print(`NuOcC1(w,m): given a word w and a word m, finds the number of occurences of m in w as a CONSECUTIVE subword.`): print(`Try: `): print(` NuOcC1([1,0,1,0,1],[1,0,1]); `): elif nops([args])=1 and op(1,[args])=SeqWtC then print(`SeqWtC(A,M,x,t,N): inputs an alphabet A, and a set of words M, outputs the first N terms (starting at n=1) of the`): print(`sequence "weight-enumerator of n-letter words in A according to the weight WtC(w,M,x,t) (q.v.) (i.e. CONSECUTIVE case). Try:`): print(`SeqWtC({0,1},{[0,0,0],[1,1,1]},x,t,5);`): elif nops([args])=1 and op(1,[args])=Wt then print(`Wt(w,M,x,t): the weight of a word w according to the weight mul(x[w[i]],i=1..nops(w))*t^NuOc(w,N). Try:`): print(`Wt([1,1,1,0,1],{[1,0,1],[1,1,1]},x,t);`): elif nops([args])=1 and op(1,[args])=WtC then print(`WtC(w,M,x,t): the weight of a word w according to the weight mul(x[w[i]],i=1..nops(w))*t^NuOcC(w,N). Try:`): print(`WtC([1,1,1,0,1],{[1,0,1],[1,1,1]},x,t);`): elif nops([args])=1 and op(1,[args])=Words then print(`Words(A,n): all the n-letter words in the alphabet A, try:`): print(`Words({0,1},5);`): else print(`There is no ezra for`,args): fi: end: #Words(A,n): all the n-letter words in the alphabet A, try: #Words({0,1},5); Words:=proc(A,n) local gu,w,a: option remember: if n=0 then RETURN({[]}): fi: gu:=Words(A,n-1): {seq(seq([a,op(w)],a in A), w in gu)}: end: #NuOcC1(w,m): given a word w and a word m, finds the number of occurences of m in w as a CONSECUTIVE subword. #Try: #NuOcC1([1,0,1,0,1],[1,0,1]); NuOcC1:=proc(w,m) local i,c,mLength: mLength:=nops(m): c:=0: for i from 1 to nops(w)-nops(m)+1 do if [op(i..i+mLength-1,w)]=m then c:=c+1: fi: od: c: end: #NuOcC(w,M): given a word w and a set of words m, finds the number of occurences of members of M in w as a CONSECUTIVE subword. #Try: #NuOcC([1,0,1,0,1,1],{[1,0,1],[0,1,1]); NuOcC:=proc(w,M) local m: add(NuOcC1(w,m), m in M): end: #NuOc1(w,m): given a word w and a word m, finds the number of occurences of m in w as ANY subword. #Try: #NuOc1([1,0,1,0,1],[1,0,1]); NuOc1:=proc(w,m) local k, lu,c, lu1,i1: k:=nops(m): lu:=choose(nops(w),k): c:=0: for lu1 in lu do if [seq(w[lu1[i1]],i1=1..k)]=m then c:=c+1: fi: od: c: end: #NuOc(w,M): given a word w and a set of words m, finds the number of occurences of members of M in w as ANY subword. #Try: #NuOc([1,0,1,0,1,1],{[1,0,1],[0,1,1]); NuOc:=proc(w,M) local m: if not type(M,set) and type(w,list) then RETURN(FAIL): fi: add(NuOc1(w,m), m in M): end: #WtC(w,M,x,t): the weight of a word w according to the weight mul(x[w[i]],i=1..nops(w))*t^NuOcC(w,N). Try #WtC([1,1,1,0,1],{[1,0,1],[1,1,1]},x,t); WtC:=proc(w,M,x,t) local i: mul(x[w[i]],i=1..nops(w))*t^NuOcC(w,M): end: #SeqWtC(A,M,x,t,N): inputs an alphabet A, and a set of words M, outputs the first N terms (starting at n=1) of the #sequence "weight-enumerator of n-letter words in A according to the weight WtC(w,M,x,t) (q.v.). Try #SeqWtC({0,1},{[0,0,0],[1,1,1]},x,t,5); SeqWtC:=proc(A,M,x,t,N) local gu,n,lu,gu1,lu1: gu:=[]: for n from 1 to N do lu:=Words(A,n): gu1:= add(WtC(lu1,M,x,t),lu1 in lu): gu:=[op(gu),gu1]: od: gu: end: #Coe(P,x,v): the coefficient of x[1]^v[1]*...x[nops(v)]^v[nops(v)] in the polynomial P. Try #Coe((x[1]+x[2]+x[3])^6,x,[2,2,2]); Coe:=proc(P,x,v) local gu,i: gu:=expand(P): for i from 1 to nops(v) do gu:=coeff(gu,x[i],v[i]): od: gu: end: #end checking part ##star with full x[a]'s and t #Overlapx(w1,w2,x): the sum of the weights of all the possible overlaps between word w1 and word w2 #where a suffix of w1 coincides with . Try #Overlapx([1,1,1,1],[1,1,1,1],x); Overlapx:=proc(w1,w2,x) local i,gu,i1: gu:=0: for i from 2 to nops(w1) do if [op(i..nops(w1),w1)]=[op(1..nops(w1)-i+1,w2)] then gu:=gu+mul(x[w1[i1]],i1=1..i-1): fi: od: gu: end: #CGFxt(M,x,t): the cluster generating function with a set of words M according to weight of words and t for keep track #of number of occurrences of members of M. Try #CGFxt({{[1,1,1],[0,0,0],[1,0,1]},x,t); CGFxt:=proc(M,x,t) local eq,var,C,m,m1,i1: var:={seq(C[m],m in M)}: eq:={}: for m in M do eq:=eq union {C[m]-(t-1)*mul(x[m[i1]],i1=1..nops(m))-(t-1)*add(C[m1]*Overlapx(m,m1,x),m1 in M)}: od: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: normal(add(subs(var,C[m]),m in M)): end: #GJGFxt(A,M,x,t): inputs an alphabet A={a1,..., ak}, say, and set of words, M, that are minimal, and symbols x and t, and outputs #the rational function in x[a1], ..., x[ak] and t whose coefficient of x[a1]^v1*...*x[ak]^vk*t^r is the number of words #in the alphabet A with exacty v1 a1-s, ..., vk, ak-s and r occurrences of the members of M as COSECUTIVE subwords. Try: #GJGFxt({1,2},{[1,1,1],[2,2,2]},x,t); GJGFxt:=proc(A,M,x,t) local gu,a: gu:=CGFxt(M,x,t): normal(1/(1-add(x[a], a in A)-gu)): end: #SeqGJGFxt(A,M,x,t,N): the first N terms of the Taylor expansion w.r.t. to s of GJGFxt(A,M,x,t) where x[i] is replaced by x[i]*s. #Try: #SeqGJGFxt({1,2},{[1,1,1],[2,2,2]},x,t,5); SeqGJGFxt:=proc(A,M,x,t,N) local gu,s,a,i: gu:=GJGFxt(A,M,x,t): gu:=subs({seq(x[a]=s*x[a], a in A)},gu): gu:=taylor(gu,s=0,N+1): [seq(expand(coeff(gu,s,i)),i=1..N)]: end: #Bdokxt(A,M,N): checks the Goluden-Jackosn method for alphabet A, set of mistakes M, up to words of length N. Try #Bdokxt({0,1},{[0,1,0],[1,1,1]},9); Bdokxt:=proc(A,M,N) local x,t: evalb(SeqGJGFxt(A,M,x,t,N)=SeqWtC(A,M,x,t,N)): end: ##end with full x[a]'s and t ##start with s and t (no individual letter) #Overlaps(w1,w2,s): the sum of the weights of all the possible overlaps between word w1 and word w2 #where a suffix of w1 coincides with . Try #Overlaps([1,1,1,1],[1,1,1,1],s); Overlaps:=proc(w1,w2,s) local i,gu,i1: gu:=0: for i from 2 to nops(w1) do if [op(i..nops(w1),w1)]=[op(1..nops(w1)-i+1,w2)] then gu:=gu+s^(i-1): fi: od: gu: end: #CGFst(M,s,t): the cluster generating function with a set of words M according to weight s^lentgh(word) and t for keep track #of number of occurrences of members of M. Try #CGFst({{[1,1,1],[0,0,0],[1,0,1]},s); CGFst:=proc(M,s,t) local eq,var,C,m,m1,i1: var:={seq(C[m],m in M)}: eq:={}: for m in M do eq:=eq union {C[m]-(t-1)*s^nops(m)-(t-1)*add(C[m1]*Overlaps(m,m1,s),m1 in M)}: od: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: normal(add(subs(var,C[m]),m in M)): end: #GJGFst(A,M,s,t): inputs an alphabet A={a1,..., ak}, say, and set of words, M, that are minimal, and symbols s and t, and outputs #the rational function in s and t whose coefficient of s^n is the number of words #in the alphabet A of length n with r occurrences of the members of M as COSECUTIVE subwords. Try: #GJGFst({1,2},{[1,1,1],[2,2,2]},x,t); GJGFst:=proc(A,M,s,t) local gu,a: gu:=CGFst(M,s,t): normal(1/(1-nops(A)*s-gu)): end: #SeqGJGFst(A,M,t,N): the first N terms of the weight enumerator of words of length n according to the weight t^(number of occurrenes of members of M #as consecutive subwords) #Try: #SeqGJGFst({1,2},{[1,1,1],[2,2,2]},t,5); SeqGJGFst:=proc(A,M,t,N) local gu,s,i: gu:=GJGFst(A,M,s,t): gu:=taylor(gu,s=0,N+1): [seq(expand(coeff(gu,s,i)),i=1..N)]: end: ##end st ##start with s only t=0 #CGFs(M,s): the cluster generating function with a set of words M according to weight s^lentgh(word) and t for keep track #of number of occurrences of members of M. Try #CGFs({{[1,1,1],[0,0,0],[1,0,1]},s); CGFs:=proc(M,s) local eq,var,C,m,m1,i1: var:={seq(C[m],m in M)}: eq:={}: for m in M do eq:=eq union {C[m]+s^nops(m)+add(C[m1]*Overlaps(m,m1,s),m1 in M)}: od: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: normal(add(subs(var,C[m]),m in M)): end: #GJGFs(A,M,s): inputs an alphabet A={a1,..., ak}, say, and set of words, M, that are minimal, and symbol s , and outputs #the rational function in s whose coefficient of s^n is the number of words avoiding the members of M as consecutive subwords GJGFs:=proc(A,M,s) local gu,a: gu:=CGFs(M,s): normal(1/(1-nops(A)*s-gu)): end: #SeqGJGFs(A,M,N): the first N terms of the sequence enumerating words of length n that avoid the members of M as consecutive subwords #Try: #SeqGJGFs({1,2},{[1,1,1],[2,2,2]},5); SeqGJGFs:=proc(A,M,N) local gu,s,i: gu:=GJGFs(A,M,s): gu:=taylor(gu,s=0,N+1): [seq(coeff(gu,s,i),i=1..N)]: end: ##end st #GFpat(pi,x,n,t): the generating function in x[1], ..., x[n], of all words in {1, ...,n} according to the weigt #t^(number of occurences of the consecutive pattern pi. Try #GFpat([1,2,3],x,5,t); GFpat:=proc(pi,x,n,t) local k,A,gu,M,i,gu1,i1: A:={seq(i,i=1..n)}: k:=nops(pi): gu:=choose(n,k): M:={seq([seq(gu1[pi[i1]],i1=1..k)],gu1 in gu)}: GJGFxt(A,M,x,t): end: #IsSymm(P,x,n): inputs a polynomial P in x[1], ..., x[n], decides whether it is symmetric. Try #IsSymm(x[1]+x[2]+x[3],x,3); IsSymm:=proc(P,x,n) local i: for i from 1 to n-1 do if normal(subs({x[i]=x[i+1],x[i+1]=x[i]},P)-P)<>0 then RETURN(false): fi: od: true: end: #Images1(L): all the images of the vector L under permutations. Try #Images1([2,1,0,0]); Images1:=proc(L) local i,n,gu,pi: n:=nops(L): gu:=permute(n): {seq([seq(L[pi[i]],i=1..n)], pi in gu)}: end: #mL(L,x,n): Inputs a partition L, a symbol x, and a positive integer m, outputs the monomial symmetric function m_L(x[1], ..., x[n]); #Try: #mL([2,1],x,4); mL:=proc(L,x,n) local L1,gu,gu1,i: if nops(L)>n then RETURN(0): fi: L1:=[op(L),0$(n-nops(L))]: gu:=Images1(L1): add(mul(x[i]^gu1[i],i=1..n),gu1 in gu): end: #KickZ(L): kicks out the zeros from the list L KickZ:=proc(L) local i: for i from 1 to nops(L) while L[i]<>0 do od: [op(1..i-1,L)]: end: #PtoM(P,x,n,M): expresses a symmetric polynomial, P, of x[1], ..., x[n] in terms of the Mononomial symmetric functions. Try #PtoM(x[1]+x[2],x,2,M); PtoM:=proc(P,x,n,M) local gu,P1,L,i,lu,c: if not IsSymm(P,x,n) then RETURN(FAIL): fi: P1:=expand(P): if type(P1,numeric) then RETURN(P1): fi: if P1=0 then RETURN(0): fi: if not type(P1,`+`) then L:=sort([seq(degree(P1,x[i]),i=1..n)]): c:=normal(P1/mL(L,x,n)): if not type(c,numeric) then RETURN(FAIL): else RETURN(c*M[op(L)]): fi: fi: gu:=0: while P1<>0 and type(P1, `+`) do lu:=op(1,P1): L:=[seq(degree(lu,x[i]),i=1..n)]: c:=normal(lu/mul(x[i]^L[i],i=1..nops(L))): L:=KickZ(sort(L,`>`)): gu:=gu+c*M[op(L)]: P1:=P1-c*mL(L,x,n): od: if P1=0 then RETURN(gu): fi: if not type(P1,`+`) then L:=KickZ(sort([seq(degree(P1,x[i]),i=1..n)],`>`)): c:=normal(P1/mL(L,x,n)): if not type(c,numeric) then RETURN(FAIL): else RETURN(gu+c*M[op(L)]): fi: else RETURN(gu): fi: end: #Mist(Setpi,n): the set of mistakes implied for n letters from Setpi Mist:=proc(Setpi,n) local k,A,gu,M,i,gu1,i1,pi: A:={seq(i,i=1..n)}: M:={}: for pi in Setpi do k:=nops(pi): gu:=choose(n,k): M:=M union {seq([seq(gu1[pi[i1]],i1=1..nops(pi))],gu1 in gu)}: od: M: end: #GFpats(Setpi,x,n,t): the generating function in x[1], ..., x[n], of all words in {1, ...,n} according to the weigt #t^(number of occurences of the consecutive pattern pi in Setpi). Try #GFpats({[1,2,3],[1,3,2]},x,5,t); GFpats:=proc(Setpi,x,n,t) local k,A,gu,M,i,gu1,i1,pi: A:={seq(i,i=1..n)}: M:={}: for pi in Setpi do k:=nops(pi): gu:=choose(n,k): M:=M union {seq([seq(gu1[pi[i1]],i1=1..nops(pi))],gu1 in gu)}: od: GJGFxt(A,M,x,t): end: #convert the denominator of the result of GFpats to a list, according to the i in m[1$i], beginning from i=0 to i=n. #Try DL({[1,2,3]},x,6,t); DL:=proc(Setpi,x,n,t) local L,i,m: option remember: L:=[seq(factor(coeff(SPtoM(denom(GFpats(Setpi,x,n,t)),x,n,m),m[1$i])),i=0..n)]: if L[1]=-1 then L:=[seq(-L[i],i=1..nops(L))]: fi: L: end: with(gfun): #conjectures a generating function for the denominator of GFpats({[1,2,3]},x,n,t) (the numerator is 1) ConjG:=proc(x,t) : guessgf(DL({[1,2,3]},x,8,t),x): end: #CGFxt1(M,x,t): the explicit expressions for C[m] with a set of mistakes M. Try: #CGFxt1({{[1,1,1],[0,0,0],[1,0,1]},x,t); CGFxt1:=proc(M,x,t) local eq,var,C,m,m1,i1: var:={seq(C[m],m in M)}: eq:={}: for m in M do eq:=eq union {C[m]-(t-1)*mul(x[m[i1]],i1=1..nops(m))-(t-1)*add(C[m1]*Overlapx(m,m1,x),m1 in M)}: od: var:=solve(eq,var): end: #IncStory(r,m,R,t): the story of the increasing pattern 1...r by doing it from r letters to R letters. Try #IncStory(3,m,6,t); IncStory:=proc(r,m,R,t) local gu,n,i,x: print(`These are the generating function enumerating words in the alphabet {1, ...n} from n=`, r, `to n= `, R): print(`according to the occurrence of the CONSECUTIVE pattern`, cat(seq(i,i=1..r)) ): print(`For any partition lambda, m[lambda], is the monomial symmetric function associated to lambda`): print(``): print(`Hopefully we can detect a pattern. `): for n from r to R do gu:=GFpats({[seq(i,i=1..r)]},x,n,t) : print(`when n=`, n, ` we have `): print(numer(gu)/SPtoM(denom(gu),x,n,m)): od: end: