aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / docs / plans / atemporal / AT1_CASE_V1.md
| 1 | # AT1_CASE_V1: AT-1 case interchange contract |
| 2 | |
| 3 | **Contract:** `AT1_CASE_V1`. **Domain tags:** `omega.at1.case.v1` (case identity), `omega.at1.acceptance.v1` (acceptance identity). |
| 4 | **Status:** FROZEN on merge of the pull request that adds this file. After that, any change to this file is a contract change and requires `AT1_CASE_V2` (AT1 charter section 8). Typos are not exempt. |
| 5 | **Owner:** Agent 0. **Program status:** NOT_RUN. **Predecessor:** `AT0_CASE_V1` (frozen, unchanged, still the AT-0 contract). |
| 6 | |
| 7 | ## 0. Changes from AT0_CASE_V1 |
| 8 | |
| 9 | - Header and tags: `OMEGA-AT1-CASE v1`, `domain omega.at1.case.v1`, `contract AT1_CASE_V1`, identity tags `omega.at1.case.v1` and `omega.at1.acceptance.v1`. |
| 10 | - `model_family PAGE_WOOTTERS_FINITE_CLOCKDIAG`; `interaction CLOCK_DIAGONAL_PAULI`; one new repeated line `interaction_pauli <j> <vx>,<vy>,<vz>` (N entries); `constraint SUM_HC_HS_V`. |
| 11 | - New acceptance line `prediction_target <IDEAL|INTERACTING>` (which reference the engine must agree with). |
| 12 | - Validity rule 4 (rational spectrum) is applied per clock level. |
| 13 | - Everything else is byte-for-byte the AT0_CASE_V1 rule. |
| 14 | |
| 15 | ## 1. File shape |
| 16 | |
| 17 | ASCII text, LF line endings, every line terminated by exactly one LF, including the last. Allowed bytes: 0x20 to 0x7E and 0x0A. No CR, no tab, no blank line, no leading or trailing space, exactly one space between tokens. Lines appear in exactly the order below; a line marked "repeated" appears once per item, in ascending index order. Unknown keys, missing keys, duplicate keys and out-of-order keys are errors (`CASE_PARSE_ERROR`), never warnings. A fixed literal that does not match (for example `model_family` or `constraint`), an enumeration token outside its set, a repeated block whose line count does not match its count line, or a repeated line whose index token is not its zero-based position, is a shape error (`CASE_PARSE_ERROR`), per the AT-0 reading "shape before range". `clock_dim` is the count line for both the `clock_energies` entries and the `interaction_pauli` lines; `clock_label_count` is the count line for the `clock_label` lines. One exception, so that version mismatches are reported as such: the three version-bearing lines (`OMEGA-AT1-CASE v1`, `domain ...`, `contract ...`) are checked for key and placement in step 1 and for their value in step 2 of section 4 (`CASE_UNSUPPORTED_VERSION`). |
| 18 | |
| 19 | ``` |
| 20 | OMEGA-AT1-CASE v1 |
| 21 | domain omega.at1.case.v1 |
| 22 | contract AT1_CASE_V1 |
| 23 | case_name <name> |
| 24 | begin semantic |
| 25 | model_family PAGE_WOOTTERS_FINITE_CLOCKDIAG |
| 26 | energy_unit DIMENSIONLESS_HBAR_1 |
| 27 | clock_dim <N> |
| 28 | clock_energies <rational>,<rational>,... (N entries, strictly increasing) |
| 29 | system_dim 2 |
| 30 | system_hamiltonian_pauli <h0>,<hx>,<hy>,<hz> (rationals) |
| 31 | interaction CLOCK_DIAGONAL_PAULI |
| 32 | interaction_pauli <j> <vx>,<vy>,<vz> (repeated, j = 0 .. N-1, rationals) |
| 33 | constraint SUM_HC_HS_V |
| 34 | physical_state NULLSPACE_PROJECTION |
| 35 | reference_clock_label <label> |
| 36 | reference_system_state <complex>,<complex> |
| 37 | clock_povm COVARIANT_DISCRETE |
| 38 | povm_tau_turns <rational> |
| 39 | povm_weight <rational> |
| 40 | clock_label_count <M> |
| 41 | clock_label <k> <label> (repeated, k = 0 .. M-1) |
| 42 | observables PAULI_X,PAULI_Y,PAULI_Z |
| 43 | end semantic |
| 44 | begin acceptance |
| 45 | control_kind <POSITIVE|NEGATIVE> |
| 46 | prediction_target <IDEAL|INTERACTING> |
| 47 | expected_outcome <PASS|FAIL> |
| 48 | expected_failure_codes <code>,<code>,... | none |
| 49 | min_bound_kind <RIGOROUS|ESTIMATED|NONE> |
| 50 | tol_constraint_residual <scaled> |
| 51 | tol_povm_residual <scaled> |
| 52 | tol_probability <scaled> |
| 53 | tol_zero_probability <scaled> |
| 54 | tol_schrodinger <scaled> |
| 55 | end acceptance |
| 56 | case_id <64 lowercase hex> |
| 57 | acceptance_id <64 lowercase hex> |
| 58 | end |
| 59 | ``` |
| 60 | |
| 61 | ## 2. Canonical encodings (shared by AT1_CASE_V1 and AT1_RESULT_V1) |
| 62 | |
| 63 | Identical to AT0_CASE_V1 section 2, restated so this file stands alone: |
| 64 | |
| 65 | - **Integer:** decimal, optional leading `-`, no leading zeros, no `+`. Zero is `0`. `-0` is invalid (`CASE_NONCANONICAL`). |
| 66 | - **Rational:** `n/d` with `d >= 1`, `gcd(|n|, d) = 1`; integers are written `n/1`; zero is `0/1`. Limits: `|n| <= 1048576`, `1 <= d <= 1048576`. Validators decide rules 3 and 4 of section 4, the kernel test and the zero test of section 3 exactly for every case within these token limits, using arbitrary-precision integers or an equivalent exact method (the sum of three squared rationals can carry a denominator near 2^240). No implementation-defined refusal exists: a validator never refuses a case within the token limits for lack of arithmetic width, and never wraps around. |
| 67 | - **Complex rational:** `(re;im)`, both rationals, no spaces. |
| 68 | - **Scaled decimal:** `N@k` meaning `N / 10^k`, `N >= 0` integer, `0 <= k <= 40`; zero is `0@0`; otherwise `N` not divisible by 10 unless `k = 0`. |
| 69 | - **Lists:** comma separated, no spaces, no trailing comma; the empty list is `none`. |
| 70 | - **Label:** `[a-z][a-z0-9_]{0,31}`. **Name:** `[A-Za-z0-9][A-Za-z0-9_.-]{0,63}`. **Digest:** 64 lowercase hex. |
| 71 | - **No floating-point text anywhere in a case file.** |
| 72 | - A token that parses but is not canonical (`2/4`, `04`, `-0/1`, `10@1`) is `CASE_NONCANONICAL`, decided after the whole shape pass. |
| 73 | |
| 74 | ## 3. Field meaning (the physics, fixed for V1) |
| 75 | |
| 76 | Units: hbar = 1, dimensionless energies, times in the reciprocal unit. Pauli matrices in the computational basis with `Z|0> = +|0>`. |
| 77 | |
| 78 | - `clock_energies`: `H_C = sum_j E_j |E_j><E_j|`, `j = 0 .. N-1`, `2 <= N <= 64`, strictly increasing. |
| 79 | - `system_hamiltonian_pauli`: `H_S = h0 I + hx X + hy Y + hz Z`. |
| 80 | - `interaction CLOCK_DIAGONAL_PAULI`, `interaction_pauli j vx,vy,vz`: `V = sum_j |E_j><E_j| (x) (vx_j X + vy_j Y + vz_j Z)`. All-zero vectors are allowed (then the case is an AT-0 ideal case written in AT-1 form). |
| 81 | - `constraint SUM_HC_HS_V`: `H_total = H_C (x) I_S + I_C (x) H_S + V`, clock factor first. Because `V` is diagonal in the clock energy basis, `H_total = sum_j |E_j><E_j| (x) (E_j I + h0 I + (h + v_j).sigma)` with `h = (hx, hy, hz)`. Level `j` has system eigenvalues `e_{j,+-} = h0 +- |h + v_j|` with eigenvectors `|e_{j,+-}>`. Write `n = h + v_j` and `s = +1` or `-1`; the unnormalized eigenvector for eigenvalue `h0 + s|n|` is `(s|n| + n_z, n_x + i n_y)` when that vector is nonzero, else `(n_x - i n_y, s|n| - n_z)`; its components are Gaussian rationals because `|n|` is rational (section 4 rule 4). For `|n| = 0` both eigenvalues equal `h0`, the eigenspace is the whole qubit, and the kernel test below matches both basis vectors `|0>, |1>` or neither. |
| 82 | - `physical_state NULLSPACE_PROJECTION`: `|Psi> = P_0 (|t_r> (x) |psi_0>)`, `P_0` the orthogonal projector onto the kernel of `H_total`, `|t_r>` the clock state of `reference_clock_label`, `|psi_0>` the unnormalized nonzero `reference_system_state`. The kernel is exact: spanned by `|E_j> (x) |e_{j,s}>` with `E_j + e_{j,s} = 0`. |
| 83 | - `clock_povm COVARIANT_DISCRETE`, `povm_tau_turns`, `povm_weight`, `clock_label`, `observables`: as AT0_CASE_V1 section 3 (`|t_k> = N^(-1/2) sum_j exp(-2 pi i E_j k tau) |E_j>`, `t_k = 2 pi k tau`, `F_k = w |t_k><t_k|`, `1 <= M <= 256`, labels unique, `reference_clock_label` among them). |
| 84 | - `Psi` is exactly zero if and only if `<e_{j,s}|psi_0> = 0` for every kernel pair `(j, s)`, decided in exact Gaussian-rational arithmetic with the unnormalized eigenvectors above (the trivial-kernel rule of AT1_RESULT_V1 then applies). |
| 85 | - Conditional vector: `phi_k = (<t_k| (x) I) Psi = (1/N) sum_{(j,s) in K} exp(+2 pi i E_j (k - r) tau) <e_{j,s}|psi_0> |e_{j,s}>`, `r` the index of the reference label. The sign is plus because the bra `<t_k|` conjugates the phase of `|t_k>`; with `E_j = -e_{j,s}` this is `exp(-i e_{j,s} (t_k - t_r))`, forward evolution, and for zero coupling it reduces to AT-0's `exp(-i H_S (t_k - t_r)) Pi_K psi_0`. Its normalization is the conditional state; `p(k) = w ||phi_k||^2 / ||Psi||^2`. Because the `|e_{j,s}>` differ from level to level, `p(k)` is in general label-dependent and the conditional state is in general not `exp(-i H_S (t_k - t_r)) psi_0`. That is the content AT-1 tests. |
| 86 | - `prediction_target`: `IDEAL` means the engine's conditional probabilities are judged against Schrodinger evolution under `H_S` alone; `INTERACTING` means they are judged against the oracle's independent computation of the interacting conditional probabilities (AT1_RESULT_V1 section 4). It is an acceptance rule, so it lives in `acceptance_id`, not in `case_id`: the same question can be judged both ways. |
| 87 | |
| 88 | No field of a case may hold a wall-clock time, a host name, a run number or anything else about a physical execution. |
| 89 | |
| 90 | ## 4. Validity rules (exact, before any numerics) |
| 91 | |
| 92 | A validator refuses the case with the AT1_RESULT_V1 refusal code shown, on the first failure, in this order: |
| 93 | |
| 94 | 1. Shape and encodings (sections 1, 2): `CASE_PARSE_ERROR` (shape) or `CASE_NONCANONICAL` (parsed, non-canonical token). |
| 95 | 2. The values of the three version-bearing lines (`OMEGA-AT1-CASE v1`, `domain omega.at1.case.v1`, `contract AT1_CASE_V1`): `CASE_UNSUPPORTED_VERSION`. |
| 96 | 3. Ranges and fixed values of section 3; `reference_system_state` nonzero; `povm_weight > 0`; `povm_tau_turns > 0`: `CASE_INVALID_PARAMETER`. (Counts and index order are shape, step 1.) |
| 97 | 4. Rational spectrum per level: for every `j`, `(hx + vx_j)^2 + (hy + vy_j)^2 + (hz + vz_j)^2` is the square of a rational: `CASE_IRRATIONAL_SPECTRUM`. |
| 98 | 5. `case_id` and `acceptance_id` equal the recomputed values (section 5): `CASE_ID_MISMATCH`. |
| 99 | 6. Acceptance: `expected_failure_codes` is `none` when `expected_outcome PASS`, nonempty, sorted bytewise ascending, no duplicates when `FAIL`, every code an AT1_RESULT_V1 failure code: `CASE_INVALID_PARAMETER`. |
| 100 | |
| 101 | ## 5. Identity |
| 102 | |
| 103 | - `case_id = SHA-256( "omega.at1.case.v1" || 0x00 || B_sem )`, `B_sem` every line from `begin semantic` through `end semantic` inclusive, each followed by LF. |
| 104 | - `acceptance_id = SHA-256( "omega.at1.acceptance.v1" || 0x00 || B_acc )`, `B_acc` every line from `begin acceptance` through `end acceptance` inclusive, each followed by LF. |
| 105 | - `case_file_sha256 = SHA-256(whole file bytes)`: artifact digest, not an identity. |
| 106 | |
| 107 | Every hashed byte is exact text. Equal digests are evidence of equal exact content, not the definition of equality. |
| 108 | |
| 109 | ## 6. Worked example (known-answer test for codecs) |
| 110 | |
| 111 | Normative for byte layout and digests. The physics table is hand-derived and informational; `AT1_SPEC.md` and the oracle are the authority on values. |
| 112 | |
| 113 | ``` |
| 114 | OMEGA-AT1-CASE v1 |
| 115 | domain omega.at1.case.v1 |
| 116 | contract AT1_CASE_V1 |
| 117 | case_name at1-kat-rotated-level-n4 |
| 118 | begin semantic |
| 119 | model_family PAGE_WOOTTERS_FINITE_CLOCKDIAG |
| 120 | energy_unit DIMENSIONLESS_HBAR_1 |
| 121 | clock_dim 4 |
| 122 | clock_energies -3/2,-1/2,1/2,3/2 |
| 123 | system_dim 2 |
| 124 | system_hamiltonian_pauli 0/1,0/1,0/1,1/2 |
| 125 | interaction CLOCK_DIAGONAL_PAULI |
| 126 | interaction_pauli 0 0/1,0/1,0/1 |
| 127 | interaction_pauli 1 0/1,0/1,0/1 |
| 128 | interaction_pauli 2 3/10,0/1,-1/10 |
| 129 | interaction_pauli 3 0/1,0/1,0/1 |
| 130 | constraint SUM_HC_HS_V |
| 131 | physical_state NULLSPACE_PROJECTION |
| 132 | reference_clock_label t0 |
| 133 | reference_system_state (1/1;0/1),(1/1;0/1) |
| 134 | clock_povm COVARIANT_DISCRETE |
| 135 | povm_tau_turns 1/4 |
| 136 | povm_weight 1/1 |
| 137 | clock_label_count 4 |
| 138 | clock_label 0 t0 |
| 139 | clock_label 1 t1 |
| 140 | clock_label 2 t2 |
| 141 | clock_label 3 t3 |
| 142 | observables PAULI_X,PAULI_Y,PAULI_Z |
| 143 | end semantic |
| 144 | begin acceptance |
| 145 | control_kind POSITIVE |
| 146 | prediction_target INTERACTING |
| 147 | expected_outcome PASS |
| 148 | expected_failure_codes none |
| 149 | min_bound_kind ESTIMATED |
| 150 | tol_constraint_residual 1@12 |
| 151 | tol_povm_residual 1@12 |
| 152 | tol_probability 1@12 |
| 153 | tol_zero_probability 1@9 |
| 154 | tol_schrodinger 1@12 |
| 155 | end acceptance |
| 156 | case_id 890980a43bd189494c2c922d2bf0049cbffb07f1090f578e04e1142aee7525f1 |
| 157 | acceptance_id d63246c391296c6cd381f1b654cc625be9f453c77c27c68d9eac240efd5b4d8f |
| 158 | end |
| 159 | ``` |
| 160 | |
| 161 | `case_file_sha256` of the 45 lines above, each LF-terminated: `76e282fecf21025c9dd675378244e90ff192822a4c49d6cb812c9fe84b3f9ba4`. |
| 162 | |
| 163 | Hand derivation (informational). Levels 0, 1, 3 are uncoupled: `e = +-1/2` with eigenvectors `|0>`, `|1>`. Level 2 has `h + v_2 = (3/10, 0, 4/10)`, `|h + v_2| = 1/2`, so its eigenvalues are also `+-1/2` but along the axis `n = (3/5, 0, 4/5)`: `|e_{2,-}> = (-1/sqrt(10)) |0> + (3/sqrt(10)) |1>`. Kernel: `(j = 1, e = +1/2)` via `|0>` and `(j = 2, e = -1/2)` via `|e_{2,-}>`; dimension 2; both system components survive. The file's `psi_0 = (1, 1)` is proportional to `|+x>`; the values below use the normalized `|+x>` (`p(k)` does not depend on the scale; with the unnormalized vector `||Psi||^2` is `7/20` instead of `7/40`). With `psi_0 = |+x>`: `<0|psi_0> = 1/sqrt(2)`, `<e_{2,-}|psi_0> = 1/sqrt(5)`, `||Psi||^2 = (1/4)(1/2 + 1/5) = 7/40`, and the cross term `<0|e_{2,-}> = -1/sqrt(10)` makes the clock marginal label-dependent: `||phi_k||^2 = (1/16)(7/10 - (1/5) cos(pi k / 2))`, so |
| 164 | |
| 165 | | label | p(clock) | ideal model would say | |
| 166 | |---|---|---| |
| 167 | | t0 | 5/28 | 1/4 | |
| 168 | | t1 | 1/4 | 1/4 | |
| 169 | | t2 | 9/28 | 1/4 | |
| 170 | | t3 | 1/4 | 1/4 | |
| 171 | |
| 172 | The four values sum to 1 (the POVM is complete for this clock), the clock probabilities alone already refute the ideal prediction (AT1_RESULT_V1 check 10 compares them with `w/N` under `prediction_target IDEAL`), and the same case with `prediction_target IDEAL` is the negative class N1 (expected `SCHRODINGER_DEVIATION_EXCEEDED`). The relative phase between the two kernel levels is real here (`cos`), so this table does not depend on the phase sign of section 3; the Y outcomes do. Conditional Pauli values are left to `AT1_SPEC.md`. |