##EXAMPLE TEMPLATE CALCULATION## #Suppose P=p_1p_2...p_t and B=b_1b_2...b_t and T=(P,B). To use this code to find R_{n,T} input the following into Maple: #fit_multi_template(n,{[[p_1,p_2,...,p_t],[b_1,b_2,...b_t]]}). #If Q=q_1q_2...q_t and C=c_1c_2...c_t and T2={(P,B),(Q,C)}. To find R_{n,T2}, input the following into Maple: #fit_multi_template(n,{[[p_1,p_2,...,p_t],[b_1,b_2,..,b_t]],[[q_1,q_2,...,q_t],[c_1,c_2,...,c_t]]}) with(combinat): Help:=proc() print(`Bn(n), all_parts(n,list), most_parts(n,list), some_parts(n,list), fit_template(n,diagram), fit_multi_template(n,diagram_set)`): print(`WhichAvoided(Perms,n)`) end: Bn:=proc(n) local b1,b2,B1,B2,i,B: option remember: if n=0 then RETURN({[]}): fi: if n=1 then RETURN({[1]}): fi: B:={}: for i from 1 to n do B1:=Bn(i-1): B2:=Bn(n-i): for b1 in B1 do B1:= (B1 minus {b1}) union {b1 + [1$(i-1)]}: #print(B1): od: for b2 in B2 do B2:= (B2 minus {b2}) union {b2 + [i$(n-i)]}: #print(B2): od: B:= B union {seq(seq([op(b1),1,op(b2)],b1 in B1),b2 in B2)}: od: RETURN(B): end: #all_parts inputs an integer n and a binary list. It outputs the set of integer partitions of n where part i is 0 or 1 if list[i] is 0 and any integer if list[i] is 1. all_parts:=proc(n,list) local m,S,S1,s1,i: option remember: m:=nops(list): if n=0 then RETURN({[0$m]}): fi: S:={}: S1:=all_parts(n-1,list): for s1 in S1 do if m>1 then for i from 2 to m-1 do if not (list[i]=0 and s1[i]=1) then S:=S union {[op(1..i-1,s1),s1[i]+1,op(i+1..m,s1)]}: fi: od: if not (list[1]=0 and s1[1]=1) then S:= S union {[s1[1]+1,op(2..m,s1)]}: fi: if not (list[m]=0 and s1[m]=1) then S:= S union {[op(1..m-1,s1),s1[m]+1]}: fi: else if not (list[1]=0 and s1[1]=1) then S:=S union {[s1[1]+1]}: fi: fi: od: RETURN(S): end: #most_parts returns the subset of all_parts in which all parts are strictly less than n most_parts:=proc(n,list) local base, b, i, m: base:=all_parts(n,list): m:=nops(list): for b in base do for i from 1 to m do if b[i] = n then base:=base minus {b}: fi: od: od: base: end: #some_parts returns the subset of all_parts in which every part which can only take on binary values takes on the value 1 some_parts:=proc(n,list) local base, b, i, m: base:=all_parts(n,list): m:=nops(list): for b in base do for i from 1 to m do if b[i] = 0 and list[i] = 0 then base:=base minus {b}: fi: od: od: base: end: fit_template:=proc(n,diagram) local d1,d2,m,S,s1,i,j,S1,d1new,parts,part,ad: option remember: if n=0 then RETURN({[]}): fi: if n=1 then RETURN({[1]}): fi: d1:=diagram[1]: d2:=diagram[2]: m:=nops(d1): if m=1 then RETURN(permute(n)): fi: parts:=some_parts(n,d2): S:={}: for part in parts do d1new:=[1$m]: for i from 1 to m do for j from 1 to m do if d1[j]