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 / om / runtime / rx_semantic_om2.om

41 lines · 1120 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: AGPL-3.0-only
3note Pure seeded OM-2 semantic incremental primitives backing src/runtime/rx_semantic.c:
4note constant-time digest equality, 56-bit derived node ID packing, and input uniqueness check.
5
6note Constant-time 32-byte digest comparison. Returns 1 if equal, 0 otherwise.
7export fn rx_sem_digest_eq_om2 a view uchar 32 b view uchar 32 to ulong
8 diff = ulong 0
9 for i ulong 32
10 diff = or diff xor ulong get a i ulong get b i
11 end
12 if eq diff 0
13 ret 1
14 end
15 ret 0
16end
17
18note Pack (kind << 56) | le56(d[0..6]) into a 64-bit semantic node ID.
19export fn rx_sem_node_id_from_hash d view uchar 32 kind ulong to ulong
20 v = ulong 0
21 for i ulong 7
22 b = ulong get d i
23 v = or v shl b mul i 8
24 end
25 ret or shl kind 56 v
26end
27
28note Verify no duplicate input semantic IDs in inputs[0..n-1]. Returns 1 if unique, 0 else.
29export fn rx_sem_inputs_unique inputs view ulong * n ulong to ulong
30 for i ulong n bound 64
31 vi = get inputs i
32 j = add i 1
33 while lt j n bound 64
34 if eq vi get inputs j
35 ret 0
36 end
37 j = add j 1
38 end
39 end
40 ret 1
41end