def __classcall_private__(self, t, max_value=None, parent=None): """ Assign the correct parent for ``t`` and call ``t`` as an element of that parent EXAMPLES:: sage: from sage.combinat.crystals.fully_commutative_stable_grothendieck import DecreasingHeckeFactorization sage: h1 = DecreasingHeckeFactorization([[3, 1], [], [3, 2]]) sage: h1.parent() Fully commutative stable Grothendieck crystal of type A_2 associated to [1, 3, 2] with excess 1 sage: h2 = DecreasingHeckeFactorization(h1) sage: h1 == h2 True sage: h1 = DecreasingHeckeFactorization([[3, 1], [2, 1], [2, 1]]) sage: F = h1.parent(); F Decreasing Hecke factorizations with 3 factors associated to [1, 3, 2, 1] with excess 2 sage: h2 = F(h1) sage: h1 == h2 True TESTS:: sage: DecreasingHeckeFactorization([[]]) () """ _check_decreasing_hecke_factorization(t) if isinstance(t, DecreasingHeckeFactorization): u = t.value if parent is None: parent = t.parent() else: u = t if parent is None: if max_value is None: letters = [x for factor in t for x in factor] max_value = max(letters) if letters else 1 from sage.monoids.hecke_monoid import HeckeMonoid S = SymmetricGroup(max_value + 1) H = HeckeMonoid(S) word = H.from_reduced_word(x for factor in t for x in factor).reduced_word() factors = len(t) excess = sum(len(l) for l in t) - len(word) p = permutation.from_reduced_word(word) if p.has_pattern([3, 2, 1]): word = S.from_reduced_word(word) parent = DecreasingHeckeFactorizations( word, factors, excess) else: word = S.from_reduced_word(word) parent = FullyCommutativeStableGrothendieckCrystal( word, factors, excess) return parent.element_class(parent, u)
def _generate_decreasing_hecke_factorizations(w, factors, ex, weight=None, parent=None): """ Generate all decreasing factorizations of word ``w`` in a 0-Hecke monoid with fixed excess and number of factors. INPUT: - ``w`` -- a reduced word, expressed as an iterable - ``factors`` -- number of factors for each decreasing factorization - ``ex`` -- number of extra letters in each decreasing factorizations - ``weight`` -- (default: None) if None, returns all possible decreasing factorizations, otherwise return all those with the specified weight EXAMPLES:: sage: from sage.combinat.crystals.fully_commutative_stable_grothendieck import _generate_decreasing_hecke_factorizations sage: _generate_decreasing_hecke_factorizations([1, 2, 1], 3, 1) [()(2, 1)(2, 1), (2)(1)(2, 1), (1)(2)(2, 1), (1)(1)(2, 1), (2, 1)()(2, 1), (2)(2, 1)(2), (1)(2, 1)(2), (1)(2, 1)(1), (2, 1)(2)(2), (2, 1)(2)(1), (2, 1)(1)(2), (2, 1)(2, 1)()] sage: _generate_decreasing_hecke_factorizations([1, 2, 1], 3, 1, weight=[1, 1, 2]) [(2, 1)(2)(2), (2, 1)(2)(1), (2, 1)(1)(2)] """ if parent is None: max_value = max(w) if w else 1 S = SymmetricGroup(max_value + 1) v = S.from_reduced_word(w) parent = DecreasingHeckeFactorizations(v, factors, ex) _canonical_word = lambda w, ex: [list(w)[0]] * ex + list(w) wt = lambda t: [len(factor) for factor in reversed(t)] L = _list_equivalent_words(_canonical_word(w, ex)) Factors = [] for word in L: F = _list_all_decreasing_runs(word, factors) for f in F: t = [[word[j] for j in range(len(word)) if f[j] == i] for i in range(factors, 0, -1)] if weight is None or weight == wt(t): Factors.append(parent.element_class(parent, t)) return sorted(Factors, reverse=True)
def _lowest_weights(w, factors, ex, parent=None): """ Generate all decreasing factorizations in the 0-Hecke monoid that correspond to some valid semistandard Young tableaux. The semistandard Young tableaux should have at most ``factors`` columns and their column reading words should be equivalent to ``w`` in a 0-Hecke monoid. INPUT: - ``w`` -- a fully commutative reduced word, expressed as an iterable - ``factors`` -- number of factors for each decreasing factorization - ``ex`` -- number of extra letters in each decreasing factorizations - ``parent`` -- (default: None) parent of the decreasing factorizations, automatically assigned if it is None EXAMPLES:: sage: from sage.combinat.crystals.fully_commutative_stable_grothendieck import _lowest_weights sage: _lowest_weights([1, 2, 1], 3, 1) Traceback (most recent call last): ... ValueError: the word w should be fully commutative sage: _lowest_weights([2, 1, 3, 2], 4, 3) [(2, 1)(3, 1)(3, 1)(2), (2, 1)(3, 1)(3, 2)(2)] sage: _lowest_weights([2, 1, 3, 2], 5, 3) [(2, 1)(3, 1)(3, 1)(2)(), (2, 1)(3, 1)(3, 2)(2)(), (2, 1)(3, 1)(1)(1)(2), (2, 1)(3, 1)(1)(2)(2), (2, 1)(3, 1)(2)(2)(2), (2, 1)(3, 2)(2)(2)(2)] sage: _lowest_weights([1, 3], 3, 1) [(3, 1)(1)(), (3, 1)(3)(), (1)(1)(3), (1)(3)(3)] sage: _lowest_weights([3, 2, 1], 5, 2) [(3, 2, 1)(1)(1)()()] """ p = permutation.from_reduced_word(w) if p.has_pattern([3, 2, 1]): raise ValueError("the word w should be fully commutative") if parent is None: k = max(w) S = SymmetricGroup(k + 1) word = S.from_reduced_word(w) parent = FullyCommutativeStableGrothendieckCrystal(word, factors, ex) _canonical_word = lambda w, ex: [list(w)[0]] * ex + list(w) L = _list_equivalent_words(_canonical_word(w, ex)) M = [] for v in L: if _is_valid_column_word(v, factors): J = [0] + _jumps(v) + [len(v)] t = [v[J[i]:J[i + 1]] for i in range(len(J) - 1)] if len(J) < factors + 1: t += [()] * (factors + 1 - len(J)) M.append(parent.element_class(parent, t)) return sorted(M)