Indexed text attachment
verify-topology.py
Source for Algebraic and Differential Topology in Higher Categories
View paper · Download original file
Lines 921–1020 of 1961. Source text is displayed literally.
921check('I1 barycentric subdivision does not change the homology groups, torsion included', oksd, 'subdivided projective plane: f-vector %s, homology %s' % (SRP.fvec(), homology(SRP)))922 923 924def last_vertex_map(K, num):925 inv_ = {i: x for x, i in num.items()}926 return {i: max(inv_[i]) for i in inv_}927 928 929okapp = True930for nm, K in NAMED[2:5]:931 SK, num = sd(K)932 vm = last_vertex_map(K, num)933 for d in range(1, K.dim + 1):934 okapp = okapp and mat_eq(mat_mul(K.bd(d), chain_map(SK, K, vm, d)), mat_mul(chain_map(SK, K, vm, d - 1), SK.bd(d)))935 # rank of the induced map on top homology mod 2 equals the Betti number936 d = K.dim937 Zs = nullspace(SK.bd(d), SK.n(d))938 img = [[sum(chain_map(SK, K, vm, d)[i][k] * z[k] for k in range(SK.n(d))) for i in range(K.n(d))] for z in Zs]939 okapp = okapp and (len(independent_extend([], img)) == bettis(K)[d])940check('I2 the last-vertex map from the subdivision back to the complex is a simplicial approximation of the identity: a chain map, onto in top homology',941 okapp, 'torus, projective plane, Klein bottle')942 943okcc = True944for nm, K in NAMED[:4]:945 CK, apex = cone(K)946 for d in range(0, CK.dim):947 n = CK.n(d)948 D = [[0] * n for _ in range(CK.n(d + 1))]949 for j, x in enumerate(CK.S[d]):950 if apex not in x:951 D[CK.idx[d + 1][x + (apex,)]][j] = (-1) ** (d + 1)952 lhs = mat_mul(CK.bd(d + 1), D)953 if d > 0:954 Dm = [[0] * CK.n(d - 1) for _ in range(n)]955 for j, x in enumerate(CK.S[d - 1]):956 if apex not in x:957 Dm[CK.idx[d][x + (apex,)]][j] = (-1) ** d958 lhs = [[a + b for a, b in zip(r, q)] for r, q in zip(lhs, mat_mul(Dm, CK.bd(d)))]959 okcc = okcc and mat_eq(lhs, [[int(i == j) for j in range(n)] for i in range(n)])960 else: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 = {}