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

476 lines · 6573 bytes Raw Blame History
1note SC1-G-v3 synchronous greatest fixed point over monitored raw transitions.
2global moves uint 2593
3global cert uint 2593
4global chosen uint 2593
5global edges uint 420066
6global keep uchar 2593
7global next uchar 2593
8global mut uint 1
9global totals ulong 4
10fn phase s uint c uint to uint
11if eq c 0
12ret rem s 18
13end
14ret rem div s 18 18
15end
16fn replace s uint c uint p uint to uint
17old = phase s c
18if eq c 0
19ret add sub s old p
20end
21ret add sub s mul old 18 mul p 18
22end
23fn epoch s uint to uint
24ret rem div s 324 2
25end
26fn object s uint to uint
27ret rem div s 648 2
28end
29fn charge p uint to uint
30if lt p 2
31ret 0
32end
33if and ge p 12 le p 14
34ret 1
35end
36ret 2
37end
38fn invariant s uint to bool
39if ge s 2592
40ret false
41end
42a = phase s 0
43b = phase s 1
44if or eq a 17 eq b 17
45ret false
46end
47if gt add charge a charge b 3
48ret false
49end
50if or or eq a 15 eq a 16 or eq b 15 eq b 16
51ret eq rem div s 324 4 0
52end
53ret true
54end
55fn enabled s uint u uint to bool
56if not invariant s
57ret false
58end
59if ge s 1296
60ret eq u 1
61end
62if eq u 1
63ret false
64end
65if eq u 0
66ret and or eq phase s 0 0 eq phase s 0 14 or eq phase s 1 0 eq phase s 1 14
67end
68c = div sub u 2 8
69k = rem sub u 2 8
70p = phase s c
71if eq k 0
72ret and eq p 1 le add charge phase s 0 charge phase s 1 1
73end
74if eq k 1
75ret and ge p 1 le p 10
76end
77if eq k 2
78ret eq p 2
79end
80if or eq k 3 eq k 7
81if and ge p 3 le p 6
82if eq k 7
83ret eq rem div s 324 4 0
84end
85ret true
86end
87ret and eq k 7 eq p 16
88end
89if eq k 4
90ret or and ge p 7 le p 10 eq p 15
91end
92if eq k 5
93ret or eq p 11 eq p 15
94end
95ret or eq p 12 eq p 13
96end
97fn environment s uint d uint to uint
98if eq d 1
99if eq phase s 0 0
100ret add s 1
101end
102end
103if eq d 2
104if eq phase s 1 0
105ret add s 18
106end
107end
108if eq d 3
109ret add s mul sub uint 1 epoch s 324
110end
111if eq d 4
112ret add s mul sub uint 1 object s 648
113end
114ret s
115end
116fn clean p uint to uint
117if and ge p 2 le p 10
118ret 0
119end
120if eq p 11
121ret 12
122end
123ret p
124end
125fn recover s uint to uint
126if or ge phase s 0 15 ge phase s 1 15
127ret 2592
128end
129s = replace s 0 clean phase s 0
130s = replace s 1 clean phase s 1
131ret rem s 1296
132end
133fn split s uint c uint k uint d uint to uint
134p = phase s c
135if eq d 7
136ret s
137end
138if eq d 5
139ret add replace s c 0 1296
140end
141if eq p 15
142if or and eq k 4 eq d 4 and eq k 5 eq d 3
143ret 2592
144end
145if or eq d 3 eq d 4
146ret environment replace s c 0 d
147end
148if eq d 6
149ret s
150end
151ret environment replace s c 14 d
152end
153if or eq d 3 eq d 4
154ret environment replace s c 0 d
155end
156ret environment replace s c 15 d
157end
158fn client s uint c uint k uint d uint to uint
159p = phase s c
160if eq k 0
161ret replace s c 2
162end
163if eq k 1
164ret replace s c 0
165end
166if eq k 2
167p = add uint 3 add epoch s mul object s 2
168ret replace s c p
169end
170if eq k 3
171if eq d 6
172ret s
173end
174ret replace s c add p 4
175end
176if eq k 4
177tag = sub p 7
178if ne get mut 0 3
179if ne tag rem div s 324 4
180ret s
181end
182end
183ret replace s c 11
184end
185if eq k 5
186if eq d 6
187if eq get mut 0 4
188ret replace s c 17
189end
190ret s
191end
192if eq d 8
193ret replace s c 13
194end
195ret replace s c 12
196end
197if eq k 6
198if eq d 8
199ret replace s c 13
200end
201ret replace s c 14
202end
203if ne rem div s 324 4 0
204ret s
205end
206ret replace s c 16
207end
208fn step s uint u uint d uint to uint
209if not enabled s u
210ret 2592
211end
212if ge u 2
213c = div sub u 2 8
214p = phase s c
215if or eq p 15 eq p 16
216if lt s 1296
217ret split s c rem sub u 2 8 d
218end
219end
220end
221if eq d 5
222ret add rem s 1296 1296
223end
224if eq d 7
225ret s
226end
227s = environment s d
228if eq u 0
229ret s
230end
231if eq u 1
232ret recover s
233end
234ret client s div sub u 2 8 rem sub u 2 8 d
235end
236fn index s uint u uint d uint to uint
237ret add mul add mul s 18 u 9 d
238end
239fn monitored s uint u uint d uint raw uint to uint
240if or lt u 2 ge raw 2592
241ret raw
242end
243c = div sub u 2 8
244p = phase s c
245q = phase raw c
246if and eq p 11 eq q 17
247ret 2592
248end
249if and eq rem sub u 2 8 4 eq q 11
250if and ge p 7 le p 10
251now = environment s d
252if ne sub p 7 rem div now 324 4
253ret 2592
254end
255end
256end
257ret raw
258end
259fn destination s uint u uint d uint to uint
260ret monitored s u d get edges index s u d
261end
262fn construct to void
263for i uint 4
264put totals i 0
265end
266for s uint 2593
267put keep s 0
268if invariant s
269put keep s 1
270end
271m = uint 0
272for u uint 18
273if enabled s u
274m = or m shl uint 1 u
275for d uint 9
276put edges index s u d step s u d
277put totals 0 add get totals 0 1
278end
279end
280end
281put moves s m
282end
283end
284fn safe s uint u uint to bool
285if eq and get moves s shl uint 1 u 0
286ret false
287end
288for d uint 9
289if not and eq get mut 0 2 eq d 4
290if eq get keep destination s u d 0
291ret false
292end
293end
294end
295ret true
296end
297fn existsaction s uint to bool
298for u uint 18
299if safe s u
300ret true
301end
302end
303ret false
304end
305fn swapped s uint to bool
306for d uint 9
307found = false
308for u uint 18
309if ne and get moves s shl uint 1 u 0
310if ne get keep destination s u d 0
311found = true
312end
313end
314end
315if not found
316ret false
317end
318end
319ret true
320end
321fn solve to void
322changed = true
323while changed bound 2594
324changed = false
325put totals 1 add get totals 1 1
326for s uint 2593
327v = false
328if ne get keep s 0
329if eq get mut 0 1
330v = swapped s
331else
332v = existsaction s
333end
334end
335put next s 0
336if v
337put next s 1
338end
339if ne get next s get keep s
340changed = true
341end
342end
343for s uint 2593
344put keep s get next s
345end
346if eq get mut 0 6
347ret
348end
349end
350end
351fn certificate to void
352for s uint 2593
353m = uint 0
354if ne get keep s 0
355put totals 2 add get totals 2 1
356for u uint 18
357if safe s u
358m = or m shl uint 1 u
359end
360end
361if or eq get mut 0 1 eq get mut 0 6
362if eq m 0
363m = get moves s
364end
365end
366end
367put cert s m
368end
369end
370fn select s uint identity uint to uint
371if ne identity 1
372ret 18
373end
374m = get cert s
375if eq m 0
376ret 18
377end
378if eq get mut 0 5
379m = get moves s
380end
381best = uint 18
382price = uint 99
383for u uint 18
384if ne and m shl uint 1 u 0
385p = uint 2
386if lt u 2
387p = 1
388else
389k = rem sub u 2 8
390if eq k 7
391p = 0
392end
393if eq k 1
394p = 4
395end
396end
397if lt p price
398price = p
399best = u
400end
401end
402end
403ret best
404end
405fn selections to void
406for s uint 2593
407put chosen s select s 1
408end
409end
410fn output to void
411sendword 1396912455
412sendword 3
413sendword 2593
414sendword get mut 0
415for s uint 2593
416sendword get moves s
417sendword get cert s
418sendword get chosen s
419for u uint 18
420if ne and get moves s shl uint 1 u 0
421for d uint 9
422sendword get edges index s u d
423end
424end
425end
426end
427flush
428end
429fn benchmark to void
430if ne get mut 0 0
431exit 90
432end
433for i ulong 101
434start = monons
435construct
436solve
437certificate
438selections
439put samples i ulong sub monons start
440end
441percentiles
442end
443fn main to int
444put mut 0 fault
445m = mode
446if eq m 7
447benchmark
448output
449ret 0
450end
451if or ne m 0 gt get mut 0 6
452ret 90
453end
454start = monons
455construct
456label 0
457number ulong sub monons start
458start = monons
459solve
460certificate
461selections
462label 1
463number ulong sub monons start
464label 3
465number 2593
466label 4
467number get totals 0
468label 5
469number get totals 2
470label 6
471number get totals 1
472label 7
473number 1721554
474output
475ret 0
476end