File size: 1,614 Bytes
33e9f46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""A small exact demonstration. Run from the research-package root."""
import sympy as sp
from src.continuation import (separation_family, compile_exterior, affine_closure,
                              snapshot_space, normalize)

def main() -> None:
    n = 8
    model = separation_family(n)
    cert = compile_exterior([model.A, model.B], [model.F[1, :]])
    affine = affine_closure([model.A, model.B], model.F[[0, 1], :])
    print("Certificate integrity:", cert.verify())
    print("Nonlinear coordinates in the explicit optimal realization:", 2)
    print("Initial affine snapshot scalars:", snapshot_space(cert).rows - 1)
    print("Fixed self-updating affine scalars:", affine.rows - 1)
    x = sp.Matrix(range(1, n + 1)) / (n * (n + 1) // 2)
    compact = model.signature(x)
    for label in [0, 0, 1, 0]:
        x = normalize([model.A, model.B][label], x)
        compact = model.compact_step(compact, label)
        assert compact == model.signature(x)
    print("Exact continuation after A,A,B,A:", list(compact))

    revised = separation_family(n, sp.Rational(1, 1000))
    nu = sp.ones(n, 1) / n
    left = nu + model.F[3, :].T / (4 * n)
    right = nu - model.F[3, :].T / (4 * n)
    assert model.signature(left) == model.signature(right)
    first = (model.F[1, :] * normalize(revised.B, left))[0]
    second = (model.F[1, :] * normalize(revised.B, right))[0]
    assert first != second
    print("Old-identical states require different post-rewrite outputs:", first, second)
    print("The old memory is therefore exactly insufficient for this rewrite.")

if __name__ == "__main__":
    main()