.. _SectCartanFinAff:

.. _finiteaffine:

Finite and Affine Coxeter  Groups
=================================

Functions related to the classification of finite and affine Coxeter groups are
described in this section. This classification is due to Cartan
:cite:`cartan` and Coxeter :cite:`coxeter`.

An affine reflection group is a group generated by reflections in affine space
(in other words, real reflections in a hyperplane that does not necessarily pass
through the origin). A Coxeter group is called *affine* if it is infinite and it
has a representation as a discrete, properly acting, affine reflection group
(see :cite:`BourbakiLie` for more details on discreteness and proper
action). Note that a Coxeter group is finite if, and only if, it has a
representation as a discrete, properly acting group of reflections of the
sphere; hence finite Coxeter groups are sometimes called *spherical*.

A Coxeter group is finite if, and only if, all its irreducible components are
finite; a Coxeter group is affine if, and only if, all its irreducible
components are finite or affine, and at least one component is affine. So it
suffices to classify irreducible Coxeter groups.

| The Dynkin diagrams of the irreducible finite crystallographic Coxeter groups
  are:  An 1—2—3- ... -n Bn 1—2- ... -(n-1)=>=n  (n-1)  /  Cn 1—2- ...
  -(n-1)=<=n Dn 1—1- ... -(n-2)  
|  n  E6 1—3—4—5—6 E7 1—3—4—5—6—7  \| \|  2 2  E8 1—3—4—5—6—7—8  \|  2  F4
  1—2=>=3—4 G2 1=<=2  3 Due to the difficulty of drawing a triple bond with text
  characters, the edge for :math:`G_2` is labelled.

The only irreducible noncrystallographic finite Coxeter groups are :math:`H_3`,
:math:`H_4` and :math:`I_2(m)` for :math:`m = 5` and :math:`m > 6`. The Coxeter
graphs of these groups are:  H3 1—2—3 H4 1—2—3—4  5 5  I2(m) 1—2  m Note that
there is some redundancy in this classification; specifically
:math:`A_1=B_1=C_1=D_1`, :math:`A_2=I_2(3)`, :math:`B_2=C_2=I_2(4)`,
:math:`D_2=A_1+A_1`, :math:`D_3=A_3`, :math:`G_2=I_2(6)`. Furthermore, for
:math:`n\ge3`, types :math:`B_n` and :math:`C_n` have identical Coxeter matrices
but inequivalent crystallographic Cartan matrices for :math:`n>2`.

| All irreducible affine groups are crystallographic. There is one corresponding
  to each irreducible crystallographic finite group. Their Dynkin diagrams are:
   A 1 1——-2 A n 1—2- ... -n  infty \| \|  —-(n+1)—-  1  
|  B n 2- ... -(n-1)=>=n  /  (n+1)  C n (n+1)=>=1—1- ... -(n-1)=<=n  1 (n-1)  
| /  D n 2- ... -(n-2)  /
|  (n+1) n  E 6 1—3—4—5—6 E 7 8—1—3—4—5—6—7  \| \|  2 2  \|  7  E 8
  1—3—4—5—6—7—8—9  \|  2  F 4 5—1—2=>=3—4 G 2 1=<=2—3  3

The labels on the vertices of these diagrams show the standard vertex order used
in Magma, which is consistent with the order used in
:cite:`BourbakiLie`.

.. magma:function:: IsCoxeterFinite(M)
   :input_types: AlgMatElt
   :output_types: BoolElt
   :label: IsCoxeterFinite_AlgMatElt

.. magma:function:: IsCoxeterFinite(G)
   :input_types: GrphUnd
   :output_types: BoolElt
   :label: IsCoxeterFinite_GrphUnd

.. magma:function:: IsCoxeterFinite(C)
   :input_types: AlgMatElt
   :output_types: BoolElt
   :label: IsCoxeterFinite_AlgMatElt_2

.. magma:function:: IsCoxeterFinite(D)
   :input_types: GrphDir
   :output_types: BoolElt
   :label: IsCoxeterFinite_GrphDir

.. magma:function:: IsCoxeterFinite(N)
   :input_types: MonStgElt
   :output_types: BoolElt
   :label: IsCoxeterFinite_MonStgElt

   Returns ``true`` if, and only if, the corresponding Coxeter group is finite. The
   input variable can be a Coxeter matrix :math:`M`, Coxeter graph :math:`G`,
   Cartan matrix :math:`C`, Dynkin digraph :math:`D`, or Cartan name given by the
   string :math:`N`.

.. magma:function:: IsCoxeterAffine(M)
   :input_types: AlgMatElt
   :output_types: BoolElt
   :label: IsCoxeterAffine_AlgMatElt

.. magma:function:: IsCoxeterAffine(G)
   :input_types: GrphUnd
   :output_types: BoolElt
   :label: IsCoxeterAffine_GrphUnd

.. magma:function:: IsCoxeterAffine(C)
   :input_types: AlgMatElt
   :output_types: BoolElt
   :label: IsCoxeterAffine_AlgMatElt_2

.. magma:function:: IsCoxeterAffine(D)
   :input_types: GrphDir
   :output_types: BoolElt
   :label: IsCoxeterAffine_GrphDir

.. magma:function:: IsCoxeterAffine(N)
   :input_types: MonStgElt
   :output_types: BoolElt
   :label: IsCoxeterAffine_MonStgElt

   Returns ``true`` if, and only if, the corresponding Coxeter group is affine. The
   input variable can be a Coxeter matrix :math:`M`, Coxeter graph :math:`G`,
   Cartan matrix :math:`C`, Dynkin digraph :math:`D`, or Cartan name given by the
   string :math:`N`.

.. magma:example:: Example: Testing
   :label: Testing

   .. code-block:: magma

      > IsCoxeterAffine("A~2");
      true
      %%a> assert $1;
      > IsCoxeterAffine("A~2B2");
      true
      %%a> assert $1;
      > IsCoxeterAffine("A2B2");
      false
      %%a> assert not $1;
      > IsCoxeterFinite("A2B2");
      true
      %%a> assert $1;

.. magma:function:: CoxeterMatrix(N)
   :input_types: MonStgElt
   :output_types: AlgMatElt
   :label: CoxeterMatrix_MonStgElt

   The Coxeter matrix with Cartan name given by the string :math:`N`.

.. magma:function:: CoxeterGraph(N)
   :input_types: MonStgElt
   :output_types: GrpUnd
   :label: CoxeterGraph_MonStgElt

   The Coxeter graph with Cartan name given by the string :math:`N`.

.. magma:function:: CartanMatrix(N)
   :input_types: MonStgElt
   :output_types: AlgMatElt
   :label: CartanMatrix_MonStgElt
   :parameters: Symmetric : BoolElt : \texttt{false}; BaseField : MonStgElt : ``NumberField"

   The Cartan matrix with Cartan name given by the string :math:`N`. By default,
   the crystallographic matrix is returned for crystallographic types; otherwise
   the Cartan matrix with :math:`c_{ij}=-4\cos^2(\pi/m_{ij})`, :math:`c_{ji}=-1`
   when :math:`m_{ij}\ne2` and :math:`i<j` is returned.

   If the ``Symmetric`` flag is set ``true``, the symmetric Cartan matrix with
   :math:`c_{ij}=c_{ji}=-2\cos(\pi/m_{ij})` is returned.

   The ``BaseField`` flag determines the field over which the Cartan matrix is
   defined. If the matrix is crystallographic however, it is defined over the
   integers regardless of the value of this flag. The possible values are:

   1. ``"NumberField"``: An algebraic number field. This is the default. See
   Chapter :ref:`FldNum:main`.

   2. ``"Cyclotomic"`` or ``"SparseCyclotomic"``: A cyclotomic field with the
   sparse representation for elements. See Chapter :ref:`ChapFldCyc`.

   3. ``"DenseCyclotomic"``: A cyclotomic field with the dense representation for
   elements. See Chapter :ref:`ChapFldCyc`.

.. magma:function:: DynkinDigraph(N)
   :input_types: MonStgElt
   :output_types: GrphDir
   :label: DynkinDigraph_MonStgElt

   The Dynkin digraph with Cartan name given by the string :math:`N`. The Cartan
   name must be crystallographic, i.e. it cannot involve types :math:`H_3`,
   :math:`H_4` and :math:`I_2(m)`.

.. magma:example:: Example: Matrices And Graphs
   :label: MatricesAndGraphs

   The code for interpreting a string as a Cartan name is quite flexible: letters
   and numbers must alternate, except in type :math:`I` where brackets must be
   used.

   .. code-block:: magma

      > CoxeterMatrix("I2(7)");
      [1 7]
      [7 1]
      > CoxeterGraph("A3");
      Graph
      Vertex  Neighbours
 
      1       2 ;
      2       1 3 ;
      3       2 ;
 
      > CartanMatrix("H3" : Symmetric);
      [   2 -$.1    0]
      [-$.1    2   -1]
      [   0   -1    2]
      > DynkinDigraph("A~2");
      Digraph
      Vertex  Neighbours
 
      1       2 3 ;
      2       1 3 ;
      3       1 2 ;
      > M := CoxeterMatrix("A_5B3 c2I2 (5)");
      > CartanName(M);
      A5 B3 B2 I2(5)

.. magma:function:: IrreducibleCoxeterMatrix(X, n)
   :input_types: MonStgElt, RngIntElt
   :output_types: AlgMatElt
   :label: IrreducibleCoxeterMatrix_MonStgElt_RngIntElt

   The irreducible Coxeter matrix with Cartan name :math:`X_n` (or :math:`I_2(n)`
   if :math:`X=`\ ``"I"``).

.. magma:function:: IrreducibleCoxeterGraph(X, n)
   :input_types: MonStgElt, RngIntElt
   :output_types: GrpUnd
   :label: IrreducibleCoxeterGraph_MonStgElt_RngIntElt

   The irreducible Coxeter graph with Cartan name :math:`X_n` (or :math:`I_2(n)` if
   :math:`X=`\ ``"I"``).

.. magma:function:: IrreducibleCartanMatrix(X, n)
   :input_types: MonStgElt, RngIntElt
   :output_types: AlgMatElt
   :label: IrreducibleCartanMatrix_MonStgElt_RngIntElt
   :parameters: Symmetric : BoolElt : \texttt{false}; BaseField : MonStgElt : ``NumberField"

   The irreducible Cartan matrix with Cartan name :math:`X_n` (or :math:`I_2(n)` if
   :math:`X=`\ ``"I"``).

   If the ``Symmetric`` flag is set ``true``, the symmetric Cartan matrix with
   :math:`c_{ij}=c_{ji}=-2\cos(\pi/m_{ij})` is returned.

   The ``BaseField`` flag determines which field the Cartan matrix is defined over.
   If the matrix is crystallographic however, it is defined over the integers
   regardless of the value of this flag. The possible values are:

   1. ``"NumberField"``: An algebraic number field. This is the default. See
   Chapter :ref:`FldNum:main`.

   2. ``"Cyclotomic"`` or ``"SparseCyclotomic"``: A cyclotomic field with the
   sparse representation for elements. See Chapter :ref:`ChapFldCyc`.

   3. ``"DenseCyclotomic"``: A cyclotomic field with the dense representation for
   elements. See Chapter :ref:`ChapFldCyc`.

.. magma:function:: IrreducibleDynkinDigraph(X, n)
   :input_types: MonStgElt, RngIntElt
   :output_types: GrphDir
   :label: IrreducibleDynkinDigraph_MonStgElt_RngIntElt

   The irreducible Dynkin digraph with Cartan name :math:`X_n`. The Cartan name
   must be crystallographic, i.e. it cannot involve types :math:`H_3`, :math:`H_4`
   or :math:`I_2(m)`.

.. magma:example:: Example: Irreducible Coxeter
   :label: IrreducibleCoxeter

   These functions are useful in loops.

   .. code-block:: magma

      > for n in [1..5] do
      >     IsTree(IrreducibleCoxeterGraph("A~", n));
      > end for;
      true
      false
      false
      false
      false
      > C := &join[ IrreducibleCoxeterGraph(t, 4) : t in ["A","B","C","D","F"] ];

.. magma:function:: IsCoxeterIsomorphic(N1, N2)
   :input_types: MonStgElt, MonStgElt
   :output_types: BoolElt
   :label: IsCoxeterIsomorphic_MonStgElt_MonStgElt

   Returns ``true`` if and only if the Cartan names given by the strings
   :math:`N_1` and :math:`N_2` correspond to isomorphic Coxeter systems.

.. magma:function:: IsCartanEquivalent(N1, N2)
   :input_types: MonStgElt, MonStgElt
   :output_types: BoolElt
   :label: IsCartanEquivalent_MonStgElt_MonStgElt

   Returns ``true`` if and only if the Cartan names given by the strings
   :math:`N_1` and :math:`N_2` correspond to Cartan equivalent Cartan matrices. The
   Cartan names must be crystallographic; i.e., they cannot involve types
   :math:`H_3`, :math:`H_4` and :math:`I_2(m)`.

.. magma:example:: Example: Isomorphism And Equivalence
   :label: IsomorphismAndEquivalence

   .. code-block:: magma

      > IsCoxeterIsomorphic("A1A1", "D2");
      true
      %%a> assert $1;
      > IsCoxeterIsomorphic("B5", "C5");
      true
      %%a> assert $1;
      > IsCartanEquivalent("B5", "C5");
      false
      %%a> assert not $1;

.. magma:function:: IsSimplyLaced(N)
   :input_types: MonStgElt
   :output_types: BoolElt
   :label: IsSimplyLaced_MonStgElt

   Returns ``true`` if, and only if, the Coxeter matrix with Cartan name given by
   the string :math:`N` is simply laced, i.e. all its entries are 1, 2, or 3.

.. magma:function:: CoxeterGroupOrder(N)
   :input_types: MonStgElt
   :output_types: .
   :label: CoxeterGroupOrder_MonStgElt

.. magma:function:: CoxeterGroupFactoredOrder(N)
   :input_types: MonStgElt
   :output_types: .
   :label: CoxeterGroupFactoredOrder_MonStgElt

   The (factored) order of the Coxeter group with Cartan name given by the string
   :math:`N`.

.. magma:function:: NumberOfPositiveRoots(N)
   :input_types: MonStgElt
   :output_types: .
   :label: NumberOfPositiveRoots_MonStgElt

.. magma:function:: NumPosRoots(N)
   :input_types: MonStgElt
   :output_types: .
   :label: NumPosRoots_MonStgElt

   The number of positive roots of the Coxeter group with Cartan name given by the
   string :math:`N`. See Subsection :ref:`SubsectRSPosSimple`
   for the definition of positive roots.

.. magma:function:: FundamentalGroup(N)
   :input_types: MonStgElt
   :output_types: GrpAb
   :label: FundamentalGroup_MonStgElt

   The fundamental group of the crystallographic Cartan matrix with Cartan name
   given by the string :math:`N`, i.e. :math:`{\mathbb{Z}}^n/\Gamma` where
   :math:`\Gamma` is the lattice generated by the rows of the Cartan matrix. The
   natural mapping :math:`{\mathbb{Z}}^n\to{\mathbb{Z}}^n/\Gamma` is the second
   returned value.

.. magma:example:: Example: Group Orders
   :label: GroupOrders

   .. code-block:: magma

      > CoxeterGroupOrder("F4");
      1152
      %%a> assert $1 eq 1152;
      > CoxeterGroupFactoredOrder("F4");
      [ <2, 7>, <3, 2> ]
      > NumPosRoots("F4");
      24
      %%a> assert $1 eq 24;
      > #FundamentalGroup("F4");
      1
      %%a> assert $1 eq 1;

.. magma:function:: CartanName(M)
   :input_types: AlgMatElt
   :output_types: MonStgElt
   :label: CartanName_AlgMatElt

.. magma:function:: CartanName(G)
   :input_types: GrphUnd
   :output_types: MonStgElt
   :label: CartanName_GrphUnd

.. magma:function:: CartanName(C)
   :input_types: AlgMatElt
   :output_types: MonStgElt
   :label: CartanName_AlgMatElt_2

.. magma:function:: CartanName(D)
   :input_types: GrphDir
   :output_types: MonStgElt
   :label: CartanName_GrphDir

The Cartan name of a Coxeter matrix :math:`M`, Coxeter graph :math:`G`, Cartan
matrix :math:`C`, or Dynkin digraph :math:`D`. If the corresponding Coxeter
group is neither finite nor affine, an error is flagged.

.. magma:example:: Example: Cartan Name
   :label: CartanName

   .. code-block:: magma

      > CartanName(SymmetricMatrix([1, 3,1, 2,3,1]));
      A3
      > CartanName(SymmetricMatrix([1, 3,1, 3,3,1]));
      A~2
      \<CartanName(SymmetricMatrix([1, 3,1, 4,3,1]));
      The component at rows and columns [ 1, 2, 3 ]
      is not a finite or affine Coxeter matrix
      > C := Matrix(4,4, [2,-2,0,0, -1,2,0,0, 0,0,2,-2, 0,0,-1,2] );
      > C;
      [ 2 -2  0  0]
      [-1  2  0  0]
      [ 0  0  2 -2]
      [ 0  0 -1  2]
      %> CartanName(C);
      %B2 B2
      %> CartanName(C : Nonreduced:={2});
      %BC2 B2
      %> CartanName(C : Nonreduced:={4});
      %B2 BC2
      %> CartanName(C : Nonreduced:={2,4});
      %BC2 BC2
      %\<CartanName(C : Nonreduced:={1});
      %Runtime error: Invalid set of non-reduced roots

.. magma:function:: DynkinDiagram(M)
   :input_types: AlgMatElt
   :label: DynkinDiagram_AlgMatElt

.. magma:function:: DynkinDiagram(G)
   :input_types: GrphUnd
   :label: DynkinDiagram_GrphUnd

.. magma:function:: DynkinDiagram(C)
   :input_types: AlgMatElt
   :label: DynkinDiagram_AlgMatElt_2

.. magma:function:: DynkinDiagram(D)
   :input_types: GrphDir
   :label: DynkinDiagram_GrphDir

.. magma:function:: DynkinDiagram(N)
   :input_types: MonStgElt
   :label: DynkinDiagram_MonStgElt

   Print the Dynkin diagram of a Coxeter matrix :math:`M`, Coxeter graph :math:`G`,
   Cartan matrix :math:`C`, Dynkin digraph :math:`D` or Cartan name given by the
   string :math:`N`. If the corresponding group is neither affine nor
   crystallographic, an error is flagged.

.. magma:example:: Example: Dynkin Diagram
   :label: DynkinDiagram

   .. code-block:: magma

      > DynkinDiagram("A~5 D4 BC3");

      A~5    1 - 2 - 3 - 4 - 5
             |               |
             ------- 6 -------

      D4    9
           /
      7 - 8
           \\
            10

      BC3    11 - 12 =>= 13

.. magma:function:: CoxeterDiagram(M)
   :input_types: AlgMatElt
   :label: CoxeterDiagram_AlgMatElt

.. magma:function:: CoxeterDiagram(G)
   :input_types: GrphUnd
   :label: CoxeterDiagram_GrphUnd

.. magma:function:: CoxeterDiagram(C)
   :input_types: AlgMatElt
   :label: CoxeterDiagram_AlgMatElt_2

.. magma:function:: CoxeterDiagram(D)
   :input_types: GrphDir
   :label: CoxeterDiagram_GrphDir

.. magma:function:: CoxeterDiagram(N)
   :input_types: MonStgElt
   :label: CoxeterDiagram_MonStgElt

   Print the Coxeter diagram of a Coxeter matrix :math:`M`, Coxeter graph
   :math:`G`, Cartan matrix :math:`C`, Dynkin digraph :math:`D` or Cartan name
   given by the string :math:`N`. If the corresponding group is not affine or is
   not crystallographic, an error is flagged.

.. magma:example:: Example: Coxeter Diagram
   :label: CoxeterDiagram

   .. code-block:: magma

      > CoxeterDiagram("A~5 D4 BC3");
 
      A~5    1 - 2 - 3 - 4 - 5
             |               |
             ------- 6 -------
 
      D4    9
           /
      7 - 8
           \\
            10

      BC3    11 - 12 === 13
