Evidence

verify bridge algebra.py

Download source fileOpen in research workspace
#!/usr/bin/env python3
"""Bounded source-bound exact arithmetic for the newly selected bridge.

No endpoint scan, second decimal reversal, significance estimate, or repository
wide source reconstruction is performed. Assertions are grouped by relation.
"""
from fractions import Fraction
from hashlib import sha256
from pathlib import Path
import argparse
import json


def inverse(n):
    assert isinstance(n, int) and n > 0
    placeholder = 1
    while n % 10 == 0:
        n //= 10
        placeholder *= 10
    return int(str(n)[::-1]) * placeholder


def key(head, held, numerator=25, denominator=23):
    return Fraction(held) + Fraction(numerator, denominator) * (head - held)


def encode(value):
    if isinstance(value, Fraction):
        return value.numerator if value.denominator == 1 else str(value)
    if isinstance(value, (tuple, list)):
        return [encode(v) for v in value]
    if isinstance(value, dict):
        return {k: encode(v) for k, v in value.items()}
    return value


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--source-dir', type=Path, default=Path(__file__).resolve().parent / 'sources')
    parser.add_argument('--output', type=Path, default=Path(__file__).with_name('bridge_algebra_verification.json'))
    args = parser.parse_args()
    root = args.source_dir
    paths = {
        'six_spines': root / 'spine_arithmetic_verification.json',
        'cap_round': root / 'cap_round_loss_identity.json',
        'File52c': root / 'File52c_latest.md',
        'File00': root / 'File00.md',
        'new_spine_study': root / 'LXX_SP_Reversed_Spines.md',
    }
    content = {k: p.read_bytes() for k, p in paths.items()}
    spine = json.loads(content['six_spines'])['computed_spines']
    cap = json.loads(content['cap_round'])
    mt = spine['MT_cumulative']
    sr = spine['SP_regular_accepted_Fall']
    sc = spine['SP_cumulative_accepted_Fall']
    lr = spine['LXX_regular']
    lc = spine['LXX_cumulative']
    mr = spine['MT_regular']
    results = []

    def check(name, actual, expected, kind='arithmetic relation'):
        passed = actual == expected
        results.append(dict(name=name, kind=kind, actual=encode(actual), expected=encode(expected), passed=passed))
        assert passed, (name, actual, expected)

    # Original/single-reversed coordinates and their source roles.
    M, Q, L, S = mt['source_head'], sc['path2'][1], lr['path3'][-1], sc['path3'][-1]
    C, restore, conquest, nativity = 2081 - 215, 536, 1406, 6
    shem = mt['flood'] + 600
    single_shem = nativity + inverse(shem - nativity)
    d = mt['original_legs'][1] - sc['original_legs'][1]
    check('selected source and generated coordinates', (M, Q, L, S, C), (14006, 2736, 13136, 14116, 1866))
    check('SP cumulative inverse Flood from original source leg', (sc['flood'] - conquest, inverse(sc['flood'] - conquest), conquest + inverse(sc['flood'] - conquest)), (3310, 1330, Q))
    check('MT inverse Shem from one original whole span', (shem, shem - nativity, inverse(shem - nativity), single_shem), (5436, 5430, 3450, 3456))
    check('File52c explicitly registers inverse Shem and its 11270 pairing', all(token in content['File52c'].decode() for token in ('6 + 3450 = 3456', '14726 − 3456 = 11270')), True, 'source-role binding')
    check('File00 explicitly registers actual LXX Year-6 state', '| File_13 LXX actual / rounded firewall | `5494 BC`; `5496 BC`; `5526 BC` | LXX actual Creation endpoint / Year-6 / +30 states |' in content['File00'].decode(), True, 'source-role binding')

    # One interval represented through inherited MT, new MT/SP, and LXX routes.
    check('three selected 11270 pairs', (mt['path3'][-1] - single_shem, M - Q, L - C), (11270, 11270, 11270))
    check('shared 490 coefficient', (M - Q, 23 * d), (23 * 490, 11270))
    check('720 translation joins MT inverse-Shem pair to new pair', (mt['path3'][-1] - M, single_shem - Q), (720, 720))
    check('870 translation preserves full three-node partition', tuple(a - b for a, b in zip((M, Q, conquest), (L, C, restore))), (870, 870, 870))
    check('three-node partitions on both sides of 870 translation', ((M - Q, Q - conquest, M - conquest), (L - C, C - restore, L - restore)), ((11270, 1330, 12600), (11270, 1330, 12600)))

    # Conditional row mechanism feeding the exact 490 difference.
    nonzero = tuple(r['rounded_reduction'] for r in cap['rows'] if r['rounded_reduction'])
    check('existing cap loss changes under source rounding', (cap['totals']['exact_excess'], nonzero, sum(nonzero)), (488, (115, 250, 120), 485))
    raw_sp_upper = sc['original_legs'][1] + 5
    check('raw Creation then accepted Fall gives 490', (mt['original_legs'][1], raw_sp_upper, sc['original_legs'][1], mt['original_legs'][1] - raw_sp_upper, d), (9170, 8685, 8680, 485, 490))
    check('source coefficient is rounded cap loss plus accepted Fall adjustment', d, cap['totals']['rounded_reduction'] + 5)
    check('same MT/SP contraction occurs on different legs', (tuple(a - b for a, b in zip(mt['reversed_legs'], mt['original_legs'])), tuple(a - b for a, b in zip(sc['reversed_legs'], sc['original_legs']))), ((0, -1980), (-1980, 0)))
    check('MT-SP cumulative head gap survives both inverse constructions', (M - sc['source_head'], mt['path2'][-1] - sc['path2'][-1], mt['path3'][-1] - S), (610, 610, 610))
    check('LXX fixed segment doubles to SP fixed segment', 2 * lc['original_legs'][0], sc['original_legs'][1])

    # Anchored Key connects independently generated heads. Reciprocal here is
    # the ordinary rational inverse of 25/23; not a second decimal reversal.
    check('head separation uses two copies of same coefficient', S - L, 2 * d)
    check('Key25/23 held at selected Covenant reaches SP inverse head', key(L, C), S)
    check('reciprocal Key23/25 returns LXX inverse head', key(S, C, 23, 25), L)
    check('fixed Key and generated heads recover Covenant pivot', Fraction(25 * L - 23 * S, 2), C)
    check('70-fold covenant measures of same Key relation', (L - C, S - C, S - L), (70 * 161, 70 * 175, 70 * 14))
    check('common first node is not mapped to itself', (key(4106, C), key(4106, C) == 4106), (Fraction(98918, 23), False), 'scope counterexample')
    check('common first node really belongs to both complete paths', (lr['path3'][1], sc['path3'][1]), (4106, 4106), 'scope binding')

    # Actual Year-6 coordinates must retain their distinction from Rounded.
    actual_lxx, actual_mt = 5496, 4116
    check('Actual-Year-6 to SP-inverse target ladder', (actual_lxx - actual_mt, actual_mt - Q), (1380, 1380))
    check('reflection about actual MT Year-6 exchanges selected LXX and SP nodes', (2 * actual_mt - actual_lxx, 2 * actual_mt - Q, 2 * actual_mt - actual_mt), (Q, actual_lxx, actual_mt))
    check('MT14006 distances along declared target ladder', (M - actual_lxx, M - actual_mt, M - Q), (23 * 370, 23 * 430, 23 * 490))
    check('rounded Creation separation agrees with ladder step', lr['source_head'] - mr['source_head'], 23 * 60)
    check('existing SP/MT 9890 translated interval', (sr['path3'][-1] - 4416, M - actual_mt), (9890, 9890))

    report = {
        'status': 'PASS',
        'scope': 'Bounded exact arithmetic and literal source-role checks for selected three-tradition relations; no source-total reconstruction rerun',
        'grouped_assertions': len(results),
        'count_note': 'One assertion per named relation/group; source-role checks and the scope counterexample are included, not counted as mathematical discoveries.',
        'source_bindings': {k: {'path': str(paths[k]), 'sha256': sha256(data).hexdigest(), 'bytes': len(data)} for k, data in content.items()},
        'source_costs': ['Accepted five-year SP Fall adjustment', 'Declared MT/LXX/SP Rounded source states and single-reversal paths', 'Conditional Covenant target1866=2081−215', 'MT4116 and LXX5496 actual Year-6 states distinct from Rounded states'],
        'limitations': ['These relations are source-specific, not generic consequences of reversal.', 'The Key maps the selected heads; common first node4106 supplies an exact counterexample to mapping the entire field by the same affine operator.', 'No probability, historical-origin, held-out prediction or minimality claim.'],
        'inverse_of_inverse_performed': False,
        'results': results,
    }
    args.output.write_text(json.dumps(report, indent=2, ensure_ascii=False) + '\n')
    print(json.dumps({'status': report['status'], 'grouped_assertions': len(results), 'output': str(args.output)}))


if __name__ == '__main__':
    main()

Linked sources and evidence

Edition and provenance

verify_bridge_algebra.py

SHA-256 3e997f330298fa3906cdf3a3e3b41261c310e70446824a799e3a85aab132c389

C480–C1634/Research_Cycles/C1432/verify_bridge_algebra.py