Help:=proc(): print(`fAFxt(A,F,x,t),EqAFxt(A,F,x,t,B), Chop(F,a)`): end: #fAFxt(A,F,x,t,B):Inputs an alphabet A, and a set of #words (given as lists of any length) in that alphabet #A, and outputs the generating function in the x[a]'s #(a in A) whose coeff. of x[a]^m[a]*x[b]^m[b]*t^n ... #is exactly the number of words in the alphabet #A avoiding (in the strong sense) with m[a] a's #m[b] b's etc. of length n fAFxt:=proc(A,F,x,t) local eq,var,B,ToDoSet,f,slava, AlreadyDone: eq:={}: var:={}: ToDoSet:={F}: AlreadyDone:={}: while ToDoSet<>{} do f:=ToDoSet[1]: AlreadyDone:=AlreadyDone union {f}: var:=var union {B[f]}: slava:=EqAFxt(A,f,x,t,B): eq:=eq union {slava[1]}: ToDoSet:=ToDoSet union slava[2] minus AlreadyDone: od: normal(subs(solve(eq,var),B[F])): end: #EqAFxt(A,F,x,t,B):Inputs an alphabet A, and a set of #words (given as lists of any length) in that alphabet #A, and outputs the equation corresponding to #fAFxt(A,F,x,t) in terms of other such (and itself) #followed by the set of (possibly) new guys EqAFxt:=proc(A,F,x,t,B) local F1,a, avital,NewGuys: if member([],F) then RETURN(B[F],{}): fi: avital:=B[F]-1: NewGuys:={}: for a in A do F1:=Chop(F,a): avital:=avital-B[F1]*t*x[a]: NewGuys:=NewGuys union {F1}: od: avital, NewGuys minus {F}: end: #inputs a set of words and a letter a #outputs the set that chops the last letter #of each of the curse words if they happen #to end with a, otherwise, it leaves them alone Chop:=proc(F,a) local f,S: S:={}: for f in F do if f[nops(f)]=a then S:=S union {[op(1..nops(f)-1,f)]}: else S:=S union {f}: fi: od: S: end: