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 / qualification / security673 / game / evidence / native-v3 / solve0.attempt1.om

606 lines · 9174 bytes Raw Blame History
1note SC1-G transport only. No transition or invariant code is shared.
2global wire uchar 4096
3global pos ulong 1
4global avail ulong 1
5global digits uchar 32
6global samples ulong 101
7text nl "\n"
8text sp " "
9text tags "construct_ns=\nsolve_ns=\ncheck_ns=\nstates=\nedges=\nwinning=\nrounds=\narray_bytes=\nPASS SC1-G-v3 finite model only\nFAIL QUANTIFIER_CLOSURE\nFAIL OMITTED_DISTURBANCE_CLOSURE\nFAIL FRESHNESS_AT_RENAME\nFAIL UNCERTAIN_REFUND\nFAIL SELECTED_NOT_SAFE\nFAIL EARLY_STOP_CLOSURE\nFAIL CERTIFICATE\nPASS certified serial witnesses empty-set costs\nFAIL PAIRED_PRODUCT\ndistinct_hidden_states=\ndistinct_hidden_edges=\nsample_ns=\np50_ns=\np95_ns=\np99_ns=\nidentical_zero_states=\nidentical_zero_edges=\nWITNESS source action disturbance raw effective\nFAIL TRANSITION_CONFORMANCE\nFAIL CLOSURE\nFAIL SOURCE_INVARIANT\nFAIL DISABLED_ACTION\nFAIL EXACTNESS\nFAIL SELECTION_COST\n"
10fn label id uint to void
11p = ulong 0
12n = uint 0
13for j ulong len tags
14if eq get tags j 10
15if eq n id
16r = write 2 tags p add sub j p 1
17if ne r long add sub j p 1
18exit 90
19end
20ret
21end
22n = add n 1
23p = add j 1
24end
25end
26exit 90
27end
28fn number n ulong to void
29p = ulong 0
30while ge n 10 bound 32
31put digits p uchar add rem n 10 48
32n = div n 10
33p = add p 1
34end
35put digits p uchar add n 48
36p = add p 1
37for j ulong p
38r = write 2 digits sub sub p j 1 1
39if ne r 1
40exit 90
41end
42end
43r = write 2 nl 0 1
44if ne r 1
45exit 90
46end
47end
48fn mode to uint
49if eq argcnt 1
50ret 0
51end
52if ne argcnt 2
53exit 90
54end
55if ne argread 1 wire 0 1 1
56exit 90
57end
58m = get wire 0
59if or lt m 48 gt m 56
60exit 90
61end
62ret sub uint m 48
63end
64fn flush to void
65n = get pos 0
66if ne write 1 wire 0 n long n
67exit 90
68end
69put pos 0 0
70end
71fn sendword x uint to void
72for i ulong 4
73p = get pos 0
74put wire p uchar and shr x mul uint i 8 255
75put pos 0 add p 1
76if eq get pos 0 4096
77flush
78end
79end
80end
81fn recvword to uint
82x = uint 0
83for i ulong 4
84if eq get pos 0 get avail 0
85n = read 0 wire 0 len wire
86if le n 0
87exit 90
88end
89put avail 0 ulong n
90put pos 0 0
91end
92p = get pos 0
93x = or x shl uint get wire p mul uint i 8
94put pos 0 add p 1
95end
96ret x
97end
98fn endinput to void
99if ne get pos 0 get avail 0
100exit 90
101end
102if ne read 0 wire 0 len wire 0
103exit 90
104end
105end
106fn percentiles to void
107for i ulong 101
108label 20
109number get samples i
110end
111for i ulong 101
112for j ulong 100
113if gt get samples j get samples add j 1
114t = get samples j
115put samples j get samples add j 1
116put samples add j 1 t
117end
118end
119end
120label 21
121number get samples 50
122label 22
123number get samples 95
124label 23
125number get samples 99
126end
127note SC1-G-v3 source-fixed experiment 0; no runtime fault selector.
128fn fault to uint
129ret 0
130end
131note SC1-G-v3 synchronous greatest fixed point over monitored raw transitions.
132global moves uint 2593
133global cert uint 2593
134global chosen uint 2593
135global edges uint 420066
136global keep uchar 2593
137global next uchar 2593
138global mut uint 1
139global totals ulong 4
140fn phase s uint c uint to uint
141if eq c 0
142ret rem s 18
143end
144ret rem div s 18 18
145end
146fn replace s uint c uint p uint to uint
147old = phase s c
148if eq c 0
149ret add sub s old p
150end
151ret add sub s mul old 18 mul p 18
152end
153fn epoch s uint to uint
154ret rem div s 324 2
155end
156fn object s uint to uint
157ret rem div s 648 2
158end
159fn charge p uint to uint
160if lt p 2
161ret 0
162end
163if and ge p 12 le p 14
164ret 1
165end
166ret 2
167end
168fn invariant s uint to bool
169if ge s 2592
170ret false
171end
172a = phase s 0
173b = phase s 1
174if or eq a 17 eq b 17
175ret false
176end
177if gt add charge a charge b 3
178ret false
179end
180if or or eq a 15 eq a 16 or eq b 15 eq b 16
181ret eq rem div s 324 4 0
182end
183ret true
184end
185fn enabled s uint u uint to bool
186if not invariant s
187ret false
188end
189if ge s 1296
190ret eq u 1
191end
192if eq u 1
193ret false
194end
195if eq u 0
196ret and or eq phase s 0 0 eq phase s 0 14 or eq phase s 1 0 eq phase s 1 14
197end
198c = div sub u 2 8
199k = rem sub u 2 8
200p = phase s c
201if eq k 0
202ret and eq p 1 le add charge phase s 0 charge phase s 1 1
203end
204if eq k 1
205ret and ge p 1 le p 10
206end
207if eq k 2
208ret eq p 2
209end
210if or eq k 3 eq k 7
211if and ge p 3 le p 6
212if eq k 7
213ret eq rem div s 324 4 0
214end
215ret true
216end
217ret and eq k 7 eq p 16
218end
219if eq k 4
220ret or and ge p 7 le p 10 eq p 15
221end
222if eq k 5
223ret or eq p 11 eq p 15
224end
225ret or eq p 12 eq p 13
226end
227fn environment s uint d uint to uint
228if eq d 1
229if eq phase s 0 0
230ret add s 1
231end
232end
233if eq d 2
234if eq phase s 1 0
235ret add s 18
236end
237end
238if eq d 3
239ret add s mul sub uint 1 epoch s 324
240end
241if eq d 4
242ret add s mul sub uint 1 object s 648
243end
244ret s
245end
246fn clean p uint to uint
247if and ge p 2 le p 10
248ret 0
249end
250if eq p 11
251ret 12
252end
253ret p
254end
255fn recover s uint to uint
256if or ge phase s 0 15 ge phase s 1 15
257ret 2592
258end
259s = replace s 0 clean phase s 0
260s = replace s 1 clean phase s 1
261ret rem s 1296
262end
263fn split s uint c uint k uint d uint to uint
264p = phase s c
265if eq d 7
266ret s
267end
268if eq d 5
269ret add replace s c 0 1296
270end
271if eq p 15
272if or and eq k 4 eq d 4 and eq k 5 eq d 3
273ret 2592
274end
275if or eq d 3 eq d 4
276ret environment replace s c 0 d
277end
278if eq d 6
279ret s
280end
281ret environment replace s c 14 d
282end
283if or eq d 3 eq d 4
284ret environment replace s c 0 d
285end
286ret environment replace s c 15 d
287end
288fn client s uint c uint k uint d uint to uint
289p = phase s c
290if eq k 0
291ret replace s c 2
292end
293if eq k 1
294ret replace s c 0
295end
296if eq k 2
297p = add uint 3 add epoch s mul object s 2
298ret replace s c p
299end
300if eq k 3
301if eq d 6
302ret s
303end
304ret replace s c add p 4
305end
306if eq k 4
307tag = sub p 7
308if ne get mut 0 3
309if ne tag rem div s 324 4
310ret s
311end
312end
313ret replace s c 11
314end
315if eq k 5
316if eq d 6
317if eq get mut 0 4
318ret replace s c 17
319end
320ret s
321end
322if eq d 8
323ret replace s c 13
324end
325ret replace s c 12
326end
327if eq k 6
328if eq d 8
329ret replace s c 13
330end
331ret replace s c 14
332end
333if ne rem div s 324 4 0
334ret s
335end
336ret replace s c 16
337end
338fn step s uint u uint d uint to uint
339if not enabled s u
340ret 2592
341end
342if ge u 2
343c = div sub u 2 8
344p = phase s c
345if or eq p 15 eq p 16
346if lt s 1296
347ret split s c rem sub u 2 8 d
348end
349end
350end
351if eq d 5
352ret add rem s 1296 1296
353end
354if eq d 7
355ret s
356end
357s = environment s d
358if eq u 0
359ret s
360end
361if eq u 1
362ret recover s
363end
364ret client s div sub u 2 8 rem sub u 2 8 d
365end
366fn index s uint u uint d uint to uint
367ret add mul add mul s 18 u 9 d
368end
369fn monitored s uint u uint d uint raw uint to uint
370if or lt u 2 ge raw 2592
371ret raw
372end
373c = div sub u 2 8
374p = phase s c
375q = phase raw c
376if and eq p 11 eq q 17
377ret 2592
378end
379if and eq rem sub u 2 8 4 eq q 11
380if and ge p 7 le p 10
381now = environment s d
382if ne sub p 7 rem div now 324 4
383ret 2592
384end
385end
386end
387ret raw
388end
389fn destination s uint u uint d uint to uint
390ret monitored s u d get edges index s u d
391end
392fn construct to void
393for i uint 4
394put totals i 0
395end
396for s uint 2593
397put keep s 0
398if invariant s
399put keep s 1
400end
401m = uint 0
402for u uint 18
403if enabled s u
404m = or m shl uint 1 u
405for d uint 9
406put edges index s u d step s u d
407put totals 0 add get totals 0 1
408end
409end
410end
411put moves s m
412end
413end
414fn safe s uint u uint to bool
415if eq and get moves s shl uint 1 u 0
416ret false
417end
418for d uint 9
419if not and eq get mut 0 2 eq d 4
420if eq get keep destination s u d 0
421ret false
422end
423end
424end
425ret true
426end
427fn existsaction s uint to bool
428for u uint 18
429if safe s u
430ret true
431end
432end
433ret false
434end
435fn swapped s uint to bool
436for d uint 9
437found = false
438for u uint 18
439if ne and get moves s shl uint 1 u 0
440if ne get keep destination s u d 0
441found = true
442end
443end
444end
445if not found
446ret false
447end
448end
449ret true
450end
451fn solve to void
452changed = true
453while changed bound 2594
454changed = false
455put totals 1 add get totals 1 1
456for s uint 2593
457v = false
458if ne get keep s 0
459if eq get mut 0 1
460v = swapped s
461else
462v = existsaction s
463end
464end
465put next s 0
466if v
467put next s 1
468end
469if ne get next s get keep s
470changed = true
471end
472end
473for s uint 2593
474put keep s get next s
475end
476if eq get mut 0 6
477ret
478end
479end
480end
481fn certificate to void
482for s uint 2593
483m = uint 0
484if ne get keep s 0
485put totals 2 add get totals 2 1
486for u uint 18
487if safe s u
488m = or m shl uint 1 u
489end
490end
491if or eq get mut 0 1 eq get mut 0 6
492if eq m 0
493m = get moves s
494end
495end
496end
497put cert s m
498end
499end
500fn select s uint identity uint to uint
501if ne identity 1
502ret 18
503end
504m = get cert s
505if eq m 0
506ret 18
507end
508if eq get mut 0 5
509m = get moves s
510end
511best = uint 18
512price = uint 99
513for u uint 18
514if ne and m shl uint 1 u 0
515p = uint 2
516if lt u 2
517p = 1
518else
519k = rem sub u 2 8
520if eq k 7
521p = 0
522end
523if eq k 1
524p = 4
525end
526end
527if lt p price
528price = p
529best = u
530end
531end
532end
533ret best
534end
535fn selections to void
536for s uint 2593
537put chosen s select s 1
538end
539end
540fn output to void
541sendword 1396912455
542sendword 3
543sendword 2593
544sendword get mut 0
545for s uint 2593
546sendword get moves s
547sendword get cert s
548sendword get chosen s
549for u uint 18
550if ne and get moves s shl uint 1 u 0
551for d uint 9
552sendword get edges index s u d
553end
554end
555end
556end
557flush
558end
559fn benchmark to void
560if ne get mut 0 0
561exit 90
562end
563for i ulong 101
564start = monons
565construct
566solve
567certificate
568selections
569put samples i ulong sub monons start
570end
571percentiles
572end
573fn main to int
574put mut 0 fault
575m = mode
576if eq m 7
577benchmark
578output
579ret 0
580end
581if or ne m 0 gt get mut 0 6
582ret 90
583end
584start = monons
585construct
586label 0
587number ulong sub monons start
588start = monons
589solve
590certificate
591selections
592label 1
593number ulong sub monons start
594label 3
595number 2593
596label 4
597number get totals 0
598label 5
599number get totals 2
600label 6
601number get totals 1
602label 7
603number 1721554
604output
605ret 0
606end