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 / seed / equiv / README.md

53 lines · 3739 bytes Raw Blame History Rendered
1# irequiv: exhaustive equivalence of OSC IR scalar functions (issue 826)
2
3`irequiv.om` is seeded Omega. It reads one OSC IR v1 unit (`spec/one-layer-format.md`) on stdin,
4interprets its functions with the semantics of `src/compiler/osc_interp.c` (wrapping unsigned
5arithmetic, signed overflow, division, shift and conversion traps, explicit `trap N`), and compares
6two functions over every input of their shared signature. Two results are equal only when both
7return the same bits or both trap with the same code.
8
9```sh
10seed/out/omc < seed/equiv/irequiv.om > irequiv && chmod +x irequiv
11{ printf 'ir\n'; cat seed/equiv/pop16.unit.om; } | seed/out/omc > pop16.ir
12./irequiv check pop16 pop16s < pop16.ir # EQUIV PASS ... domain=65536 checked=65536 differing=0
13./irequiv check pop16 pop16e < pop16.ir # EQUIV FAIL ... differing=1 first=ushort:65535 ...
14./irequiv sample A B N SEED < unit.ir # wider domains: EQUIV SAMPLED ... NOT_A_PROOF, exit 10
15./irequiv eval F uchar:1 uchar:9 < unit.ir # value:N or trap:C
16./irequiv dump F < unit.ir # 8 LE bytes per input, enumeration order
17sh seed/equiv/gate-irequiv.sh
18```
19
20- `check` needs identical parameter and return types and at most 24 parameter bits (bool counts 1);
21 inputs are enumerated with the last parameter in the low bits. The whole domain is scanned; the
22 line reports the count of differing inputs and the first one with both results.
23- `sample` draws N inputs (at most 67108864) from xorshift64* seeded by SEED. Agreement exits 10,
24 never 0, and prints `NOT_A_PROOF`.
25- Each evaluation has 16777216 instructions of fuel; running out prints `EQUIV INCONCLUSIVE`
26 and exits 6, never PASS or FAIL.
27- Exit codes: 0 PASS, 1 FAIL, 2 usage, 3 unknown function, 4 signature, 5 domain over 24 bits,
28 6 fuel, 7 trap during `dump`, 10 sampled agreement, 20-28 the IR reader's refusals.
29
30Lines 43-496 are the OSC IR v1 reader and validator, shared byte for byte with
31`seed/spirv/irspirv.om` (the same lines there). `seed/wasm/irwasm.om` copied the same reader and
32then extended it for IR v7 (regions, f32/f64, RLOAD/RSTORE/BITCAST/RINIT; #818). Its lines 65-843
33must equal irequiv's range with the POSIX sed edits in `irwasm-v7.sed` applied (`N a\` inserts
34after range line N, `N c\` replaces it). Any change on either side that the recorded edits do not
35cover fails the gate as `reader drift`. A deliberate irwasm reader change updates `irwasm-v7.sed`
36in the same commit. The gate also builds irwasm and requires both readers to give the same
37verdict on every v1 unit it uses: they accept the same units and refuse bad magic (20),
38version (21), truncation (22) and trailing bytes (27) with the same status
39(`READERS units=26 agree=26`). It also requires irequiv to refuse a version-7 header as VERSION.
40Fixtures: `hexv` (js_hexv from seed/json/json.om,
41hhexv from seed/net/http.om), `clamp` (dev01 clamp_add), `bitrev` (dev09 bitrev8), `rot` (r8 from
42seed/omc/om2/s1/rot.om), `pop16`, and `wide` (sampling and fuel). Each names its source and its
43deliberate mutants.
44
45The gate also runs every row of `seed/wasm/cases.tsv` (129), `seed/spirv/regression.tsv` (8) and
46`seed/spirv/demo.tsv` (3) twice: as a native program built by `omc` with the irwasm/irspirv gates'
4764-bit result dumper, and through `irequiv eval` on the unit's IR. It requires the same bits or the
48same trap code on all 140 rows (`CONFORM native rows=140 equal=140`), so an interpreter defect that
49no fixture pair reaches still fails the gate.
50
51Limits: OSC IR v1 scalar functions only (what `omc` IR mode emits: at most 32 functions, 6
52parameters); the result is a statement about the IR both functions lowered to, not about the
53AArch64 words the native path emits for the same source.