%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Physical background}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

$x_i$ : position de la particule i
lambda_i: position initiale de la particule i

Example trivial de problème à $n$ corps intégrable:
Yang, potentiel \sum \delta(x_i-x_j)

Trivial en non quantique; y'a du boulot en quantique (Les équations de
Yang-Baxter viennent de là).

Calogero model: tout premier example de problème à $n$ corps
intégrable à une dimension:

M(t) = D(lambda_1,...,lambda_n) + t* [[0,1,1],[1,0,1],[1,1,0]]
     = U(t) D(x_1(t) ... x_n(t)) U(t)^-1

Il se trouve (long calcul pénible) que ça correspond à des particules
qui satisfont le potentiel \sum 1/(x_i-x_j)^2.

On peut rajouter sans soucis \sum x_i^2 au potentiel pour éviter que
les particules partent à l'infini (bidule harmonique).

On sait le résoudre, et c'est la projection (non linéaire) d'un
système simple (linéaire) en n^2 dimension projeté en n dimension.

A partir de M(t) on peut calculer les intégrales premières.

\begin{definition}
  Particules sans spin: la fonction d'onde est à valeur dans \C.
  
  Particules avec spin s: la fonction d'onde est à valeur dans espace
  vectoriel de dimensions 2s+1 sur \C (on l'identifie à \C_2s[X,Y]
  pour obtenir une représentation irréductible de SU(2)).
\end{definition}

Sans spin, l'espace de toutes les fonctions d'ondes possibles de
chaque particule est L^2(R,\C) (on prends L^2 pour avoir un espace de
Hilbert). Pour plusieurs particules on prends les produits tensoriels
de ces espaces.

Objectif: généralisation de Calogero au cas quantique. Cela revient à
transformer le Hamiltonien en un opérateur. Le problème a été résolu
par Calogero ou quelqu'un proche dans le cas sans spin (pas
d'interaction des moments magnétiques).

Comme on a des particules identiques, on peut faire agir S_n sur le
produit tensoriel. Il se trouve que les transpositions t_{j,k}
modélise raisonnablement l'interaction des moments magnétiques.
L'intérêt, c'est que on a des interactions longues distances (entre
particules j et k éloignées.

Cela revient à rajouter \sum h_{j,l} t_{j,k} au Hamiltonien.

Il se trouve que l'on peut décomposer le problème entre celui sans
interaction des moments, et celui avec juste \sum h_{j,l} t_{j,k}
comme Hamiltonien pur. Donc maintenant, les particules sont fixées; on
est à l'équilibre pour le modèle quantique standard de Calogero.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Random notes and comments}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Associated Hermite polynomials (specializes at c=0 on the Hermite polynomials):

\begin{displaymath}
  H_{n+1}^c = 2x H_n^c - 2(n+c) H_{n-1}^c
\end{displaymath}

Relations between the roots of the Hermite polynomials:

\begin{displaymath}
  a_1 = \sum_{1<i} \frac1{(a_1-a_i)}
\end{displaymath}

Alain: look at the logarithmic derivative $f'(x)/f(x)$ of the Hermite
polynomials to try to obtain a nice expression for \sum_{i<j}
\frac{s_{i,j}}{(x_i-x_j)^2}.

    H_n = \sum_{i<j} \sigma_{i,j} /(x_i-x_j)^2

Idea: look for the lagrangian operators. In
$K[x_1,\dots,x_n]/(e_i(x_1,\dots,x_n)=e_i(\alpha_1,\dots,\alpha_n)$,
those lagrangians interpolation operators $X_\sigma$ are characterized
by: $x_i X_\sigma = \alpha_{\sigma(i)} X_\sigma$

(find again the formula by using the fact that
$\prod_j(x_i-\alpha_\sigma_j) = 0$).


Est-ce que l'algèbre du groupe symmétrique est stable par
multiplication par le commutant. Sinon, est-ce que l'on peut retrouver
l'action sur les permutations via un projecteur qui va bien.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{The Hecke-SymmetricGroup algebra}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{conjecture}
  dimension = a_n # pairs of permutations without common descents
\end{conjecture}

Numériquement: vérifié par Florent pour $n\leq 6$

\begin{proposition}
  The products p_\tau s_\sigma are linearly independant
\end{proposition}
\begin{proof}
  Take a basis of V by ordering the permutations lexicographically (or
  by any order which extends the permutohedron order by action on
  position).
  
  Consider the matrix $M:=(M_{s,t})$ of the operator $pi_\tau
  s_\sigma$. Take the smallest $s$ such that the row of $M$ indexed by
  $s$ is non zero. Then, $\tau=s$. Consider the group $G$ generated by
  the $pi_i$'s, where $i$ runs through the descents of $\tau$. Then,
  the coefficients $1$ in the row correspond to the permutations in $G
  \sigma$, and $\sigma$ is the unique permutation in those which has
  no reculs in common with the descents of $\tau$; it's also the
  lexicographically smallest one.
\end{proof}

Experimental evidence:

The rewriting rules as implemented do terminate, and allow to rewrite
any product of pi_i's and s_i's as a linear combination of pi_tau s_sigma.

\begin{Mexin}
export(combinat): export(experimental::HeckeSymmetricGroupAlgebraTools):
H:=experimental::HeckeSymmetricGroupAlgebra(3):
H::printTerm := H::printTermReducedWords:
p:=()->H([permutations::fromReducedWord([args()], H::N), [$1..H::N]]):
s:=()->H([[$1..H::N], permutations::fromReducedWord([args()], H::N)]):
\end{Mexin}

Consider a term pi_tau' s_sigma' in the expansion of pi_tau s_sigma pi_i.
If length(sigma') > length(sigma) then length(tau') > length(tau).
Checked for n<=5:
\begin{Mexin}
H:=experimental::HeckeSymmetricGroupAlgebra(5):
for x in H::basisIndices() do
    l1 := permutations::inversionsNumber(x[1]);
    l2 := permutations::inversionsNumber(x[2]);
    x := H::term(x);
    for i from 1 to H::N -1 do
        for t in H::support(x*p(i)) do
            prog::test(bool(permutations::inversionsNumber(t[2]) <= l2 or
		            permutations::inversionsNumber(t[1]) >  l1));
	end;
    end
end
\end{Mexin}

Assume furthermore that the reduced word entries of sigma are included
in those of tau. Then the same holds for all terms pi_tau' s_sigma' in
the product pi_tau s_sigma pi_i such that length(sigma') > length(sigma).
Checked from n <= 5:
\begin{Mexin}
H:=experimental::HeckeSymmetricGroupAlgebra(5):
H::printTerm := H::printTermReducedWords:
for x in H::basisIndices() do
    [tau, sigma] := x;
    ltau   := permutations::inversionsNumber(tau);
    lsigma := permutations::inversionsNumber(sigma);
    if not _subset({op(permutations::reducedWord(sigma))},
                   {op(permutations::reducedWord(tau))}) then
        next;
    end;
    x := H::term(x);
    //print(x);
    for i from 1 to H::N -1 do
	//print(x, i, x*p(i));
        for t in H::support(x*p(i)) do
            [taup, sigmap] := t;
            ltaup   := permutations::inversionsNumber(taup);
            lsigmap := permutations::inversionsNumber(sigmap);
            if lsigmap <= lsigma then next; end_if;
            prog::test(bool(_subset({op(permutations::reducedWord(sigmap))},
                                    {op(permutations::reducedWord(taup))})));
	end;
    end
end:
\end{Mexin}
Related remark: assume that the reduced word entries of sigma are
included in those of tau, and consider a product of the form:
	pi_tau' pi_tau s_sigma.
Write the normal form of this product as
	pi_tau'' s_sigma'.
Then, either
	length(tau'') > length(tau')
or
	length(tau'') = length(tau') and sigma'=id.


In any term pi_tau s_sigma' in the product s_sigma pi_i, if
length(sigma') > length(sigma) then length(tau) >= 2.
Checked for n <= 6:
\begin{Mexin}
H:=experimental::HeckeSymmetricGroupAlgebra(4):
H::printTerm := H::printTermReducedWords:
for sigma in permutations(H::N) do
    lsigma := permutations::inversionsNumber(sigma);
    sigma := H::term([[$1..H::N],sigma]);
    for i from 1 to H::N -1 do
	// print(sigma, i, sigma*p(i));
        for t in H::support(sigma*p(i)) do
            [taup, sigmap] := t;
            ltaup   := permutations::inversionsNumber(taup);
            lsigmap := permutations::inversionsNumber(sigmap);
            if lsigmap <= lsigma then next; end_if;
            // prog::test(bool(lsigmap <= lsigma+1)); FALSE!
            prog::test(bool(ltaup >= 2));
	end;
    end
end:
\end{Mexin} %$

Some badly behaved examples:
  p(2,1,3)*s(2,1,3) * p(2) = p(2,1,3,2)*s(3,2,1,2,3)

  p(4,3,4)*s(1,2,3) * p(4) = p(1,4,3,2,4)s(3,2,4,3) + ...

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Studying the representations of HeckeSym}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{remark}
  Dès que $q$ est dans le corps de base.
  
  L'algèbre de Hecke $H_n(q)$ se plonge injectivement dans HeckeSym.
\end{remark}

\begin{remark}
  Il y a un morphisme surjectif de l'algèbre de Hecke affine
  spécialisée à $1,q,\dots,q^{n-1}$ sur HeckeSym.
\end{remark}

Florent n'a pas réussi pour le moment à construire des représentations
irréductibles intéressantes de HeckeSym autres que la naturelle.

\begin{remark}
  pi_omega generates a left ideal of size n!
\end{remark}
Checked for n<=5
\begin{Mexin}
N := 5:
H := experimental::HeckeSymmetricGroupAlgebra(N): H::Name := "H":
p := ()->H([permutations::fromReducedWord([args()], H::N), [$1..H::N]]):
s := ()->H([[$1..H::N], permutations::fromReducedWord([args()], H::N)]):
w:=p(1,2,1,3,2,1,4,3,2,1):
M:=_concat(H::sparseVector(b*w) $ b in map(H::basisIndices(), H::term)):
linalg::rank(M);
\end{Mexin} %$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Finding the algebraic extension containing the coefficients
  of the Hamiltonian}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lemma}
  Let $A=(x_1,\dots,x_n)$ be an alphabet, and $B$ be the alphabet
  ((x_i-x_j)^2_{i<j}). Then the $k$-th symmetric powersum of the
  alphabet $B$ can be expressed from the symmetric functions in $A$
  as:
  \begin{displaymath}
    p_k(B) = (n-1) p_(2k)(A) + \sum_{l=1}^k (-1)^l \binom{2k}{l} m_{2k-l,l}
           = n p_(2k)(A) + \frac12\sum_{l=1}^{2k} (-1)^l \binom{2k}{l} p(2k-l,l)
  \end{displaymath}
\end{lemma}
\begin{proof}
  Expand $(x_i-x_j)^2k$.
\end{proof}
Numerical check:
\begin{Mexin}
S:=examples::SymmetricFunctions():
roots:=[x1,x2,x3,x4]:
for k from 1 to 10 do
    prog::test(iszero(Sym::fromPoly(_plus(poly(t[1]-t[2], roots)^2^k $
				          t in combinat::subwords(roots,2))) -
	       ((nops(roots)-1) * S::m([2*k]) +
                _plus( (-1)^l * binomial(2*k,l) * S::m([2*k-l,l])  $ l = 1 .. k)))):
end:
\end{Mexin}

Application to compute for N=4 a field extension containing the
coefficients of the Hamiltonian without necessarily containing the
roots of the hermite polynomials.

\begin{Mexin}
export(combinat): export(experimental::HeckeSymmetricGroupAlgebraTools):
N:=4:
hermite := orthpoly::hermite(N,x):
p := changeRootsSquareDifferences(orthpoly::hermite(N,x)):
K:=Dom::AlgebraicExtension(Dom::AlgebraicExtension(Dom::Rational, s2^2=2),
			   s3^2=3):
K::Name := "Q(s2,s3)":
// Check that all the roots of p are in K
prog::test(polylib::splitfield(poly(p,K))[1],K):
[ L, roots ] := polylib::splitfield(poly(orthpoly::hermite(N,x), K)):
rootsInL := map([ roots[2*i-1] $i=1..nops(roots)/2 ], L):
hcoeffs := map(table((i,j) = 1 / (rootsInL[i]-rootsInL[j])^2
                     $ i=1..j-1 $j=1..nops(rootsInL)),
               K@expr):

[Kbis, X, is2, is3] :=
    polylib::primitiveElement(Dom::AlgebraicExtension(Dom::Rational, s2^2=2), K):
s := expr((Kbis(X) -is2)/is3):
operators::overloaded::declareConversion
 (K, Kbis, e -> Kbis(subs(expr(e), s2=expr(is2), s3=expr(is3)))):
operators::overloaded::declareConversion
 (Kbis, K, e -> K(subs(expr(e), X=s2+s*s3))):

extendCoeffRingConversion :=
proc(F, G)
    option escape;
    local L;
begin
    L := G::coeffRing;
    proc(x: F) : G
    begin
	G::fromList(map(F::toList(x),
                    t -> [operators::overloaded::convert(t[1],L), t[2]]));
    end_proc:
end_proc:
S := examples::SymmetricGroupAlgebra(N, K):
H := experimental::HeckeSymmetricGroupAlgebra(N, K):
Hbis := experimental::HeckeSymmetricGroupAlgebra(N, Kbis):
operators::overloaded::declareConversion
  (H, Hbis, extendCoeffRingConversion(H, Hbis)):
operators::overloaded::declareConversion
  (Hbis, H, extendCoeffRingConversion(Hbis, H)):

h    := H(hamiltonian(S, hcoeffs)):
hbis := Hbis(h):
setuserinfo(Any,3):
commutant(h, map(H::basisIndices(), H::term));
commutant(Hbis(h), map(Hbis::basisIndices(), Hbis::term));
\end{Mexin} %$

Timings:
     standard N=3  fraction free N=3 fraction free N=4
Expr:0.57 msec
H:   1.40 s     2.3 msec         17000 s
Hbis 1.22 s     1.7 msec         16000 s (4 h)

Another hand building of a splitfield of the hermite polynomials
\begin{Mexin}
N := 5:
hermite := orthpoly::hermite(N,x):
p2 := hermite:
if N mod 2 = 1 then
    p2 := p2/poly(x);
end:
p2 := poly(p2(sqrt(X))):
[K, roots] := polylib::splitfield(p2):
K::Name := "Q(X)":
roots := map([ roots[2*i-1] $i=1..nops(roots)/2 ], K):
L:=K:
knownRoots := table():
rootsInL := [ if N mod 2 = 1 then 0 else null() end ]:
i := 1:
for r in roots do
    if contains(knownRoots, -r) then
	next;
    end;
    knownRoot[r]:=TRUE;
    X := hold(r).i;
    p := poly(X^2,[X],L)-poly(r,[X],L);
    if irreducible(p) then
        oldL:=L;
        L := Dom::AlgebraicExtension(L, p);
	L::Name := oldL::Name."(".X.")";
	i := i+1;
	rootsInL := append(map(rootsInL, L), L(X), L(-X));
    else
	warning("forgotten root"):
    end;
end:
P:=polylib::Poly([x], L):
prog::test(iszero(_mult(P(lcoeff(hermite)), (P(x)-P(r)) $ r in rootsInL) -
                  P(hermite))):
rootsdInL := [(r[1]-r[2])^2 $ r in combinat::subwords::list(rootsInL,2)]:
_mult((P(x)-P((r[1]-r[2])^2)) $ r in combinat::subwords::list(rootsInL,2)):
\end{Mexin}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Commutant of the Hamiltonian inside the symmetric group algebra}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{Mexin}
export(combinat):export(experimental::HeckeSymmetricGroupAlgebraTools):
H:=examples::SymmetricGroupAlgebra(3):
h := hamiltonian(H):
comm := commutant(h, genericElement(H)):
nops(comm[2]);
\end{Mexin}

Conjecture: the commutant is of size binomial(H::N,2)+1;
a basis is given by the sums of all permutations having a fixed number
of inversions. FALSE for n>=4

\begin{Mexin}
permutationsByInversions := table(i=[] $i=0..binomial(H::N,2)):
for p in permutations(H::N) do
    i := permutations::inversionsNumber(p);
    permutationsByInversions[i] := append(permutationsByInversions[i], p)
end:
for i from 0 to binomial(H::N,2) do
    bla := _plus(H::term(p) $ p in permutationsByInversions[i]):
    print(i);
    prog::test(iszero(bla*h-h*bla));
end
\end{Mexin}

for n from 1 to 4 do
H:=examples::SymmetricGroupAlgebra(n):
h := hamiltonian(H):
comm := commutant(h, genericElement(H)):
print(nops(comm[2]));
end;

For n=4, it seems to be much faster to first compute the commutant
(16s), and then to compute the eigen vectors in the commutant (stopped
after a few minutes). In the splitting field of the hermite
polynomial, the computation of the commutant goes down to 4s, and
about 3 seconds for each eigenvalue.

export(combinat): export(experimental::HeckeSymmetricGroupAlgebraTools):
N := 4:
P := orthpoly::hermite(N, X):
[K, roots] := polylib::splitfield(P):
K::Name := "K":
roots := map([ roots[2*i-1] $i=1..nops(roots)/2 ], K):
droots := { (s[1] - s[2])^2 $ s in combinat::subwords(roots,2) }:
S := examples::SymmetricGroupAlgebra(N, K): S::Name := "S":
h := hamiltonian(S, roots):
basis := map(S::basisIndices(), S::term):

// Looking for the commutant algebra
nops((basisCom := commutant(h, basis)));
eigenvalues := [(2*i-binomial(N,2))/2 $ i=0..binomial(N,2)]:
for lambda in eigenvalues do
    fprint(Unquoted, 0, "Eigenvalue ", lambda,
           ", time: ",
           time((basisComEigen[lambda]
                 := commutantByEigenvalue(h, basisCom, lambda)))," ms");
end:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Commutant of the hamiltonian inside the Hecke-Symmetric algebra}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{Mexin}
export(combinat): export(experimental::HeckeSymmetricGroupAlgebraTools):
S:=examples::SymmetricGroupAlgebra(3):
H:=experimental::HeckeSymmetricGroupAlgebra(3):
p:=()->H([permutations::fromReducedWord([args()], H::N), [$1..H::N]]):
s:=()->H([[$1..H::N], permutations::fromReducedWord([args()], H::N)]):
h := H(hamiltonian(S)):

// Looking for the commutant algebra
[genCom, paramCom] := commutant(h, genericElement(H)):
basisCom := genericElement2Basis(%):
prog::test(nops(basisCom), H::N!):

// Check that this algebra is commutative
{ b1*b2 - b2*b1 $ b1 in basisCom $ b2 in basisCom }

// Looking for the one of the commutant algebra
equations := [coeff(genCom * f-f) $ f in basisCom]:
result    := linsolve(equations, paramCom):
oneCom    := mapcoeffs(genCom, subs, result):
// Ok, that's the one of the full algebra, as expected

// Looking for the top of the commutant algebra
// We assume that the homogeneous components of positive degree are
// orthogonal to the identity for the natural scalar product.
equations := [coeff(genCom * f) $ f in {op(basisCom)} minus {oneCom}]:
result    := linsolve(equations, paramCom):
bla    := mapcoeffs(genCom, subs, result):
// Does not work


Note: the sum and alternating sum of all permutations are in the
commutant and are dimension 1 idempotents:

\begin{Mexin}
square := _plus(H([ [$1..H::N], p ]) $ p in permutations(H::N)) / H::N!:
nabla := _plus(permutations::sign(p)*H([ [$1..H::N], p ])
               $ p in permutations(H::N)) / H::N!:
prog::test(contains(checkMinimalIdempotent(square, basisCom), FAIL),0):
prog::test(contains(checkMinimalIdempotent(nabla,  basisCom), FAIL),0):
\end{Mexin} %$

Search for all the minimal idempotents that are orthogonal to
square and nabla
\begin{Mexin}
setuserinfo(groebner,1):setuserinfo(Any,0):
equations := {coeff(genCom^2-genCom),
              coeff(square*genCom), coeff(nabla*genCom)}:
unknowns  := paramCom.[hold(a)[i] $ i=1..nops(basisCom)]:
idempotents := [op(map(map(solve(equations, unknowns), map, radsimp),
	               eq -> mapcoeffs(genCom, subs, eq)))]:
minimalIdempotents := selectMinimalIdempotents(idempotents);
allMinimalIdempotents := [square, op(minimalIdempotents), nabla]:
prog::test(nops(allMinimalIdempotents), H::N!):
\end{Mexin} %$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Analysis of the idempotents for the squarefree hamiltonian}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Notes:
 - They all share the same support of size 18:
\begin{Mexin}
nops({op(map(minimalIdempotents, polylib::support))})
\end{Mexin}
 - They all use 9 different coefficients (but not the same ones),
   with the same number of repetitions:
\begin{Mexin}
map(minimalIdempotents, nops@DOM_SET@coeff)
{op(map(minimalIdempotents, words::evaluationPartition@DOM_LIST@coeff))}
\end{Mexin}

// Associate to each coefficient in x the set of the elements in the support
// having this coefficient
bla :=
proc(x)
begin
    t := table(c=[] $ c in [coeff(x)]);
    for s in polylib::support(x) do
        c:=coeff(x,s);
	t[c] := append(t[c],s);
    end_for;
    map(t, DOM_SET@op);
end;

{{rhs(eq) $ eq in bla(minimalIdempotents[i])} $ i =1..4}

// Reorder the idempotents
minimalIdempotents:=[minimalIdempotents[i] $i in [1,4,2,3]];
// The idempotents split in two parts
A:=[2*mapcoeffs(x, subs, sqrt(13)=0) $ x in minimalIdempotents]:
B:=[2*(x-mapcoeffs(x, subs, sqrt(13)=0)) $ x in minimalIdempotents]:

\begin{Mexin}
perms:=permutations::list(H::N):
compactReduced:=l->_concat(hold(p), op(permutations::reducedWord(l))):
annotate(H::toMatrix(3*A[1]), map(perms, compactReduced) $2);
\end{Mexin} %$

Remarks:
 - 3*A[i] have -1,0,1 coefficients
 - 3*sqrt(13)*B[i] have integer coefficients
 - A[i] is an idempotent
 - B[i]^2 = A[i]
 - B[i]*A[i] = B[i]
 - the rowsums of the A's and B's are always 0
 - A[1]= A[2], A[3]= A[4]
 - B[1]=-B[2], B[3]=-B[4]
 - A[1] and A[3] differ by permutations of sign  1
 - B[1] and B[3] differ by permutations of sign -1
 - A[1] is obtained from A[3] by reordering the rows and columnts
   by inversion of the permutations
 - A[i](t_2 x) = A[i](x) // in reduced word notation
 - A[i](x t_2) = A[i](x)t_2
 - t_1 A[i](x) = -A[i](x)
 - A[i](x) = (1-t_1)(1+t_2) x

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Analysis of the idempotents for the correct Hamiltonian}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Timing for the computation of the minimal idempotents for n=3
 - 7.7s with minimalIdempotents by Gröbner basis
 - with minimalIdempotents by generic element using K=Q
   2.4 s with 0-1 coeffs (3 recursive calls)
   1.9 s with 1-2 coeffs (1 recursive call)
   1.6 s with 1-3 coeffs (0 recursive calls)

   1.6 over Dom::ExpressionField()
   5.6s over K=Q(sqrt(2), sqrt(3))

\begin{Mexin}
export(combinat): export(experimental::HeckeSymmetricGroupAlgebraTools):
N:=4:
hermite := orthpoly::hermite(N,x):
//p := changeRootsSquareDifferences(hermite):
K:=Dom::AlgebraicExtension(Dom::AlgebraicExtension(Dom::Rational, s2^2=2),
			   s3^2=3):
K::Name := "Q(s2,s3)":
// Build the coefficients of the hamiltonian inside K
[ L, roots ] := polylib::splitfield(poly(hermite, K)):
rootsInL := map(sort([ roots[2*i-1] $i=1..nops(roots)/2 ]), L):
hcoeffs := map(table((i,j) = 1 / (rootsInL[i]-rootsInL[j])^2
                     $ i=1..j-1 $j=1..nops(rootsInL)),
               K@expr):
// Defining the algebras
S := examples::SymmetricGroupAlgebra(N, K): S::Name := "S":
H := experimental::HeckeSymmetricGroupAlgebra(N, K): H::Name := "H":

h    := H(hamiltonian(S, hcoeffs)):
basisH := map(H::basisIndices(), H::term):

// Looking for the commutant algebra
setuserinfo(Any,3): debugOf():
basisCom := commutantRem(h, map(H::basisIndices(), H::term)):
// read("basisCommutant4.mu"):
// basisCom := map(basisCom4, H::fromList@map, t->[K(t[1]), t[2]]):
prog::test(nops(basisCom), H::N!):
eigenvalues := [(2*i-binomial(N,2))/2 $ i=0..binomial(N,2)]:
basisComEigen :=
    table(lambda = commutantByEigenvalue(h, basisCom, lambda)
          $ lambda in eigenvalues):

minimalIdempotents([genCom, paramCom]);
\end{Mexin} %$

Pretty print, eigenvectors, ...
\begin{Mexin}
map(allMinimalIdempotents, H::toMatrixAnnotated@_mult, H::N!):
map(allMinimalIdempotents, H::printMatrixAnnotated@_mult, H::N!):
map(allMinimalIdempotents, linalg::eigenvectors@H::toMatrix)
\end{Mexin}
Of course, the minimal idempotents are projectors on dimension 1
subspaces of V; those subspace are the eigenvectors of H.
\begin{mexin}
  map(map(allMinimalIdempotents, linalg::eigenvectors@H::toMatrix), op, [1,3,1])
\end{mexin}
\begin{mexout}
     -- +-   -+  +-    -+  +-    -+  +-      -+  +-    -+  +-    -+ --
     |  |  1  |  |  -1  |  |   2  |  |   1/2  |  |   0  |  |  -1  |  |
     |  |     |  |      |  |      |  |        |  |      |  |      |  |
     |  |  1  |  |  -1  |  |  -2  |  |  -1/2  |  |   0  |  |   1  |  |
     |  |     |  |      |  |      |  |        |  |      |  |      |  |
     |  |  1  |  |   1  |  |   1  |  |  -1/2  |  |  -1  |  |   1  |  |
     |  |     |, |      |, |      |, |        |, |      |, |      |  |
     |  |  1  |  |   1  |  |  -1  |  |   1/2  |  |  -1  |  |  -1  |  |
     |  |     |  |      |  |      |  |        |  |      |  |      |  |
     |  |  1  |  |   0  |  |  -1  |  |   -1   |  |   1  |  |  -1  |  |
     |  |     |  |      |  |      |  |        |  |      |  |      |  |
     |  |  1  |  |   0  |  |   1  |  |    1   |  |   1  |  |   1  |  |
     -- +-   -+  +-    -+  +-    -+  +-      -+  +-    -+  +-    -+ --
\end{mexout}
annotate(_concat(op(bla)),map(H::permutations(), H::permutationsPrint),[$1..H::N!])

\begin{Mexin}
minimalIdempotentsFromEigenvalue :=
proc(eigenvalue: Type::Constant)
    local unknows, equations, idempotents;
    option remember;
begin
    setuserinfo(groebner,1):setuserinfo(Any,0):
    equations := {coeff(genCom^2-genCom), coeff(genCom*h-genCom*eigenvalue)}:
    unknowns  := paramCom.[hold(a)[i] $ i=1..nops(basisCom)]:
    idempotents := [op(map(map(solve(equations, unknowns), map, radsimp),
	               eq -> mapcoeffs(genCom, subs, eq)))]:
    selectMinimalIdempotents(idempotents):
end_proc:
\end{Mexin}

The projectors on the eigenspace E_{1/2} and E_{-1/2} are in the symmetric group
algebra, and factorize nicely:
\begin{Mexin}
m:=minimalIdempotentsFromEigenvalue(1/2):
proj12 := m[1]+m[2]:
m:=minimalIdempotentsFromEigenvalue(-1/2):
projm12 := m[1]+m[2]:
H::printMatrixAnnotated(6*proj12);
H::printMatrixAnnotated(6*projm12);
prog::test(iszero(projm12 * s(2) - projm12)):
prog::test(iszero(s(2) * projm12 - projm12)):
prog::test(iszero(projm12        - 1/6*(1+s(2))*(1-s(1))*(1+s(2)))):
prog::test(iszero(proj12         - 1/6*(1-s(2))*(1+s(1))*(1-s(2)))):
\end{Mexin}

map(minimalIdempotentsFromEigenvalue(1/2), H::printMatrixAnnotated)
map(minimalIdempotentsFromEigenvalue(1/2), H::printMatrixAnnotated)

The idempotents for 1/2 is killed by multiplication on the left by p(2):
\begin{Mexin}
for m in minimalIdempotentsFromEigenvalue(1/2) do
    prog::test(iszero(p(2)*m));
end:
\end{Mexin}

p(1)*m factorises nicely:

\begin{mexin}
prog::test(iszero(  p(1)*m - 1/2 * p(1) * (p(2)*s(1)-1) * (s(2)-1) )):
prog::test(iszero(m - 1/6*(-p(2,1) + p(1,2)*s(1) + p(1) + 2*p(2)*s(1) -2*s(1) - 2) * (s(2)-1))):
\end{mexin}

m factorises as follow

\begin{Mexin}
subs(a*f( (1+b[i]*s(1)+c[i]*s(2)+d[i]*p(1)+e[i]*p(2)) $ i=1..3,s(2)-1),
     op(res),b[1]=0,c[1]=0,d[3]=0,e[3]=0,e[2]=-1)
\end{Mexin} %$
\begin{Mexout}
                 / p(1)   p(2)                 p(1)                              \
                f| ---- - ---- + 1, 1 - p(2) - ----, 2 s(2) - s(1) + 1, s(2) - 1 |
                 \   2      2                    2                               /
                ------------------------------------------------------------------
                                                 3
\end{Mexout}


Problem: look for elements of Hecke-Sym (or in the matrix group) which
anticommutes with the hamiltonian (hence send E_\lambda(h) to
E_-\lambda(h), and which semi commutes: f h = f (h+1) so that f sends
E_\lambda(h) to E_{\lambda+1}(H).


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Commutation with left actions of the young symmetrizer}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SGA := examples::SymmetricGroupAlgebra(H::N):
SGA::onPermutationLeftMatrix(SGA::YoungSymmetrizer([[1],[2,3]], Left))
 - H::toMatrix(3*A[1]);

For N<=5, the action of the left young symmetrizer on the left commutes with the
action of the hamiltonian on the right. Which of those left actions can
be implemented by a right action of the Hecke-Sym algebra ?
\begin{Mexin}
reset():
export(combinat): export(experimental::HeckeSymmetricGroupAlgebraTools):
N:=4:
SGA:=examples::SymmetricGroupAlgebra(N):
h := hamiltonian(SGA):
hm:=SGA::onPermutationRightMatrix(h):
for p in combinat::partitions::list(N) do
    m:=SGA::onPermutationLeftMatrix(SGA::YoungSymmetrizer(tableaux::canonical(p), Left)):
    print(p, iszero(hm*m-m*hm));
end_for;
\begin{Mexin}

Search for all the minimal idempotents that are orthogonal to
square and nabla. Why doesnt this work ?
\begin{Mexin}
setuserinfo(groebner,1):setuserinfo(Any,0):
equations := {coeff(genCom^2-genCom),
              coeff(square*genCom), coeff(nabla*genCom),
              coeff(genCom*(basisCom[i]-hold(a)[i])) $ i=1..nops(basisCom)}:
unknowns  := paramCom.[hold(a)[i] $ i=1..nops(basisCom)]:
result    := map(solve(equations, unknowns), map, radsimp);
\end{Mexin} %$


The center of the full algebra is trivial:
\begin{Mexin}
equations:={coeff(f*b-b*f) $ b in map(H::basisIndices(), H::term)}
19-nops(linsolve(equations))
\end{Mexin} %$

Dimension of the center of the 0-Hecke algebra; What about n=6 ?
1, 2, 3, 5, 7

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Problème de Alain:

On considère l'algèbre du groupe symmétrique sur le corps des
fractions rationnelles en $X$. On peut plonger dedans à la fois les
pi_i (différences divisées) et sigma_i. Donc en fait n'importe quel
opérateur $T_i$ avec (T_i-q_1)(T_1-q_2)=0.

On prends K(A,B) = \prod_{j>i} (b_j-a_i).

On considère les lettres de $B$ comme paramètres, et on fait agir les
$T_i$ dessus. Enfin, on construit $X_\sigma(A,B)$ comme pour les
Schubert:
\begin{displaymath}
X_\sigma(A,B) = T_{i_1} \dots T_{i_k} K(A,B)
\end{displaymath}
où $i_1,\dots,i_k$ est un mot réduit pour $\sigma\omega$.

\section{Desossage, Florent, 10/09/2004}

Il y a une série génératrice raisonnable pour les couples de
permutations telles que:

$l(\sigma_1\sigma_2) = l(\sigma_1) + l(\sigma_2)$

Cf. Carlitz


Matrice d'invariants de cartan: multiplicité des modules simples dans
les modules projectifs.

Par calcul:
\begin{itemize}
\item Dans HS_n, les modules sont indexés par les compositions de n,
  comme pour H_n(0)
\item Module S_I: \dim S_I est le nombres de permutations ayant I pour
  descentes
\item Matrice de cartan: matrice du treillis booléen: 1 si I \subset J
  avec I et J vus comme ensembles.
\end{itemize}

Donc on a deux algèbres G(0) et K(0) en dualité. G(0) et K(0) ont les
mêmes dimensions graduées que QSym et NCSF, et on a des morphismes
G(0) <-> QSym et K(0) <-> NCSF; ces morphismes ne sont pas des
isomorphismes dès n=3; il n'est pas impossible que le morphisme de
NCSF->K(0) soit bêtement le morphisme de NCSF -> Sym.



\section{Generic matrix in HeckeSym}

n:= 3:
H:=experimental::HeckeSymmetricGroupAlgebra(n):
[rank, unrank] := H::permutationsRanker():[rank, unrank] := H::permutationsRanker():
M := matrix(n!, n!):
for b in H::basis() do
    t := H::lsupport(b);
    co := _concat(op(map(t, H::permutationsPrint)));
    for c from 1 to n! do
	r := rank(H::onListBasis(t, unrank(c)));
	M[r,c] := M[r,c] + co;
    end_for;
end_for:
M

It is probably simpler to just do: H::toMatrix(H::genericElement(t->...))


The algebra of the symmetric group, in its natural right action
on $V_n$ is defined inside $\Env(V_n)$ by the equations s_i M = M s_i
where $\overline s_i\in\End(V_n)$ is the $i$-th elementary
transposition acting on the values of the permutations.
See H::isSG and the test file.


The Hecke algebra, in its natural right representation
on $V_n$ is defined inside $\Env(V_n)$ by the commutation relations
$\overline p_i M = M \overline p_i,$
where $\overline p_i\in\End(V_n)$ is $\pi_i$ acting on the values of
the permutations. See H::isHecke and the test file.

The Hecke-SG algebra, in its natural right representation
on $V_n$ is defined inside $\Env(V_n)$ by the relations
$(1 + \overline s_i) \circ f \circ (1 - \overline s_i) = 0$
where $\overline s_i\in\End(V_n)$ is $s_i$ acting on the values of
the permutations. See H::isHeckeSG and the test file.

There is no diagonal matrix in \heckesg except for \lambda id;

prog::test(n!-nops(linsolve(H::isHeckeSGEquations(H::matrixDomain(i->hold(z).i,Diagonal)))),
           1):


\section{Looking for a decomposition of the identity into orthogonal
  idempotents indexed by permutations in HeckeSym}

export(combinat,Alias, permutations, compositions, words, subsets):
n := 4:
H:=experimental::HeckeSymmetricGroupAlgebra(n):
H::matrixDomain::printMaxSize := 1000:
[rank, unrank] := H::permutationsRanker():

// Builds a matrix of a generic endomorphism which kills
// any permutation which is not a suffix of p
// and return linear combinations of permutations which are
// suffixed by p
permutationToGenericMat :=
proc(p:permutations, z=hold(z))
    option remember;
    local M, rank, unrank, q1, q2, res;
begin
    [rank, unrank] := H::permutationsRanker():
    M:=H::matrixDomain::zero:
    for q1 in permutations::greaterPermutohedron(p, Left) do
	for q2 in permutations::smallerPermutohedron(p, Left) do
	    M[rank(q1), rank(q2)] := z[rank(q1),rank(q2)]:
	end_for:
    end_for:
    M[rank(p), rank(p)] := 1:
    res := linsolve(H::isHeckeSGEquations(M));
    if res=FAIL then FAIL else subs(M, res) end_if;
end_proc:
permutationToGenericMatHeckeSG :=
proc(p: permutations, z=hold(z))
    local M;
    option remember;
begin
    if (M:=permutationToGenericMat(p,_concat(z,op(p)))) = FAIL then return(FAIL); end_if;
    subs(M,linsolve(H::isHeckeSGEquations(M)))
end_proc:
f := permutationToGenericMatHeckeSG:

equations := {op(1-_plus(f(p1) $p1 in permutations(n)))}:
for p1 in permutations(n) do
    for p2 in permutations(n) do
        if p1=p2 then
	    equations := equations union {op(f(p1)^2-f(p1))};
        else
	    equations := equations union {op(f(p1)*f(p2))};
	end_if
    end_for
end_for:
if equations = { 0 } then
    res := [{}];
else
    res := solve(equations):
end_if:
g := p1 -> subs(f(p1), op(res,1)):

// Checking that those are really idempotents:
for p in permutations(n) do
    for q in permutations(n) do
        if p=q then prog::test(iszero(g(p)^2-g(p)));
        else prog::test(iszero(g(p)*g(q)));
	end_if
    end_for
end_for:
prog::test(iszero(_plus(g(p) $ p in permutations(n))-1)):


up   := p -> permutations::greaterPermutohedron(p, Left):
upcoeff   := (q,p) ->g(p)[rank(q), rank(p)]:
image := p -> select(up(p), not iszero@ upcoeff, p):
imageConj :=
proc(p)
begin
    R := {op(permutations::reculs(p))};
    map(permutations::youngSubgroup(compositions::fromDescents(R,n)),
	permutations::mult2, p);
end_proc:

down := p -> permutations::smallerPermutohedron(p, Left):
downcoeff := (q,p) ->g(p)[rank(p), rank(q)]:
preimage := p -> select(down(p), not iszero @ downcoeff, p):
preimageConj :=
proc(p)
begin
    R := {op(permutations::reculs(p))};
    map(permutations::youngSubgroup(compositions::fromDescents({$1..n-1} minus R,n)),
	permutations::mult2, p);
end_proc:

// There seems to be an incompatibility between the choice for a nice preimage
// and the choice for a nice image ...

// With this choice, the preimage is nice:
g := proc(p) option remember; begin subs(f(p), op(res,1), z1324[24,3]=-1, z2143[24,8]=-1); end_proc:
for p in permutations(4) do
    prog::test(sort(preimageConj(p)), sort(preimage(p)));
    for q in preimageConj(p) do
        prog::test(downcoeff(q,p),1)
    end_for:
end_for:

// With this choice, the image is nice:
g := p1 -> subs(f(p1), op(res,1), z1324[24,3]=0,z2143[24,8]=0):
for p in permutations(4) do
    prog::test(sort(imageConj(p)), sort(image(p))):
    for q in imageConj(p) do
        prog::test(upcoeff(q,p),permutations::sign(p)*permutations::sign(q));
    end_for:
end_for:

idempotent :=
proc(p)
    option remember;
begin
    [rank, unrank] := H::permutationsRanker():
    M:=H::matrixDomain::zero;
    for q1 in imageConj(p) do
	s := permutations::sign(q1) * permutations::sign(p);
	for q2 in preimageConj(p) do
	    M[rank(q1), rank(q2)] := s;
	end_for;
    end_for;
    M;
end_proc:

// OK
for p in permutations(n) do
    M := idempotent(p):
    prog::test(iszero(M^2-M)):
end_for:

// Almost ok
for p in permutations(4) do
    for q in permutations(4) do
	if p <> q then
            prog::test(iszero(idempotent(p) * idempotent(q)));
	else
	    prog::test(iszero(idempotent(p)^2- idempotent(p)));
        end_if;
    end_for
end_for

// FAILS
prog::test(iszero(_plus(idempotent(p) $ p in permutations(n))-1))


HeckeSymBasis := [H::toMatrix(h) $ h in H::basis()]:
dimOfRightIdeal := proc(f) option remember; begin linalg::rank(_concat(H::matrixDomain::sparseVector(f * M) $ M in HeckeSymBasis)); end:
print(p, dimOfRightIdeal(g(p))) $ p in permutations(n):
// Seems to be something like the size of a Young subgroup
_plus(dimOfRightIdeal(g(p)) $ p in permutations(n)):

\section{Looking for a decomposition of the identity into orthogonal idempotents indexed by compositions in Hecke(Sym)}

descentsToGenericMat :=
proc(I1: Type::SetOf(Type::PosInt), z=hold(z))
    local q1, q2, M, I2, rank, unrank;
begin
[rank, unrank] := H::permutationsRanker();
M:=H::matrixDomain::zero:
for q1 in _concat(permutations::fromDescents({$1..n-1} minus I2,n) $ I2 in combinat::subsets({$1..n-1} minus I1)) do
    for q2 in _concat(permutations::fromDescents(I2,n) $ I2 in combinat::subsets(I1)) do
	M[rank(q1), rank(q2)] := z[rank(q1),rank(q2)]:
    end_for
end_for:
for q in permutations::fromDescents(I1,n) do
    M[rank(q), rank(q)] := 1;
end_for;
M:
end_proc:

descentsToGenericMatHeckeSG :=
proc(I1: Type::SetOf(Type::PosInt), z=hold(z))
    local M;
    option remember;
begin
    M:=descentsToGenericMat(I1,_concat(z,op(I1))):
    subs(M,linsolve(H::isHeckeSGEquations(M)))
end_proc:

descentsToGenericMatHecke :=
proc(I1: Type::SetOf(Type::PosInt), z=hold(z))
    local M;
    option remember;
begin
    M:=descentsToGenericMat(I1,_concat(z,op(I1))):
    subs(M,linsolve(H::isHeckeEquations(M)))
end_proc:

//f := descentsToGenericMatHeckeSG:
f := descentsToGenericMatHecke:

/*for I1 in subsets(n-1) do
    for J in subsets(n-1) do
        if I1=J then prog::test(iszero(f(I1)^2-f(I1)));
        else prog::test(iszero(f(I1)*f(J)));
	end_if
    end_for
end_for:*/

equations := {op(1-_plus(f(I1) $I1 in subsets(n-1)))}:
for I1 in subsets(n-1) do
    for J in subsets(n-1) do
        if I1=J then
	    equations := equations union {op(f(I1)^2-f(I1))};
        else
	    equations := equations union {op(f(I1)*f(J))};
	end_if
    end_for
end_for:
res := solve(equations):
g := I1 -> subs(f(I1), op(res,1)):

// In HeckeSym, there is a little bit of slackness;
// In Hecke, there seems to be a unique solution
{op(g(I1)) $ I1 in subsets(n-1)}

// Bet: p_\sigma     \prod_{\sigma\in S_I} (-1)^{\sign\sigma} p_\sigma


pp := p->permutations::reducedWord(p):
M:=g({1,3}):
perms := {};
t :=0;
for p in permutations(n) do
    for q in permutations(n) do 
	if M[rank(p), rank(q)] <> 0 then
	    t := t+1;
	    perms := perms union { q };
	    print(pp(p),pp(q), M[rank(p),rank(q)])
        end_if;
    end_for
end_for:
t,nops(perms):

eq := []:
print(I1, { words::evaluationTable([op(linalg::row(g(I1),j))]) $j = 1..n! }) $I1 in subsets(n-1)
eq := []:
print(I1, words::evaluationTable([op(g(I1))]) $I1 in subsets(n-1):



%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
