# compute HL polynomial in n variables: gensym(n);comphl1([partition]); #read "N:/My Documents/soft/alcoves/hall-litt-a.txt": with(combinat); Perm2Length:=proc(p) local i,j,l; l:=0; for i from 1 to nops(p)-1 do for j from i+1 to nops(p) do if p[j]
w[p[2]] then true else false fi;
end;
rev:=proc(s) local i; [seq(s[nops(s)+1-i],i=1..nops(s))] end;
tr:=proc(p,t) local aux,p1;
p1:=p;aux:=p1[t[1]];p1[t[1]]:=p1[t[2]];p1[t[2]]:=aux;p1
end;
#ll[1] limit in chain of perms;ll[2] height of column; typical [[0,0],[4,2],[7,1]] for [[1,4],[1,3][2,4],[2,3],[1,4],[1,3],[1,2]]
#returns list of tableaux for each folding plus related parameters
fold:=proc(lc,w,ll) local i,j,ww,lfld,lw,llw,fld,ready,lt,t,w1,k,kk;
#print(lc,w,ll);
lfld:=[[]];ww:=w;llw:=[[w]];
i:=1;lw:=[w];fld:=[];ready:=false;
while not ready do
if i<=nops(lc) then
if decl(ww,lc[i]) then
ww:=tr(ww,lc[i]);
lw:=[op(lw),ww];
fld:=[op(fld),i];lfld:=[op(lfld),fld];llw:=[op(llw),lw];
fi;
i:=i+1;
fi;
if i>nops(lc) then
if fld=[] then ready:=true
else
i:=fld[-1]+1;fld:=subsop(-1=NULL,fld);lw:=subsop(-1=NULL,lw);
ww:=lw[-1];
fi
fi;
od;
#print(lfld);
lt:=[];
for i from 1 to nops(lfld) do
t:=[];fld:=lfld[i];kk:=0;w1:=w;lw:=llw[i];
for j from 1 to nops(ll)-1 do
t:=[op(t),[seq(w1[k],k=1..ll[j+1][2])]];
while (kk+1<=nops(fld)) and (fld[kk+1]<=ll[j+1][1]) do kk:=kk+1 od;
if kk<=nops(fld) then w1:=lw[kk+1] fi;
od;
lt:=[op(lt),[t,Perm2Length(lw[-1]),nops(fld)]];
od;
#print(`----`,lt);
lt;
end;
#USE tab();
#lam as [2,1,1,0];
comphl1:=proc(lam) local lam1,lc,ll,n,i,hl,j,lt,k,nhl,r,lpt;global bc,sbc;
n:=nops(lam);lam1:=cnjpart(lam);
r:=lch(lam1,n);lc:=r[1];ll:=r[2];
#print(lc,ll);
hl:=array(1..80000);nhl:=0;lpt:=table();
for i from 1 to nops(bc) do
j:=1;while (j<=n-1) and ((lam[j]<>lam[j+1]) or (bc[i][j] 1 then i:=i-1 else
if j>1 then j:=j-1;i:=p[j] else i:=0;j:=0 fi
fi;
[i,j];
end;
stat:=proc(tt) local s,n,i,j,k;
n:=0;
for i from 1 to nops(tt)-1 do
for j from 1 to nops(tt[i+1]) do
if tt[i][j]<>tt[i+1][j] then n:=n+1 fi
od
od;
s:=(1-t)^n;
n:=0;
for i from 1 to nops(tt) do
for j from 1 to nops(tt[i])-1 do
for k from j+1 to nops(tt[i]) do
if (tt[i][j]>tt[i][k]) and ((i=nops(tt)) or (k>nops(tt[i+1])) or (tt[i][j]tt[i+1][j] then n:=n+1 fi
od
od;
s:=(1-t)^n;
n:=0;
for i from 1 to nops(tt) do
for j from 1 to nops(tt[i])-1 do
for k from j+1 to nops(tt[i]) do
if (tt[i][j]>tt[i][k]) and ((i=nops(tt)) or (k>nops(tt[i+1])) or (tt[i][j][0,0] do
ct[cp[2]][cp[1]]:=la[-1][1];la[-1]:=subsop(1=NULL,la[-1]);
cp1:=nxt(p1,cp);poss:=true;la1:=[];
while cp1<>[0,0] and poss do
adm:={seq(ct[cp1[2]][i],i=1..cp1[1]-1)};
if cp1[2]>1 then pp:=ct[cp1[2]-1][cp1[1]];adm:=adm union {seq(ct[cp1[2]-1][i],i=1..cp1[1]-1)} else pp:=1 fi;
adm:={seq(i,i=pp..n)} minus adm;
if nops(adm)>0 then
ct[cp1[2]][cp1[1]]:=adm[1];adm:=subsop(1=NULL,adm);la1:=[op(la1),adm];
cp1:=nxt(p1,cp1);
else poss:=false;
fi;
od;
if poss then
la:=[op(la),op(la1)];
lt:=[op(lt),ct];
cp:=[p1[-1],nops(p1)];
else
cp:=prev(p1,cp);la:=subsop(-1=NULL,la);
fi;
while cp<>[0,0] and la[-1]={} do la:=subsop(-1=NULL,la);cp:=prev(p1,cp) od;
od;
hhl:=array(1..800000);nhhl:=0;lpt:=table();
for i from 1 to nops(lt) do
ct:=ordtab(conjtab(rev(lt[i])));
k:=lpt[op(ct)];s:=stat(lt[i]);
if op(0,k)<>`Integer` then
nhhl:=nhhl+1;
if nhhl mod 2000=0 then print(nhhl) fi;
lpt[op(ct)]:=nhhl;
hhl[nhhl]:=[s,ct]
else hhl[k][1]:=expand(hhl[k][1]+s)
fi;
od;
err:=[];
if nhl=nhhl then
for i from 1 to nhl do
k:=lpt[op(hl[i][2])];
if op(0,k)<>`Integer` then ERROR(`--- element not found`,hl[i][2])
else if expand(hhl[k][1]-hl[i][1]*den)<>0 then err:=[op(err),[factor(hl[i][1]),factor(hhl[k][1]),hl[i][2]]] fi
fi
od
else ERROR(`different number of terms`);
fi;
print(`***`,err);
end;
#example of running: gensym(5);comphlred([3,2,2,0,0]);genhhl([3,2,2],5); - need to get [] in both cases as "error terms"
print(`for Maple 9,10; run gensym first`);