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 / neuralese / decode.om

134 lines · 2442 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Concatenate before om/tls/sha2.om. No learned producer is implemented.
3note NLE1: ten metadata bytes, four payload bytes, lowercase hex SHA-256 of those bytes.
4note Unknown identities and representations have no executable interpretation.
5om2 debug
6text magic "NLE1"
7text hexdigs "0123456789abcdef"
8text prefix "om2 debug\nfn apply x uint to uint\nrequires le x 16\nensures le result 32\n"
9text incop "ret add x 1\n"
10text dblop "ret mul x 2\n"
11text idop "ret x\n"
12text suffix "end\nfn main to int\nret int apply uint "
13text tail "\nend\n"
14fn hashok a view uchar 79 to bool
15msgbuf = new uchar 14 0
16digest = new uchar 32 0
17ctx = new ulong 40 0
18for i ulong 14
19put msgbuf i get a i
20end
21sha256_init ctx
22sha256_update ctx msgbuf
23sha256_final ctx digest
24for i ulong 32
25offset = add mul i 2 14
26value = get digest i
27if ne get a offset get hexdigs shr value 4
28ret false
29end
30offset = add offset 1
31if ne get a offset get hexdigs and value 15
32ret false
33end
34end
35ret true
36end
37fn validate a view uchar 79 n ulong to int
38if gt n 78
39ret 10
40end
41if lt n 78
42ret 16
43end
44for i ulong 4
45if ne get a i get magic i
46ret 11
47end
48end
49note This registry pair denotes a hand-authored fixture, not a trained model.
50if or ne get a 4 1 ne get a 5 1
51ret 12
52end
53if ne get a 6 4
54ret 13
55end
56if ne get a 7 1
57ret 14
58end
59if ne get a 8 1
60ret 15
61end
62if ne get a 9 4
63ret 20
64end
65if not hashok a
66ret 17
67end
68if or ne get a 12 0 ne get a 13 0
69ret 18
70end
71if or lt get a 10 1 gt get a 10 3
72ret 19
73end
74ret 0
75end
76fn output b view uchar * to void
77p = ulong 0
78while lt p len b bound 256
79r = write 1 b p sub len b p
80if le r 0
81exit 81
82end
83p = add p ulong r
84end
85end
86fn number v uchar to void
87b = new uchar 3 0
88n = ulong 0
89if ge v 100
90put b n add uchar 48 div v 100
91n = add n 1
92end
93if ge v 10
94put b n add uchar 48 rem div v 10 10
95n = add n 1
96end
97put b n add uchar 48 rem v 10
98n = add n 1
99output part b 0 n
100end
101fn main to int
102a = new uchar 79 0
103n = ulong 0
104note Every successful read increases n, so at most seventy-nine iterations occur.
105while lt n 79 bound 79
106r = read 0 a n sub 79 n
107if lt r 0
108ret 80
109end
110if eq r 0
111break
112end
113n = add n ulong r
114end
115status = validate a n
116if ne status 0
117ret status
118end
119note Emission happens only after complete validation. No payload is ever execprog input.
120output prefix
121if eq get a 10 1
122output incop
123end
124if eq get a 10 2
125output dblop
126end
127if eq get a 10 3
128output idop
129end
130output suffix
131number get a 11
132output tail
133ret 0
134end