def _element_constructor_(self, cartan_type, **kwds): """ The element constructor. This method is called internally when we try to convert something into an element. In this case, the only thing that can be converted into an associahedron is the Cartan type. EXAMPLES:: sage: from sage.combinat.root_system.associahedron import Associahedra sage: parent = Associahedra(QQ,2) sage: parent(['A',2]) Generalized associahedron of type ['A', 2] with 5 vertices sage: parent._element_constructor_(['A',2]) Generalized associahedron of type ['A', 2] with 5 vertices """ cartan_type = CartanType(cartan_type) if not cartan_type.is_finite(): raise ValueError("the Cartan type must be finite") root_space = cartan_type.root_system().root_space() # TODO: generalize this as a method of root lattice realization rhocheck = sum(beta.associated_coroot() for beta in root_space.positive_roots()) / 2 I = root_space.index_set() inequalities = [] for orbit in root_space.almost_positive_roots_decomposition(): c = rhocheck.coefficient(orbit[0].leading_support()) for beta in orbit: inequalities.append([c] + [beta.coefficient(i) for i in I]) associahedron = super(Associahedra, self)._element_constructor_(None, [inequalities, []]) associahedron._cartan_type = cartan_type return associahedron
def __classcall_private__(cls, cartan_type, r, s): """ Normalize the input arguments to ensure unique representation. EXAMPLES:: sage: KRT1 = KirillovReshetikhinTableaux(CartanType(['A',3,1]), 2, 3) sage: KRT2 = KirillovReshetikhinTableaux(['A',3,1], 2, 3) sage: KRT1 is KRT2 True """ ct = CartanType(cartan_type) assert ct.is_affine() if ct.is_untwisted_affine(): if ct.letter == 'D': if r == ct.n or r == ct.n - 1: return KRTableauxSpin(ct, r, s) return KRTableauxTypeVertical(ct, r, s) if ct.letter == 'B': if r == ct.n: return KRTableauxBn(ct, r, s) return KRTypeVertical(ct, r, s) if ct.letter == 'A' or (ct.letter == 'C' and r == ct.n): return KRTableauxRectangle(ct, r, s) else: if ct.dual().letter == 'B': return KRTableauxTypeVertical(ct, r, s) raise NotImplementedError
def __classcall_private__(cls, ambient, virtualization, scaling_factors, contained=None, generators=None, cartan_type=None, index_set=None, category=None): """ Normalize arguments to ensure a unique representation. EXAMPLES:: sage: B = crystals.Tableaux(['B',3], shape=[1]) sage: C = crystals.Tableaux(['D',4], shape=[2]) sage: psi1 = B.crystal_morphism(C.module_generators) sage: V1 = psi1.image() sage: psi2 = B.crystal_morphism(C.module_generators, index_set=[1,2,3]) sage: V2 = psi2.image() sage: V1 is V2 True """ if cartan_type is None: cartan_type = ambient.cartan_type() else: cartan_type = CartanType(cartan_type) if index_set is None: index_set = cartan_type.index_set() if generators is None: generators = ambient.module_generators virtualization = Family(virtualization) scaling_factors = Family(scaling_factors) category = Crystals().or_subcategory(category) return super(Subcrystal, cls).__classcall__(cls, ambient, virtualization, scaling_factors, contained, tuple(generators), cartan_type, tuple(index_set), category)
def __classcall_private__(cls, arg0, cartan_type=None, kac_moody=True): """ Parse input to ensure a unique representation. INPUT: - ``arg0`` -- a simple Lie algebra or a base ring - ``cartan_type`` -- a Cartan type EXAMPLES:: sage: L1 = lie_algebras.Affine(QQ, ['A',4,1]) sage: cl = lie_algebras.sl(QQ, 5) sage: L2 = lie_algebras.Affine(cl) sage: L1 is L2 True sage: cl.affine() is L1 True """ if isinstance(arg0, LieAlgebra): ct = arg0.cartan_type() if not ct.is_finite(): raise ValueError("the base Lie algebra is not simple") cartan_type = ct.affine() g = arg0 else: # arg0 is the base ring cartan_type = CartanType(cartan_type) if not cartan_type.is_affine(): raise ValueError("the Cartan type must be affine") g = LieAlgebra(arg0, cartan_type=cartan_type.classical()) if not cartan_type.is_untwisted_affine(): raise NotImplementedError("only currently implemented for untwisted affine types") return super(AffineLieAlgebra, cls).__classcall__(cls, g, kac_moody)
def __init__(self, W_types, index_set=None, hyperplane_index_set=None, reflection_index_set=None): r""" Initialize ``self``. TESTS:: sage: W = ReflectionGroup(['A',3]) # optional - gap3 sage: TestSuite(W).run() # optional - gap3 """ W_types = tuple([tuple(W_type) if isinstance(W_type, (list, tuple)) else W_type for W_type in W_types]) cartan_types = [] for W_type in W_types: W_type = CartanType(W_type) if not W_type.is_finite() or not W_type.is_irreducible(): raise ValueError("the given Cartan type of a component is not irreducible and finite") cartan_types.append(W_type) if len(W_types) == 1: cls = IrreducibleComplexReflectionGroup else: cls = ComplexReflectionGroup cls.__init__( self, W_types, index_set=index_set, hyperplane_index_set=hyperplane_index_set, reflection_index_set=reflection_index_set, )
def __classcall_private__(cls, cartan_type, virtual, orbit): """ Normalize input to ensure a unique representation. EXAMPLES:: sage: from sage.combinat.root_system.type_folded import CartanTypeFolded sage: sigma_list = [[0], [1,5], [2,4], [3]] sage: fct1 = CartanTypeFolded(['C',3,1], ['A',5,1], sigma_list) sage: sigma_tuple = tuple(map(tuple, sigma_list)) sage: fct2 = CartanTypeFolded(CartanType(['C',3,1]), CartanType(['A',5,1]), sigma_tuple) sage: fct3 = CartanTypeFolded('C3~', 'A5~', {0:[0], 2:[2,4], 1:[1,5], 3:[3]}) sage: fct1 is fct2 and fct2 is fct3 True """ if isinstance(cartan_type, CartanTypeFolded): return cartan_type cartan_type = CartanType(cartan_type) virtual = CartanType(virtual) if isinstance(orbit, dict): i_set = cartan_type.index_set() orb = [None]*len(i_set) for k,v in six.iteritems(orbit): orb[i_set.index(k)] = tuple(v) orbit = tuple(orb) else: orbit = tuple(map(tuple, orbit)) return super(CartanTypeFolded, cls).__classcall__(cls, cartan_type, virtual, orbit)
def __classcall_private__(cls, cartan_type, wt=None): r""" Normalize the input arguments to ensure unique representation. EXAMPLES:: sage: La = RootSystem(['A', 2]).weight_lattice().fundamental_weights() sage: RC = crystals.RiggedConfigurations(La[1]) sage: RC2 = crystals.RiggedConfigurations(['A', 2], La[1]) sage: RC is RC2 True """ if wt is None: wt = cartan_type cartan_type = wt.parent().cartan_type() else: cartan_type = CartanType(cartan_type) wt_lattice = cartan_type.root_system().weight_lattice() wt = wt_lattice(wt) if not cartan_type.is_simply_laced(): vct = cartan_type.as_folding() return CrystalOfNonSimplyLacedRC(vct, wt) return super(CrystalOfRiggedConfigurations, cls).__classcall__(cls, wt)
def __classcall_private__(cls, ct, c=None, use_Y=None): r""" Normalize input to ensure a unique representation. INPUT: - ``ct`` -- a Cartan type EXAMPLES:: sage: M = crystals.infinity.NakajimaMonomials("E8") sage: M1 = crystals.infinity.NakajimaMonomials(['E',8]) sage: M2 = crystals.infinity.NakajimaMonomials(CartanType(['E',8])) sage: M is M1 is M2 True """ if use_Y is not None: from sage.misc.superseded import deprecation deprecation(18895, 'use_Y is deprecated; use the set_variables() method instead.') else: use_Y = True cartan_type = CartanType(ct) n = len(cartan_type.index_set()) c = InfinityCrystalOfNakajimaMonomials._normalize_c(c, n) M = super(InfinityCrystalOfNakajimaMonomials, cls).__classcall__(cls, cartan_type, c) if not use_Y: M.set_variables('A') else: M.set_variables('Y') return M
def __classcall_private__(cls, cartan_type, shapes = None, shape = None): """ Normalizes the input arguments to ensure unique representation, and to delegate the construction of spin tableaux. EXAMPLES:: sage: T1 = CrystalOfTableaux(CartanType(['A',3]), shape = [2,2]) sage: T2 = CrystalOfTableaux(['A',3], shape = (2,2)) sage: T3 = CrystalOfTableaux(['A',3], shapes = ([2,2],)) sage: T2 is T1, T3 is T1 (True, True) """ cartan_type = CartanType(cartan_type) n = cartan_type.rank() # standardize shape/shapes input into a tuple of tuples assert operator.xor(shape is not None, shapes is not None) if shape is not None: shapes = (shape,) spin_shapes = tuple( tuple(shape) for shape in shapes ) try: shapes = tuple( tuple(trunc(i) for i in shape) for shape in spin_shapes ) except StandardError: raise ValueError("shapes should all be partitions or half-integer partitions") if spin_shapes == shapes: return super(CrystalOfTableaux, cls).__classcall__(cls, cartan_type, shapes) # Handle the construction of a crystals of spin tableaux # Caveat: this currently only supports all shapes being half # integer partitions of length the rank for type B and D. In # particular, for type D, the spins all have to be plus or all # minus spins assert all(len(sh) == n for sh in shapes), \ "the length of all half-integer partition shapes should be the rank" assert all(2*i % 2 == 1 for shape in spin_shapes for i in shape), \ "shapes should be either all partitions or all half-integer partitions" if cartan_type.type() == 'D': if all( i >= 0 for shape in spin_shapes for i in shape): S = CrystalOfSpinsPlus(cartan_type) elif all(shape[-1]<0 for shape in spin_shapes): S = CrystalOfSpinsMinus(cartan_type) else: raise ValueError, "In type D spins should all be positive or negative" else: assert all( i >= 0 for shape in spin_shapes for i in shape), \ "shapes should all be partitions" S = CrystalOfSpins(cartan_type) B = CrystalOfTableaux(cartan_type, shapes = shapes) T = TensorProductOfCrystals(S,B, generators=[[S.module_generators[0],x] for x in B.module_generators]) T.rename("The crystal of tableaux of type %s and shape(s) %s"%(cartan_type, list(list(shape) for shape in spin_shapes))) T.shapes = spin_shapes return T
def cartan_type(self): """ Return the Cartan type of ``self``. EXAMPLES:: sage: FiniteWeylGroups().example().cartan_type() ['A', 3] relabelled by {1: 0, 2: 1, 3: 2} """ from sage.combinat.root_system.cartan_type import CartanType C = CartanType(['A',self.n-1]) C = C.relabel(lambda i:i-1) return C
def __classcall_private__(cls, cartan_type): """ Normalize input to ensure a unique representation. EXAMPLES:: sage: B = crystals.infinity.Tableaux(['A',4]) sage: B2 = crystals.infinity.Tableaux(CartanType(['A',4])) sage: B is B2 True """ cartan_type = CartanType(cartan_type) if cartan_type.type() == 'D': return InfinityCrystalOfTableauxTypeD(cartan_type) return super(InfinityCrystalOfTableaux, cls).__classcall__(cls, cartan_type)
def __classcall_private__(cls, cartan_type, i): r""" Normalize input to ensure a unique representation. EXAMPLES:: sage: B = crystals.elementary.Elementary(['A',4], 3) sage: C = crystals.elementary.Elementary(CartanType("A4"), int(3)) sage: B is C True """ cartan_type = CartanType(cartan_type) if i not in cartan_type.index_set(): raise ValueError('i must an element of the index set.') return super(ElementaryCrystal, cls).__classcall__(cls, cartan_type, i)
def __classcall__(cls, cartan_type): """ Normalize input to ensure a unique representation. EXAMPLES:: sage: B1 = crystals.infinity.PBW(['A', 2]) sage: B2 = crystals.infinity.PBW("A2") sage: B3 = crystals.infinity.PBW(CartanType("A2")) sage: B1 is B2 and B2 is B3 True """ cartan_type = CartanType(cartan_type) if not cartan_type.is_finite(): raise NotImplementedError("only implemented for finite types") return super(PBWCrystal, cls).__classcall__(cls, cartan_type)
def __classcall_private__(cls, cartan_type): r""" Normalize the input arguments to ensure unique representation. EXAMPLES:: sage: RC1 = crystals.infinity.RiggedConfigurations(CartanType(['A',3])) sage: RC2 = crystals.infinity.RiggedConfigurations(['A',3]) sage: RC2 is RC1 True """ cartan_type = CartanType(cartan_type) if not cartan_type.is_simply_laced(): vct = cartan_type.as_folding() return InfinityCrystalOfNonSimplyLacedRC(vct) return super(InfinityCrystalOfRiggedConfigurations, cls).__classcall__(cls, cartan_type)
class CartanTypeFindStat(object): """ A Cartan type class for FindStat """ def __init__(self, ct): self._cartan_type = CartanType(ct) def __hash__(self): return hash(self._cartan_type) def _latex_(self): return self._cartan_type.dynkin_diagram()._latex_() def __repr__(self): return self._cartan_type._repr_() _repr_ = __repr__
def __classcall_private__(cls, starting_weight, cartan_type = None, starting_weight_parent = None): """ Classcall to mend the input. Internally, the :class:`~sage.combinat.crystals.littlemann_path.CrystalOfLSPaths` code works with a ``starting_weight`` that is in the weight space associated to the crystal. The user can, however, also input a ``cartan_type`` and the coefficients of the fundamental weights as ``starting_weight``. This code transforms the input into the right format (also necessary for UniqueRepresentation). TESTS:: sage: crystals.LSPaths(['A',2,1],[-1,0,1]) The crystal of LS paths of type ['A', 2, 1] and weight -Lambda[0] + Lambda[2] sage: R = RootSystem(['B',2,1]) sage: La = R.weight_space(extended=True).basis() sage: C = crystals.LSPaths(['B',2,1],[0,0,1]) sage: B = crystals.LSPaths(La[2]) sage: B is C True """ if cartan_type is not None: cartan_type, starting_weight = CartanType(starting_weight), cartan_type if cartan_type.is_affine(): extended = True else: extended = False R = RootSystem(cartan_type) P = R.weight_space(extended = extended) Lambda = P.basis() offset = R.index_set()[Integer(0)] starting_weight = P.sum(starting_weight[j-offset]*Lambda[j] for j in R.index_set()) if starting_weight_parent is None: starting_weight_parent = starting_weight.parent() else: # Both the weight and the parent of the weight are passed as arguments of init to be able # to distinguish between crystals with the extended and non-extended weight lattice! if starting_weight.parent() != starting_weight_parent: raise ValueError("The passed parent is not equal to parent of the inputted weight!") return super(CrystalOfLSPaths, cls).__classcall__(cls, starting_weight, starting_weight_parent = starting_weight_parent)
def __classcall_private__(cls, ambient, virtualization, scaling_factors, contained=None, generators=None, cartan_type=None, index_set=None, category=None): """ Normalize arguments to ensure a unique representation. EXAMPLES:: sage: B = crystals.Tableaux(['B',3], shape=[1]) sage: C = crystals.Tableaux(['D',4], shape=[2]) sage: psi1 = B.crystal_morphism(C.module_generators) sage: V1 = psi1.image() sage: psi2 = B.crystal_morphism(C.module_generators, index_set=[1,2,3]) sage: V2 = psi2.image() sage: V1 is V2 True TESTS: Check that :trac:`19481` is fixed:: sage: from sage.combinat.crystals.virtual_crystal import VirtualCrystal sage: A = crystals.Tableaux(['A',3], shape=[2,1,1]) sage: V = VirtualCrystal(A, {1:(1,3), 2:(2,)}, {1:1, 2:2}, cartan_type=['C',2]) sage: V.category() Category of finite crystals """ if cartan_type is None: cartan_type = ambient.cartan_type() else: cartan_type = CartanType(cartan_type) if index_set is None: index_set = cartan_type.index_set() if generators is None: generators = ambient.module_generators virtualization = Family(virtualization) scaling_factors = Family(scaling_factors) category = Crystals().or_subcategory(category) if ambient in FiniteCrystals() or isinstance(contained, frozenset): category = category.Finite() return super(Subcrystal, cls).__classcall__(cls, ambient, virtualization, scaling_factors, contained, tuple(generators), cartan_type, tuple(index_set), category)
def __classcall_private__(cls, cartan_type, B): """ Normalize the input arguments to ensure unique representation. EXAMPLES:: sage: T1 = crystals.TensorProductOfKirillovReshetikhinTableaux(CartanType(['A',3,1]), [[2,2]]) sage: T2 = crystals.TensorProductOfKirillovReshetikhinTableaux(['A',3,1], [(2,2)]) sage: T3 = crystals.TensorProductOfKirillovReshetikhinTableaux(['A',3,1], ((2,2),)) sage: T2 is T1, T3 is T1 (True, True) """ cartan_type = CartanType(cartan_type) if not cartan_type.is_affine(): raise ValueError("The Cartan type must be affine") # Standardize B input into a tuple of tuples B = tuple(tuple(dim) for dim in B) return super(TensorProductOfKirillovReshetikhinTableaux, cls).__classcall__(cls, cartan_type, B)
def __classcall_private__(cls, cartan_type, seq=None): """ Normalize input to ensure a unique representation. EXAMPLES:: sage: B1 = crystals.infinity.PolyhedralRealization(['A',2]) sage: B2 = crystals.infinity.PolyhedralRealization(['A',2], [1,2]) sage: B1 is B2 True """ cartan_type = CartanType(cartan_type) if seq is None: seq = cartan_type.index_set() else: seq = tuple(seq) if set(seq) != set(cartan_type.index_set()): raise ValueError("the support of seq is not the index set") return super(InfinityCrystalAsPolyhedralRealization, cls).__classcall__(cls, cartan_type, seq)
def __classcall_private__(cls, cartan_type, La): r""" Normalize input to ensure a unique representation. EXAMPLES:: sage: La = RootSystem(['E',8,1]).weight_lattice(extended=True).fundamental_weights() sage: M = crystals.NakajimaMonomials(['E',8,1],La[0]+La[8]) sage: M1 = crystals.NakajimaMonomials(CartanType(['E',8,1]),La[0]+La[8]) sage: M2 = crystals.NakajimaMonomials(['E',8,1],M.Lambda()[0] + M.Lambda()[8]) sage: M is M1 is M2 True """ cartan_type = CartanType(cartan_type) if cartan_type.is_affine(): La = RootSystem(cartan_type).weight_lattice(extended=True)(La) else: La = RootSystem(cartan_type).weight_lattice()(La) return super(CrystalOfNakajimaMonomials, cls).__classcall__(cls, cartan_type, La)
def __classcall_private__(cls, ct, c=1, t=None, base_ring=None, prefix=('a', 's', 'ac')): """ Normalize input to ensure a unique representation. EXAMPLES:: sage: R1 = algebras.RationalCherednik(['B',2], 1, 1, QQ) sage: R2 = algebras.RationalCherednik(CartanType(['B',2]), [1,1], 1, QQ, ('a', 's', 'ac')) sage: R1 is R2 True """ ct = CartanType(ct) if not ct.is_finite(): raise ValueError("the Cartan type must be finite") if base_ring is None: if t is None: base_ring = QQ else: base_ring = t.parent() if t is None: t = base_ring.one() else: t = base_ring(t) # Normalize the parameter c if isinstance(c, (tuple, list)): if ct.is_simply_laced(): if len(c) != 1: raise ValueError("1 parameter c_s must be given for simply-laced types") c = (base_ring(c[0]),) else: if len(c) != 2: raise ValueError("2 parameters c_s must be given for non-simply-laced types") c = (base_ring(c[0]), base_ring(c[1])) else: c = base_ring(c) if ct.is_simply_laced(): c = (c,) else: c = (c, c) return super(RationalCherednikAlgebra, cls).__classcall__(cls, ct, c, t, base_ring, tuple(prefix))
def coxeter_matrix_as_function(t): """ Return the Coxeter matrix, as a function. INPUT: - ``t`` -- a Cartan type EXAMPLES:: sage: from sage.combinat.root_system.coxeter_matrix import coxeter_matrix_as_function sage: f = coxeter_matrix_as_function(['A',4]) sage: matrix([[f(i,j) for j in range(1,5)] for i in range(1,5)]) [1 3 2 2] [3 1 3 2] [2 3 1 3] [2 2 3 1] """ t = CartanType(t) m = t.coxeter_matrix() return lambda i, j: m[i, j]
def __classcall_private__(cls, ct, c=None): r""" Normalize input to ensure a unique representation. INPUT: - ``ct`` -- a Cartan type EXAMPLES:: sage: M = crystals.infinity.NakajimaMonomials("E8") sage: M1 = crystals.infinity.NakajimaMonomials(['E',8]) sage: M2 = crystals.infinity.NakajimaMonomials(CartanType(['E',8])) sage: M is M1 is M2 True """ cartan_type = CartanType(ct) n = len(cartan_type.index_set()) c = InfinityCrystalOfNakajimaMonomials._normalize_c(c, n) M = super(InfinityCrystalOfNakajimaMonomials, cls).__classcall__(cls, cartan_type, c) M.set_variables('Y') return M
def __init__(self, n): """ Initialize ``self``. EXAMPLES:: sage: B = crystals.infinity.Multisegments(2) sage: TestSuite(B).run() """ self._cartan_type = CartanType(['A', n, 1]) self._Zn = IntegerModRing(n+1) Parent.__init__(self, category=(HighestWeightCrystals(), InfiniteEnumeratedSets())) self.module_generators = (self.highest_weight_vector(),)
def cartan_type(self): r""" Return the Cartan type of ``self``. EXAMPLES:: sage: W = ReflectionGroup(['A',3]) # optional - gap3 sage: W.cartan_type() # optional - gap3 ['A', 3] sage: W = ReflectionGroup(['A',3], ['B',3]) # optional - gap3 sage: W.cartan_type() # optional - gap3 A3xB3 relabelled by {1: 3, 2: 2, 3: 1} """ if len(self._type) == 1: ct = self._type[0] C = CartanType([ct['series'], ct['rank']]) CG = C.coxeter_diagram() G = self.coxeter_diagram() return C.relabel(CG.is_isomorphic(G, edge_labels=True, certificate=True)[1]) else: return CartanType([W.cartan_type() for W in self.irreducible_components()])
def __classcall_private__(cls, cartan_type): """ Normalize input to ensure a unique representation. EXAMPLES:: sage: B = crystals.infinity.Tableaux(['D',4]) sage: B2 = crystals.infinity.Tableaux(CartanType(['D',4])) sage: B is B2 True """ return super(InfinityCrystalOfTableauxTypeD, cls).__classcall__(cls, CartanType(cartan_type))
def __classcall__(cls, cartan_type): """ TESTS:: sage: from sage.combinat.root_system.coxeter_group import CoxeterGroupAsPermutationGroup sage: W1 = CoxeterGroupAsPermutationGroup(CartanType(["H",3])) # optional - gap3 sage: W2 = CoxeterGroupAsPermutationGroup(["H",3]) # optional - gap3 sage: W1 is W2 # optional - gap3 True """ cartan_type = CartanType(cartan_type) return super(CoxeterGroupAsPermutationGroup, cls).__classcall__(cls, cartan_type)
def __classcall_private__(cls, cartan_type): r""" Normalize input to ensure a unique representation. EXAMPLES:: sage: C = ComponentCrystal("A2") sage: D = ComponentCrystal(CartanType(['A',2])) sage: C is D True """ cartan_type = CartanType(cartan_type) return super(ComponentCrystal, cls).__classcall__(cls, cartan_type)
def __init__(self, initial_state, cartan_type=2, vacuum=1): """ Initialize ``self``. EXAMPLES:: sage: B = SolitonCellularAutomata('3411111122411112223', 4) sage: TestSuite(B).run() """ if cartan_type in ZZ: cartan_type = CartanType(['A', cartan_type - 1, 1]) else: cartan_type = CartanType(cartan_type) self._cartan_type = cartan_type self._vacuum = vacuum K = KirillovReshetikhinTableaux(self._cartan_type, self._vacuum, 1) try: # FIXME: the maximal_vector() does not work in type E and F self._vacuum_elt = K.maximal_vector() except (ValueError, TypeError, AttributeError): self._vacuum_elt = K.module_generators[0] if isinstance(initial_state, str): # We consider things 1-9 initial_state = [[ZZ(x) if x != '.' else ZZ.one()] for x in initial_state] try: KRT = TensorProductOfKirillovReshetikhinTableaux( self._cartan_type, [[vacuum, len(st) // vacuum] for st in initial_state]) self._states = [KRT(pathlist=initial_state)] except TypeError: KRT = TensorProductOfKirillovReshetikhinTableaux( self._cartan_type, [[vacuum, 1] for st in initial_state]) self._states = [KRT(*initial_state)] self._evolutions = [] self._nballs = len(self._states[0])
def __classcall_private__(cls, cartan_type, wt=None, WLR=None): r""" Normalize the input arguments to ensure unique representation. EXAMPLES:: sage: La = RootSystem(['A', 2]).weight_lattice().fundamental_weights() sage: RC = crystals.RiggedConfigurations(La[1]) sage: RC2 = crystals.RiggedConfigurations(['A', 2], La[1]) sage: RC3 = crystals.RiggedConfigurations(['A', 2], La[1], La[1].parent()) sage: RC is RC2 and RC2 is RC3 True sage: La = RootSystem(['A',2,1]).weight_lattice().fundamental_weights() sage: LaE = RootSystem(['A',2,1]).weight_lattice(extended=True).fundamental_weights() sage: RC = crystals.RiggedConfigurations(La[1]) sage: RCE = crystals.RiggedConfigurations(LaE[1]) sage: RC is RCE False """ if wt is None: wt = cartan_type cartan_type = wt.parent().cartan_type() else: cartan_type = CartanType(cartan_type) if WLR is None: WLR = wt.parent() else: wt = WLR(wt) if not cartan_type.is_simply_laced(): vct = cartan_type.as_folding() return CrystalOfNonSimplyLacedRC(vct, wt, WLR) return super(CrystalOfRiggedConfigurations, cls).__classcall__(cls, wt, WLR=WLR)
def __classcall_private__(cls, starting_weight, cartan_type=None): """ Classcall to mend the input. Internally, the CrystalOfLSPaths code works with a ``starting_weight`` that is in the ``weight_space`` associated to the crystal. The user can, however, also input a ``cartan_type`` and the coefficients of the fundamental weights as ``starting_weight``. This code transforms the input into the right format (also necessary for UniqueRepresentation). TESTS:: sage: CrystalOfLSPaths(['A',2,1],[-1,0,1]) The crystal of LS paths of type ['A', 2, 1] and weight -Lambda[0] + Lambda[2] sage: R = RootSystem(['B',2,1]) sage: La = R.weight_space().basis() sage: C = CrystalOfLSPaths(['B',2,1],[0,0,1]) sage: B = CrystalOfLSPaths(La[2]) sage: B is C True """ if cartan_type is not None: cartan_type, starting_weight = CartanType( starting_weight), cartan_type if cartan_type.is_affine(): extended = True else: extended = False R = RootSystem(cartan_type) P = R.weight_space(extended=extended) Lambda = P.basis() offset = R.index_set()[Integer(0)] starting_weight = P.sum(starting_weight[j - offset] * Lambda[j] for j in R.index_set()) return super(CrystalOfLSPaths, cls).__classcall__(cls, starting_weight)
def __classcall__(cls, cartan_type, starting_weight): """ cartan_type and starting_weight are lists, which are mutable. The class UniqueRepresentation requires immutable inputs. The following code fixes this problem. TESTS:: sage: CrystalOfLSPaths.__classcall__(CrystalOfLSPaths,['A',2,1],[-1,0,1]) The crystal of LS paths of type ['A', 2, 1] and weight (-1, 0, 1) """ cartan_type = CartanType(cartan_type) starting_weight = tuple(starting_weight) return super(CrystalOfLSPaths, cls).__classcall__(cls, cartan_type, starting_weight)
def __classcall_private__(cls, cartan_type): """ Normalize input to ensure a unique representation. EXAMPLES:: sage: from sage.combinat.root_system.coxeter_type import CoxeterTypeFromCartanType sage: C1 = CoxeterTypeFromCartanType(['A',3]) sage: C2 = CoxeterTypeFromCartanType(CartanType(['A',3])) sage: C1 is C2 True """ return super(CoxeterTypeFromCartanType, cls).__classcall__(cls, CartanType(cartan_type))
def cartan_type(self): r""" Return the Cartan type of ``self``. EXAMPLES:: sage: W = ReflectionGroup(['A',3]) # optional - gap3 sage: W.cartan_type() # optional - gap3 ['A', 3] sage: W = ReflectionGroup(['A',3], ['B',2]) # optional - gap3 sage: W.cartan_type() # optional - gap3 A3xB2 """ if len(self._type) == 1: ct = self._type[0] C = CartanType([ct['series'], ct['rank']]) return C.relabel( {i + 1: ii for i, ii in enumerate(self.index_set())}) else: return CartanType( [W.cartan_type() for W in self.irreducible_components()])
def __classcall_private__(cls, ambient, contained=None, generators=None, virtualization=None, scaling_factors=None, cartan_type=None, index_set=None, category=None): """ Normalize arguments to ensure a (relatively) unique representation. EXAMPLES:: sage: B = crystals.Tableaux(['A',4], shape=[2,1]) sage: S1 = B.subcrystal(generators=(B(2,1,1), B(5,2,4)), index_set=[1,2]) sage: S2 = B.subcrystal(generators=[B(2,1,1), B(5,2,4)], cartan_type=['A',4], index_set=(1,2)) sage: S1 is S2 True """ if isinstance(contained, (list, tuple, set, frozenset)): contained = frozenset(contained) #elif contained in Sets(): if cartan_type is None: cartan_type = ambient.cartan_type() else: cartan_type = CartanType(cartan_type) if index_set is None: index_set = cartan_type.index_set if generators is None: generators = ambient.module_generators category = Crystals().or_subcategory(category) if ambient in FiniteCrystals() or isinstance(contained, frozenset): category = category.Finite() if virtualization is not None: if scaling_factors is None: scaling_factors = {i:1 for i in index_set} from sage.combinat.crystals.virtual_crystal import VirtualCrystal return VirtualCrystal(ambient, virtualization, scaling_factors, contained, generators, cartan_type, index_set, category) if scaling_factors is not None: # virtualization must be None virtualization = {i:(i,) for i in index_set} from sage.combinat.crystals.virtual_crystal import VirtualCrystal return VirtualCrystal(ambient, virtualization, scaling_factors, contained, generators, cartan_type, index_set, category) # We need to give these as optional arguments so it unpickles correctly return super(Subcrystal, cls).__classcall__(cls, ambient, contained, tuple(generators), cartan_type=cartan_type, index_set=tuple(index_set), category=category)
def __classcall__(cls, cartan_type, highest_weight): """ cartan_type and heighest_weight are lists, which are mutable, this causes a problem for class UniqueRepresentation, the following code fixes this problem. EXAMPLES:: sage: ClassicalCrystalOfAlcovePaths.__classcall__(ClassicalCrystalOfAlcovePaths,['A',3],[0,1,0]) <class 'sage.combinat.crystals.alcove_path.ClassicalCrystalOfAlcovePaths_with_category'> """ cartan_type = CartanType(cartan_type) highest_weight = tuple(highest_weight) return super(ClassicalCrystalOfAlcovePaths, cls).__classcall__(cls, cartan_type, highest_weight)
def __init__(self): """ EXAMPLES:: sage: C = sage.categories.examples.crystals.NaiveCrystal() sage: C == Crystals().example(choice='naive') True """ Parent.__init__(self, category = ClassicalCrystals()) self.n = 2 self._cartan_type = CartanType(['A',2]) self.G = DiGraph(5) self.G.add_edges([ [0,1,1], [1,2,1], [2,3,1], [3,5,1], [0,4,2], [4,5,2] ]) self.module_generators = [ self(0) ]
def _CM_init(self, cartan_type, index_set, cartan_type_check): """ Initialize ``self`` as a Cartan matrix. TESTS:: sage: C = CartanMatrix(['A',1,1]) # indirect doctest sage: TestSuite(C).run(skip=["_test_category", "_test_change_ring"]) """ self._index_set = index_set self.set_immutable() if cartan_type is not None: cartan_type = CartanType(cartan_type) elif self.nrows() == 1: cartan_type = CartanType(['A', 1]) elif cartan_type_check: # Placeholder so we don't have to reimplement creating a # Dynkin diagram from a Cartan matrix self._cartan_type = None cartan_type = find_cartan_type_from_matrix(self) self._cartan_type = cartan_type
def __init__(self, w, factors, excess): """ Initialize a crystal for ``self`` given reduced word ``w`` in the symmetric group, number of factors ``factors`` and``excess`` extra letters. EXAMPLES:: sage: S = SymmetricGroup(3+1) sage: w = S.from_reduced_word([1, 3, 2]) sage: B = crystals.FullyCommutativeStableGrothendieck(w, 3, 2) sage: B.w (1, 3, 2) sage: B.factors 3 sage: B.excess 2 sage: B.H 0-Hecke monoid of the Symmetric group of order 4! as a permutation group The reduced word ``w`` should be fully commutative, that is, its associated permutation should avoid the pattern 321:: sage: S = SymmetricGroup(3+1) sage: w = S.from_reduced_word([1, 2, 1]) sage: B = crystals.FullyCommutativeStableGrothendieck(w, 4, 2) Traceback (most recent call last): ... ValueError: w should be fully commutative TESTS:: sage: S = SymmetricGroup(3+1) sage: w = S.from_reduced_word([2, 3, 1]) sage: B = crystals.FullyCommutativeStableGrothendieck(w, 4, 2) sage: TestSuite(B).run() """ # Check if w is fully commutative word = w.reduced_word() p = permutation.from_reduced_word(word) if p.has_pattern([3, 2, 1]): raise ValueError("w should be fully commutative") Parent.__init__(self, category=ClassicalCrystals()) self.w = tuple(word) self.factors = factors self.H = w.parent() self.max_value = len(self.H.gens()) self.excess = excess self._cartan_type = CartanType(['A', self.factors - 1])
def __init__(self, W_types, index_set=None, hyperplane_index_set=None, reflection_index_set=None): r""" Initialize ``self``. TESTS:: sage: W = ReflectionGroup(['A',3]) # optional - gap3 sage: TestSuite(W).run() # optional - gap3 """ W_types = tuple([tuple(W_type) if isinstance(W_type, (list,tuple)) else W_type for W_type in W_types]) cartan_types = [] for W_type in W_types: W_type = CartanType(W_type) if not W_type.is_finite() or not W_type.is_irreducible(): raise ValueError("the given Cartan type of a component is not irreducible and finite") cartan_types.append( W_type ) if len(W_types) == 1: cls = IrreducibleComplexReflectionGroup else: cls = ComplexReflectionGroup cls.__init__(self, W_types, index_set = index_set, hyperplane_index_set = hyperplane_index_set, reflection_index_set = reflection_index_set)
def __classcall__(cls, base_ring, cartan_type, level=None, twisted=False): """ Normalize arguments to ensure a unique representation. EXAMPLES:: sage: Q1 = QSystem(QQ, ['A',4]) sage: Q2 = QSystem(QQ, 'A4') sage: Q1 is Q2 True Twisted Q-systems are different from untwisted Q-systems:: sage: Q1 = QSystem(QQ, ['E',6,2], twisted=True) sage: Q2 = QSystem(QQ, ['E',6,2]) sage: Q1 is Q2 False """ cartan_type = CartanType(cartan_type) if not is_tamely_laced(cartan_type): raise ValueError("the Cartan type is not tamely-laced") if twisted and not cartan_type.is_affine() and not cartan_type.is_untwisted_affine(): raise ValueError("the Cartan type must be of twisted type") return super(QSystem, cls).__classcall__(cls, base_ring, cartan_type, level, twisted)
def __classcall_private__(cls, starting_weight, cartan_type = None): """ Classcall to mend the input. Internally, the CrystalOfLSPaths code works with a ``starting_weight`` that is in the ``weight_space`` associated to the crystal. The user can, however, also input a ``cartan_type`` and the coefficients of the fundamental weights as ``starting_weight``. This code transforms the input into the right format (also necessary for UniqueRepresentation). TESTS:: sage: CrystalOfLSPaths(['A',2,1],[-1,0,1]) The crystal of LS paths of type ['A', 2, 1] and weight -Lambda[0] + Lambda[2] sage: R = RootSystem(['B',2,1]) sage: La = R.weight_space().basis() sage: C = CrystalOfLSPaths(['B',2,1],[0,0,1]) sage: B = CrystalOfLSPaths(La[2]) sage: B is C True """ if cartan_type is not None: cartan_type, starting_weight = CartanType(starting_weight), cartan_type if cartan_type.is_affine(): extended = True else: extended = False R = RootSystem(cartan_type) P = R.weight_space(extended = extended) Lambda = P.basis() offset = R.index_set()[Integer(0)] starting_weight = P.sum(starting_weight[j-offset]*Lambda[j] for j in R.index_set()) return super(CrystalOfLSPaths, cls).__classcall__(cls, starting_weight)
def __classcall__(cls, cartan_type, *args, **options): """ TESTS:: sage: n = 1 sage: C = CrystalOfTableaux(['A',n],shape=[1]) sage: pr = attrcall("promotion") sage: pr_inverse = attrcall("promotion_inverse") sage: A = AffineCrystalFromClassicalAndPromotion(['A',n,1],C,pr,pr_inverse,1) # indirect doctest sage: B = AffineCrystalFromClassicalAndPromotion(['A',n,1],C,pr,pr_inverse,1) # indirect doctest sage: A is B True """ ct = CartanType(cartan_type) return super(AffineCrystalFromClassical, cls).__classcall__(cls, ct, *args, **options)
def __classcall_private__(cls, cartan_type, La=None, c=None): r""" Normalize input to ensure a unique representation. EXAMPLES:: sage: La = RootSystem(['E',8,1]).weight_lattice(extended=True).fundamental_weights() sage: M = crystals.NakajimaMonomials(['E',8,1],La[0]+La[8]) sage: M1 = crystals.NakajimaMonomials(CartanType(['E',8,1]),La[0]+La[8]) sage: M2 = crystals.NakajimaMonomials(['E',8,1],M.Lambda()[0] + M.Lambda()[8]) sage: M is M1 is M2 True """ if La is None: La = cartan_type cartan_type = La.parent().cartan_type() cartan_type = CartanType(cartan_type) if cartan_type.is_affine(): La = RootSystem(cartan_type).weight_lattice(extended=True)(La) else: La = RootSystem(cartan_type).weight_lattice()(La) n = len(cartan_type.index_set()) c = InfinityCrystalOfNakajimaMonomials._normalize_c(c, n) return super(CrystalOfNakajimaMonomials, cls).__classcall__(cls, cartan_type, La, c)
def cartan_type(self): r""" Return the Cartan type of ``self``. EXAMPLES:: sage: W = ReflectionGroup(['A',3]) # optional - gap3 sage: W.cartan_type() # optional - gap3 ['A', 3] sage: W = ReflectionGroup(['A',3], ['B',3]) # optional - gap3 sage: W.cartan_type() # optional - gap3 A3xB3 relabelled by {1: 3, 2: 2, 3: 1} """ if len(self._type) == 1: ct = self._type[0] C = CartanType([ct['series'], ct['rank']]) CG = C.coxeter_diagram() G = self.coxeter_diagram() return C.relabel( CG.is_isomorphic(G, edge_labels=True, certificate=True)[1]) else: return CartanType( [W.cartan_type() for W in self.irreducible_components()])
def __classcall_private__(cls, cartan_type, P=None): r""" Normalize input to ensure a unique representation. EXAMPLES:: sage: C = crystals.elementary.Component("A2") sage: D = crystals.elementary.Component(CartanType(['A',2])) sage: C is D True sage: AS = RootSystem(['A',2]).ambient_space() sage: E = crystals.elementary.Component(AS) sage: F = crystals.elementary.Component(CartanType(['A',2]), AS) sage: C is E and C is F True """ if cartan_type in RootLatticeRealizations: P = cartan_type elif P is None: cartan_type = CartanType(cartan_type) P = cartan_type.root_system().ambient_space() if P is None: P = cartan_type.root_system().weight_lattice() return super(ComponentCrystal, cls).__classcall__(cls, P)
def __init__(self, cartan_type): """ TESTS:: sage: Asso = Associahedron(['A',2]); Asso Generalized associahedron of type ['A', 2] with 5 vertices sage: TestSuite(Asso).run() """ self._cartan_type = CartanType(cartan_type) assert self._cartan_type.is_finite() root_space = self._cartan_type.root_system().root_space() # TODO: generalize this as a method of root lattice realization rhocheck = sum(beta.associated_coroot() for beta in root_space.positive_roots()) / 2 I = root_space.index_set() inequalities = [] for orbit in root_space.almost_positive_roots_decomposition(): c = rhocheck.coefficient(orbit[0].leading_support()) for beta in orbit: inequalities.append([c] + [beta.coefficient(i) for i in I]) Polyhedron_QQ_ppl.__init__(self, len(I), None, [inequalities, []]) # check that there are non non trivial facets assert self.n_facets() == len(inequalities)
def coxeter_matrix(self): """ Return the Coxeter matrix of ``self``. EXAMPLES:: sage: S = SignedPermutations(4) sage: S.coxeter_matrix() [1 3 2 2] [3 1 3 2] [2 3 1 4] [2 2 4 1] """ from sage.combinat.root_system.cartan_type import CartanType return CartanType(['B', self._n]).coxeter_matrix()
def __classcall_private__(cls, cartan_type, la, mu): """ Normalize input to ensure a unique representation. TESTS:: sage: K1 = crystals.KacModule(['A', [2,1]], [2,1], [1]) sage: K2 = crystals.KacModule(CartanType(['A', [2,1]]), (2,1), (1,)) sage: K1 is K2 True """ cartan_type = CartanType(cartan_type) la = _Partitions(la) mu = _Partitions(mu) return super(CrystalOfKacModule, cls).__classcall__(cls, cartan_type, la, mu)
def __classcall_private__(cls, arg0, cartan_type=None, kac_moody=True): """ Parse input to ensure a unique representation. INPUT: - ``arg0`` -- a simple Lie algebra or a base ring - ``cartan_type`` -- a Cartan type EXAMPLES:: sage: L1 = lie_algebras.Affine(QQ, ['A',4,1]) sage: cl = lie_algebras.sl(QQ, 5) sage: L2 = lie_algebras.Affine(cl) sage: L1 is L2 True sage: cl.affine() is L1 True """ if isinstance(arg0, LieAlgebra): ct = arg0.cartan_type() if not ct.is_finite(): raise ValueError("the base Lie algebra is not simple") cartan_type = ct.affine() g = arg0 else: # arg0 is the base ring cartan_type = CartanType(cartan_type) if not cartan_type.is_affine(): raise ValueError("the Cartan type must be affine") g = LieAlgebra(arg0, cartan_type=cartan_type.classical()) if not cartan_type.is_untwisted_affine(): raise NotImplementedError( "only currently implemented for untwisted affine types") return super(AffineLieAlgebra, cls).__classcall__(cls, g, kac_moody)
def su(R, n, representation='matrix'): r""" The Lie algebra `\mathfrak{su}_n`. The Lie algebra `\mathfrak{su}_n` is the compact real form of the type `A_{n-1}` Lie algebra and is finite-dimensional. As a matrix Lie algebra, it is given by the set of all `n \times n` skew-Hermitian matrices with trace 0. INPUT: - ``R`` -- the base ring - ``n`` -- the size of the matrix - ``representation`` -- (default: ``'matrix'``) can be one of the following: * ``'bracket'`` - use brackets and the Chevalley basis * ``'matrix'`` - use matrices EXAMPLES: We construct `\mathfrak{su}_2`, where the default is as a matrix Lie algebra:: sage: su2 = lie_algebras.su(QQ, 2) sage: E,H,F = su2.basis() sage: E.bracket(F) == 2*H True sage: H.bracket(E) == 2*F True sage: H.bracket(F) == -2*E True Since `\mathfrak{su}_n` is the same as the type `A_{n-1}` Lie algebra, the bracket is the same as :func:`sl`:: sage: su2 = lie_algebras.su(QQ, 2, representation='bracket') sage: su2 is lie_algebras.sl(QQ, 2, representation='bracket') True """ if representation == 'bracket': from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis return LieAlgebraChevalleyBasis(R, ['A', n-1]) if representation == 'matrix': from sage.algebras.lie_algebras.classical_lie_algebra import MatrixCompactRealForm from sage.combinat.root_system.cartan_type import CartanType return MatrixCompactRealForm(R, CartanType(['A', n-1])) raise ValueError("invalid representation")
def __classcall_private__(cls, cartan_type, La): r""" Normalize input to ensure a unique representation. EXAMPLES:: sage: La = RootSystem(['E',8,1]).weight_lattice().fundamental_weights() sage: M = crystals.NakajimaMonomials(['E',8,1],La[0]+La[8]) sage: M1 = crystals.NakajimaMonomials(CartanType(['E',8,1]),La[0]+La[8]) sage: M2 = crystals.NakajimaMonomials(['E',8,1],M.Lambda()[0] + M.Lambda()[8]) sage: M is M1 is M2 True """ cartan_type = CartanType(cartan_type) La = RootSystem(cartan_type).weight_lattice()(La) return super(CrystalOfNakajimaMonomials, cls).__classcall__(cls, cartan_type, La)
def __classcall__(cls, base_ring, cartan_type, level=None): """ Normalize arguments to ensure a unique representation. EXAMPLES:: sage: Q1 = QSystem(QQ, ['A',4]) sage: Q2 = QSystem(QQ, 'A4') sage: Q1 is Q2 True """ cartan_type = CartanType(cartan_type) if not is_tamely_laced(cartan_type): raise ValueError("the Cartan type is not tamely-laced") return super(QSystem, cls).__classcall__(cls, base_ring, cartan_type, level)
def __init__(self, R, n): """ Initialize ``self``. EXAMPLES:: sage: g = lie_algebras.sl(QQ, 5, representation='matrix') sage: TestSuite(g).run() """ MS = MatrixSpace(R, n, sparse=True) one = R.one() e = [MS({(i,i+1):one}) for i in range(n-1)] f = [MS({(i+1,i):one}) for i in range(n-1)] h = [MS({(i,i):one, (i+1,i+1):-one}) for i in range(n-1)] self._n = n ClassicalMatrixLieAlgebra.__init__(self, R, CartanType(['A', n-1]), e, f, h)
def __classcall_private__(cls, cartan_type): r""" Normalize the input arguments to ensure unique representation. EXAMPLES:: sage: RC1 = crystals.infinity.RiggedConfigurations(CartanType(['A',3])) sage: RC2 = crystals.infinity.RiggedConfigurations(['A',3]) sage: RC2 is RC1 True """ from sage.combinat.root_system.type_folded import CartanTypeFolded if isinstance(cartan_type, CartanTypeFolded): return InfinityCrystalOfNonSimplyLacedRC(cartan_type) cartan_type = CartanType(cartan_type) return super(InfinityCrystalOfRiggedConfigurations, cls).__classcall__(cls, cartan_type)
def __init__(self, cartan_type, starting_weight): """ EXAMPLES:: sage: C = CrystalOfLSPaths(['A',2,1],[-1,0,1]); C The crystal of LS paths of type ['A', 2, 1] and weight (-1, 0, 1) sage: C.R Root system of type ['A', 2, 1] sage: C.weight -Lambda[0] + Lambda[2] sage: C.weight.parent() Extended weight space over the Rational Field of the Root system of type ['A', 2, 1] sage: C.module_generators [(-Lambda[0] + Lambda[2],)] """ self._cartan_type = CartanType(cartan_type) self.R = RootSystem(cartan_type) self._name = "The crystal of LS paths of type %s and weight %s"%(cartan_type,starting_weight) if self._cartan_type.is_affine(): self.extended = True if all(i>=0 for i in starting_weight): Parent.__init__(self, category = HighestWeightCrystals()) else: Parent.__init__(self, category = Crystals()) else: self.extended = False Parent.__init__(self, category = FiniteCrystals()) Lambda = self.R.weight_space(extended = self.extended).basis() offset = self.R.index_set()[Integer(0)] zero_weight = self.R.weight_space(extended = self.extended).zero() self.weight = sum([zero_weight]+[starting_weight[j-offset]*Lambda[j] for j in self.R.index_set()]) if self.weight == zero_weight: initial_element = self(tuple([])) else: initial_element = self(tuple([self.weight])) self.module_generators = [initial_element]