print(` Version of Feb 2005`): print(`This package is prepared for using the Gouden-Jackson for the two`): print(`dimensional case.`): print(`Suppose we are using the alphabet {1,2,3...d} to fill out a `): print(`an rectangle, whose one side has fixed length m,`): print(`Then try to find the generationg function of the # of the rectangles `): print(`which avoiding some patterns in vertical, horizontal, and two crossed diagonals`): print(`Written by Xiangdong Wen and Doron Zeilberger.`): print(`For general help, and a list of the available functions,`): print(` type ezra();. For specific help type ezra(procedure_name) `): lprint(``): ezra:=proc() if args=NULL then print(`Contains Procedures: `): print(` AllAlphaBeta,AllMistakes`): print(` For specific help type ezra(procedure_name) `): fi: if nops([args])=1 and op(1,[args])=`AllMistakes` then print(`AllMistakes(m,pattern,d) gives all the mistakes`): print(`for the letters 1,2...d. and fixed word length m `): print(`avoiding the given pattern`): print(`For example to get all the mistakes that for the alphabeta {1,2,3}`): print(`length of word is 2, avoiding [1,1]`): print(`AllMistakes(2,[1,1],3) `): fi: if nops([args])=1 and op(1,[args])=`AllAlphaBeta` then print(`AllAlphaBeta(m,pattern,d) gives the BIGalphabeta`): print(`for the letters 1,2...d. and fixed word length m `): print(`avoiding the given pattern`): print(`For example to get the BIGalphabeta that for the alphabeta {1,2,3}`): print(`length of word is 2, avoiding [1,1]`): print(`AllAlphaBeta(2,[1,1],3) `): fi: end: ###################################################################### #gives all possible length n with letters 1..d: AllPermute:=proc(d,n) local i,A,j,answer: answer:=[]: if n<=0 then return ([[]]):fi: A:=AllPermute(d,n-1): for i from 1 to d do for j from 1 to nops(A) do answer:= [op(answer), [op(op(j,A)),i]]: od: od: answer: end: ###################################################################### ###CollectMistakes_0(2,[2,2],2); ######vertical line mistakes CollectMistakes_0:=proc(m,pattern,d) local i,j,k,l,answer,A,B; answer:={}: l:=nops(pattern): A:=AllPermute(d,m-l): if l>m then return({}): fi: if l=m then return({pattern}): fi: for i from 0 to m-l do k:=i+1; for j from 1 to nops(A) do B:=op(j,A): answer:=answer union {[op(1..i,B),op(pattern),op(k..nops(B),B)]}: #, od: od: answer: end: ###################################################################### ###CollectMistakes_1(2,[2,2],2); ###horizental line mistakes CollectMistakes_1:=proc(m,pattern,d) local i,j,k,l,answer,A,B,C,t,begin1,end1,begin2,end2; answer:={}: l:=nops(pattern): A:=AllPermute(d,(m-1)*(l)): for i from 0 to m-1 do for j from 1 to nops(A) do B:=[]: C:=op(j,A); for t from 1 to l do begin1:=1+(t-1)*(m-1); end1:=i+(t-1)*(m-1); begin2:=end1+1; end2:=(t)*(m-1); B:=[op(B),[op(begin1..end1, C),op(t,pattern),op(begin2..end2,C)]] od: answer:=answer union {B}: od: od: answer: end: ###################################################################### ###CollectMistakes_2(2,[2,2],2); ###\\ diagonal mistakes CollectMistakes_2:=proc(m,pattern,d) local i,j,k,l,answer,A,B,C,t,begin1,end1,begin2,end2; answer:={}: l:=nops(pattern): A:=AllPermute(d,(m-1)*(l)): for i from 0 to m-l do for j from 1 to nops(A) do B:=[]: C:=op(j,A); for t from 1 to l do begin1:=1+(t-1)*(m-1); end1:=i+(t-1)*(m-1)+t-1; begin2:=end1+1; end2:=(t)*(m-1); B:=[op(B),[op(begin1..end1, C),op(t,pattern),op(begin2..end2,C)]] od: answer:=answer union {B}: od: od: answer: end: ###################################################################### ###CollectMistakes_3(2,[2,2],2); ###//diagonal mistakes CollectMistakes_3:=proc(m,pattern,d) local i,j,k,l,answer,A,B,C,t,begin1,end1,begin2,end2; answer:={}: l:=nops(pattern): A:=AllPermute(d,(m-1)*(l)): for i from 0 to m-l do for j from 1 to nops(A) do B:=[]: C:=op(j,A); for t from 1 to l do begin1:=1+(t-1)*(m-1); end1:=i+(t-1)*(m-1)+l-(t); begin2:=end1+1; end2:=(t)*(m-1); B:=[op(B),[op(begin1..end1, C),op(t,pattern),op(begin2..end2,C)]] od: answer:=answer union {B}: od: od: answer: end: IsFactor:=proc(small,big) local i,j,k,s: s:=op(small): for i from 1 to nops(big) do if s=op(i,big) then return(true): fi: od: false: end: ###gives all the mistakes AllMistakes:=proc(m,pattern,d) local i,j,k,M0,M1,M2,M3,All,isfactor; M1:=CollectMistakes_1(m,pattern,d): M2:=CollectMistakes_2(m,pattern,d): M3:=CollectMistakes_3(m,pattern,d): All:={}: for i from 1 to nops(M1) do isfactor:=false: for j from 1 to nops(M0) do if IsFactor(op(j,M0),op(i,M1)) then isfactor:=true: break:fi: od: if not isfactor then All:=All union {op(i,M1)}: fi: od: return (All): end: ###gives d^m - 1_dim mistakes AllAlphaBeta:=proc(m,pattern,d) local A: A:={op(AllPermute(d,m))}: A:=A minus CollectMistakes_0(m,pattern,d): A: end: