Skip to content

Commit

Permalink
Trac #20973: Cartan type Aoo
Browse files Browse the repository at this point in the history
Gives a ''minimal'' implementation of the `A_oo` Cartan type:
{{{#!sage
sage: CartanType(['A',oo])
['A', oo]
sage: CartanType(['A',oo]).is_irreducible()
True
sage: CartanType(['A',oo]).is_simply_laced()
True
sage: print(CartanType(['A', oo]).ascii_art())
...---O---O---O---O---O---O---O---...
     -3  -2  -1   0   1   2   3
}}}

In addition, the ticket fixes the following error in `CartanType`:
{{{#!sage
sage: CartanType(['A',-1])
  File "<string>", line unknown

    ^
SyntaxError: unexpected EOF while parsing
}}}
This, and other nonsensical input, now raises a `ValueError`.

See related discussion on [https://groups.google.com/forum/#!topic/sage-
combinat-devel/tnQngybmlI4 sage-combinat].

URL: https://trac.sagemath.org/20973
Reported by: andrew.mathas
Ticket author(s): Andrew Mathas
Reviewer(s): Nicolas Thiéry, Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Jul 21, 2016
2 parents 8218404 + c1b57e6 commit 8c6f3ec
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 60 deletions.
1 change: 1 addition & 0 deletions src/doc/en/reference/combinat/module_list.rst
Expand Up @@ -230,6 +230,7 @@ Comprehensive Module list
sage/combinat/root_system/root_system
sage/combinat/root_system/type_A
sage/combinat/root_system/type_A_affine
sage/combinat/root_system/type_A_infinity
sage/combinat/root_system/type_B
sage/combinat/root_system/type_BC_affine
sage/combinat/root_system/type_B_affine
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/root_system/__init__.py
Expand Up @@ -109,6 +109,7 @@
- :ref:`sage.combinat.root_system.type_F_affine`
- :ref:`sage.combinat.root_system.type_G_affine`
- :ref:`sage.combinat.root_system.type_BC_affine`
- :ref:`sage.combinat.root_system.type_A_infinity`
"""
# currently needed to activate the backward compatibility
# register_unpickle_override
Expand Down
163 changes: 103 additions & 60 deletions src/sage/combinat/root_system/cartan_type.py
Expand Up @@ -390,9 +390,24 @@
E6^2
sage: CartanType.options['notation'] = 'BC'
.. TODO:: Should those indexes come before the introduction?
.. rubric:: Infinite Cartan types
There are minimal implementations of the Cartan types `A_{\infty}` and
`A_{+\infty}`. In sage `oo` is the same as `+Infinity`, so `NN` and `ZZ` are
used to differentiate between the `A_{+\infty}` and `A_{\infty}` root systems::
Abstract classes for cartan types
sage: CartanType(['A', NN])
['A', NN]
sage: print(CartanType(['A', NN]).ascii_art())
O---O---O---O---O---O---O---..
0 1 2 3 4 5 6
sage: CartanType(['A', ZZ])
['A', ZZ]
sage: print(CartanType(['A', ZZ]).ascii_art())
..---O---O---O---O---O---O---O---..
-3 -2 -1 0 1 2 3
.. rubric:: Abstract classes for cartan types
- :class:`CartanType_abstract`
- :class:`CartanType_crystallographic`
Expand All @@ -407,6 +422,8 @@
Concrete classes for cartan types
- :class:`CartanType_standard`
- :class:`CartanType_standard_finite`
- :class:`CartanType_standard_affine`
- :class:`CartanType_standard_untwisted_affine`
Expand Down Expand Up @@ -434,6 +451,9 @@
- :ref:`sage.combinat.root_system.type_F_affine`
- :ref:`sage.combinat.root_system.type_G_affine`
- :ref:`sage.combinat.root_system.type_BC_affine`
- :ref:`sage.combinat.root_system.type_A_infinity`
.. TODO:: Should those indexes come before the introduction?
"""
#*****************************************************************************
# Copyright (C) 2007 Mike Hansen <mhansen@gmail.com>,
Expand All @@ -449,6 +469,7 @@
from sage.misc.abstract_method import abstract_method
from sage.misc.lazy_import import LazyImport
from sage.rings.all import ZZ
from sage.rings.infinity import Infinity
from sage.structure.sage_object import SageObject
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.global_options import GlobalOptions
Expand Down Expand Up @@ -534,11 +555,19 @@ def __call__(self, *args):
sage: CT = CartanType('A2').relabel({1:-1, 2:-2})
sage: CartanType([CT])
['A', 2] relabelled by {1: -1, 2: -2}
Check the errors from trac:`20973`::
sage: CartanType(['A',-1])
Traceback (most recent call last):
...
ValueError: ['A', -1] is not a valid Cartan type
"""
if len(args) == 1:
t = args[0]
else:
t = args

if isinstance(t, CartanType_abstract):
return t
if hasattr(t, "cartan_type"):
Expand All @@ -564,6 +593,16 @@ def __call__(self, *args):

t = list(t)

from sage.rings.semirings.non_negative_integer_semiring import NN
if isinstance(t[0], str) and t[1] in [Infinity, ZZ, NN]:
letter, n = t[0], t[1]
if letter == 'A':
from . import type_A_infinity
if t[1] == NN:
return type_A_infinity.CartanType(NN)
else:
return type_A_infinity.CartanType(ZZ)

if isinstance(t[0], str) and t[1] in ZZ and t[1] >= 0:
letter, n = t[0], t[1]
if len(t) == 2:
Expand Down Expand Up @@ -611,6 +650,7 @@ def __call__(self, *args):
if n >= 1:
from . import type_I
return type_I.CartanType(n)

if len(t) == 3:
if t[2] == 1: # Untwisted affine
if letter == "A":
Expand Down Expand Up @@ -658,8 +698,14 @@ def __call__(self, *args):
if letter == "E" and t[2] == 2 and n == 6:
return CartanType(["F", 4, 1]).dual()
raise ValueError("%s is not a valid Cartan type"%t)

# As the Cartan type has not been recognised try subtypes - but check
# for the error noted in trac:???
from . import type_reducible
return type_reducible.CartanType([ CartanType(subtype) for subtype in t ])
try:
return type_reducible.CartanType([ CartanType(subtype) for subtype in t ])
except (SyntaxError, ValueError):
raise ValueError("%s is not a valid Cartan type"%t)

def _repr_(self):
"""
Expand Down Expand Up @@ -2342,7 +2388,59 @@ def other_affinization(self):
##############################################################################
# Concrete base classes

class CartanType_standard_finite(UniqueRepresentation, SageObject, CartanType_finite):
class CartanType_standard(UniqueRepresentation, SageObject):
# Technical methods
def _repr_(self, compact = False):
"""
TESTS::
sage: ct = CartanType(['A',3])
sage: repr(ct)
"['A', 3]"
sage: ct._repr_(compact=True)
'A3'
"""
format = '%s%s' if compact else "['%s', %s]"
return format%(self.letter, self.n)

def __len__(self):
"""
EXAMPLES::
sage: len(CartanType(['A',4]))
2
sage: len(CartanType(['A',4,1]))
3
"""
return 3 if self.is_affine() else 2

def __getitem__(self, i):
"""
EXAMPLES::
sage: t = CartanType(['A', 3, 1])
sage: t[0]
'A'
sage: t[1]
3
sage: t[2]
1
sage: t[3]
Traceback (most recent call last):
...
IndexError: index out of range
"""
if i == 0:
return self.letter
elif i==1:
return self.n
elif hasattr(self, 'affine') and i==2:
return self.affine
else:
raise IndexError("index out of range")


class CartanType_standard_finite(CartanType_standard, CartanType_finite):
"""
A concrete base class for the finite standard Cartan types.
Expand Down Expand Up @@ -2378,20 +2476,6 @@ def __init__(self, letter, n):
self.letter = letter
self.n = n

# Technical methods
def _repr_(self, compact = False):
"""
TESTS::
sage: ct = CartanType(['A',3])
sage: repr(ct)
"['A', 3]"
sage: ct._repr_(compact=True)
'A3'
"""
format = '%s%s' if compact else "['%s', %s]"
return format%(self.letter, self.n)

def __reduce__(self):
"""
TESTS::
Expand Down Expand Up @@ -2434,38 +2518,6 @@ def __hash__(self):
"""
return hash((self.n, self.letter))

def __getitem__(self, i):
"""
EXAMPLES::
sage: t = CartanType(['A', 3, 1])
sage: t[0]
'A'
sage: t[1]
3
sage: t[2]
1
sage: t[3]
Traceback (most recent call last):
...
IndexError: index out of range
"""
if i == 0:
return self.letter
elif i==1:
return self.n
else:
raise IndexError("index out of range")

def __len__(self):
"""
EXAMPLES::
sage: len(CartanType(['A',4]))
2
"""
return 2

# mathematical methods

def index_set(self):
Expand Down Expand Up @@ -2600,7 +2652,7 @@ def opposition_automorphism(self):
return Family(d)

##########################################################################
class CartanType_standard_affine(UniqueRepresentation, SageObject, CartanType_affine):
class CartanType_standard_affine(CartanType_standard, CartanType_affine):
r"""
A concrete class for affine simple Cartan types.
"""
Expand Down Expand Up @@ -2668,15 +2720,6 @@ def __reduce__(self):
from sage.combinat.root_system.cartan_type import CartanType
return (CartanType, (self.letter, self.n, self.affine))

def __len__(self):
"""
EXAMPLES::
sage: len(CartanType(['A',4,1]))
3
"""
return 3

def __getitem__(self, i):
"""
EXAMPLES::
Expand Down

0 comments on commit 8c6f3ec

Please sign in to comment.