Beispiel #1
0
def test():

    n = 9
    G = Group.symmetric(n)
    t = Young(G, (4, 3, 1, 1))
    assert t.rows == [[0, 1, 2, 3], [4, 5, 6], [7], [8]]
    assert t.cols == [[0, 4, 7, 8], [1, 5], [2, 6], [3]]

    G = t.get_rowperms()
    assert len(G) == factorial(4) * factorial(3)
Beispiel #2
0
def test():

    ring = element.Q

    n = argv.get("n", 3)
    d = argv.get("d", 2)

    G = Group.symmetric(n)

    algebra = GroupAlgebra(G, ring)
    v = algebra.zero
    for g in G:
        v = v + g
    assert 2 * v == v + v
    assert v - v == algebra.zero

    for g in algebra.basis:
        assert g * v == v
        assert v * g == v

    center = algebra.get_center()
    for v in center:
        for g in algebra.basis:
            assert g * v == v * g

    # ---------------------------------------

    # build standard representation of symmetric group

    act = G.left_action(list(range(n)))
    #print(act)

    tp = Cat(G, ring)
    rep = Rep.mk_rep(act, tp)
    #rep.dump()

    module = algebra.extend(rep)
    #print(module.action(v))

    # ---------------------------------------

    # build representation of symmetric group on tensor product

    space = Space(d, ring)
    rep = tensor_rep(G, space)
    #rep.check()

    module = algebra.extend(rep)
    #print(module.action(v))

    # ---------------------------------------

    # Build the young symmetrizers
    projs = []
    part = argv.get("part")
    parts = [part] if part else partitions(n)
    for part in parts:

        items = G.items
        A = algebra.zero
        for g in G:
            labels = [g[item] for item in items]
            tableau = Young(G, part, labels)
            P = algebra.get_symmetrizer(tableau)
            A = A + P

        #tableau = Young(G, part)
        #A = algebra.get_symmetrizer(tableau)

        print("partition:", part)
        #print("H:")
        #print(module.action(H))
        #print("V:")
        #print(module.action(V))

        print([g * A == A * g for g in algebra.basis])

        specht = []
        for v in algebra.basis:
            u = v * A
            specht.append(u.to_array())
        hom = Space(len(G), ring).endo_hom()
        specht = Map.from_array(specht, hom)
        specht = specht.image()
        #print(specht)
        dim = specht.shape[1]
        print("S(n)-algebra dim:", dim)

        if len(part) > d:
            continue

        print("A:", A)
        P = module.action(A)
        #P = P.transpose()
        P = P.image()
        print(P.longstr())

        print(P.shape)
        return
        print("multiplicity:", P.shape[1])

        src = P.src
        for v in src.get_basis():
            u = P * v
            #print(u.longstr())
            items = []
            for g in algebra.basis:
                g = module.action(g)
                w = g * u
                #print(w.longstr())
                items.append(w)
            A = find_span(items)
            print("dimension:", A.shape[1])
Beispiel #3
0
def super_young(U, V, part):
    ring = U.ring

    n = sum(part)

    lookup = {}
    summands = []
    for idxs in cross([(0, 1)] * n):
        spaces = [[U, V][idx] for idx in idxs]
        space = reduce(matmul, spaces)
        lookup[idxs] = len(summands)
        summands.append(space)
        #print(idxs, end=" ")
        #print(space.n)

    src = reduce(add, summands)

    G = Group.symmetric(n)
    hom = {}

    colim = src.identity()
    for action in G:
        perm = tuple(action[i] for i in range(n))
        #print(perm)
        sumswap = [None] * len(summands)
        fs = []
        for i, idxs in enumerate(cross([(0, 1)] * n)):
            jdxs = tuple(idxs[i] for i in perm)
            #print(idxs, "-->", jdxs)
            sumswap[lookup[jdxs]] = i
            space = src.items[i]
            f = space.get_swap(perm)
            fs.append(f)
        #print(sumswap)
        f = reduce(dsum, fs)
        #print(f.src.name, "-->", f.tgt.name)
        g = f.tgt.get_swap(sumswap)
        #print(g.src.name, "-->", g.tgt.name)
        assert f.tgt == g.src
        assert g.tgt == src
        hom[action] = (g, f)
        #print()

    young = Young(G, part)
    #print("Young:")
    #print(young)

    rowperms = young.get_rowperms()
    colperms = young.get_colperms()
    #print("rowperms", len(rowperms))
    #print("colperms", len(colperms))

    horiz = None
    for action in rowperms:
        (g, f) = hom[action]
        gf = g * f
        horiz = gf if horiz is None else (horiz + gf)
    assert horiz is not None

    vert = None
    for action in colperms:
        sign = action.sign() * ring.one
        g, f = hom[action]
        g = sign * g
        gf = g * f
        vert = gf if vert is None else (vert + gf)
    assert vert is not None
    P = horiz * vert

    P = P.row_reduce()
    #print(P.rank())
    #print(P)

    #for a in src.items:
    #    print(a)

    even = src.identity()
    odd = src.identity()
    i = 0
    j = 0
    for space in src.items:
        j += space.n
        while i < j:
            if space.grade % 2 == 0:
                odd[i, i] = ring.zero
            else:
                even[i, i] = ring.zero
            i += 1

    return (P * even).rank(), (P * odd).rank()
Beispiel #4
0
def test_young0():
    ring = element.Q

    n = argv.get("n", 3)
    part = argv.get("part", (1, 1, 1))
    assert sum(part) == n

    V = Space(ring, n)

    # build action of symmetric group on the space V
    items = list(range(n))
    gen1 = []
    gen2 = []
    for i in range(n - 1):
        perm = dict((item, item) for item in items)
        perm[items[i]] = items[i + 1]
        perm[items[i + 1]] = items[i]
        g = Perm(perm, items)
        gen1.append(g)
        A = elim.zeros(ring, n, n)
        for k, v in perm.items():
            A[v, k] = ring.one
        lin = Lin(V, V, A)
        gen2.append(lin)

    perms = mulclose(gen1)
    G = Group(perms, items)

    #print(G)

    action = mulclose_hom(gen1, gen2)
    for g in G:
        for h in G:
            assert action[g *
                          h] == action[g] * action[h]  # check it's a group hom

    young = Young(G, part)
    rowG = young.get_rowperms()
    print("rowG", len(rowG))
    colG = young.get_colperms()
    print("colG", len(colG))

    horiz = None
    for g in rowG:
        P = action[g]
        horiz = P if horiz is None else (horiz + P)

    vert = None
    for g in colG:
        P = action[g]
        s = g.sign()
        P = ring.promote(s) * P
        vert = P if vert is None else (vert + P)
    A = horiz * vert

    assert vert * vert == len(colG) * vert
    assert horiz * horiz == len(rowG) * horiz

    print("part:", part)
    print(young)
    print("rank:", A.rank())
    print("is_zero:", A.is_zero())
    print(A)
    #if not A.is_zero():
    #    print(A)

    print()
Beispiel #5
0
def test_young():
    # code ripped from qu.py

    d = argv.get("d", 2)
    n = argv.get("n", 3)
    p = argv.get("p")

    if p is None:
        ring = element.Q
    else:
        ring = element.FiniteField(p)
    print("ring:", ring)

    space = Space(ring, d)

    # tensor power of the space
    tspace = reduce(matmul, [space] * n)

    # build action of symmetric group on the tensor power
    items = list(range(n))
    gen1 = []
    gen2 = []
    for i in range(n - 1):
        perm = dict((item, item) for item in items)
        perm[items[i]] = items[i + 1]
        perm[items[i + 1]] = items[i]
        g = Perm(perm, items)
        gen1.append(g)
        lin = tspace.get_swap([g[i] for i in items])
        #print(lin.hom)
        gen2.append(lin)

    perms = mulclose(gen1)
    G = Group(perms, items)

    #print(G)

    action = mulclose_hom(gen1, gen2)
    for g in G:
        for h in G:
            assert action[g *
                          h] == action[g] * action[h]  # check it's a group hom

    # Build the young symmetrizers
    projs = []
    part = argv.get("part")
    parts = list(partitions(n)) if part is None else [part]
    for part in parts:
        assert sum(part) == n

        t = Young(G, part)

        rowG = t.get_rowperms()
        colG = t.get_colperms()
        horiz = None
        for g in rowG:
            P = action[g]
            horiz = P if horiz is None else (horiz + P)

        vert = None
        for g in colG:
            P = action[g]
            s = g.sign()
            P = ring.promote(s) * P
            vert = P if vert is None else (vert + P)
        A = horiz * vert

        assert vert * vert == len(colG) * vert
        assert horiz * horiz == len(rowG) * horiz
        #A = A.transpose()
        projs.append(A)

        print("part:", part)
        print(t)
        print("rank:", A.rank())
        print("is_zero:", A.is_zero())
        #if not A.is_zero():
        #    print(A)

        print()
Beispiel #6
0
    def __init__(self, n, space):
        assert n >= 2
        d = len(space)
        ring = space.ring

        items = list(range(n))
        gen1 = []
        for i in range(n - 1):
            perm = dict((item, item) for item in items)
            perm[items[i]] = items[i + 1]
            perm[items[i + 1]] = items[i]
            perm = Perm(perm, items)
            gen1.append(perm)

        perms = mulclose(gen1)
        G = Group(perms, items)

        #I = space.ident

        # tensor power of the space
        tensor = lambda x, y: x @ y
        tspace = reduce(tensor, [space] * n)

        # build action of symmetric group on the tensor power
        thom = Hom(tspace, tspace)
        gen2 = []
        for g in gen1:
            items = []
            for idxs in tspace.gen:
                jdxs = tuple(idxs[g[i]] for i in range(len(idxs)))
                items.append(((idxs, jdxs), ring.one))
                #print(idxs, "->", jdxs)
            #print()
            swap = Map(items, thom)
            gen2.append(swap)

        action = mulclose_hom(gen1, gen2)
        for g in G:
            for h in G:
                assert action[
                    g * h] == action[g] * action[h]  # check it's a group hom

        # Build the young symmetrizers
        projs = []
        parts = []
        for part in partitions(n):
            if len(part) > d:
                continue
            parts.append(part)
            t = Young(G, part)

            rowG = t.get_rowperms()
            colG = t.get_colperms()
            horiz = None
            for g in rowG:
                P = action[g]
                horiz = P if horiz is None else (horiz + P)

            vert = None
            for g in colG:
                P = action[g]
                s = g.sign()
                P = s * P
                vert = P if vert is None else (vert + P)
            A = vert * horiz + horiz * vert
            #A = horiz * vert

            assert vert * vert == len(colG) * vert
            assert horiz * horiz == len(rowG) * horiz
            #A = A.transpose()
            projs.append(A)

            #print(part)
            #print(t)
            #print(A)

        self.projs = projs
        self.parts = parts
Beispiel #7
0
def main():

    #ring = element.Z
    ring = element.Q

    qubit = Space(2, ring)

    q2 = qubit @ qubit

    hom = Hom(qubit, qubit)

    I = Map.from_array([[1, 0], [0, 1]], hom)
    X = Map.from_array([[0, 1], [1, 0]], hom)
    Z = Map.from_array([[1, 0], [0, -1]], hom)
    H = X + Z
    E = Map.from_array([[0, 1], [0, 0]], hom)  # raising
    F = Map.from_array([[0, 0], [1, 0]], hom)  # lowering
    II = I @ I
    XI = X @ I
    IX = I @ X
    XX = X @ X
    assert XI * IX == XX

    CNOT = Map.from_array(
        [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]], hom @ hom)

    SWAP = Map.from_array(
        [[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]], hom @ hom)

    assert SWAP * SWAP == II
    assert CNOT * CNOT == II

    G = mulclose([XI, IX, CNOT])  # order 8
    G = mulclose([XI, IX, CNOT, SWAP])  # order 24.. must be S_4
    G = mulclose([CNOT, SWAP])
    #    print(len(G))
    #    for g in G:
    #        print(g)

    A = SWAP @ I
    B = I @ SWAP
    S_3 = list(mulclose([A, B]))
    assert len(S_3) == 6
    #    for g in G:
    #        print(g)
    #    print(g.hom)

    hom = A.hom
    space = hom.src
    N = 2**3
    basis = space.get_basis()
    orbits = set()
    for v in basis:
        v1 = space.zero_vector()
        for g in S_3:
            u = g * v
            v1 = v1 + u
        orbits.add(v1)
    orbits = list(orbits)
    #    for v in orbits:
    #        print(v)

    HHH = H @ H @ H
    v = basis[7]
    #print(v)
    #print(HHH * v)

    # ----------------------------------------------------------

    specht = Specht(4, qubit)

    for i, A in enumerate(specht.projs):
        print("part:", specht.parts[i])
        print("proj:")
        im = A.image()
        #im = A
        src, tgt = im.hom
        for i in src:
            for j in tgt:
                v = im[j, i]
                if v != ring.zero:
                    print("%s*%s" % (v, j), end=" ")
            print()

    return

    # ----------------------------------------------------------

    items = [0, 1, 2, 3]
    g1 = Perm({0: 1, 1: 0, 2: 2, 3: 3}, items)
    g2 = Perm({0: 0, 1: 2, 2: 1, 3: 3}, items)
    g3 = Perm({0: 0, 1: 1, 2: 3, 3: 2}, items)
    gen1 = [g1, g2, g3]

    s1 = SWAP @ I @ I
    s2 = I @ SWAP @ I
    s3 = I @ I @ SWAP
    gen2 = [s1, s2, s3]

    G = mulclose(gen1)
    hom = mulclose_hom(gen1, gen2)
    for g in G:
        for h in G:
            assert hom[g * h] == hom[g] * hom[h]  # check it's a group hom

    projs = []
    for part in [(4, ), (3, 1), (2, 2)]:
        t = Young(part)

        rowG = t.get_rowperms()
        colG = t.get_colperms()
        horiz = None
        for g in rowG:
            P = hom[g]
            horiz = P if horiz is None else (horiz + P)

        vert = None
        for g in colG:
            P = hom[g]
            s = g.sign()
            P = s * P
            vert = P if vert is None else (vert + P)
        A = vert * horiz
        #A = horiz * vert

        assert vert * vert == len(colG) * vert
        assert horiz * horiz == len(rowG) * horiz
        #print(t)
        #print(A)
        projs.append(A)

    for A in projs:
        for B in projs:
            assert A * B == B * A


#    print()
#    for A in projs:
#        for g in G:
#            P = hom[g]
#            if P*A != A*P:
#                print(P*A)
#                print(A*P)
#                return

    for A in projs:
        print("proj:")
        im = A.image()
        #im = A
        src, tgt = im.hom
        for i in src:
            for j in tgt:
                v = im[j, i]
                if v != ring.zero:
                    print("%s*%s" % (v, j), end=" ")
            print()