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 721–820 of 1961. Source text is displayed literally.

721            F.append([v(i, j), v(i, j + 1), v(i + 1, j + 1)])722    return Cx(F)723 724 725def moebius():726    return Cx([[i, (i + 1) % 5, (i + 2) % 5] for i in range(5)])727 728 729def simplex_boundary(n):730    return Cx([c for c in itertools.combinations(range(n + 2), n + 1)])731 732 733def cross_sphere(n):734    """boundary of the (n+1)-dimensional cross-polytope; vertex 2i is +e_i, 2i+1 is -e_i"""735    return Cx([[2 * i + s for i, s in enumerate(signs)] for signs in itertools.product((0, 1), repeat=n + 1)])736 737 738def icosahedron():739    T, B = 0, 11740    u = lambda i: 1 + i % 5741    l = lambda i: 6 + i % 5742    F = []743    for i in range(5):744        F += [[T, u(i), u(i + 1)], [u(i), u(i + 1), l(i)], [u(i + 1), l(i), l(i + 1)], [B, l(i), l(i + 1)]]745    return Cx(F)746 747 748def grid_torus(m, d):749    """Freudenthal triangulation of (Z/m)^d"""750    def num(v):751        r = 0752        for a in v:753            r = r * m + a % m754        return r755    F = []756    for v in itertools.product(range(m), repeat=d):757        for perm in itertools.permutations(range(d)):758            w = list(v)759            s = [num(w)]760            for k in perm:761                w[k] += 1762                s.append(num(w))763            F.append(s)764    return Cx(F)765 766 767def circle(n):768    return Cx([[i, (i + 1) % n] for i in range(n)])769 770 771 772 773# ######################## CHECKS: PART ONE ########################774random.seed(20261119)775T7, RP2, KB, MB, ICO = torus7(), rp2(), klein(), moebius(), icosahedron()776S2 = simplex_boundary(2)777NAMED = [('sphere', S2), ('icosahedron', ICO), ('torus', T7), ('projective plane', RP2), ('Klein bottle', KB), ('Moebius band', MB)]778 779 780def rand_complex(nv=7, nf=6, dmax=3):781    return Cx([random.sample(range(nv), random.randint(1, dmax + 1)) for _ in range(nf)])782 783 784sec('1. Complexes as presheaves')785fv = {nm: K.fvec() for nm, K in NAMED}786okpm = all(is_pseudomanifold(K, closed=(nm != 'Moebius band')) for nm, K in NAMED)787check('C1 the six model complexes are pseudo-manifolds with f-vectors (4,6,4), (12,30,20), (7,21,14), (6,15,10), (16,48,32), (5,10,5)',788      okpm and fv['sphere'] == [4, 6, 4] and fv['icosahedron'] == [12, 30, 20] and fv['torus'] == [7, 21, 14] and fv['projective plane'] == [6, 15, 10]789      and fv['Klein bottle'] == [16, 48, 32] and fv['Moebius band'] == [5, 10, 5],790      'Euler characteristics %s' % ', '.join('%s %d' % (nm, K.chi()) for nm, K in NAMED))791 792 793def affinely_independent(pts):794    rows = [[Fr(a) - Fr(b) for a, b in zip(p, pts[0])] for p in pts[1:]]795    return rank_exact(rows) == len(pts) - 1796 797 798def moment(t, n):799    return [Fr(t) ** k for k in range(1, n + 1)]800 801 802okgp = all(affinely_independent([moment(t, 5) for t in c]) for c in itertools.combinations(range(1, 8), 6))803okgp3 = all(affinely_independent([moment(t, 3) for t in c]) for c in itertools.combinations(range(1, 8), 4))804check('C2 seven points on the moment curve of R^5 are in general position: every 2-complex on them is realized (dimension 2r+1)',805      okgp and okgp3, 'all 7 six-point subsets affinely independent in R^5; all 35 four-point subsets in R^3')806 807 808def nerve_of_stars(K):809    verts = [x[0] for x in K.S[0]]810    stars = {v: set(x for d in K.S for x in K.S[d] if v in x) for v in verts}811    F = []812    for k in range(1, K.dim + 3):813        for c in itertools.combinations(verts, k):814            if set.intersection(*[stars[v] for v in c]):815                F.append(c)816    return Cx(F)817 818 819oknerve = all(nerve_of_stars(K).S == K.S for _, K in NAMED)820check('C3 the nerve of the cover of a complex by its open vertex stars is the complex itself', oknerve, 'checked on the six model complexes')