Independent scholarship · Open accessThe monthly digest

Indexed text attachment

verify-topology.py

Source for Algebraic and Differential Topology in Higher Categories

View paper · Download original file

Lines 961–1060 of 1961. Source text is displayed literally.

961            ai = CK.idx[0][(apex,)]962            okcc = okcc and mat_eq(lhs, [[int(i == j) - int(i == ai) for j in range(n)] for i in range(n)])963check('I3 the conic construction is a chain contraction: boundary of the cone on c plus the cone on the boundary of c is c', okcc,964      'in degree 0 the right-hand side is c minus (sum of coefficients) times the apex')965 966 967def mesh_after(m):968    tri = [[(Fr(0), Fr(0)), (Fr(1), Fr(0)), (Fr(0), Fr(1))]]969    for _ in range(m):970        new = []971        for t in tri:972            for perm in itertools.permutations(t):973                new.append([tuple(sum(p[k] for p in perm[:j]) / j for k in range(2)) for j in (1, 2, 3)])974        tri = new975    return max(math.sqrt(float((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)) for t in tri for a, b in itertools.combinations(t, 2)), len(tri)976 977 978meshes = [mesh_after(m) for m in range(0, 5)]979ratios = [meshes[i + 1][0] / meshes[i][0] for i in range(4)]980check('I4 each barycentric subdivision of a triangle multiplies the mesh by at most 2/3 and the number of triangles by 6',981      all(r <= 2 / 3 + 1e-12 for r in ratios) and [m[1] for m in meshes] == [1, 6, 36, 216, 1296],982      'mesh %s; ratios %s' % (', '.join('%.4f' % m[0] for m in meshes), ', '.join('%.4f' % r for r in ratios)))983 984 985def simplicial_degree(d, N):986    """degree of the simplicial approximation of z -> z^d from an N-gon to a triangle"""987    def img(j):988        ang = (d * 2 * PI * j / N) % (2 * PI)989        return int(ang // (2 * PI / 3)) % 3990    tot = 0991    for j in range(N):992        a, b = img(j), img((j + 1) % N)993        if (a, b) == (2, 0):994            tot += 1995        elif (a, b) == (0, 2):996            tot -= 1997    return tot998 999 1000degs = {d: simplicial_degree(d, 60) for d in (-2, -1, 0, 1, 2, 3)}1001fail = simplicial_degree(3, 8)1002check('I5 a simplicial approximation of z -> z^d from a 60-gon to a triangle has degree d; on an octagon the same vertex rule gives degree 2 for d = 3',1003      all(degs[d] == d for d in degs) and fail == 2, 'degrees %s; octagon, d = 3: degree %s' % (degs, fail))1004 1005sec('4. Sperner, Brouwer, dimension')1006 1007 1008def sperner_grid(n):1009    """triangular grid of side n: vertices (i,j), i+j<=n; returns list of (triangle, orientation)"""1010    tris = []1011    for i in range(n):1012        for j in range(n - i):1013            tris.append(((i, j), (i + 1, j), (i, j + 1)))1014            if i + j < n - 1:1015                tris.append(((i + 1, j), (i + 1, j + 1), (i, j + 1)))1016    return tris1017 1018 1019def sperner_label(n):1020    lab = {}1021    for i in range(n + 1):1022        for j in range(n + 1 - i):1023            k = n - i - j1024            allowed = [c for c, v in ((0, k), (1, i), (2, j)) if v > 0]1025            lab[(i, j)] = random.choice(allowed)1026    return lab1027 1028 1029def signed_rainbow(tris, lab):1030    tot = cnt = 01031    for t in tris:1032        l = [lab[v] for v in t]1033        if sorted(l) == [0, 1, 2]:1034            cnt += 11035            tot += perm_sign(l)1036    return cnt, tot1037 1038 1039okS = True1040counts = []1041for _ in range(200):1042    n = 121043    lab = sperner_label(n)1044    c, s = signed_rainbow(sperner_grid(n), lab)1045    counts.append(c)1046    okS = okS and c % 2 == 1 and s == 11047check('S1 Sperner: every admissible labelling of a subdivided triangle has an odd number of complete cells, and their signed count is +1',1048      okS, '200 random labellings of the grid of side 12: between %d and %d complete cells' % (min(counts), max(counts)))1049 1050okE = True1051for _ in range(200):1052    n = 121053    lab = sperner_label(n)1054    e = sum((1 if (lab[(i, 0)], lab[(i + 1, 0)]) == (0, 1) else -1 if (lab[(i, 0)], lab[(i + 1, 0)]) == (1, 0) else 0) for i in range(n))1055    okE = okE and e == 11056check('S2 the signed count is the degree of the labelling on the boundary: on the side labelled 0 and 1 the signed number of 01-edges is +1', okE, '200 labellings')1057 1058 1059def sperner3(m):1060    """m-fold barycentric subdivision of a tetrahedron with coordinates; random Sperner labels"""