示例#1
0
def test_refined_gq_to_gp_expansion(k=12):  # noqa
    for mu in Partition.all(k, strict=True):
        print('mu =', mu)
        print()
        print(Partition.printable(mu, shifted=True))
        print()
        n = len(mu)
        q = SymmetricPolynomial._slow_refined_dual_stable_grothendieck_q(n, mu)
        expected = {}
        for a in zero_one_tuples(len(mu)):
            if not all(mu[i - 1] - a[i - 1] > mu[i] - a[i]
                       for i in range(1, len(a))):
                continue
            if not all(mu[i] - a[i] > 0 for i in range(len(a))):
                continue
            nu = Partition.trim(tuple(mu[i] - a[i] for i in range(len(a))))
            coeff = 2**(len(nu) - sum(a)) * sgn(nu, mu) * BETA**sum(a)
            assert coeff != 0
            expected[nu] = coeff
        print('  expected =', expected)
        expected = sum([
            coeff *
            SymmetricPolynomial._slow_refined_dual_stable_grothendieck_p(
                n, nu) for (nu, coeff) in expected.items()
        ])
        print('           =', expected)
        assert q == expected
        print()
        print()
def _test(n_max, v_max):
    for n in range(n_max + 1):
        for v in range(1, v_max + 1):
            for lam1 in Partition.all(n):
                for lam2 in Partition.all(n):
                    print()
                    print()
                    print('* v =', v, ', n =', n, ', mu =', lam1, ', nu =',
                          lam2)
                    print()

                    print('Computing LHS . . .')
                    print()

                    s = Polynomial()
                    for mu in Partition.all(n + max(sum(lam1), sum(lam2))):
                        a = SymmetricPolynomial.stable_grothendieck_doublebar(
                            v, mu, lam1).truncate(n).polynomial('x')
                        b = SymmetricPolynomial.dual_stable_grothendieck(
                            v, mu, lam2).truncate(n).polynomial('y')
                        s += (a * b).truncate(n)
                        print('  ', mu, ':', s, '|', a, '|', b)
                        print()
                    print('LHS =', s)
                    print()
                    print()

                    print('Computing RHS . . .')
                    print()

                    f = Polynomial.one()
                    x = Polynomial.x
                    y = Polynomial.y
                    for i in range(1, v + 1):
                        for j in range(1, v + 1):
                            a = x(i) * y(j)
                            term = Polynomial.one()
                            for e in range(1, n + 1):
                                term += a**e
                            f = (f * term).truncate(n)
                    print('  ', '   :', f)
                    print()

                    t = Polynomial()
                    for kappa in Partition.subpartitions(lam2):
                        a = SymmetricPolynomial.stable_grothendieck_doublebar(
                            v, lam2, kappa).truncate(n)
                        b = SymmetricPolynomial.dual_stable_grothendieck(
                            v, lam1, kappa).truncate(n)
                        t += (f * a.polynomial('x') *
                              b.polynomial('y')).truncate(n)
                        print('  ', kappa, ':', t)
                        print()

                    print('RHS =', t)
                    print()
                    print()
                    print('diff =', s - t)
                    print()
                    assert s == t
示例#3
0
def test_simple():
    f = SymmetricPolynomial._slow_transposed_dual_stable_grothendieck_q(4, (4,))
    g = SymmetricPolynomial.dual_stable_grothendieck_q(4, (4,))
    assert f.omega_schur_expansion(f) == g.schur_expansion(g)

    f = SymmetricPolynomial._slow_transposed_dual_stable_grothendieck_p(4, (4,))
    g = SymmetricPolynomial.dual_stable_grothendieck_p(4, (4,))
    assert f.omega_schur_expansion(f) == g.schur_expansion(g)
def test_slow_symmetric_functions():
    for mu in [(), (1, ), (1, 1), (2, ), (2, 1)]:
        for n in range(4):
            f = SymmetricPolynomial._slow_schur(n, mu)
            g = SymmetricPolynomial._slow_stable_grothendieck(n, mu)
            h = SymmetricPolynomial._slow_schur_s(n, mu)
            k = SymmetricPolynomial._slow_stable_grothendieck_s(n, mu)
            assert g.lowest_degree_terms() == f
            assert k.lowest_degree_terms() == h
示例#5
0
def test_q(n=4):
    lam = tuple([n - i for i in range(n)])
    for mu in Partition.subpartitions(lam, strict=True):
        for nu in Partition.subpartitions(mu, strict=True):
            f = SymmetricPolynomial._slow_transposed_dual_stable_grothendieck_q(n, mu, nu)
            g = SymmetricPolynomial.dual_stable_grothendieck_q(n, mu, nu)
            ef, eg = f.omega_schur_expansion(f), g.schur_expansion(g)
            print('n =', n, 'mu =', mu)
            print(ef)
            print(eg)
            print()
            assert ef == eg
def _test_shifted_p(n_max, v_max):
    for n in range(n_max + 1):
        for v in range(1, v_max + 1):
            for lam1 in Partition.all(n, strict=True):
                for lam2 in Partition.all(n, strict=True):
                    print()
                    print()
                    print('* v =', v, ', n =', n, ', mu =', lam1, ', nu =',
                          lam2)
                    print()

                    print('Computing LHS . . .')
                    print()

                    s = Polynomial()
                    for mu in Partition.all(n + max(sum(lam1), sum(lam2)),
                                            strict=True):
                        a = SymmetricPolynomial.stable_grothendieck_p_doublebar(
                            v, mu, lam1).truncate(n).polynomial('x')
                        b = SymmetricPolynomial.dual_stable_grothendieck_q(
                            v, mu, lam2).truncate(n).polynomial('y')
                        s += (a * b).truncate(n)
                        print('  ', mu, ':', s, '|', a, '|', b)
                        print()
                    print('LHS =', s)
                    print()
                    print()

                    print('Computing RHS . . .')
                    print()

                    f = kernel(n, v)
                    print('  ', '   :', f)
                    print()

                    t = Polynomial()
                    for kappa in Partition.subpartitions(lam2, strict=True):
                        a = SymmetricPolynomial.stable_grothendieck_p_doublebar(
                            v, lam2, kappa).truncate(n)
                        b = SymmetricPolynomial.dual_stable_grothendieck_q(
                            v, lam1, kappa).truncate(n)
                        t += (f * a.polynomial('x') *
                              b.polynomial('y')).truncate(n)
                        print('  ', kappa, ':', t)
                        print()

                    print('RHS =', t)
                    print()
                    print()
                    print('diff =', s - t)
                    print()
                    assert s == t
示例#7
0
def test_gq_to_gp_expansion():  # noqa
    for mu in Partition.all(15, strict=True):
        print('mu =', mu)
        print()
        print(Partition.printable(mu, shifted=True))
        print()
        n = len(mu)
        q = gq(n, mu)
        expansion = SymmetricPolynomial.gp_expansion(q)
        print('  mu =', mu, 'n =', n)
        print('  expansion =', expansion)
        assert all(len(nu) == len(mu) for nu in expansion)
        assert all(Partition.contains(mu, nu) for nu in expansion)
        # assert all(c % 2**(len(mu) - sum(nu) + sum(mu)) == 0 for nu, c in expansion.items())
        expected = {}
        for a in zero_one_tuples(len(mu)):
            if not all(mu[i - 1] - a[i - 1] > mu[i] - a[i]
                       for i in range(1, len(a))):
                continue
            if not all(mu[i] - a[i] > 0 for i in range(len(a))):
                continue
            nu = Partition.trim(tuple(mu[i] - a[i] for i in range(len(a))))
            coeff = 2**(len(nu) - sum(a)) * sgn(nu, mu) * BETA**sum(a)
            assert coeff != 0
            expected[nu] = coeff
        print('  expected =', expected)
        assert expansion == Vector(expected)
        print()
        print()
示例#8
0
def grothendieck_P(num_variables, mu, nu=(), degree_bound=None):  # noqa
    if type(mu) == Permutation:
        assert nu == ()
        return mu.symplectic_stable_grothendieck(num_variables, degree_bound)
    else:
        return SymmetricPolynomial.stable_grothendieck_p(
            num_variables, mu, nu, degree_bound)
示例#9
0
def test_GQ_to_GP_expansion():  # noqa
    for mu in Partition.all(25, strict=True):
        print('mu =', mu)
        print()
        print(Partition.printable(mu, shifted=True))
        print()
        n = len(mu)
        q = GQ(n, mu)
        expansion = SymmetricPolynomial.GP_expansion(q)
        normalized = Vector({
            tuple(nu[i] - mu[i] for i in range(len(mu))): c * sgn(mu, nu) *
            BETA**(sum(nu) - sum(mu)) / 2**(len(mu) - sum(nu) + sum(mu))
            for nu, c in expansion.items()
        })
        unsigned = all(c > 0 for c in normalized.values())
        print('  mu =', mu, 'n =', n)
        print('  expansion =', expansion)
        print('  normalized expansion =', normalized)
        assert all(len(nu) == 0 or max(nu) <= 1 for nu in normalized)
        assert all(len(nu) == len(mu) for nu in expansion)
        assert all(Partition.contains(nu, mu) for nu in expansion)
        assert all(c % 2**(len(mu) - sum(nu) + sum(mu)) == 0
                   for nu, c in expansion.items())
        assert unsigned
        expected = {
            tuple(mu[i] + a[i] for i in range(len(a)))
            for a in zero_one_tuples(len(mu)) if all(
                mu[i - 1] + a[i - 1] > mu[i] + a[i] for i in range(1, len(a)))
        }
        print('  expected =', expected)
        assert set(expansion) == expected
        print()
        print()
示例#10
0
def grothendieck_S(num_variables, mu, nu=(), degree_bound=None):  # noqa
    if type(mu) == Permutation:
        assert nu == ()
        return mu.signed_involution_stable_grothendieck(
            num_variables, degree_bound)
    else:
        return SymmetricPolynomial.stable_grothendieck_s(
            num_variables, mu, nu, degree_bound)
def test_slow_dual_stable_grothendieck():
    n = 3
    mu = (1, )
    g = SymmetricPolynomial._slow_dual_stable_grothendieck(n, mu)
    print(g)
    assert g == SymmetricMonomial(n, (1, ))

    n = 3
    mu = (2, )
    g = SymmetricPolynomial._slow_dual_stable_grothendieck(n, mu)
    print(g)
    assert g == SymmetricMonomial(n, (1, 1)) + SymmetricMonomial(n, (2, ))

    n = 3
    mu = (2, 1)
    for t in Tableau.semistandard_rpp(n, mu):
        print(t)
    g = SymmetricPolynomial._slow_dual_stable_grothendieck(n, mu)
    print(g)
    assert g == -BETA * SymmetricMonomial(
        n,
        (1, 1)) - BETA * SymmetricMonomial(n, (2, )) + 2 * SymmetricMonomial(
            n, (1, 1, 1)) + SymmetricMonomial(n, (2, 1))
    def _symmetrize(cls, vector, n, check=True):
        def sort(t):
            return tuple(reversed(sorted(t)))

        ans = SymmetricPolynomial({
            SymmetricMonomial(n, alpha): max(vector[a] for a in vector if sort(a) == sort(alpha))
            for alpha in vector if sort(alpha) == alpha and len(alpha) <= n
        })

        if check:
            assert all(
                vector.dictionary[sort(alpha)] == vector.dictionary[alpha]
                for alpha in vector.dictionary if len(alpha) <= n
            )
        return ans
示例#13
0
def test_skew_GP_positivity():  # noqa
    k = 10
    for mu in Partition.all(k, strict=True):
        for nu in Partition.all(k, strict=True):
            if not Partition.contains(mu, nu):
                continue
            n = len(mu)
            f = GP(n, mu, nu)
            expansion = SymmetricPolynomial.GP_expansion(f)
            normalized = Vector({
                lam: c * BETA**(sum(lam) - sum(mu) + sum(nu))
                for lam, c in expansion.items()
            })
            print('GP_{%s/%s}(x_%s) =' % (mu, nu, n), normalized)
            print()
            assert all(c > 0 for c in normalized.values())
示例#14
0
def test_staircase_grothendieck_GP_positivity():  # noqa
    r = 6
    for k in range(r):
        delta = tuple(k - i for i in range(k))
        for nu in Partition.all(sum(delta)):
            if not Partition.contains(delta, nu):
                continue
            n = len(delta)
            f = G(n, delta, nu)
            expansion = SymmetricPolynomial.GP_expansion(f)
            normalized = Vector({
                lam: c * BETA**(sum(lam) - sum(delta) + sum(nu))
                for lam, c in expansion.items()
            })
            print('G_{%s/%s}(x_%s) =' % (delta, nu, n), normalized)
            print()
            assert all(c > 0 for c in normalized.values())
def _test(it, upper):
    for w in it:
        nu = w.fpf_involution_shape()
        if nu:
            for n in range(upper):
                f = SymmetricPolynomial.stable_grothendieck_p(nu, n, n)
                g = w.symplectic_stable_grothendieck(degree_bound=n)
                print(w, nu)
                print()
                print(f)
                print()
                print(g)
                print()
                print(f - g)
                print()
                print()
                print()
                assert f == g
def test_decompose():
    schur = SymmetricPolynomial.schur
    schur_P = SymmetricPolynomial.schur_p  # noqa
    dual_grothendieck = SymmetricPolynomial.dual_stable_grothendieck
    grothendieck = SymmetricPolynomial.stable_grothendieck
    GP = SymmetricPolynomial.stable_grothendieck_p  # noqa
    GQ = SymmetricPolynomial.stable_grothendieck_q  # noqa

    n = 6
    mu = (3, 2, 1)
    nu = (4, 2, 1)

    f = schur(n, mu) * schur(n, mu)
    exp = SymmetricPolynomial.schur_expansion(f)
    assert f == sum([schur(n, a) * coeff for a, coeff in exp.items()])

    f = schur_P(n, nu)
    exp = SymmetricPolynomial.schur_expansion(f)
    assert f == sum([schur(n, a) * coeff for a, coeff in exp.items()])

    f = GP(n, nu)
    exp = SymmetricPolynomial.grothendieck_expansion(f)
    assert f == sum([grothendieck(n, a) * coeff for a, coeff in exp.items()])

    f = GQ(n, nu)
    exp = SymmetricPolynomial.grothendieck_expansion(f)
    assert f == sum([grothendieck(n, a) * coeff for a, coeff in exp.items()])

    f = SymmetricPolynomial.dual_stable_grothendieck_p(n, nu)
    exp = SymmetricPolynomial.dual_grothendieck_expansion(f)
    assert f == sum(
        [dual_grothendieck(n, a) * coeff for a, coeff in exp.items()])

    f = SymmetricPolynomial.dual_stable_grothendieck_q(n, nu)
    exp = SymmetricPolynomial.dual_grothendieck_expansion(f)
    assert f == sum(
        [dual_grothendieck(n, a) * coeff for a, coeff in exp.items()])
示例#17
0
def grothendieck_P_doublebar(num_variables,
                             mu,
                             nu=(),
                             degree_bound=None):  # noqa
    return SymmetricPolynomial.stable_grothendieck_p_doublebar(
        num_variables, mu, nu, degree_bound=degree_bound)
示例#18
0
def dual_grothendieck_P(num_variables, mu, nu=()):  # noqa
    return SymmetricPolynomial.dual_stable_grothendieck_p(
        num_variables, mu, nu)
def test_strict_symmetric_functions():
    nn = 5
    for mu in Partition.all(nn, strict=True):
        for nu in Partition.all(nn, strict=True):
            for n in range(nn):
                print(n, mu, nu)
                print()

                # Schur-P and GP

                f = SymmetricPolynomial.schur_p(n, mu, nu)
                g = SymmetricPolynomial.stable_grothendieck_p(n, mu, nu)
                h = SymmetricPolynomial.dual_stable_grothendieck_p(n, mu, nu)

                fs = SymmetricPolynomial._slow_schur_p(n, mu, nu)
                gs = SymmetricPolynomial._slow_stable_grothendieck_p(n, mu, nu)
                hs = SymmetricPolynomial._slow_dual_stable_grothendieck_p(
                    n, mu, nu)

                if f != fs:
                    print(f)
                    print(fs)
                    print()

                if g != gs:
                    print(g)
                    print(gs)
                    print()

                if h != hs:
                    print(h)
                    print(hs)
                    print()
                    print()
                    print()

                assert f == fs
                assert g == gs
                assert h == hs

                if mu == nu:
                    assert f == 1
                    assert g == 1
                    assert h == 1
                    assert fs == 1
                    assert gs == 1
                    assert hs == 1

                if not Partition.contains(mu, nu):
                    assert f == 0
                    assert g == 0
                    assert h == 0
                    assert fs == 0
                    assert gs == 0
                    assert hs == 0

                # Schur-Q and GQ

                f = SymmetricPolynomial.schur_q(n, mu, nu)
                g = SymmetricPolynomial.stable_grothendieck_q(n, mu, nu)
                h = SymmetricPolynomial.dual_stable_grothendieck_q(n, mu, nu)

                fs = SymmetricPolynomial._slow_schur_q(n, mu, nu)
                gs = SymmetricPolynomial._slow_stable_grothendieck_q(n, mu, nu)
                hs = SymmetricPolynomial._slow_dual_stable_grothendieck_q(
                    n, mu, nu)

                if f != fs:
                    print(f)
                    print(fs)
                    print()

                if g != gs:
                    print(g)
                    print(gs)
                    print()

                if h != hs:
                    print(h)
                    print(hs)
                    print()
                    print()
                    print()

                assert f == fs
                assert g == gs
                assert h == hs

                if mu == nu:
                    assert f == 1
                    assert g == 1
                    assert h == 1
                    assert fs == 1
                    assert gs == 1
                    assert hs == 1

                if not Partition.contains(mu, nu):
                    assert f == 0
                    assert g == 0
                    assert h == 0
                    assert fs == 0
                    assert gs == 0
                    assert hs == 0
def test_symmetric_functions():
    nn = 6
    for mu in Partition.all(nn):
        for nu in Partition.all(nn, strict=True):
            for n in range(nn):
                print(n, mu, nu)
                print()

                f = SymmetricPolynomial.schur(n, mu, nu)
                g = SymmetricPolynomial.stable_grothendieck(n, mu, nu)
                h = SymmetricPolynomial.dual_stable_grothendieck(n, mu, nu)

                fs = SymmetricPolynomial._slow_schur(n, mu, nu)
                gs = SymmetricPolynomial._slow_stable_grothendieck(n, mu, nu)
                hs = SymmetricPolynomial._slow_dual_stable_grothendieck(
                    n, mu, nu)

                if f != fs:
                    print(f)
                    print(fs)
                    print()
                if g != gs:
                    print(g)
                    print(gs)
                    print()
                if h != hs:
                    print(h)
                    print(hs)
                    print()
                    print()

                assert f == fs
                assert g == gs
                assert h == hs

                hh = SymmetricPolynomial.schur_s(n, mu, nu)
                kk = SymmetricPolynomial.stable_grothendieck_s(n, mu, nu)

                if mu == nu:
                    assert f == 1
                    assert g == 1
                    assert h == 1
                    assert fs == 1
                    assert gs == 1
                    assert hs == 1
                    assert hh == 1
                    assert kk == 1

                if not Partition.contains(mu, nu):
                    assert f == 0
                    assert g == 0
                    assert h == 0
                    assert fs == 0
                    assert gs == 0
                    assert hs == 0
                    assert hh == 0
                    assert kk == 0

                print(f)
                print(g)
                print()
                print(hh)
                print(kk)
                print()
                assert g.lowest_degree_terms() == f
                assert kk.lowest_degree_terms() == hh
示例#21
0
def schur(num_variables, mu, nu=()):
    return SymmetricPolynomial.schur(num_variables, mu, nu)
def test_slow_dual_stable_grothendieck_pq():
    n = 3
    mu = (1, )
    g = SymmetricPolynomial._slow_dual_stable_grothendieck_p(n, mu)
    h = SymmetricPolynomial._slow_dual_stable_grothendieck_q(n, mu)
    print(g)
    print(h)
    print()
    assert g == SymmetricMonomial(n, (1, ))
    assert h == 2 * SymmetricMonomial(n, (1, ))

    n = 3
    mu = (2, )
    for t in Tableau.semistandard_marked_rpp(3, mu, diagonal_nonprimes=False):
        print(t)
    g = SymmetricPolynomial._slow_dual_stable_grothendieck_p(n, mu)
    print(g)
    assert g == \
        SymmetricPolynomial._slow_dual_stable_grothendieck(n, (1, 1)) + \
        SymmetricPolynomial._slow_dual_stable_grothendieck(n, (2,))

    n = 3
    mu = (2, 1)
    for t in Tableau.semistandard_marked_rpp(n, mu):
        print(t)
    g = SymmetricPolynomial._slow_dual_stable_grothendieck_p(n, mu)
    h = SymmetricPolynomial._slow_dual_stable_grothendieck_q(n, mu)
    print(g)
    print(h)
    print()
    assert g == -BETA * SymmetricMonomial(
        n,
        (1, 1)) + -BETA * SymmetricMonomial(n, (2, )) + 2 * SymmetricMonomial(
            n, (1, 1, 1)) + SymmetricMonomial(n, (2, 1))

    n = 5
    mu = (3, 2)
    g = SymmetricPolynomial._slow_dual_stable_grothendieck_p(n, mu)
    h = SymmetricPolynomial._slow_dual_stable_grothendieck_q(n, mu)

    n = 6
    mu = (3, 2, 1)
    assert SymmetricPolynomial._slow_dual_stable_grothendieck_p(n, mu) == \
        SymmetricPolynomial._slow_dual_stable_grothendieck(n, mu)
示例#23
0
def schur_Q(num_variables, mu, nu=()):  # noqa
    return SymmetricPolynomial.schur_q(num_variables, mu, nu)