.. _SectGrpCoxRDRoots:

.. _root-data-roots:

Roots, Coroots and Reflections
==============================

The functions in this section give access to the underlying root system (or
datum) of a permutation Coxeter group. These functions do not apply to finitely
presented Coxeter groups

Roots are stored as an indexed set

.. math:: \{@\; \alpha_1,\dots,\alpha_N,\alpha_{N+1},\dots,\alpha_{2N} \; @\},

where :math:`\alpha_1,\dots,\alpha_N` are the positive roots in an order
compatible with height; and :math:`\alpha_{N+1},\dots,\alpha_{2N}` are the
corresponding negative roots (i.e. :math:`\alpha_{i+N}=-\alpha_i`). The simple
roots are :math:`\alpha_1,\dots,\alpha_n` where :math:`n` is the rank.

Many of these functions have an optional argument ``Basis`` which may take one
of the following values

1. ``"Standard"``: the standard basis for the (co)root space. This is the
default.

2. ``"Root"``: the basis of simple (co)roots.

3. ``"Weight"``: the basis of fundamental (co)weights (see
Subsection :ref:`SubsectRDRootWeight` below).

.. _SubsectRDRootAccess:

.. _access:

Accessing Roots and Coroots
---------------------------

.. magma:function:: RootSpace(W)
   :input_types: GrpPermCox
   :output_types: .
   :label: RootSpace_GrpPermCox

.. magma:function:: CorootSpace(W)
   :input_types: GrpPermCox
   :output_types: .
   :label: CorootSpace_GrpPermCox

   The (co)root space of the Coxeter group :math:`W`. This can be a vector space
   over a field of characteristic zero
   (Chapter :ref:`ChapVectSpace`), or an integer lattice in the
   crystallographic case (Chapter :ref:`ChapLat`). The (co)reflection
   group of :math:`W` acts on the (co)root space.

.. magma:function:: SimpleRoots(W)
   :input_types: GrpPermCox
   :output_types: Mtrx
   :label: SimpleRoots_GrpPermCox

.. magma:function:: SimpleCoroots(W)
   :input_types: GrpPermCox
   :output_types: Mtrx
   :label: SimpleCoroots_GrpPermCox

   The simple (co)roots of the Coxeter group :math:`W` as the rows of a matrix.

.. magma:example:: Example: Root Space
   :label: RootSpace

   .. code-block:: magma

      > W := CoxeterGroup("G2");
      > RootSpace(W);
      Full Vector space of degree 2 over Rational Field
      > CorootSpace(W);
      Full Vector space of degree 2 over Rational Field
      > SimpleRoots(W);
      [1 0]
      [0 1]
      > SimpleCoroots(W);
      [ 2 -3]
      [-1  2]
      > CartanMatrix(W);
      [ 2 -1]
      [-3  2]

.. magma:function:: NumberOfPositiveRoots(W)
   :input_types: GrpPermCox
   :output_types: RngIntElt
   :label: NumberOfPositiveRoots_GrpPermCox

.. magma:function:: NumPosRoots(W)
   :input_types: GrpPermCox
   :output_types: RngIntElt
   :label: NumPosRoots_GrpPermCox

   The number of positive roots of the Coxeter group :math:`W`.

.. magma:function:: Roots(W)
   :input_types: GrpPermCox
   :output_types: $\{@@\}$
   :label: Roots_GrpPermCox

.. magma:function:: Coroots(W)
   :input_types: GrpPermCox
   :output_types: $\{@@\}$
   :label: Coroots_GrpPermCox

Basis : MonStgElt : “Standard"

An indexed set containing the (co)roots of the Coxeter group :math:`W`.

.. magma:function:: PositiveRoots(W)
   :input_types: GrpPermCox
   :output_types: $\{@@\}$
   :label: PositiveRoots_GrpPermCox

.. magma:function:: PositiveCoroots(W)
   :input_types: GrpPermCox
   :output_types: $\{@@\}$
   :label: PositiveCoroots_GrpPermCox

Basis : MonStgElt : “Standard"

An indexed set containing the positive (co)roots of the Coxeter group :math:`W`.

.. magma:function:: Root(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: $\{@@\}$
   :label: Root_GrpPermCox_RngIntElt

.. magma:function:: Coroot(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: $\{@@\}$
   :label: Coroot_GrpPermCox_RngIntElt

Basis : MonStgElt : “Standard"

The :math:`r`\ th (co)root of the Coxeter group :math:`W`.

.. magma:function:: RootPosition(W, v)
   :input_types: GrpPermCox, .
   :output_types: $\{@@\}$
   :label: RootPosition_GrpPermCox

.. magma:function:: CorootPosition(W, v)
   :input_types: GrpPermCox, .
   :output_types: $\{@@\}$
   :label: CorootPosition_GrpPermCox

Basis : MonStgElt : “Standard"

If :math:`v` is a (co)root of the Coxeter group :math:`W`, this returns its
position; otherwise it returns 0. These functions will try to coerce :math:`v`,
which can be a vector or a sequence representing a vector, into the appropriate
vector space; :math:`v` should be written with respect to the basis specified by
the parameter ``Basis``.

.. magma:example:: Example: Roots Coroots
   :label: RootsCoroots

   .. code-block:: magma

      > A := Matrix(2,3, [1,-1,0, -1,1,-1]);
      > B := Matrix(2,3, [1,-1,1, 0,1,-1]);
      > W := CoxeterGroup(A, B);
      > Roots(W);
      {@
          (1 -1  0),
          (-1  1 -1),
          (0  0 -1),
          (1 -1 -1),
          (2 -2 -1),
          (1 -1 -2),
          (-1  1  0),
          (1 -1  1),
          (0 0 1),
          (-1  1  1),
          (-2  2  1),
          (-1  1  2)
      @}
      > PositiveCoroots(W);
      {@
          (1 -1  1),
          (0  1 -1),
          (1  2 -2),
          (2  1 -1),
          (1 0 0),
          (1  1 -1)
      @}
      > #Roots(W) eq 2*NumPosRoots(W);
      true
      %%a> assert $1;
      > Root(W, 4);
      (1 -1 -1)
      > Root(W, 4 : Basis := "Root");
      (2 1)
      > RootPosition(W, [1,-1,-1]);
      4
      %%a> assert $1 eq 4;
      > RootPosition(W, [2,1] : Basis := "Root");
      4
      %%a> assert $1 eq 4;

.. magma:function:: HighestRoot(W)
   :input_types: GrpPermCox
   :output_types: .
   :label: HighestRoot_GrpPermCox

.. magma:function:: HighestLongRoot(W)
   :input_types: GrpPermCox
   :output_types: .
   :label: HighestLongRoot_GrpPermCox
   :parameters: Basis : MonStgElt : ``Standard"

   The unique (long) root of greatest height of the irreducible Coxeter group
   :math:`W`.

.. magma:function:: HighestShortRoot(W)
   :input_types: GrpPermCox
   :output_types: .
   :label: HighestShortRoot_GrpPermCox
   :parameters: Basis : MonStgElt : ``Standard"

   The unique short root of greatest height of the irreducible Coxeter group
   :math:`W`.

.. magma:example:: Example: Heighest Roots
   :label: HeighestRoots

   .. code-block:: magma

      > W := RootDatum("G2");
      > HighestRoot(W);
      (3 2)
      > HighestLongRoot(W);
      (3 2)
      > HighestShortRoot(W);
      (2 1)

.. magma:function:: CoxeterForm(W)
   :input_types: GrpPermCox
   :output_types: AlgMatElt
   :label: CoxeterForm_GrpPermCox

.. magma:function:: DualCoxeterForm(W)
   :input_types: GrpPermCox
   :output_types: AlgMatElt
   :label: DualCoxeterForm_GrpPermCox
   :parameters: Basis : MonStgElt : ``Standard"

   The matrix of an inner product on the (co)root space of the finite Coxeter group
   :math:`W` which is invariant under the action of :math:`W`. This inner product
   is uniquely determined up to a constant on each irreducible component of
   :math:`W`. The inner product is normalised so that the short roots in each
   crystallographic component have length one.

.. magma:function:: AdditiveOrder(W)
   :input_types: GrpPermCox
   :output_types: SeqEnum
   :label: AdditiveOrder_GrpPermCox

   An additive order on the positive roots of the finite Coxeter group :math:`W`,
   i.e. a sequence containing the numbers :math:`1,\dots,N` in some order such that
   :math:`\alpha_r+\alpha_s=\alpha_t` implies :math:`t` is between :math:`r` and
   :math:`s`. This is computed using the techniques of Papi
   :cite:`Papi`.

.. magma:function:: PapiOrder(W,w)
   :input_types: GrpPermCox, GrpPermElt
   :output_types: SeqEnum
   :label: PapiOrder_GrpPermCox_GrpPermElt

.. magma:function:: PapiOrder(W, wd)
   :input_types: GrpPermCox, SeqEnum[RngIntElt]
   :output_types: SeqEnum
   :label: PapiOrder_GrpPermCox_SeqEnum_RngIntElt

   An additive order for the set of positive roots of the finite Coxeter group
   :math:`W` sent negative by :math:`w^{-1}`. The element :math:`w` can be supplied
   either as an element of the permutation group :math:`W` or as a sequence
   representing a word in its generators.

.. _SubsectRDRootOp:

.. _ops-root-coroot:

Operations and Properties for Root and Coroot Indices
-----------------------------------------------------

.. magma:function:: Sum(W, r, s)
   :input_types: GrpPermCox, RngIntElt, RngIntElt
   :output_types: RngIntElt
   :label: Sum_GrpPermCox_RngIntElt_RngIntElt

   The index of the sum of the :math:`r`\ th and :math:`s`\ th roots in the Coxeter
   group :math:`W`, or 0 if the sum is not a root. In other words, if
   :math:`t = \hbox{\tt Sum(W,$r$,$s$)} \ne 0` then
   :math:`\alpha_t=\alpha_r+\alpha_s`. The condition :math:`\alpha_r\ne\pm\alpha_s`
   must be satisfied. If :math:`W` is noncrystallographic, an error is flagged.

.. magma:function:: IsPositive(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: BoolElt
   :label: IsPositive_GrpPermCox_RngIntElt

   Returns ``true`` if, and only if, the :math:`r`\ th (co)root of the Coxeter
   group :math:`W` is a positive root.

.. magma:function:: IsNegative(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: BoolElt
   :label: IsNegative_GrpPermCox_RngIntElt

   Returns ``true`` if, and only if, the :math:`r`\ th (co)root of the Coxeter
   group :math:`W` is a negative root.

.. magma:function:: Negative(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: RngIntElt
   :label: Negative_GrpPermCox_RngIntElt

   The index of the negative of the :math:`r`\ th (co)root of the Coxeter group
   :math:`W`. In other words, if :math:`s = \hbox{\tt Negative(W,$r$)}` then
   :math:`\alpha_s=-\alpha_r`.

.. magma:function:: LeftString(W, r, s)
   :input_types: GrpPermCox, RngIntElt, RngIntElt
   :output_types: RngIntElt
   :label: LeftString_GrpPermCox_RngIntElt_RngIntElt

   Root indices in the Coxeter group :math:`W` of the left string through
   :math:`\alpha_s` in the direction of :math:`\alpha_r`, i.e. the indices of
   :math:`\alpha_s-\alpha_r,\alpha_s-2\alpha_r,\dots,\alpha_s-p\alpha_r`. In other
   words, this returns the sequence :math:`[r_1,\dots,r_p]` where
   :math:`\alpha_{r_i}=\alpha_s-i\alpha_r` and :math:`\alpha_s-(p+1)\alpha_r` is
   not a root. The condition :math:`\alpha_r\ne\pm\alpha_s` must be satisfied. If
   :math:`W` is noncrystallographic, an error is flagged.

.. magma:function:: RightString(W, r, s)
   :input_types: GrpPermCox, RngIntElt, RngIntElt
   :output_types: RngIntElt
   :label: RightString_GrpPermCox_RngIntElt_RngIntElt

   Root indices of the Coxeter group :math:`W` of the left string through
   :math:`\alpha_s` in the direction of :math:`\alpha_r`, i.e. the indices of
   :math:`\alpha_s+\alpha_r,\alpha_s+2\alpha_r,\dots,\alpha_s+q\alpha_r`. In other
   words, this returns the sequence :math:`[r_1,\dots,r_q]` where
   :math:`\alpha_{r_i}=\alpha_s+i\alpha_r` and :math:`\alpha_s+(q+1)\alpha_r` is
   not a root. The condition :math:`\alpha_r\ne\pm\alpha_s` must be satisfied. If
   :math:`W` is noncrystallographic, an error is flagged.

.. magma:function:: LeftStringLength(W, r, s)
   :input_types: GrpPermCox, RngIntElt, RngIntElt
   :output_types: RngIntElt
   :label: LeftStringLength_GrpPermCox_RngIntElt_RngIntElt

   The largest :math:`p` such that :math:`\alpha_s-p\alpha_r` is a root of the
   Coxeter group :math:`W`. The condition :math:`\alpha_r\ne\pm\alpha_s` must be
   satisfied. If :math:`W` is noncrystallographic, an error is flagged.

.. magma:function:: RightStringLength(W, r, s)
   :input_types: GrpPermCox, RngIntElt, RngIntElt
   :output_types: RngIntElt
   :label: RightStringLength_GrpPermCox_RngIntElt_RngIntElt

   The largest :math:`q` such that :math:`\alpha_s+q\alpha_r` is a root of the
   Coxeter group :math:`W`. The condition :math:`\alpha_r\ne\pm\alpha_s` must be
   satisfied. If :math:`W` is noncrystallographic, an error is flagged.

.. magma:example:: Example: Root Arithmetic
   :label: RootArithmetic

   .. code-block:: magma

      > W := RootDatum("G2");
      > Sum(W, 1, Negative(W,5));
      10
      %%a> assert $1 eq 10;
      > IsPositive(W, 10);
      false
      %%a> assert not $1;
      > Negative(W, 10);
      4
      %%a> assert $1 eq 4;
      > P := PositiveRoots(W);
      > P[1] - P[5] eq -P[4];
      true
      %%a> assert $1;

.. magma:function:: RootHeight(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: RngIntElt
   :label: RootHeight_GrpPermCox_RngIntElt

.. magma:function:: CorootHeight(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: RngIntElt
   :label: CorootHeight_GrpPermCox_RngIntElt

   The height of the :math:`r`\ th (co)root of the Coxeter group :math:`W`,
   i.e. the sum of the coefficients of :math:`\alpha_r` (respectively,
   :math:`\alpha_r^\star`) with respect to the simple (co)roots.

.. magma:function:: RootNorms(W)
   :input_types: GrpPermCox
   :output_types: [RngIntElt]
   :label: RootNorms_GrpPermCox

.. magma:function:: CorootNorms(W)
   :input_types: GrpPermCox
   :output_types: [RngIntElt]
   :label: CorootNorms_GrpPermCox

   The sequence of squares of the lengths of the (co)roots of the Coxeter group
   :math:`W`.

.. magma:function:: RootNorm(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: RngIntElt
   :label: RootNorm_GrpPermCox_RngIntElt

.. magma:function:: CorootNorm(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: RngIntElt
   :label: CorootNorm_GrpPermCox_RngIntElt

   The square of the length of the :math:`r`\ th (co)root of the Coxeter group
   :math:`W`.

.. magma:function:: IsLongRoot(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: BoolElt
   :label: IsLongRoot_GrpPermCox_RngIntElt

   Returns ``true`` if, and only if, the :math:`r`\ th root of the Coxeter group
   :math:`W` is long, i.e. the :math:`r`\ th coroot is short. An error is flagged
   unless :math:`W` is irreducible and crystallographic.

.. magma:function:: IsShortRoot(W, r)
   :input_types: GrpPermCox, RngIntElt
   :output_types: BoolElt
   :label: IsShortRoot_GrpPermCox_RngIntElt

   Returns ``true`` if, and only if, the :math:`r`\ th root of the Coxeter group
   :math:`W` is short, i.e. the :math:`r`\ th coroot is long. An error is flagged
   unless :math:`W` is irreducible and crystallographic.

.. magma:example:: Example: Root Operations
   :label: RootOperations

   .. code-block:: magma

      > W := RootDatum("G2");
      > RootHeight(W, 5);
      4
      %%a> assert $1 eq 4;
      > F := CoxeterForm(W);
      > v := VectorSpace(Rationals(),2) ! Root(W, 5);
      > (v*F, v) eq RootNorm(W, 5);
      true
      %%a> assert $1;
      > IsLongRoot(W, 5);
      true
      %%a> assert $1;
      > LeftString(W, 1, 5);
      [ 4, 3, 2 ]
      > roots := Roots(W);
      > for i in [1..3] do
      >   RootPosition(W, roots[5]-i*roots[1]);
      > end for;
      4
      3
      2

.. _SubsectGrpPermCoxRootWeight:

.. _weights:

Weights
-------

.. magma:function:: WeightLattice(W)
   :input_types: GrpPermCox
   :output_types: Lat
   :label: WeightLattice_GrpPermCox

.. magma:function:: CoweightLattice(W)
   :input_types: GrpPermCox
   :output_types: Lat
   :label: CoweightLattice_GrpPermCox

   The (co)weight lattice of the Coxeter group :math:`W`. The roots and coroots of
   :math:`W` must have integral components.

.. magma:function:: FundamentalWeights(W)
   :input_types: GrpPermCox
   :output_types: SeqEnum
   :label: FundamentalWeights_GrpPermCox

.. magma:function:: FundamentalCoweights(W)
   :input_types: GrpPermCox
   :output_types: SeqEnum
   :label: FundamentalCoweights_GrpPermCox

Basis : MonStgElt : “Standard"

The fundamental (co)weights of the Coxeter group :math:`W`. The roots and
coroots of :math:`W` must have integral components.

.. magma:function:: IsDominant(R, v)
   :input_types: RootDtm, .
   :output_types: ModTupFldElt, GrpFPCoxElt
   :label: IsDominant_RootDtm
   :parameters: Basis : MonStgElt : ``Standard"

   Returns ``true`` if, and only if, :math:`v` is a dominant weight for the root
   datum :math:`R`, ie, a nonnegative integral linear combination of the
   fundamental weights.

.. magma:function:: DominantWeight(W, v)
   :input_types: GrpPermCox, .
   :output_types: ModTupFldElt, GrpFPCoxElt
   :label: DominantWeight_GrpPermCox

Basis : MonStgElt : “Standard"

The unique element in the :math:`W`-orbit of the weight :math:`v` which lies in
the fundamental Weyl chamber, and the word in the generators which sends
:math:`v` to this element. The Coxeter group :math:`W` must have a root datum.
The weight :math:`v` can be given either as a vector or as a sequence
representing the vector and is coerced into the weight lattice first.

.. magma:function:: WeightOrbit(W, v)
   :input_types: GrpPermCox, .
   :output_types: {@ ModTupFldElt @}, [GrpFPCoxElt]
   :label: WeightOrbit_GrpPermCox

Basis : MonStgElt : “Standard"

The orbit of the weight :math:`v` under the action of :math:`W`. The Coxeter
group :math:`W` must have a root datum. The weight :math:`v` can be given either
as a vector or as a sequence representing the vector and is coerced into the
weight lattice first.

.. magma:example:: Example: Dominant Weights
   :label: DominantWeights

   .. code-block:: magma

      > W := CoxeterGroup("B3");
      > DominantWeight(W, [1,-1,0] : Basis:="Weight");  
      (1 0 0)
      [ 2, 3, 2, 1 ]
      > #WeightOrbit(W, [1,-1,0] : Basis:="Weight");   
      6
      %%a> assert $1 eq 6;
