Datasets:
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematics
nonlinear-systems
model-reduction
state-representation
exterior-algebra
exact-arithmetic
Download check_exported.py from PureOne/AELYRAITH-III: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/datasets/PureOne/AELYRAITH-III/resolve/main/check_exported.py
- Command line
-
hf download hf://datasets/PureOne/AELYRAITH-III/check_exported.py
-
curl -L -o check_exported.py https://huggingface.co/datasets/PureOne/AELYRAITH-III/resolve/main/check_exported.py
1.55 kB
| """Check exported rational certificates without invoking the compiler.""" | |
| import json | |
| from pathlib import Path | |
| import sympy as sp | |
| from src.continuation import ExteriorCertificate, Ratio | |
| ROOT = Path(__file__).resolve().parent | |
| def matrix(rows): | |
| return sp.Matrix([[sp.Rational(value) for value in row] for row in rows]) | |
| def ratio(record): | |
| return Ratio(matrix(record['beta']), matrix(record['alpha']), tuple(record['word'])) | |
| def main() -> None: | |
| records = json.loads((ROOT/'results'/'exact_certificates.json').read_text()) | |
| for record in records: | |
| n = int(record['n']) | |
| seeds = tuple(ratio(row) for row in record['seeds']) | |
| ratios = [ratio(row) for row in record['ratios']] | |
| branches = (matrix(record['A']), matrix(record['B'])) | |
| cert = ExteriorCertificate( | |
| normalizer=matrix(record['normalizer']), | |
| readouts=tuple(seed.numerator for seed in seeds), seeds=seeds, | |
| branches=branches, ratios=ratios, R=matrix(record['R']), | |
| transports=[matrix(H) for H in record['H']], | |
| depth=max((len(r.word) for r in ratios), default=0)) | |
| if not cert.verify(): | |
| raise AssertionError(f'Failed certificate at n={n}') | |
| if cert.normalizer*(branches[0]+branches[1]) != cert.normalizer: | |
| raise AssertionError(f'Failed instrument normalization at n={n}') | |
| print(f'n={n}: seed coverage, provenance, row integrity, positivity, ' | |
| 'transport, and normalization all pass.') | |
| if __name__ == '__main__': | |
| main() | |