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 Source

irequiv: exhaustive equivalence of OSC IR scalar functions (issue 826)

irequiv.om is seeded Omega. It reads one OSC IR v1 unit (spec/one-layer-format.md) on stdin, interprets its functions with the semantics of src/compiler/osc_interp.c (wrapping unsigned arithmetic, signed overflow, division, shift and conversion traps, explicit trap N), and compares two functions over every input of their shared signature. Two results are equal only when both return the same bits or both trap with the same code.

seed/out/omc < seed/equiv/irequiv.om > irequiv && chmod +x irequiv
{ printf 'ir\n'; cat seed/equiv/pop16.unit.om; } | seed/out/omc > pop16.ir
./irequiv check pop16 pop16s < pop16.ir      # EQUIV PASS ... domain=65536 checked=65536 differing=0
./irequiv check pop16 pop16e < pop16.ir      # EQUIV FAIL ... differing=1 first=ushort:65535 ...
./irequiv sample A B N SEED < unit.ir        # wider domains: EQUIV SAMPLED ... NOT_A_PROOF, exit 10
./irequiv eval F uchar:1 uchar:9 < unit.ir   # value:N or trap:C
./irequiv dump F < unit.ir                   # 8 LE bytes per input, enumeration order
sh seed/equiv/gate-irequiv.sh

Lines 43-496 are the OSC IR v1 reader and validator, shared byte for byte with seed/spirv/irspirv.om (the same lines there). seed/wasm/irwasm.om copied the same reader and then extended it for IR v7 (regions, f32/f64, RLOAD/RSTORE/BITCAST/RINIT; #818). Its lines 65-843 must equal irequiv's range with the POSIX sed edits in irwasm-v7.sed applied (N a\ inserts after range line N, N c\ replaces it). Any change on either side that the recorded edits do not cover fails the gate as reader drift. A deliberate irwasm reader change updates irwasm-v7.sed in the same commit. The gate also builds irwasm and requires both readers to give the same verdict on every v1 unit it uses: they accept the same units and refuse bad magic (20), version (21), truncation (22) and trailing bytes (27) with the same status (READERS units=26 agree=26). It also requires irequiv to refuse a version-7 header as VERSION. Fixtures: hexv (js_hexv from seed/json/json.om, hhexv from seed/net/http.om), clamp (dev01 clamp_add), bitrev (dev09 bitrev8), rot (r8 from seed/omc/om2/s1/rot.om), pop16, and wide (sampling and fuel). Each names its source and its deliberate mutants.

The gate also runs every row of seed/wasm/cases.tsv (129), seed/spirv/regression.tsv (8) and seed/spirv/demo.tsv (3) twice: as a native program built by omc with the irwasm/irspirv gates' 64-bit result dumper, and through irequiv eval on the unit's IR. It requires the same bits or the same trap code on all 140 rows (CONFORM native rows=140 equal=140), so an interpreter defect that no fixture pair reaches still fails the gate.

Limits: OSC IR v1 scalar functions only (what omc IR mode emits: at most 32 functions, 6 parameters); the result is a statement about the IR both functions lowered to, not about the AArch64 words the native path emits for the same source.