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 / spec / mixed-algebra-phase-twin.md

243 lines · 13881 bytes Raw Blame History Rendered
1# Omega mixed algebra: phase-domain Z3 digital twin (MA-8 step 0)
2
3Status: ADR 0019 **MA-8 step 0**, a simulated precursor of MA-8 ("physical
4phase or external-Machine realization"). It is not MA-8 itself: there is no
5physical device. Provenance of every result is `SIMULATED_DEVELOPMENT`
6(ADR 0018 AR1/AR2 wording). It makes no speed, latency, energy or physical
7claim, does no selection or ranking, and mints no semantic id or digest. It
8may be cited as model-only evidence toward the Turing gate
9DIGITAL_PHASE_EQUIVALENCE; it does not claim that gate.
10
11Code: `src/algebra/phase_twin.{h,c}` (twin), `tests/algebra/test_phase_twin.c`
12(gates and receipt). Receipt: `evidence/MIXED_ALGEBRA/phase_twin_receipt.<sha256>.json`.
13Commands: `make test-phase-twin` (full run into `build/`, quick run plain and
14under ASan+UBSan with byte-identical receipts, reproduction check against the
15committed receipt; about 90 s wall on the Spark), `make phase-twin-receipt`
16(clean committed tree only; writes the content-addressed receipt). C11 + libm,
17no other dependencies, CPU only.
18
19Sources: ADR 0019 (sections 3, 5, 6.3, 8), ADR 0018 (sections 3, 12),
20`docs/plans/mixed-algebra/MIXED_ALGEBRA_THEORY.md` section 6,
21`docs/plans/mixed-algebra/research/PHASE_EXPERIMENT_AND_HARDWARE.md`
22("research note"), all at aien-architecture `origin/main` 1438799. Oracle:
23`oma_z3_add` / `oma_z3_mul` (`src/algebra/oma_z3.c`).
24
25## Claim form
26
27Every result below has the form: under model profile P (the declared
28parameters), candidate realization C versus the oracle `oma_z3`, measured X,
29from the receipt. Nothing transfers to hardware without AR4-grade physical
30evidence.
31
32## Model
33
34Encoding: Z3 value k is the tone `A cos(2 pi n / 64 + 2 pi k / 3)`, so
35`f_c = f_s / 64` and the phase is 0, 120 or 240 degrees. Converter full scale
36is +/-1; A = 0.5 (-6.02 dBFS). Converters are mid-tread quantizers with
37clipping (`bits = 0` means ideal).
38
39Addition is phasor multiplication (theory 6.1, 6.2). Three candidate
40realizations:
41
42| rz_id | mechanism | where the multiply happens |
43|---|---|---|
44| PT_corr_product | two channels emit a and b; each is I/Q-correlated at f_c; the two correlator outputs are multiplied | complex multiply of measured phasors (research note loopback) |
45| PT_mixer | two tones enter an ideal analog mixer; the product is digitized and correlated at 2 f_c | analog multiply (simulated) |
46| PT_nco | 32-bit phase words `a T + b T` (T = floor(2^32/3)) wrap-add; one tone at that phase | integer phase accumulator (NCO) |
47
48Measurement: `I = sum x[n] cos(2 pi n / 64)`, `Q = -sum x[n] sin(2 pi n / 64)`
49(bin 2 for mixer and doubler). Decision: `k = mod(round(theta / 120 deg), 3)`,
50cells +/-60 degrees.
51
52Calibration (research note "Timing and calibration"): every
53`interval` operations, emit k = 0 on each path `reps` times, average the
54correlator outputs, store the phase as the path offset and the magnitude as
55the erasure reference; then emit k = 1 `reps` times and require
56120 +/- `tol` degrees after correction, else a calibration fault. Later
57correlator outputs are rotated by the stored offset. The reference is
58time-multiplexed on the signal paths (the research note's procedure); a
59dedicated always-on pilot tone is the hardware alternative and is not modelled.
60
61Flags (each fails the trial; no voting): erasure (magnitude below 0.3 x
62reference), reject (output phase more than 30 degrees from the nearest
63center), calibration fault (every operation in a block after a failed check).
64
65Noise and impairments: AWGN per sample at the ADC input (std `sigma`,
66independent per channel); one Gaussian phase jitter per channel per frame;
67DAC and ADC quantization; fixed per-channel path offset; linear per-channel
68drift in simulated time (`frame_s` per frame, calibration frames included).
69Symbol SNR at the correlator output is `rho = A^2 N / (4 sigma^2)`, equal to
70the research note's `rho = N SNR_1 / 2`.
71
72Declared simplifications: the analog path is a pure phase shift at f_c applied
73before the DAC; noise is white Gaussian; converters have no INL/DNL or spurs;
74mixer and doubler are ideal multipliers; one shared clock (no sample slip, no
75frequency offset); no crosstalk; no amplitude drift.
76
77RNG: xoshiro256** seeded by splitmix64, Gaussian by the Marsaglia polar
78method, fixed seed per scenario (listed in the receipt). No clock or host data
79enters the receipt except the recorded commit, dirty count and compiler
80version, so plain and sanitizer builds write byte-identical receipts.
81
82## Profiles
83
84| profile | f_s | N | bits DAC/ADC | use |
85|---|---|---|---|---|
86| A | 125 MS/s | 4096 | 14/14 | research note reference design |
87| B | 1 MS/s | 1024 | 12/12 | research note low-rate design |
88| B-ideal | 1 MS/s | 1024 | ideal | quantization-free control |
89| SWEEP | 1 MS/s | 64 | ideal | gate 2; flags, jitter, offset, calibration off |
90| P (contract) | 1 MS/s | 64 | 12/12 | gate 3; frame 128 us, rho 25 dB per input, jitter 1 deg rms, flags on, calibration every 1000 ops with 32 reference frames, tol 5 deg |
91
92## Pre-registered gates and thresholds
93
94These thresholds are fixed in this document and in `tests/algebra/test_phase_twin.c`
95before the committed receipt is generated.
96
97- **Self-checks.** Decoder boundaries (59.9 degrees -> 0, 60.1 -> 1), NCO wrap
98 pair (2,2) -> 1, argument rejection, RNG moments, the analytic add reference
99 stable between grids of 3600 and 7200 points (relative 1e-3), Craig integral
100 at 0 dB within 5e-4 of 0.1834.
101- **Gate 1, noiseless (exhaustive).** Profiles A, B, B-ideal x realizations
102 PT_corr_product, PT_mixer, PT_nco: all 9 input pairs x 1000 repetitions
103 decode equal to `oma_z3_add`, zero mismatches, zero flags. Multiply by a known
104 constant on profile B (calibration on): 9 pairs x 1000 equal to `oma_z3_mul`.
105 Quantization sweep 16 to 1 bits is informational only.
106- **Gate 1b, research note pass condition.** Profile A, `SNR_1` = 80 dB per
107 sample, 1 ps jitter (7.0e-4 degrees at 1.953 MHz), 3.35 degree fixed offset
108 on channel b (1 m cable), calibration on: 9 x 1000, zero failures.
109- **Gate 2, error rate versus SNR (PT_corr_product, profile SWEEP).** At rho
110 = 0, 6, 8, 10, 12 dB per input with 1e5, 2e5, 4e5, 1e6, 4e6 trials:
111 (a) the exact add reference (numerical circular convolution of the exact
112 PSK phase density, 7200 points) lies inside the measured Wilson 99.9 %
113 interval; (b) the research note's Monte Carlo add values (3.52e-1, 5.76e-2,
114 1.52e-2, 1.96e-3, 8.46e-5) are within 5 % of the exact reference at 10 and
115 12 dB; (c) the single-phasor read of channel a matches Craig's exact 3-PSK
116 error inside Wilson 99.9 % wherever at least 100 errors are expected, and
117 Craig matches the research note's table within 1 %; (d) pure 15 degree
118 per-input jitter, 4e5 trials: `2 Q(60 / (sqrt2 x 15))` = 4.68e-3 inside
119 Wilson 99.9 %.
120- **Gate 3, calibration (profile P).** Cases offset-only (50, 20 degrees),
121 drift-only (2.0, 1.5 degrees/s), offset and drift. Uncalibrated runs
122 (2e5, 1e6, 2e5 trials) must **violate** the contract: Wilson 95 % lower
123 bound above 1e-6. Calibrated runs (2e5, 1e6, 4e6 trials) must have zero
124 failures. The contract case (offset and drift, 4e6 trials) must meet the
125 contract below.
126- **Gate 4, receipt.** Records every profile parameter, the contract, measured
127 error rates with Wilson bounds, evidence tiers per ADR 0019 section 8, the
128 Z3 multiply verdict, and field names from `src/turing/field.h` where they
129 apply (`rz_id`, `algebra`, `representation`, `tier_source`, `run_id`,
130 `git_commit`, `tree_dirty`, `toolchain`, `verified`).
131
132Contract (ADR 0018 `BOUNDED_STOCHASTIC`): operation Z3 add `(a + b) mod 3`,
133realization PT_corr_product at profile P; bound: probability of a failed
134operation (mismatch or any flag) <= 1e-6; confidence 95 %; required: zero
135failures in at least `ceil(-ln 0.05 / 1e-6)` = 2,995,733 trials, and the
136two-sided Wilson 95 % upper bound <= 1e-6 (hence 4,000,000 trials).
137
138### Pre-registration record
139
140The thresholds above were written into the test code before the first full
141run, but that run (uncommitted working tree) came before this document. One
142parameter changed after it: profile P first used 8 calibration reference
143frames. At rho 25 dB the k = 1 check then misfires about once per 4,000
144calibrations (6e-5 per check); one such false calibration fault flagged a
145block of 1,000 operations in the drift-only and contract cases. The frame
146count was raised to 32, which puts the check tolerance at about 8 standard
147deviations. The contract bound, confidence, SNR, trial counts, tolerances and
148flag thresholds did not change. This is a post-observation change to a
149calibration parameter and is recorded here as such.
150
151## Z3 multiplication
152
153Two unknown operands: **not realizable in this model.** Phasor multiplication
154realizes Z3 addition. Z3 `a b` corresponds to `w^(a b) = (w^a)^b`, which is
155exponentiation, and no bilinear phasor operation computes it (theory 6.4). A
156decode-then-select circuit (decode b digitally, then identity, doubler or
157constant source) is a hybrid digital realization and is not claimed.
158
159Multiplication by a known constant b: **realized** (gate 1): b = 0 is a constant
160k = 0 source, b = 1 identity, b = 2 a frequency doubler (squarer read at
1612 f_c), since `w^(2a) = conj(w^a)`.
162
163## Evidence tiers (ADR 0019 section 8)
164
165| item | tier | scope |
166|---|---|---|
167| add, noiseless, each profile x realization | E3 (all 9 pairs) | the twin model; the ideal map itself is E4 (theory 6.1 proof) |
168| mul by known constant, noiseless | E3 | the twin model |
169| add, bounded contract at profile P | E1 | the twin model only |
170| SNR curve and jitter check | model validation, not a contract | agreement with analytic references |
171| mul of two unknowns | E0: no realization exists | |
172
173## What the twin proves and what it does not
174
175It shows that, inside the declared model, the phase encoding plus the three
176add mechanisms compute exactly `oma_z3_add` on the whole Z3 domain; that
177the decoder's error statistics match the analytic 3-PSK results, so the
178contract arithmetic is right; and that the reference-frame calibration turns
179a failing channel (offset and drift) into one that meets a 1e-6 bound at
180rho 25 dB.
181
182It does **not** show that any physical board does this. ADR 0018 forbids a
183physical analog claim without physical evidence, and there is none. It makes
184no claim about speed, latency, energy, or cost against the digital
185`oma_z3_add`. The noise models are idealized (list above); real converters,
186cables, mixers and clocks have effects the twin leaves out.
187
188## What a real board must meet for the contract to transfer
189
190A board inherits the twin's contract only if measurements (AR4 evidence)
191show all of these at the operating point used:
192
1931. One clock and PLL for DAC, ADC and NCOs; NCOs cleared on the same cycle;
194 no sample slip (one sample at `f_s / 64` is 5.625 degrees).
1952. Symbol SNR at the correlator output >= 25 dB per input:
196 `N SNR_1 / 2 >= 316`, measured with the board's effective bits, at -6 dBFS
197 and no clipping.
1983. DAC and ADC >= 12 effective bits over the used band, no spur at f_c or
199 2 f_c above the noise that the SNR figure assumes.
2004. Frame-to-frame phase jitter <= 1 degree rms per channel (1.42 ns rms at
201 1.953 MHz; 178 ns at 15.625 kHz).
2025. Any fixed path offset, with the k = 1 check passing (120 +/- 5 degrees).
2036. Phase drift <= 2 degrees/s per channel with recalibration every 1,000
204 operations (0.13 s at profile P), or proportionally faster recalibration;
205 board temperature within 2 degrees C across a block.
2067. 32 reference frames per calibration step at rho 25 dB (fewer at higher
207 SNR, as long as the check's false-fault rate stays below the contract).
2088. Noise white and Gaussian enough that the measured error curve matches the
209 gate 2 curve; independent channels; crosstalk below the noise floor.
2109. For PT_mixer: mixer linear enough that the 2 f_c product term dominates,
211 and the ADC sees the product without clipping.
212
213## Results (receipt `evidence/MIXED_ALGEBRA/phase_twin_receipt.5d6ca45e970faf19986490264e35db453211ffe6dfff03d1cfb10937f329a22b.json`)
214
215Generated by `make phase-twin-receipt` from clean commit 48ef003 (`tree_dirty` 0),
216gcc 13.3.0. Overall **PASS**. The quick run (trial counts / 50) is byte-identical
217between the plain and the ASan+UBSan build.
218
219- Gate 1: 9 configurations (A, B, B-ideal x corr_product, mixer, nco), 9,000
220 checks each, 0 mismatches, 0 flags. Largest phase error from a cell center:
221 3.6e-2 degrees (mixer, 12-bit). Multiply by known constant: 9,000 checks, 0
222 failures. Quantization is harmless down to 2 bits (max 3.75 degrees); the
223 degenerate 1-bit mid-tread quantizer fails (informational).
224- Gate 1b: 9,000 checks at the research note's reference operating point, 0
225 failures.
226- Gate 2, PT_corr_product add error versus rho per input (exact reference /
227 research note / twin):
228
229 | rho | exact | note | twin (errors / trials) | Wilson 99.9 % |
230 |---|---|---|---|---|
231 | 0 dB | 3.517e-1 | 3.52e-1 | 3.531e-1 (35,314 / 1e5) | 3.48e-1 .. 3.58e-1 |
232 | 6 dB | 5.771e-2 | 5.76e-2 | 5.793e-2 (11,585 / 2e5) | 5.62e-2 .. 5.97e-2 |
233 | 8 dB | 1.514e-2 | 1.52e-2 | 1.526e-2 (6,104 / 4e5) | 1.46e-2 .. 1.59e-2 |
234 | 10 dB | 1.961e-3 | 1.96e-3 | 1.938e-3 (1,938 / 1e6) | 1.80e-3 .. 2.09e-3 |
235 | 12 dB | 8.530e-5 | 8.46e-5 | 9.125e-5 (365 / 4e6) | 7.68e-5 .. 1.08e-4 |
236
237 Single-phasor reads match Craig's formula (for example 1.020e-4 vs 1.065e-4
238 at 10 dB). Jitter 15 degrees per input: 4.68e-3 measured, 4.68e-3 formula.
239- Gate 3 (profile P, contract bound 1e-6 at 95 %): uncalibrated offset-only,
240 drift-only and offset-and-drift runs fail at 1.00, 0.80 and 1.00 (contract
241 violated). Calibrated: 0 failures in 2e5, 1e6 and 4e6 operations; the
242 contract case gives Wilson 95 % upper bound 9.6e-7 and E1 bound 7.5e-7:
243 **CONTRACT_MET** under profile P. 4,000 calibrations, 0 calibration faults.