##################################################################### ##PWilfCases.txt: Save this file as PWilfCases.txt. # #To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read `PWilfcases.txt` : s[1][2] then if s[2][2]<>1 then RETURN(FAIL): else RETURN(a123(n-1,[[s[1][1]-1],[s[2][1]]])): fi: else if s[1][1]<>1 then RETURN(FAIL): else RETURN(s[2][2]/(s[2][2]-1)*a123(n-1,[[s[1][2]-1],[s[2][2]-1]])): fi: fi: end: #A123(n): The sum of CFO for 123-avoding permutations of length n. Try: #A123(10): A123:=proc(n) local gu,gu1: option remember: gu:=All1a(n): add(a123(n,gu1), gu1 in gu): end: #End 123-avoiding #Start 123 and 132 -avoiding ez:=proc(): print(`All1b(n), Childb(n,s), b123132(n,s), B123132(n) `): end: #All1b(n): all the bi-suffixes of 123-avoiding permutations. Try #All1b(7); All1b:=proc(n) local i: {seq([[i],[i]],i=1..n)}: end: #Childb(n,s): all the kids of suffix s for permutations of length n avoiding 123. Try: #Childb(7,[[1],[1]]); Childb:=proc(n,s) local i: if not member(s,All1b(n)) then RETURN(FAIL): fi: if s=[[1],[1]] then RETURN({seq([[i,1],[i-1,1]],i=2..n)}): else RETURN({[[1,s[1][1]],[1,s[2][1]]]}): fi: end: #B123132(n): The sum of CFO for 123-avoding permutations of length n. Try: #B123132(10): B123132:=proc(n) local gu,gu1: option remember: gu:=All1b(n): add(b123132(n,gu1), gu1 in gu): end: #b123132(n,s): the contribution from suffix s b123132:=proc(n,s) local lu,lu1: option remember: if n=1 then if s=[[1],[1]] then RETURN(1): else RETURN(0): fi: fi: if nops(s[1])=1 then lu:=Childb(n,s): RETURN(add(b123132(n,lu1),lu1 in lu)): fi: if s[1][1]>s[1][2] then if s[2][2]<>1 then RETURN(FAIL): else RETURN(b123132(n-1,[[s[1][1]-1],[s[2][1]]])): fi: else if s[1][1]<>1 then RETURN(FAIL): else RETURN(s[2][2]/(s[2][2]-1)*b123132(n-1,[[s[1][2]-1],[s[2][2]-1]])): fi: fi: end: #End 123 and 132 -avoiding #123 and 231 avoding ez:=proc(): print(`All1c(n), Childc(n,s), c123231(n,s), C123231(n) `): end: #All1c(n): all the bi-suffixes of 123-avoiding permutations. Try #All1c(7); All1c:=proc(n) local i: {seq([[i],[i]],i=1..n-1),seq([[i],[1]],i=1..n-1),[[n],[n]]} end: #Childc(n,s): all the kids of suffix s for permutations of length n avoiding 123. Try: #Child(7,[[1],[1]]); Childc:=proc(n,s): if not member(s,All1c(n)) then RETURN(FAIL): fi: if s=[[1],[1]] then RETURN({[[2,1],[1,1]]}): fi: if s[1]=s[2] then RETURN({[[1,s[1][1]],[1,s[2][1]]]}): else if s[2][1]<>1 then RETURN(FAIL): elif s=[[n-1],[1]] then RETURN({[[n,n-1],[n-1,1]]}): else RETURN({[[s[1][1]+1,s[1][1]],[s[1][1],1]],[[s[1][1]+1,s[1][1]],[1,1]]}): fi: fi: end: #C123231(n): The sum of CFO for 123-avoding permutations of length n. Try: #C123231(10): C123231:=proc(n) local gu,gu1: option remember: gu:=All1c(n): add(c123231(n,gu1), gu1 in gu): end: #c123231(n,s): the contribution from suffix s c123231:=proc(n,s) local lu,lu1: option remember: if n=1 then if s=[[1],[1]] then RETURN(1): else RETURN(0): fi: fi: if nops(s[1])=1 then lu:=Childc(n,s): RETURN(add(c123231(n,lu1),lu1 in lu)): fi: if s[1][1]>s[1][2] then if s[1][1]-s[1][2]<>1 then RETURN(FAIL): else RETURN(c123231(n-1,[[s[1][1]-1],[s[2][1]]])): fi: fi: if s[1][1]<>1 then RETURN(FAIL): else RETURN(s[2][2]*c123231(n-1,[[1],[1]])): fi: end: