Пример #1
0
    def testAbsGrading(self):
        def testOneAlgebra(alg, test_op = True):
            abs_gr = AbsZ2Grading(alg)
            for gen in alg.getGenerators():
                # Test asserts in getAbsGrading
                abs_gr.getAbsGrading(gen)
            if not test_op:
                return
            # Test differential and multiplication
            for a in alg.getGenerators():
                for term in a.diff():
                    a_gr, da_gr = [abs_gr.getAbsGrading(gen) for gen in a, term]
                    assert (a_gr - 1) % 2 == da_gr
            for a in alg.getGenerators():
                for b in alg.getGenerators():
                    if a * b != 0:
                        a_gr, b_gr, ab_gr = [abs_gr.getAbsGrading(gen)
                                             for gen in a, b, (a*b).getElt()]
                        assert (a_gr + b_gr) % 2 == ab_gr

        for pmc in [splitPMC(1), splitPMC(2), linearPMC(2)]:
            testOneAlgebra(pmc.getAlgebra())
        for pmc in [antipodalPMC(2), splitPMC(3)]:
            testOneAlgebra(pmc.getAlgebra(), test_op = False)
        for (pmc, idem_size) in [(splitPMC(1), 1), (splitPMC(1), 2),
                                 (splitPMC(2), 1), (splitPMC(2), 2)]:
            testOneAlgebra(PreStrandAlgebra(F2, pmc, idem_size))
        for (pmc, idem_size) in [(splitPMC(2), 3), (splitPMC(2), 4),
                                 (splitPMC(3), 2)]:
            testOneAlgebra(PreStrandAlgebra(F2, pmc, idem_size),
                           test_op = False)
Пример #2
0
    def testTensorDoubleDD(self):
        dd_id = identityDD(splitPMC(1))
        self.assertTrue(computeDATensorDD(dd_id, dd_id).testDelta())
        dd_id2 = identityDD(splitPMC(2))
        self.assertTrue(computeDATensorDD(dd_id2, dd_id2).testDelta())

        def composeSlides(start_pmc, slides):
            cur_dd = Arcslide(start_pmc, *slides[0]).getDDStructure()
            for slide in slides[1:]:
                next_dd = Arcslide(
                    cur_dd.algebra2.pmc.opp(), *slide).getDDStructure()
                cur_dd = computeDATensorDD(cur_dd, next_dd)
                cur_dd.simplify()
                cur_dd.reindex()
            return cur_dd

        tests = [(splitPMC(1), [(0,1),(3,2)], 2),
                 (PMC([(0,3),(1,6),(2,4),(5,7)]), [(2,1),(6,5),(4,3)], 6)]
        for start_pmc, slides, result in tests:
            composed_dd = composeSlides(start_pmc, slides)
            self.assertEqual(len(composed_dd), result)
            composed_dd.checkGrading()
            if DEFAULT_GRADING == SMALL_GRADING:
                ref_gr = composed_dd.grading.values()[0]
                for gen, gr in composed_dd.grading.items():
                    self.assertEqual(gr, ref_gr)
Пример #3
0
 def testGetIntervalOrdering(self):
     tests = [(splitPMC(1), [0,1,2]),
              (splitPMC(2), [4,5,6,3,0,1,2]),
              (antipodalPMC(2), [2,5,0,3,6,1,4]),
              (linearPMC(2), [4,0,1,3,5,6,2])]
     for pmc, order in tests:
         self.assertEqual(_getIntervalOrdering(pmc), order)
Пример #4
0
 def testSignedDiff(self):
     for pmc, idem_size in [(splitPMC(2), 3),
                            (splitPMC(2), 4),
                            (splitPMC(3), 3)]:
         algebra = PreStrandAlgebra(ZZ, pmc, idem_size)
         # Test d^2 = 0.
         for gen in algebra.getGenerators():
             assert gen.diff().diff() == 0
Пример #5
0
 def testShortUnderslideDownLocal(self):
     slides_to_test = [
         Arcslide(splitPMC(1), 1, 0),
         Arcslide(splitPMC(1), 2, 1),
         Arcslide(splitPMC(2), 2, 1),
     ]
     for slide in slides_to_test:
         local_dastr = ArcslideDA(slide).getLocalDAStructure()
         self.assertTrue(local_dastr.testDelta())
Пример #6
0
 def testGrading(self):
     slides_to_test = [
         Arcslide(splitPMC(1), 1, 0),
         Arcslide(splitPMC(2), 4, 3),
         Arcslide(linearPMC(2), 1, 0),
     ]
     for slide in slides_to_test:
         dastr = ArcslideDA(slide)
         dastr.toSimpleDAStructure().checkGrading()
Пример #7
0
 def testGeneralOverslideDownLocal(self):
     slides_to_test = [
         Arcslide(splitPMC(1), 3, 2),
         Arcslide(splitPMC(2), 3, 2),
         Arcslide(splitPMC(2), 4, 3),
         Arcslide(splitPMC(2), 7, 6),
     ]
     for slide in slides_to_test:
         local_dastr = ArcslideDA(slide).getLocalDAStructure()
         self.assertTrue(local_dastr.testDelta())
Пример #8
0
 def testAutoCompleteArcslide(self):
     for slide, d_side_order in [
             (Arcslide(splitPMC(2), 2, 1), (3, 0)),
             (Arcslide(PMC([(0, 3), (1, 6), (2, 4), (5, 7)]), 2, 1),
              (5, 0, 4, 2)),
             (Arcslide(splitPMC(2), 2, 3), (3, 0)),
             (Arcslide(PMC([(0, 3), (1, 6), (2, 4), (5, 7)]), 5, 6),
              (5, 0, 3, 1))]:
         print slide, d_side_order
         raw_da = ArcslideDA(slide).getLocalDAStructure(seeds_only = True)
         autoCompleteDA(raw_da, d_side_order)
Пример #9
0
 def testArcslideDiagram(self):
     slide_to_test = [Arcslide(splitPMC(2), 4, 3), Arcslide(splitPMC(2), 2, 3)]
     for slide in slide_to_test:
         diagram = getArcslideDiagram(slide)
         self.assertEqual(diagram.getPMCs(), [slide.start_pmc.opp(), slide.end_pmc])
         self.assertEqual(len(diagram.getHFGenerators()), 8)
         periodic_domains = diagram.getPeriodicDomains()
         self.assertEqual(len(periodic_domains), 4)
         for domain in periodic_domains:
             alpha_bd = diagram.restrictOneChain(domain.diff(), ALPHA)
             self.assertEqual(diagram.restrictZeroChain(alpha_bd.diff()), 0)
Пример #10
0
 def testIdentityDiagram(self):
     pmc_to_test = [splitPMC(1), splitPMC(2), linearPMC(2), antipodalPMC(2)]
     pmc_to_test.append(PMC([(0, 2), (1, 6), (3, 5), (4, 7)]))
     pmc_to_test += [splitPMC(3), antipodalPMC(4)]
     genus_to_size = [2, 6, 20, 70]
     for pmc in pmc_to_test:
         diagram = getIdentityDiagram(pmc)
         self.assertEqual(diagram.getPMCs(), [pmc.opp(), pmc])
         expected_size = genus_to_size[pmc.genus - 1]
         self.assertEqual(len(diagram.getHFGenerators()), expected_size)
         self.assertEqual(len(diagram.getPeriodicDomains()), pmc.genus * 2)
Пример #11
0
 def testTensorDDandD(self):
     d1 = zeroTypeD(1)
     d2 = zeroTypeDAdm(1)
     d3 = zeroTypeD(2)
     dd_id = identityDD(splitPMC(1))
     dd_id2 = identityDD(splitPMC(2))
     dd_slide1 = Arcslide(splitPMC(1), 0, 1).getDDStructure()
     dstr1 = computeDATensorD(dd_id, d1)
     dstr2 = computeDATensorD(dd_id, d2)
     dstr3 = computeDATensorD(dd_slide1, d1)
     dstr4 = computeDATensorD(dd_id2, d3)
Пример #12
0
 def testRestrictPMC(self):
     pmc1 = splitPMC(1)
     pmc2 = splitPMC(2)
     self.assertEqual(PMCSplitting.restrictPMC(pmc1, [(0, 2)]),
                      (LocalPMC(4, [(0, 2), (1,)], [3]), {0:0, 1:1, 2:2}))
     self.assertEqual(PMCSplitting.restrictPMC(pmc1, [(1, 3)]),
                      (LocalPMC(4, [(1, 3), (2,)], [0]), {1:1, 2:2, 3:3}))
     self.assertEqual(PMCSplitting.restrictPMC(pmc2, [(5, 7)]),
                      (LocalPMC(4, [(1, 3), (2,)], [0]), {5:1, 6:2, 7:3}))
     # Restriction is (0*-1-2*) (3*-4-5*), with 2 and 4 paired
     self.assertEqual(PMCSplitting.restrictPMC(pmc2, [(4, 4), (6, 6)]),
                      (LocalPMC(6, [(1, 4)], [0, 2, 3, 5]), {4:1, 6:4}))
Пример #13
0
 def testOverslideAgreesWithDD(self):
     # This is not guaranteed (since there is choice involved in type DD for
     # overslides, but appears to work
     slides_to_test = [
         # General overslides down
         Arcslide(splitPMC(1), 3, 2),
         Arcslide(splitPMC(2), 3, 2),
         Arcslide(splitPMC(2), 4, 3),
         Arcslide(splitPMC(2), 7, 6),
         Arcslide(linearPMC(2), 3, 2),
         Arcslide(linearPMC(2), 5, 4),
         Arcslide(linearPMC(2), 7, 6),
         Arcslide(antipodalPMC(2), 5, 4),
         Arcslide(antipodalPMC(2), 6, 5),
         Arcslide(antipodalPMC(2), 7, 6),
         # General overslides up
         Arcslide(splitPMC(1), 0, 1),
         Arcslide(splitPMC(2), 0, 1),
         Arcslide(splitPMC(2), 3, 4),
         Arcslide(splitPMC(2), 4, 5),
         Arcslide(linearPMC(2), 0, 1),
         Arcslide(linearPMC(2), 2, 3),
         Arcslide(linearPMC(2), 4, 5),
         Arcslide(antipodalPMC(2), 0, 1),
         Arcslide(antipodalPMC(2), 1, 2),
         Arcslide(antipodalPMC(2), 2, 3),
     ]
     for slide in slides_to_test:
         dastr = ArcslideDA(slide)
         ddstr = dastr.tensorDD(identityDD(slide.end_pmc))
         ori_ddstr = slide.getDDStructure()
         self.assertTrue(ddstr.compareDDStructures(ori_ddstr))
Пример #14
0
 def testSimpleCobordismDA(self):
     for pmc, insert_pos in [
             (splitPMC(1), 3),
             (splitPMC(1), 1),
     ]:
         c_da = SimpleCobordismDA(pmc, insert_pos)
         dastr = c_da.toSimpleDAStructure()
         self.assertTrue(dastr.testDelta())
         ddstr = dastr.tensorDD(identityDD(c_da.end_pmc))
         ddstr.simplify()
         ddstr.reindex()
         self.assertEquals(len(ddstr.getGenerators()), 2)
         self.assertEquals(
             sorted(len(gen.delta()) for gen in ddstr.getGenerators()),
             [2, 6])
Пример #15
0
 def testMultiply(self):
     pmc = splitPMC(2)
     alg = pmc.getAlgebra()
     tensor_alg = TensorDGAlgebra((alg, alg))
     ddstr = SimpleDDStructure(F2, alg, alg)
     gens = dict()
     gens["x"] = SimpleDDGenerator(ddstr, pmc.idem([0]), pmc.idem([0]), "x")
     gens["y"] = SimpleDDGenerator(ddstr, pmc.idem([1]), pmc.idem([1]), "y")
     ddstr.addGenerator(gens["x"])
     ddstr.addGenerator(gens["y"])
     
     morphism_cx = MorDDtoDDComplex(F2, ddstr, ddstr)
     morphism1 = 1*MorDDtoDDGenerator(
         morphism_cx, gens["x"],
         TensorGenerator((pmc.sd([(0, 1)]), pmc.sd([(0, 1)])), tensor_alg),
         gens["y"])
     morphism1 += 1*MorDDtoDDGenerator(
         morphism_cx, gens["x"],
         TensorGenerator((pmc.sd([(2, 3)]), pmc.sd([(2, 3)])), tensor_alg),
         gens["y"])
     morphism2 = 1*MorDDtoDDGenerator(
         morphism_cx, gens["y"],
         TensorGenerator((pmc.sd([(1, 2)]), pmc.sd([(1, 2)])), tensor_alg),
         gens["x"])
     self.assertEqual(len(morphism1 * morphism2), 1)
     self.assertEqual(len(morphism2 * morphism1), 1)
     self.assertNotEqual(morphism1 * morphism2, morphism2 * morphism1)
Пример #16
0
 def testAATensorDD1(self):
     pmc = splitPMC(2)
     aa_graph = getTypeAAGraph(pmc)
     ddstr1 = identityDD(pmc)
     dd_graph1 = TypeDDGraph(ddstr1, 1)
     dastr1 = aa_graph.tensorAAandDD(dd_graph1)
     self.assertTrue(dastr1.testDelta())
Пример #17
0
 def testGrading(self):
     d1 = zeroTypeD(1)
     d2 = infTypeD(1)
     dd_id = identityDD(splitPMC(1))
     cx = computeATensorD(d1.dual(), d2)
     dstr1 = computeDATensorD(dd_id, d1)
     dstr2 = computeATensorDD(d1, dd_id)
Пример #18
0
 def testComposeBottom(self):
     c_da = SimpleCobordismDA(splitPMC(1), 1)
     dd = c_da.tensorDD(self.slideSeq(c_da.pmc2, [(0, 1)]))
     dd.simplify()
     c = Cobordism(2, 0, RIGHT)
     ori_dd = c.getDDStructure()
     self.assertTrue(dd.compareDDStructures(ori_dd))
Пример #19
0
def infTypeD(genus, is_dual = False, abs_gr_info = None):
    """Returns the type D structure for the inf-framed handlebody of a given
    genus.

    """
    pmc = splitPMC(genus)
    algebra = pmc.getAlgebra()
    dstr = SimpleDStructure(F2, algebra)
    idem = pmc.idem([4*i+1 for i in range(genus)])
    geny = SimpleDGenerator(dstr, idem, "y")
    dstr.addGenerator(geny)
    for i in range(genus):
        sd = StrandDiagram(algebra, idem, [(4*i+1, 4*i+3)])
        dstr.addDelta(geny, geny, sd, 1)
    if abs_gr_info is None:
        geny_gr = None
    else:
        assert DEFAULT_GRADING == SMALL_GRADING
        if is_dual:
            maslov, spinc = getDGrs(reversed(abs_gr_info), "infDual")
        else:
            maslov, spinc = getDGrs(abs_gr_info, "infReg")
        geny_gr = pmc.small_gr(maslov, spinc) # really pmc_opp
    dstr.registerHDiagram(getInfFrameDiagram(genus), geny, geny_gr)
    if is_dual:
        dstr = dstr.dual()
    return dstr
Пример #20
0
 def testIdentityDAMatchDiagram(self):
     dastr = identityDA(splitPMC(2))
     dastr.checkGrading()
     if DEFAULT_GRADING == SMALL_GRADING:
         # Special check for the identity diagram: all gradings should be
         # zero
         for gen in dastr.getGenerators():
             self.assertEqual(dastr.grading[gen], dastr.gr_set.zero())
Пример #21
0
 def testDATensorD(self):
     dastr = identityDA(splitPMC(2))
     dstr = zeroTypeD(2)
     dstr_result = dastr.tensorD(dstr)
     cx = dstr_result.morToD(infTypeD(2))
     cx.simplify()
     # Basic check that dstr_result is still zeroTypeD(2)
     self.assertEqual(len(cx), 1)
Пример #22
0
 def testGeneralOverslideDown(self):
     slides_to_test = [
         Arcslide(splitPMC(1), 3, 2),
         Arcslide(splitPMC(2), 3, 2),
         Arcslide(splitPMC(2), 4, 3),
         Arcslide(splitPMC(2), 7, 6),
         Arcslide(linearPMC(2), 3, 2),
         Arcslide(linearPMC(2), 5, 4),
         Arcslide(linearPMC(2), 7, 6),
         Arcslide(antipodalPMC(2), 5, 4),
         Arcslide(antipodalPMC(2), 6, 5),
         Arcslide(antipodalPMC(2), 7, 6),
     ]
     for slide in slides_to_test:
         print slide
         dastr = ArcslideDA(slide).toSimpleDAStructure()
         self.assertTrue(dastr.testDelta())
Пример #23
0
 def testDiff(self):
     algebra = PreStrandAlgebra(F2, splitPMC(1), 2)
     for sd, sd_diff in [([(1, 3), (2, 2)], [(1, 2), (2, 3)]),
                         ([(0, 3), (1, 2)], [(0, 2), (1, 3)])]:
         self.assertEquals(PreStrandDiagram(algebra, sd).diff(),
                           PreStrandDiagram(algebra, sd_diff).elt())
     for sd in [[(0, 2), (1, 3)], [(1, 2), (2, 3)]]:
         self.assertEquals(PreStrandDiagram(algebra, sd).diff(), E0)
Пример #24
0
 def testComposeMiddle(self):
     c_da = SimpleCobordismDA(splitPMC(1), 1)
     dd = c_da.tensorDD(self.slideSeq(
         c_da.pmc2, [(5, 4), (2, 1), (3, 2), (6, 5)]))
     dd.simplify()
     c = Cobordism(2, 1, RIGHT)
     ori_dd = c.getDDStructure()
     self.assertTrue(dd.compareDDStructures(ori_dd))
Пример #25
0
 def testDATensorD(self):
     # So far mostly checking that it will run in a reasonable amount of
     # time.
     slide = Arcslide(splitPMC(5), 2, 1)  # will change zeroTypeD
     dastr = ArcslideDA(slide)
     dstr = zeroTypeD(5)
     dstr_result = dastr.tensorD(dstr)
     dstr_result.reindex()
     self.assertEqual(len(dstr_result), 2)
Пример #26
0
 def testHandlebodyDiagram(self):
     diagram = getInfFrameDiagram(2)
     self.assertEqual(diagram.getPMCs(), [splitPMC(2)])
     self.assertEqual(len(diagram.getHFGenerators()), 1)
     periodic_domains = diagram.getPeriodicDomains()
     self.assertEqual(len(periodic_domains), 2)
     for domain in periodic_domains:
         alpha_bd = diagram.restrictOneChain(domain.diff(), ALPHA)
         self.assertEqual(diagram.restrictZeroChain(alpha_bd.diff()), 0)
     diagram2 = getPlatDiagram(2)
Пример #27
0
 def testGetGenerators(self):
     for pmc, idem_size, n in [(splitPMC(1), 1, 10),
                               (splitPMC(1), 2, 25),
                               (splitPMC(2), 1, 36),
                               (splitPMC(2), 2, 462),
                               (splitPMC(2), 3, 2646),
                               (splitPMC(2), 4, 6951),
                               (splitPMC(3), 2, 2431),
                               (splitPMC(3), 3, 39325)]:
         # Further numbers:
         # splitPMC(3), 4 --> 359502
         algebra = PreStrandAlgebra(F2, pmc, idem_size)
         self.assertEqual(n, len(algebra.getGenerators()))
Пример #28
0
 def testIdentityMatchDiagram(self):
     pmc_to_test = [splitPMC(2), PMC([(0,2),(1,6),(3,5),(4,7)])]
     for pmc in pmc_to_test:
         for idem_size in [0,1,2,3,4]:
             ddstr = identityDD(pmc, idem_size)
             # Special check for the identity diagram: all gradings should be
             # zero
             if DEFAULT_GRADING == SMALL_GRADING:
                 for gen in ddstr.generators:
                     self.assertEqual(ddstr.grading[gen],
                                      ddstr.gr_set.zero())
Пример #29
0
 def testMorToD(self):
     id2 = identityDD(splitPMC(2))
     d = infTypeD(2)
     d2 = id2.morToD(d)
     self.assertTrue(d2.testDelta())
     d2.simplify()
     self.assertEqual(len(d2), 1)
     d3 = zeroTypeD(2)
     d4 = id2.morToD(d3)
     self.assertTrue(d4.testDelta())
     d4.simplify()
     self.assertEqual(len(d4), 1)
Пример #30
0
    def testDDTensorAA(self):
        pmc = splitPMC(1)
        aa_graph = getTypeAAGraph(pmc)
        ddstr1 = identityDD(pmc)
        dd_graph1 = TypeDDGraph(ddstr1, 2)
        dastr1 = aa_graph.tensorDDandAA(dd_graph1)
        self.assertTrue(dastr1.testDelta())

        ddstr2 = Arcslide(pmc, 0, 1).getDDStructure()
        dd_graph2 = TypeDDGraph(ddstr2, 2)
        dastr2 = aa_graph.tensorDDandAA(dd_graph2)
        self.assertTrue(dastr2.testDelta())