interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / research / atemporal / at1 / model / README.md

178 lines · 16565 bytes Raw Blame History Rendered
1# AT-1 candidate engine (Agent 3)
2
3The candidate relational quantum engine for AT-1, tracked on aien-dev/omega#371. It reads one `AT1_CASE_V1` case, validates it, builds the literal constraint matrix `H_total = H_C (x) I_S + I_C (x) H_S + V`, finds its exact nullspace, applies the covariant clock POVM and writes one `AT1_RESULT_V1` result.
4
5Portable C11, libc and libm only (plus the repository's own `src/sha256.c`). No Python, no clock, no randomness, no threads, no network. A PASS from this engine means conformance with the frozen contracts and `AT1_SPEC.md`; it says nothing about physics.
6
7Contracts (aien-architecture `docs/plans/atemporal`, main `ea91d7c`): `AT1_CASE_V1.md` (sha256 `e62018d8...`), `AT1_RESULT_V1.md` (sha256 `3e6efd7e...`), `AT0_RESULT_V2.md` sections 2, 4, 5, 7 (sha256 `bd0f9eb8...`), `AT1_SPEC.md` (merged at `81047f5`), charter readings (c), (d), (e).
8
9## Build and run
10
11```
12make # build/at1-model and build/test_model
13make test # every test below; exit status 0 only if all pass
14make asan # the same tests under -fsanitize=address,undefined, if the compiler supports it
15make CC=clang test # another compiler
16```
17
18The Makefile is plain POSIX make (works with GNU Make 3.81 on macOS). Flags: `-std=c11 -O2 -ffp-contract=off -Wall -Wextra -Werror -pedantic`. `-ffp-contract=off` keeps compilers from fusing multiply-adds, so gcc and clang round the same way. Without make:
19
20```
21cc -std=c11 -O2 -ffp-contract=off -I../../../../src -o at1-model \
22 at1_bn.c at1_case.c at1_exact.c at1_numeric.c at1_result.c at1_io.c ../../../../src/sha256.c at1_main.c -lm
23```
24
25### Command line
26
27```
28at1-model result <case> <oracle-record|none> <provenance> [--reversed]
29at1-model values <case> [--reversed]
30```
31
32- `result` writes the complete `AT1_RESULT_V1` file to standard output.
33 - The `reference_label`, `reference_clock_probability`, `reference_ideal` and `reference_interacting` lines are copied verbatim from the oracle record (charter reading (c)): every line whose key is one of those four, in the contract order. If the record has a `begin values` block, only lines inside it count.
34 - `case_id` / `acceptance_id` lines in the record must match the case. Count, order, index, label, axis, sign and token grammar are checked.
35 - The placement of `undefined` is checked against section 1: `reference_ideal` is never `undefined`; the six `reference_interacting` lines of a label are `undefined` exactly when its `reference_label` is not `DEFINED`; `reference_clock_probability` is `undefined` only in the trivial shape (all labels at once, every `reference_label` `UNDEFINED`); and every written `reference_label` must follow the status rule applied to its own `reference_clock_probability` value and bound. A record that breaks any of these is refused (exit 1), so a blanked-out record can never reach the judge.
36 - `none`, or an oracle record file that cannot be read, writes an `ERROR` result with `error_code ORACLE_UNAVAILABLE`, with the oracle provenance fields set to `none`.
37- The case is parsed and validated before the oracle record and the provenance file are opened, so a refusal is never masked by a missing file.
38- The provenance file holds the provenance lines in contract order, `source_repo` through `run_finished_utc`, then optional `artifact` lines. The runner supplies them, so the engine never reads a clock. The writer refuses `build_cc` starting with `oracle ` and `engine_sha256` equal to `oracle_sha256` (oracle-written records are never candidate results).
39- `values` prints only the engine's own values lines. It is component output for debugging, not a contract file.
40- `--reversed` evaluates the labels in reverse order. The output is bit-identical (test T8).
41- Exit status:
42 - `0`: written.
43 - `2`: case refused. Exactly one line `AT1_CASE_REFUSED <code>` on stderr, nothing on stdout.
44 - `1`: engine error. One line `AT1_ENGINE_ERROR <reason>` on stderr, nothing on stdout. Causes: an unreadable case or provenance file, a malformed or inconsistent oracle record, a malformed provenance file, or an engine limit hit while parsing.
45 - A failure after the case was accepted (an internal consistency check) is written as an `ERROR` result with `INTERNAL_ERROR`.
46
47## Method
48
49| File | Role |
50|---|---|
51| `at1_bn.c` | Arbitrary-precision integers, reduced rationals, Gaussian rationals; correctly rounded rational to binary64. |
52| `at1_case.c` | `AT1_CASE_V1` parser. Rules 1 to 6 of section 4 in order, first failure wins: shape, then non-canonical forms (decided after the whole shape pass), versions, ranges, per-level rational spectrum (exact integer square roots of the reduced `\|h + v_j\|^2`), identities, acceptance codes. Readings (d) (version lines: key in step 1, value in step 2) and (e) (index tokens compared by value; `01` is `CASE_NONCANONICAL`) are applied. |
53| `at1_exact.c` | Builds `H_total` term by term with explicit Kronecker products as a `2N x 2N` matrix of exact Gaussian rationals, assuming no block structure. Exact Gauss-Jordan elimination gives rank and kernel basis `B`. Checks `H_total B = 0` exactly. Forms `P_0 = B (B^dagger B)^-1 B^dagger` exactly. Computes `y_j = P_0 (\|E_j> (x) psi_0)` exactly. Exact zero test: supports of the nonzero `y_j` checked pairwise disjoint, then `Psi = 0` iff every `y_j = 0`. |
54| `at1_numeric.c` | Binary64 physics (formulas below). |
55| `at1_result.c` | Oracle splice, provenance checks, the 12 checks in exact rational arithmetic on the written tokens, the writer, `verdict_id`, `evidence_digest`. |
56| `at1_io.c`, `at1_main.c` | File reading (the only file access) and the tool. |
57
58### The projected state
59
60The brief asks for the projection from the literal matrix, independent of the oracle's closed form. `AT1_SPEC.md` 8.4 item 3 warns that a *numerical* projector (eigen-decomposition with a threshold) loses accuracy like `1/delta_min` and fails P6. This engine does neither:
61
62- The kernel and `P_0` are exact, from the literal matrix.
63- `Psi = P_0 (|t_r> (x) psi_0) = sum_j <E_j|t_r> y_j` by linearity. Each entry of `Psi` is one clock amplitude times one exact `y_j` entry rounded once.
64- So there is no `1/delta_min` loss (P6 measures like every other case) and no cancellation, even when `psi_0` is nearly orthogonal to the kernel (control C1).
65
66The closed forms of `AT1_SPEC.md` sections 2 to 4 appear only in the tests, as the expected answers.
67
68### Numerics
69
70| Quantity | How it is computed |
71|---|---|
72| Clock amplitudes `<E_j\|t_k>` | Phase `exp(-2 pi i E_j k tau)` from the turn count `E_j k tau`, reduced modulo 1 exactly in int64 (8.4 item 1), then `cos`, `sin` and `N^(-1/2)`. |
73| `phi_k` | `(<t_k\| (x) I) Psi` (the bra conjugates the coefficients, phase `exp(+2 pi i E_j (k - r) tau)` overall). |
74| `p(k)` | `w \|\|phi_k\|\|^2 / \|\|Psi\|\|^2`. |
75| Each Pauli outcome | Its own trace `Tr(rho_k Pi)` against its own projector `Pi`, never `1 - other`. |
76| `constraint_residual` | `\|\|H_total Psi_hat\|\|` with the literal matrix (rounded once). |
77| `povm_residual` | `\|\|sum_k w \|t_k><t_k\| - I\|\|_F`, pairwise summation over `k` for each entry, then pairwise summation of the `N^2` squared moduli. |
78
79All bounds are `bound_kind ESTIMATED`: first-order operation counts with a safety factor 2, not a proof. They assume `cos`, `sin` and `sqrt` within a few ulp.
80
81Symbols:
82- `eps = 2^-53`.
83- `L` = number of clock levels that carry `Psi` (exact).
84- `c = L + 12`.
85- `delta = 16 eps` (relative error of `Psi`: one rounded `y_j`, `cos`/`sin`, `N^(-1/2)`, one complex product, about 8 eps, times 2).
86- `eta = sqrt(L/N) (delta + c eps)` (error of `phi_k` relative to `||Psi||`: the `L`-term sum and the conjugated amplitudes).
87- `Hpsi` = the largest row sum of `|H_total|` over the columns where `Psi` is nonzero.
88
89| Quantity | Bound |
90|---|---|
91| `constraint_residual` | `2 [Hpsi delta + 8 eps (Hpsi + 1)] + 4 eps value` |
92| `povm_residual` | `2 [(ceil(log2 M) + 8) eps (M w + 1) + (2 ceil(log2 N) + 4) eps value]` |
93| `clock_probability` | `2 [2 sqrt(w p) eta + (2 delta + (2L + 12) eps) p] + 4 w eta^2` |
94| `pauli` | `2 [2 eta sqrt(w / p) + 16 eps]` |
95
96The `p` and Pauli forms follow 8.4 item 4: an error `Delta phi` moves `p` by about `2 sqrt(w p) |Delta phi| / ||Psi||` and a conditional probability by about `2 |Delta phi| / ||phi_k||`.
97
98Each bound is written as the smallest scaled decimal with at most 7 significant digits that is at least the binary64 bound. That `>=` is verified exactly. Minimality is tested: one unit less in the seventh significant digit is below the binary64 bound. The label status rule (section 3) is decided exactly on the binary64 value and the bound as written.
99
100The judge compares the written tokens in exact rational arithmetic, never in floating point:
101- Absolute form: PASS if `|v| + b <= tol`, FAIL if `|v| - b > tol`, else INDETERMINATE. Check 7 uses the signed form.
102- Check 10 uses the exact rational `w/N` as the ideal clock marginal.
103- Aggregation is per-input `NOT_EVALUATED`. Any INDETERMINATE check or label adds `PRECISION_INSUFFICIENT`.
104
105### Measured (this host only)
106
107Host: Linux aarch64 (DGX Spark), gcc 13.3.0, `make test`, 2026-10-09. Every number below comes from that run.
108
109| Quantity | Measured | Ratio to its own bound |
110|---|---|---|
111| `\|p(k) - exact\|`, all section 13 cases and controls | at most `1.78e-16` | at most `0.0129` |
112| `\|pauli - exact\|`, all DEFINED labels | at most `3.89e-16` | at most `0.00973` |
113| `constraint_residual` | at most `5.72e-17` | at most `0.007` |
114| `povm_residual`, complete clocks | at most `4e-16` | |
115| `povm_residual`, N4a and N4b | `1` and `sqrt(42)/4` within their bounds | |
116| Large case N = 64, M = 256 | `sum p - 1 = 0`, `constraint_residual 0` (bound `8.17e-15`), `povm_residual 1.33e-15` (bound `2.31e-13`) | |
117| Review reproducer N = 64, M = 1, `w = 1/3`, exact `sqrt(571)/3` | value `7.9652020968990138`, equal to the binary64 `sqrt(571.0)/3.0`; inside `[exact - bound, exact + bound]` in exact arithmetic, bound `3066656@20` | |
118
119For comparison, `AT1_SPEC.md` 8.4 item 5 reports `5.6e-16` from its scratch builds. The bounds are 75 to 150 times the largest errors seen. The whole test program runs in about 0.1 s on this host.
120
121## Tests (`make test`)
122
123`tests/test_model.c` currently passes 1390 assertions, 0 failures. Clean under `-fsanitize=address,undefined` with leak detection (`make asan`, gcc 13.3).
124
1251. **Worked example** `tests/cases/at1-kat-rotated-level-n4.case`, byte-identical to `AT1_CASE_V1` section 6.
126 - File sha256 `76e282fe...`, `case_id 890980a4...`, `acceptance_id d63246c3...`.
127 - The test generator reproduces the file byte for byte.
128 - Kernel dimension 2, `p = 5/28, 1/4, 9/28, 1/4`.
1292. **Every `AT1_SPEC.md` section 13 class**, generated with recomputed identities:
130 - Positive: P1a, P1b, P1c, P2, P3, P3b, P4, P5, P6.
131 - N1 to N1f: the positive cases with target IDEAL, giving `SCHRODINGER_DEVIATION_EXCEEDED`.
132 - Negative: N2, N3, N4a, N4b, N5, N6.
133 - Each one checks:
134 - the kernel dimension;
135 - every `p(k)` and Pauli value against the exact table, `|value - exact| <= written bound`, in exact arithmetic;
136 - label status and the trivial-kernel rule;
137 - a full result written with an oracle record built from the exact tables;
138 - the 12-check vector, outcome, failure codes and `expectation_met YES` against section 13;
139 - line count, byte range, `verdict_id` and `evidence_digest`.
1403. **Controls added here:**
141 - C1: `psi_0` nearly orthogonal to the only kernel vector. PASS, exact values met.
142 - C2: energies shifted by 1000, cancelled by `h0`. P2's table, PASS.
143 - C3: a kernel level with `|E_j + h0| = R_j = 1025/2` on a rotated axis. Check 4 INDETERMINATE, `PRECISION_INSUFFICIENT` (the declared limit below, shown working).
1444. **Refusals:** 67 files with exact codes.
145 - R0 to R14 of section 13.5, including R2b, R2c, R3b, R5b, R6b, R12b.
146 - All 42 inherited AT-0 rows re-expressed on P2 (R01 to R39, R06b to R06d, CRLF, missing final LF, empty file).
147 - Readings (d) and (e): `OMEGA-AT0-CASE v1` gives `CASE_PARSE_ERROR`; `domain omega.at0.case.v1` gives `CASE_UNSUPPORTED_VERSION`; index `01` gives `CASE_NONCANONICAL`; index `x` or `5` gives `CASE_PARSE_ERROR`.
148 - A 5001-digit token is an engine limit error, not a refusal.
1495. **Invariance (spec section 9.1)**, on P2 and P4:
150 - T4 phase times `i`; T5 scale times 2; T6 purity;
151 - T7 shift of `r` by one shifts the labels;
152 - T8 reversed order bit-identical; T9 second run bit-identical.
1536. **Large case:** N = 64, M = 256, two kernel levels, full result PASS.
1547. **Judge and tool rules:**
155 - Status disagreement gives check 12 FAIL; an INDETERMINATE reference label gives `PRECISION_INSUFFICIENT`.
156 - A wrong oracle marginal gives `INTERACTING_DEVIATION_EXCEEDED`; a wrong `reference_interacting` under IDEAL gives check 11 `ORACLE_DISAGREEMENT`; a `nonfinite` reference gives `NONFINITE_VALUE`.
157 - Malformed oracle records are rejected: missing line, wrong label, `-0.0`, foreign `case_id`.
158 - Refused provenance: `build_cc oracle ...`, equal engine and oracle digests, duplicate artifact path, bad timestamp.
159 - `ORACLE_UNAVAILABLE` and `INTERNAL_ERROR` result shapes.
160 - Through the CLI: output equals the library output, `--reversed`, `none`, refusal exit 2 with the exact stderr line, bad provenance exit 1 with empty stdout.
161 - Oracle `undefined` placement: one clock line undefined, a status that contradicts its own clock value, an all-`undefined` record with `DEFINED` labels, a status change without its lines, `reference_ideal` undefined, `reference_interacting` undefined on a `DEFINED` label: all refused. A consistent trivial-shape oracle record against a nontrivial engine is accepted and gives check 12 FAIL.
1628. **Independent review findings** (46 assertions; 28 of them fail on the pre-review code, all pass now):
163 - The review reproducer above for the POVM bound (the pre-review code was 58 times over its bound).
164 - Minimal bound tokens: `1` is `1@0`, `0.25` is `25@2`, plus the minimality property on 12 values from `3e-41` to `123456789`.
165 - Label status rule at its exact boundaries (`p + b == tol` is `UNDEFINED`, `p - b == tol` is `INDETERMINATE`).
166 - Absolute-form boundary on check 10: `|d| + b == tol` is PASS; one ulp more is INDETERMINATE with `PRECISION_INSUFFICIENT`.
167 - An oracle record that is a full result file: reference-like lines outside its `begin values` block are ignored.
168 - Through the CLI: an unreadable oracle record gives `ERROR ORACLE_UNAVAILABLE` with exit 0; a refused case with unreadable oracle and provenance still exits 2 with its refusal line; an unreadable provenance file exits 1.
169
170## Declared limits
171
172- **`bound_kind ESTIMATED`, not RIGOROUS.** Cases with `min_bound_kind RIGOROUS` fail check 1 by design (N5).
173- **Large matrix entries.** `constraint_residual` is evaluated in binary64. When `|H_total|` acting on `Psi` has row sums `Hpsi` above about 187 (where `48 eps Hpsi` reaches `1e-12`), its bound exceeds `tol_constraint_residual 1@12`, and check 4 is INDETERMINATE (`PRECISION_INSUFFICIENT`) even though the measured residual stays small. C3 (`Hpsi` near 1230) shows this. A shift common to `E_j` and `h0` does not count, because the matrix entries are exact sums (C2).
174- **Small marginals.** Bounds on conditional probabilities grow like `1/sqrt(p(k))`. `AT1_SPEC.md` 8.3 keeps `p(k) >= 1e-3` in every case.
175- **Engine limits.** Case, oracle and provenance files up to 1 MiB; numeric tokens up to 4096 digits (the contract's own limits are far below). Beyond these the tool exits 1 with `AT1_ENGINE_ERROR RESOURCE_LIMIT`, which is not a refusal code.
176- **Exact arithmetic cost.** The exact elimination of the `2N x 2N` matrix is cheap at contract sizes (N = 64, M = 256 runs in milliseconds here). It was not timed beyond the contract limits.
177- **ERROR results.** The labels are written `UNDEFINED`, the same reading as the trivial-kernel rule; the contract fixes values and bounds for `ERROR` but not the label status token.
178- **Platforms.** Built and tested only on Linux aarch64 with gcc 13.3. Not yet built here with clang. macOS arm64 with Apple clang 17 and GNU Make 3.81 is the stated replication target: no GNU-make-4 features, no glibc-only calls, no Linux-only headers in the engine, no `long double`, digests computed in C. The sanitizer target probes the compiler first and skips if unsupported. Values may differ in the last bits across libm implementations (`cos`, `sin`); verdicts are designed not to (spec 8.3 margins).