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 / evidence / ECOSYSTEM663 / mutant-offset.om

379 lines · 5678 bytes Raw Blame History
1note M20 metadata-v1. Integer metadata only; no allocator or numeric execution.
2note ED: schema,dtype,rank,elements,offset,slot,generation,reserved,shape8,stride8.
3note ES: live,retired,slot,generation,dtype,elements,reserved,reserved.
4note ES is the caller-owned allocator snapshot. It is not untrusted wire input.
5global ED ulong 24
6global ES ulong 8
7
8fn emshape to int
9rank = get ED 2
10if gt rank 8
11ret -2
12end
13n = ulong 1
14for d ulong rank
15size = get ED add 8 d
16if eq size 0
17ret -3
18end
19if gt size div 1073741824 n
20ret -8
21end
22n = mul n size
23end
24if ne get ED 3 n
25ret -3
26end
27ret 0
28end
29
30fn emlive slot ulong gen ulong to int
31if gt slot 4294967295
32ret -5
33end
34if or ne get ES 0 1 ne get ES 1 0
35ret -5
36end
37if or eq gen 0 ne slot get ES 2
38ret -5
39end
40if ne gen get ES 3
41ret -5
42end
43ret 0
44end
45
46fn embounds to int
47size = get ES 5
48offset = get ED 4
49if or eq size 0 gt size 1073741824
50ret -8
51end
52if ge offset size
53ret -6
54end
55note Compare against remaining extent before multiplication, never overflow.
56room = sub size 1
57for d ulong get ED 2
58count = sub get ED add 8 d 1
59stride = get ED add 16 d
60if ne stride 0
61if gt count div room stride
62ret -6
63end
64room = sub room mul count stride
65end
66end
67ret 0
68end
69
70fn emcheck to int
71if or ne get ED 0 1 ne get ED 7 0
72ret -1
73end
74if or ne get ES 6 0 ne get ES 7 0
75ret -1
76end
77dtype = get ED 1
78if or lt dtype 1 gt dtype 3
79ret -4
80end
81status = emshape
82if ne status 0
83ret status
84end
85status = emlive get ED 5 get ED 6
86if ne status 0
87ret status
88end
89if ne dtype get ES 4
90ret -4
91end
92ret embounds
93end
94
95fn emrelease slot ulong gen ulong to int
96status = emlive slot gen
97if ne status 0
98ret status
99end
100note A maximal generation is retired, never wrapped into a valid old handle.
101if eq gen 18446744073709551615
102put ES 1 1
103else
104put ES 3 add gen 1
105end
106put ES 0 0
107ret 0
108end
109note Native checks plus independent element-by-element view bounds oracle.
110global EC ulong 1
111global Digits uchar 20
112text Pass "M20_METADATA_V1_PASS checks="
113text Fail "M20_METADATA_V1_FAIL check="
114text NL "\n"
115
116fn number n ulong to void
117if eq n 0
118put Digits 0 48
119w = write 1 Digits 0 1
120if ne w 1
121exit 90
122end
123ret
124end
125pos = ulong 20
126while gt n 0 bound 20
127pos = sub pos 1
128put Digits pos uchar add 48 rem n 10
129n = div n 10
130end
131w = write 1 Digits pos sub 20 pos
132if ne w long sub 20 pos
133exit 90
134end
135end
136
137fn check got int want int to void
138put EC 0 add get EC 0 1
139if ne got want
140w = write 1 Fail 0 len Fail
141number get EC 0
142w = write 1 NL 0 1
143if ne w 1
144exit 90
145end
146exit 1
147end
148end
149
150fn fixture to void
151for i ulong 24
152put ED i 0
153end
154for i ulong 8
155put ES i 0
156end
157put ED 0 1
158put ED 1 1
159put ED 2 2
160put ED 3 6
161put ED 5 4
162put ED 6 17
163put ED 8 2
164put ED 9 3
165put ED 16 3
166put ED 17 1
167put ES 0 1
168put ES 2 4
169put ES 3 17
170put ES 4 1
171put ES 5 6
172end
173
174fn direct to void
175fixture
176check emcheck 0
177put ED 0 2
178check emcheck -1
179fixture
180put ED 7 1
181check emcheck -1
182fixture
183put ES 6 1
184check emcheck -1
185fixture
186put ES 7 1
187check emcheck -1
188fixture
189put ED 1 0
190check emcheck -4
191put ED 1 4
192check emcheck -4
193fixture
194put ES 4 2
195check emcheck -4
196put ED 1 2
197check emcheck 0
198put ED 1 3
199put ES 4 3
200check emcheck 0
201fixture
202put ED 2 9
203check emcheck -2
204fixture
205put ED 8 0
206check emcheck -3
207fixture
208put ED 3 7
209check emcheck -3
210fixture
211put ED 8 1073741824
212check emcheck -8
213fixture
214put ED 8 18446744073709551615
215check emcheck -8
216fixture
217put ES 5 0
218check emcheck -8
219put ES 5 1073741825
220check emcheck -8
221fixture
222put ED 4 6
223check emcheck -6
224fixture
225put ED 4 18446744073709551615
226check emcheck -6
227fixture
228put ED 16 18446744073709551615
229check emcheck -6
230fixture
231put ED 8 1
232put ED 3 3
233put ED 16 18446744073709551615
234check emcheck 0
235fixture
236put ED 16 0
237check emcheck 0
238fixture
239put ED 16 1
240put ED 17 2
241check emcheck 0
242put ES 5 5
243check emcheck -6
244fixture
245put ED 2 0
246put ED 3 1
247put ED 4 5
248check emcheck 0
249put ED 4 6
250check emcheck -6
251fixture
252put ED 2 8
253put ED 3 1
254for i ulong 8
255put ED add 8 i 1
256put ED add 16 i 18446744073709551615
257end
258check emcheck 0
259fixture
260put ED 2 1
261put ED 8 1073741824
262put ED 3 1073741824
263put ED 16 0
264put ES 5 1
265check emcheck 0
266put ED 16 1
267put ES 5 1073741824
268check emcheck 0
269put ED 4 1
270check emcheck -6
271end
272
273fn lifetime to void
274fixture
275check emlive 4 17 0
276put ED 5 0
277put ES 2 0
278check emcheck 0
279put ED 5 4294967295
280put ES 2 4294967295
281check emcheck 0
282put ED 5 4294967296
283put ES 2 4294967296
284check emcheck -5
285fixture
286check emlive 5 17 -5
287check emlive 4 0 -5
288check emlive 4 16 -5
289check emrelease 4 16 -5
290check emlive 4 17 0
291check emrelease 4 17 0
292check int get ES 0 0
293check int get ES 3 18
294check emcheck -5
295check emrelease 4 17 -5
296put ES 0 1
297check emcheck -5
298put ED 6 18
299check emcheck 0
300check emlive 4 17 -5
301fixture
302put ES 1 1
303check emcheck -5
304fixture
305put ES 0 2
306check emcheck -5
307fixture
308put ES 1 2
309check emcheck -5
310fixture
311put ES 3 18446744073709551615
312put ED 6 18446744073709551615
313check emcheck 0
314check emrelease 4 18446744073709551615 0
315check int get ES 0 0
316check int get ES 1 1
317check emlive 4 18446744073709551615 -5
318put ES 0 1
319check emcheck -5
320if ne get ES 3 18446744073709551615
321check 1 0
322end
323fixture
324check emcheck 0
325end
326
327note Independent oracle visits every element; it never uses maximal extent.
328fn oracle a ulong b ulong s ulong t ulong off ulong cap ulong to int
329for i ulong a
330for j ulong b
331index = add off add mul i s mul j t
332if ge index cap
333ret -6
334end
335end
336end
337ret 0
338end
339
340fn enumerate to void
341fixture
342for ai ulong 3
343a = add ai 1
344put ED 8 a
345for bi ulong 3
346b = add bi 1
347put ED 9 b
348put ED 3 mul a b
349for s ulong 5
350put ED 16 s
351for t ulong 5
352put ED 17 t
353for off ulong 4
354put ED 4 off
355for ci ulong 16
356cap = add ci 1
357put ES 5 cap
358want = oracle a b s t off cap
359check emcheck want
360end
361end
362end
363end
364end
365end
366end
367
368fn main to int
369direct
370lifetime
371enumerate
372w = write 1 Pass 0 len Pass
373number get EC 0
374w = write 1 NL 0 1
375if ne w 1
376ret 90
377end
378ret 0
379end