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 / proposal.om

155 lines · 2799 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note NL4 consumes NL3 lpvalid and NL1 nddec; neither is execution authority.
3note Caller must run lpvalid against receiver-owned context before this decoder.
4note No host words, executable payload, capability, allocation from input or effects.
5note Concatenate after an om2 debug entry, NL1 hadamard.om and NL3 validator.om.
6fn nlencode f view f64 4 wire edit uchar 32 to int
7stage = new uint 8 0
8for i ulong 4
9if not and ge get f i 0.0f64 le get f i 1.0f64
10ret 50
11end
12end
13for i ulong 8
14v = 0.0f64
15for j ulong 4
16v = add v mul get f j ndelem i j
17end
18put stage i bitcast uint f32 v
19end
20for i ulong 8
21u = get stage i
22off = mul i 4
23for j ulong 4
24sh = mul sub ulong 3 j 8
25c = uchar and shr u sh 255
26put wire add off j c
27end
28end
29ret 0
30end
31fn nlbe32 a view uchar * off ulong to uint
32v = uint 0
33for i ulong 4
34v = or shl v 8 uint get a add off i
35end
36ret v
37end
38fn nlbit v f64 to int
39note Closed synthetic codebook tolerance; ambiguous and nonfinite scores refuse.
40if and ge v -0.0625f64 le v 0.0625f64
41ret 0
42end
43if and ge v 0.9375f64 le v 1.0625f64
44ret 1
45end
46ret -1
47end
48fn nlproposal a view uchar * p edit uint 16 to int
49note This function proposes only; it does not validate context, reserve or execute.
50b = new uint 4 0
51if lt len a 1024
52ret 40
53end
54if ne get a 5 1
55ret 41
56end
57dtype = get a 10
58width = uint 4
59if eq dtype 2
60width = 1
61else
62if ne dtype 1
63ret 41
64end
65end
66if ne len a add ulong 1024 ulong mul width 8
67ret 40
68end
69if or ne get a 11 1 ne nlbe32 a 24 8
70ret 42
71end
72if or ne nlbe32 a 16 mul width 8 ne nlbe32 a 20 8
73ret 42
74end
75if ne get a 101 0
76ret 43
77end
78if lt nlbe32 a 104 1
79ret 44
80end
81factor = 1.0f64
82zero = int 0
83if eq dtype 2
84scale = nlbe32 a 56
85zero = bitcast int nlbe32 a 60
86if or eq scale 0 ge scale 0x7f800000
87ret 45
88end
89if or lt zero -128 gt zero 127
90ret 45
91end
92factor = f64 bitcast f32 scale
93end
94for i ulong 8
95if eq dtype 1
96u = nlbe32 a add 1024 mul i 4
97note Exponent255 includes every NaN and infinity, without floating comparison.
98if eq and shr u 23 255 255
99ret 45
100end
101put NM i f64 bitcast f32 u
102else
103q = int get a add 1024 i
104if ge q 128
105q = sub q 256
106end
107put NM i mul f64 sub q zero factor
108end
109end
110r = nddec 8
111if ne r 0
112ret 46
113end
114for i ulong 4
115v = nlbit get NF i
116if lt v 0
117ret 47
118end
119put b i uint v
120end
121op = add get b 0 mul get b 1 2
122if eq op 0
123ret 48
124end
125arg = add get b 2 mul get b 3 2
126note All checks precede output writes: refusal preserves the caller's proposal.
127for i ulong 16
128put p i 0
129end
130put p 0 op
131put p 1 arg
132if eq op 1
133put p 2 1
134end
135if eq op 2
136put p 2 2
137end
138put p 3 1
139put p 4 1
140put p 5 1
141put p 6 4
142put p 7 1
143put p 8 0
144put p 9 1
145ret 0
146end
147fn nlmatch p view uint 16 e view uint 16 to bool
148note Independent receiver expectation, never sourced from the numerical message.
149for i ulong 16
150if ne get p i get e i
151ret false
152end
153end
154ret true
155end