File size: 7,185 Bytes
fcedaa0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/usr/bin/env python3
"""Exact audit of a fixed-five-dimensional holonomy completion example.

All arithmetic is rational. The base is S^1 x R^4, the flat connection is
d + N dt, and N is a nilpotent Jordan shift. No surreal or differential
geometry package is required. The general statements are proved separately.
"""
from fractions import Fraction as Q
from math import factorial
from pathlib import Path
import json


def identity(n):
    return [[Q(int(i == j)) for j in range(n)] for i in range(n)]


def multiply(a, b):
    return [[sum(a[i][k] * b[k][j] for k in range(len(b)))
             for j in range(len(b[0]))] for i in range(len(a))]


def power(a, j):
    result = identity(len(a))
    for _ in range(j):
        result = multiply(result, a)
    return result


def rank(a):
    a = [list(row) for row in a]
    i = 0
    for j in range(len(a[0])):
        p = next((p for p in range(i, len(a)) if a[p][j]), None)
        if p is None:
            continue
        a[i], a[p] = a[p], a[i]
        pivot = a[i][j]
        a[i] = [x/pivot for x in a[i]]
        for p in range(len(a)):
            if p != i:
                scale = a[p][j]
                a[p] = [x-scale*y for x, y in zip(a[p], a[i])]
        i += 1
        if i == len(a):
            break
    return i


def determinant(a):
    a = [list(row) for row in a]
    result = Q(1)
    for j in range(len(a)):
        p = next((p for p in range(j, len(a)) if a[p][j]), None)
        if p is None:
            return Q(0)
        if p != j:
            a[j], a[p] = a[p], a[j]
            result = -result
        pivot = a[j][j]
        result *= pivot
        for p in range(j+1, len(a)):
            scale = a[p][j]/pivot
            for k in range(j, len(a)):
                a[p][k] -= scale*a[j][k]
    return result


def jordan_shift(n):
    return [[Q(int(j == i+1)) for j in range(n)] for i in range(n)]


def exp_negative_nilpotent(n, epsilon=Q(1)):
    N = jordan_shift(n)
    result = [[Q(0) for _ in range(n)] for _ in range(n)]
    for p in range(n):
        term = power(N, p)
        coefficient = (-epsilon)**p / factorial(p)
        for i in range(n):
            for j in range(n):
                result[i][j] += coefficient*term[i][j]
    return result


def orbit_matrix(n, start, epsilon=Q(1)):
    T = exp_negative_nilpotent(n, epsilon)
    vector = [[Q(int(i == start))] for i in range(n)]
    columns = []
    for j in range(n):
        columns.append([row[0] for row in vector])
        vector = multiply(T, vector)
    return [list(row) for row in zip(*columns)]


def log_unipotent(T):
    n = len(T)
    S = [[T[i][j]-Q(int(i == j)) for j in range(n)] for i in range(n)]
    result = [[Q(0) for _ in range(n)] for _ in range(n)]
    for p in range(1, n):
        term = power(S, p)
        coefficient = Q((-1)**(p+1), p)
        for i in range(n):
            for j in range(n):
                result[i][j] += coefficient*term[i][j]
    return result


def wedge(a, b):
    """Exterior monomial product, returning (sign, sorted indices)."""
    if set(a) & set(b):
        return 0, ()
    sign = (-1)**sum(x > y for x in a for y in b)
    return sign, tuple(sorted(a+b))


def main():
    # Coordinates 0=t, 1=x1, ..., 4=x4.
    B_indices = (0, 2, 3, 4)
    derivative_sign, F_indices = wedge((1,), B_indices)
    # B=-x1*v*dt^dx2^dx3^dx4, so the coefficient derivative is -v.
    assert -derivative_sign == 1 and F_indices == (0, 1, 2, 3, 4)
    assert wedge((0,), B_indices)[0] == 0  # N dt wedge B = 0.
    assert wedge((0,), (0,))[0] == 0       # A wedge A = 0.
    cases = []
    for n in range(1, 13):
        N = jordan_shift(n)
        assert all(x == 0 for row in power(N, n) for x in row)
        orbit = orbit_matrix(n, n-1)
        det = determinant(orbit)
        assert det == 1 and rank(orbit) == n
        for i in range(n):
            for j in range(n):
                p = n-1-i
                assert orbit[i][j] == Q((-j)**p, factorial(p))
        partial_ranks = []
        for s in range(n):
            r = rank(orbit_matrix(n, s))
            assert r == s+1
            partial_ranks.append(r)
        cases.append({'coefficient_rank': n,
                      'pointwise_curvature_rank': 1,
                      'holonomy_saturated_rank': rank(orbit),
                      'cyclic_orbit_determinant': str(det),
                      'nonterminal_vector_orbit_ranks': partial_ranks})
    scaled_cases = []
    prefix_checks = 0
    for n in range(1, 9):
        N = jordan_shift(n)
        v = [[Q(int(i == n-1))] for i in range(n)]
        for epsilon in (Q(0), Q(1, 7), Q(-2, 3)):
            T = exp_negative_nilpotent(n, epsilon)
            orbit = orbit_matrix(n, n-1, epsilon)
            det = determinant(orbit)
            expected_det = epsilon**(n*(n-1)//2)
            assert det == expected_det
            assert rank(orbit) == (n if epsilon else 1)
            assert log_unipotent(T) == [[-epsilon*x for x in row] for row in N]
            if epsilon:
                for r in range(n):
                    # For one Jordan block all invariant proper spaces are
                    # these prefixes; the classification is proved in prose.
                    P = [[Q(int(i == j and i < r)) for j in range(n)]
                         for i in range(n)]
                    assert multiply(P, multiply(N, P)) == multiply(N, P)
                    assert multiply(P, multiply(T, P)) == multiply(T, P)
                    projection = multiply(P, v)
                    assert all(row[0] == 0 for row in projection)
                    error_squared = sum((v[i][0]-projection[i][0])**2
                                        for i in range(n))
                    assert error_squared == 1
                    prefix_checks += 1
            scaled_cases.append({'coefficient_rank': n,
                                 'epsilon': str(epsilon),
                                 'orbit_determinant': str(det),
                                 'expected_epsilon_power': str(expected_det),
                                 'orbit_rank': rank(orbit),
                                 'finite_logarithm_identity': True})
    result = {
        'status': 'all exact checks passed',
        'arithmetic': 'fractions.Fraction',
        'base': 'S^1 x R^4 (dimension five)',
        'connection': 'd + N dt; t has period one',
        'monodromy': 'exp(-N)',
        'potential': '-x1 v dt wedge dx2 wedge dx3 wedge dx4',
        'curvature': 'v dt wedge dx1 wedge dx2 wedge dx3 wedge dx4',
        'flatness_and_wedge_sign_checks': 'passed',
        'cases': cases,
        'scaled_connection_cases': scaled_cases,
        'proper_invariant_prefix_and_unit_error_checks': prefix_checks,
        'prefix_scope': 'Invariant-space classification is proved separately; the verifier checks every prefix in the tested dimensions.',
        'scope': 'Finite exact certificates for the separately proved arbitrary-rank family.'
    }
    target = Path(__file__).with_name('holonomy_completion_results.json')
    target.write_text(json.dumps(result, indent=2)+'\n')
    print(json.dumps(result, indent=2))


if __name__ == '__main__':
    main()