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

725 lines · 10942 bytes Raw Blame History
1note Independent SC1-G-v3 enumerator and rename safety monitor.
2note Reverse-order in-place losing attractor, versus synchronous solver bitmaps.
3global fields uint 5
4global costs uint 18
5global rules uint 18
6global submit uint 2593
7global chosen uint 2593
8global alive uchar 2593
9global counts ulong 3
10global pairs ulong 4
11global variant uint 1
12global claim uint 1
13fn refuse id uint to void
14if eq id 8
15label 17
16exit 78
17end
18label add id 8
19exit add int id 70
20end
21fn witness s uint u uint d uint raw uint effect uint to void
22label 26
23number ulong s
24number ulong u
25number ulong d
26number ulong raw
27number ulong effect
28end
29fn unpack s uint to void
30put fields 0 rem s 18
31put fields 1 rem div s 18 18
32put fields 2 and div s 324 1
33put fields 3 and div s 648 1
34put fields 4 div s 1296
35end
36fn pack to uint
37n = get fields 4
38n = add mul n 2 get fields 3
39n = add mul n 2 get fields 2
40n = add mul n 18 get fields 1
41ret add mul n 18 get fields 0
42end
43fn localok s uint to bool
44if eq s 2592
45ret false
46end
47x = rem s 18
48y = rem div s 18 18
49if or eq x 17 eq y 17
50ret false
51end
52if gt add get costs x get costs y 3
53ret false
54end
55if ne rem div s 324 4 0
56if and ge x 15 le x 16
57ret false
58end
59if and ge y 15 le y 16
60ret false
61end
62end
63ret true
64end
65fn actions s uint to uint
66if not localok s
67ret 0
68end
69if ge s 1296
70ret 2
71end
72x = rem s 18
73y = rem div s 18 18
74m = shl get rules x 2
75m = or m shl get rules y 10
76if gt add get costs x get costs y 1
77m = and m not uint 1028
78end
79if ne rem div s 324 4 0
80m = and m not uint 131584
81end
82if and or eq x 0 eq x 14 or eq y 0 eq y 14
83m = or m 1
84end
85ret m
86end
87fn init to void
88for p uint 18
89put costs p 2
90end
91put costs 0 0
92put costs 1 0
93put costs 12 1
94put costs 13 1
95put costs 14 1
96put rules 1 3
97put rules 2 6
98for p uint 4
99put rules add p 3 138
100put rules add p 7 18
101end
102put rules 11 32
103put rules 12 64
104put rules 13 64
105put rules 15 48
106put rules 16 128
107for s uint 2593
108put alive s 0
109if localok s
110put alive s 1
111end
112end
113end
114fn disturb d uint to void
115if eq d 4
116put fields 3 1
117end
118if eq d 3
119put fields 2 1
120end
121if eq d 2
122if eq get fields 1 0
123put fields 1 1
124end
125end
126if eq d 1
127if eq get fields 0 0
128put fields 0 1
129end
130end
131end
132fn special c uint k uint d uint to uint
133p = get fields c
134if or eq d 7 and eq p 15 eq d 6
135ret pack
136end
137if eq d 5
138put fields c 0
139put fields 4 1
140ret pack
141end
142if or eq d 3 eq d 4
143if eq p 15
144if eq add k d 8
145ret 2592
146end
147end
148put fields c 0
149disturb d
150ret pack
151end
152if eq p 16
153put fields c 15
154else
155put fields c 14
156end
157disturb d
158ret pack
159end
160fn reconc to uint
161for c uint 2
162p = get fields c
163if ge p 15
164ret 2592
165end
166if and ge p 2 lt p 11
167put fields c 0
168end
169if eq p 11
170put fields c 12
171end
172end
173put fields 4 0
174ret pack
175end
176fn enact c uint k uint d uint to uint
177p = get fields c
178q = p
179if eq k 7
180if eq add get fields 2 get fields 3 0
181q = 16
182end
183end
184if eq k 6
185q = 14
186if eq d 8
187q = 13
188end
189end
190if eq k 5
191if ne d 6
192q = 12
193if eq d 8
194q = 13
195end
196end
197end
198if eq k 4
199t = add get fields 2 mul get fields 3 2
200if eq sub p 7 t
201q = 11
202end
203end
204if eq k 3
205if ne d 6
206q = add p 4
207end
208end
209if eq k 2
210q = add uint 3 add get fields 2 mul get fields 3 2
211end
212if eq k 1
213q = 0
214end
215if eq k 0
216q = 2
217end
218put fields c q
219ret pack
220end
221fn oracle s uint u uint d uint to uint
222if eq and actions s shl uint 1 u 0
223ret 2592
224end
225unpack s
226if ge u 2
227c = uint 0
228if ge u 10
229c = 1
230end
231p = get fields c
232if and ge p 15 le p 16
233ret special c rem sub u 2 8 d
234end
235end
236if eq d 7
237ret s
238end
239if eq d 5
240put fields 4 1
241ret pack
242end
243disturb d
244if eq u 1
245ret reconc
246end
247if eq u 0
248ret pack
249end
250ret enact div sub u 2 8 rem sub u 2 8 d
251end
252fn clientphase s uint c uint to uint
253if eq c 1
254s = div s 18
255end
256ret rem s 18
257end
258fn monitor s uint u uint d uint got uint to uint
259if or lt u 2 ge got 2592
260ret 0
261end
262c = div sub u 2 8
263p = clientphase s c
264q = clientphase got c
265if and eq p 11 eq q 17
266ret 4
267end
268if ne rem sub u 2 8 4
269ret 0
270end
271if or lt p 7 gt p 10
272ret 0
273end
274if ne q 11
275ret 0
276end
277e = and div s 324 1
278v = and div s 648 1
279if eq d 3
280e = 1
281end
282if eq d 4
283v = 1
284end
285if ne sub p 7 add e mul v 2
286ret 3
287end
288ret 0
289end
290fn readstate s uint to void
291m = recvword
292if ne m actions s
293refuse 7
294end
295put submit s recvword
296put chosen s recvword
297for u uint 18
298if ne and m shl uint 1 u 0
299for d uint 9
300got = recvword
301if ge got 2593
302refuse 7
303end
304bad = monitor s u d got
305if ne bad 0
306witness s u d got 2592
307refuse bad
308end
309want = oracle s u d
310put counts 0 add get counts 0 1
311if ne got want
312witness s u d got want
313label 27
314exit 79
315end
316end
317end
318end
319end
320fn allwithin s uint u uint nd uint to bool
321if or eq nd 0 gt nd 9
322ret false
323end
324if eq and actions s shl uint 1 u 0
325ret false
326end
327d = nd
328while gt d 0 bound 9
329d = sub d 1
330y = oracle s u d
331if eq get alive y 0
332ret false
333end
334end
335ret true
336end
337fn allsafe s uint u uint to bool
338ret allwithin s u 9
339end
340fn actionmask s uint to uint
341m = uint 0
342u = uint 18
343while gt u 0 bound 18
344u = sub u 1
345if allsafe s u
346m = or m shl uint 1 u
347end
348end
349ret m
350end
351fn attractor to void
352change = true
353while change bound 2594
354change = false
355put counts 1 add get counts 1 1
356s = uint 2593
357while gt s 0 bound 2593
358s = sub s 1
359if ne get alive s 0
360if eq actionmask s 0
361put alive s 0
362change = true
363end
364end
365end
366end
367end
368fn closurefail s uint u uint d uint y uint to void
369witness s u d y y
370label 28
371note Untrusted experiment label annotates an observed closure violation, not its inferred cause.
372v = get claim 0
373if or eq v 1 or eq v 2 eq v 6
374refuse v
375end
376exit 80
377end
378fn closeone s uint to void
379m = get submit s
380if eq m 0
381ret
382end
383if not localok s
384witness s 18 9 s s
385label 29
386exit 81
387end
388if ne and m not actions s 0
389witness s 18 9 m actions s
390label 30
391exit 82
392end
393for u uint 18
394if ne and m shl uint 1 u 0
395for d uint 9
396y = oracle s u d
397if eq get submit y 0
398closurefail s u d y
399end
400end
401end
402end
403end
404fn validate to void
405if eq get submit fixture 0 0
406refuse 7
407end
408for s uint 2593
409closeone s
410end
411for s uint 2593
412m = uint 0
413if ne get alive s 0
414m = actionmask s
415put counts 2 add get counts 2 1
416end
417if ne get submit s m
418witness s 18 9 get submit s m
419label 31
420exit 83
421end
422end
423end
424fn require b bool to void
425if not b
426refuse 7
427end
428end
429fn rank s uint identity uint to uint
430if ne identity 1
431ret 18
432end
433best = uint 18
434price = uint 99
435for u uint 18
436if ne and get submit s shl uint 1 u 0
437p = uint 2
438if lt u 2
439p = 1
440else
441k = rem sub u 2 8
442if eq k 7
443p = 0
444end
445if eq k 1
446p = 4
447end
448end
449if lt p price
450price = p
451best = u
452end
453end
454end
455ret best
456end
457fn selections to void
458for s uint 2593
459u = get chosen s
460if eq get submit s 0
461require eq u 18
462else
463if ge u 18
464witness s u 9 2592 2592
465refuse 5
466end
467if eq and get submit s shl uint 1 u 0
468witness s u 9 u get submit s
469refuse 5
470end
471if ne u rank s 1
472witness s u 9 u rank s 1
473label 32
474exit 84
475end
476if ge u 2
477require ne rem sub u 2 8 7
478end
479require eq rank s 0 18
480require eq rank s 2 18
481end
482end
483end
484fn serial s uint u uint d uint to uint
485require ne get submit s 0
486require ne and get submit s shl uint 1 u 0
487y = oracle s u d
488require ne get submit y 0
489ret y
490end
491fn observation secret uint protect bool to uint
492used = secret
493if protect
494used = 2
495end
496note Public envelope size2 within public capacity3 and fixed release identity1.
497ret add sub uint 3 used 16
498end
499fn witnesses to void
500require localok fixture 1
501require eq get alive fixture 1 0
502require eq get alive fixture 2 0
503require eq oracle fixture 1 6 4 fixture 8
504require eq oracle fixture 1 7 3 fixture 8
505require eq oracle fixture 3 6 0 fixture 3
506require eq oracle fixture 4 7 6 fixture 4
507require eq and actions fixture 5 shl uint 1 10 0
508require ne and actions fixture 6 shl uint 1 10 0
509note Every step uses the submitted safe certificate, not only the transition relation.
510s = serial fixture 0 0 1
511s = serial s 2 2
512require eq s fixture 5
513s = serial s 4 0
514s = serial s 5 0
515s = serial s 6 0
516s = serial s 7 0
517s = serial s 8 0
518require eq s fixture 6
519s = serial s 10 0
520s = serial s 12 0
521s = serial s 13 0
522s = serial s 14 0
523s = serial s 15 0
524s = serial s 16 0
525require eq s fixture 7
526require eq add get costs rem s 18 get costs rem div s 18 18 2
527require eq actions fixture 8 0
528require eq oracle fixture 8 0 0 fixture 8
529require eq oracle fixture 0 0 0 fixture 0
530require not allwithin 0 0 0
531require not allwithin 0 0 10
532require eq observation 1 true observation 2 true
533require ne observation 1 false observation 2 false
534label 16
535end
536fn envelope s uint to bool
537if ge s 2592
538ret false
539end
540ret or eq get costs rem s 18 2 eq get costs rem div s 18 18 2
541end
542fn hidden s uint h uint to bool
543if envelope s
544ret or eq h 1 eq h 2
545end
546ret eq h 0
547end
548fn pairmask s uint h uint to uint
549if not hidden s h
550refuse 8
551end
552m = actions s
553note Negative baseline incorrectly uses physical hidden occupancy instead of full reservation.
554if and eq get variant 0 8 eq h 1
555if eq rem s 18 1
556m = or m 4
557end
558if eq rem div s 18 18 1
559m = or m 1024
560end
561end
562ret m
563end
564fn pairnext s uint u uint d uint h uint to uint
565if not hidden s h
566refuse 8
567end
568note Actual game relation, independently compared to every submitted solver edge.
569ret oracle s u d
570end
571fn publicob s uint h uint to uint
572if not hidden s h
573refuse 8
574end
575if eq s 2592
576ret 2592
577end
578q = add get costs rem s 18 get costs rem div s 18 18
579if gt q 3
580ret 2592
581end
582note Available public capacity plus whole-service ready/recovery class.
583ret add sub uint 3 q mul div s 1296 4
584end
585fn newlabel s uint old uint to uint
586if envelope s
587if eq old 0
588ret 1
589end
590ret old
591end
592ret 0
593end
594fn pairselect s uint h uint to uint
595m = pairmask s h
596if ne and get submit s not m 0
597witness s 18 9 get submit s m
598refuse 8
599end
600ret get chosen s
601end
602fn pairrun s uint h1 uint h2 uint to void
603m = pairmask s h1
604if ne m pairmask s h2
605witness s 18 9 m pairmask s h2
606refuse 8
607end
608if ne pairselect s h1 pairselect s h2
609refuse 8
610end
611m = get submit s
612if ne publicob s h1 publicob s h2
613refuse 8
614end
615for u uint 18
616if ne and m shl uint 1 u 0
617for d uint 9
618x = pairnext s u d h1
619y = pairnext s u d h2
620if ne x y
621refuse 8
622end
623if eq get submit x 0
624refuse 8
625end
626if ne publicob x newlabel x h1 publicob y newlabel y h2
627refuse 8
628end
629if eq h1 h2
630put pairs 3 add get pairs 3 1
631else
632put pairs 1 add get pairs 1 1
633end
634end
635end
636end
637end
638fn product to void
639for s uint 2593
640if localok s
641if envelope s
642put pairs 0 add get pairs 0 1
643pairrun s 1 2
644else
645put pairs 2 add get pairs 2 1
646pairrun s 0 0
647end
648end
649end
650end
651fn checkonce to void
652for i ulong 3
653put counts i 0
654end
655for i ulong 4
656put pairs i 0
657end
658init
659if ne recvword 1396912455
660refuse 7
661end
662if ne recvword 3
663refuse 7
664end
665if ne recvword 2593
666refuse 7
667end
668put claim 0 recvword
669if gt get claim 0 6
670refuse 7
671end
672for s uint 2593
673readstate s
674end
675endinput
676attractor
677validate
678selections
679product
680end
681fn main to int
682m = mode
683if and ne m 0 ne m 7
684ret 90
685end
686put variant 0 fault
687start = monons
688checkonce
689label 2
690number ulong sub monons start
691witnesses
692label 3
693number 2593
694label 4
695number get counts 0
696label 5
697number get counts 2
698label 6
699number get counts 1
700label 7
701number 28517
702label 18
703number get pairs 0
704label 19
705number get pairs 1
706label 24
707number get pairs 2
708label 25
709number get pairs 3
710if eq m 7
711for i ulong 101
712if ne fseek 0 0 0 0
713ret 90
714end
715put pos 0 0
716put avail 0 0
717start = monons
718checkonce
719put samples i ulong sub monons start
720end
721percentiles
722end
723label 8
724ret 0
725end