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 / core / rsi / tests / reuse-eval / gen-final.om

937 lines · 14066 bytes Raw Blame History
1note units: sha256 ref
2note needs: gen
3note gen-final: DEV and FINAL (a fixed test seed) are exactly the composition of contract 7.2 and
4note clarification K8. Generates TRAIN, TRAINP, DEV, FINAL into argv[1]; replays every request
5note through ref.om and checks: index (magic, version, split id, 24 groups, 192 sessions, request and
6note QUERY counts, group counts, holdout digest = SHA-256 of the .req files in group order); every
7note .exp record (status 0, q, r0, r1, op, ordinal, cold flag); the sessions file (ordinal, group,
8note family, n class, n, shape id, program digest, counts, first request index); 4 sessions per
9note family x type x n with n in {64, 512, 4096}; the request pattern of every type; novelty classes
10note (recall = a TRAIN program, transfer = a TRAIN shape with a program not in TRAIN, novel = a shape
11note in neither TRAIN nor TRAINP, FSM recall / new) with their frozen counts; type A: AGG f MIN or
12note MAX and each DEL removes the first index holding the current extreme, FSM every symbol a
13note permutation and every SET at index 0 changes q_t for every t >= 1 (no reconvergence);
14note type P: each PROGRAM keeps the shape (FSM S and A) and changes the program.
15note Exit 0 pass; 1 args; 2 a gen run failed; 3 file; codes 20..69 name the failed check.
16text tgnull "/dev/null"
17text tgs1 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
18global TGB uchar 16777216
19global TGC uchar 16777216
20global TGP uchar 4096
21global TGK uchar 4096
22global TGA uchar 4096
23global TGS uchar 4096
24global TGT ulong 16
25global TGST uchar 4
26global TGIX ulong 128
27global TGSS ulong 3840
28global TGTR ulong 15360
29global TGTS ulong 240
30global TGPS ulong 240
31global TGCU ulong 32
32global TGOP ulong 256
33global TGOLD ulong 64
34global TGQ ulong 4097
35global TGCN ulong 64
36global TGNV ulong 384
37
38note TGT: 0 scratch length, 1 gen path length, 2 path length, 3 packet position, 4 record count,
39note 5 directory path length, 6 TGB length, 7 TGC length, 8 TRAIN rows, 9 TRAINP rows
40note TGCU: 0 open session (1), 1 session requests, 2 session QUERYs, 3 cold pending, 4 type,
41note 5 family, 6 novelty, 7 ordinal, 8 first failure, 9 requests, 10 QUERYs, 11 slot in group,
42note 12 group, 13 n class
43
44fn tgpput v ulong n ulong to void
45l = get TGT 2
46x = v
47for i ulong n
48put TGP add l i uchar and x 255
49x = shr x 8
50end
51put TGT 2 add l n
52end
53
54fn tgdir c ulong to void
55l = get TGT 0
56for i ulong l
57put TGP i get TGS i
58end
59put TGT 2 l
60tgpput add 47 mul c 256 2
61put TGT 5 get TGT 2
62end
63
64fn tgfile v ulong n ulong to void
65put TGT 2 get TGT 5
66tgpput 47 1
67tgpput v n
68end
69
70fn tggfile g ulong ext ulong to void
71put TGT 2 get TGT 5
72tgpput 26415 2
73tgpput add 48 div g 10 1
74tgpput add 48 rem g 10 1
75if eq ext 0
76tgpput 1902473774 4
77else
78tgpput 1886938414 4
79end
80end
81
82fn tgkhdr n ulong to ulong
83p = get TGT 3
84put TGK p uchar and n 255
85put TGK add p 1 uchar shr n 8
86put TGT 3 add p add n 2
87put TGT 4 add get TGT 4 1
88ret add p 2
89end
90
91fn tgkgen to void
92n = get TGT 1
93p = tgkhdr n
94for i ulong n
95put TGK add p i get TGA i
96end
97end
98
99fn tgkval v ulong n ulong to void
100p = tgkhdr n
101x = v
102for i ulong n
103put TGK add p i uchar and x 255
104x = shr x 8
105end
106end
107
108fn tgkpath to void
109n = get TGT 2
110p = tgkhdr n
111for i ulong n
112put TGK add p i get TGP i
113end
114end
115
116fn tgkseed to void
117p = tgkhdr 64
118for i ulong 64
119put TGK add p i get tgs1 i
120end
121end
122
123fn tgexec to ulong
124put TGK 0 uchar get TGT 4
125put TGK 1 0
126pid = fork
127if lt pid 0
128ret 256
129end
130if eq pid 0
131fd = fopen tgnull 0 len tgnull 1 0
132if ge fd 0
133d = dupfd int fd 1 0
134end
135r = execprog TGK 0 get TGT 3
136exit 97
137end
138w = waitpid int pid TGST 0 4 0
139if or ne w pid ne get TGST 0 0
140ret 256
141end
142ret ulong get TGST 1
143end
144
145fn tggen v ulong n ulong c ulong w ulong to ulong
146put TGT 3 2
147put TGT 4 0
148tgkgen
149tgkval v n
150tgdir c
151tgkpath
152if ne w 0
153tgkseed
154end
155ret tgexec
156end
157
158fn tgreadb to ulong
159fd = fopen TGP 0 get TGT 2 0 0
160if lt fd 0
161ret 0
162end
163n = read int fd TGB 0 len TGB
164x = fclose int fd
165if lt n 0
166ret 0
167end
168ret ulong n
169end
170
171fn tgreadc to ulong
172fd = fopen TGP 0 get TGT 2 0 0
173if lt fd 0
174ret 0
175end
176n = read int fd TGC 0 len TGC
177x = fclose int fd
178if lt n 0
179ret 0
180end
181ret ulong n
182end
183
184fn tgwb i ulong to ulong
185v = ulong 0
186b = mul i 8
187for j ulong 8
188v = or v shl ulong get TGB add b j mul j 8
189end
190ret v
191end
192
193fn tgwc i ulong to ulong
194v = ulong 0
195b = mul i 8
196for j ulong 8
197v = or v shl ulong get TGC add b j mul j 8
198end
199ret v
200end
201
202fn tgerr code ulong to void
203if eq get TGCU 8 0
204put TGCU 8 code
205end
206end
207
208note ---- TRAIN and TRAINP tables ----
209
210note the BEGIN program at word w of TGB as TRAIN row r (which 1) or TRAINP shape r (which 5)
211fn tgtrow w ulong r ulong which ulong to void
212for j ulong 64
213put RFP j tgwb add add w 2 j
214end
215if eq which 1
216for i ulong 64
217put TGTR add mul r 64 i get RFP i
218end
219put TGTS r rfshape
220else
221put TGPS r rfshape
222end
223end
224
225note BEGIN programs of directory c into TGTR / TGTS (which 1) or their shapes into TGPS (which 5)
226fn tgtrain c ulong which ulong to void
227rows = ulong 0
228for g ulong 30
229tgdir c
230tggfile g 0
231nw = div tgreadb 8
232w = ulong 0
233while lt w nw bound 99999
234op = tgwb w
235p = tgwb add w 1
236if eq op 1
237tgtrow w rows which
238rows = add rows 1
239end
240w = add w add p 2
241end
242end
243if eq which 1
244put TGT 8 rows
245else
246put TGT 9 rows
247end
248end
249
250fn tgrowis r ulong to bool
251for j ulong 64
252if ne get RFP j get TGTR add mul r 64 j
253ret false
254end
255end
256ret true
257end
258
259note RFP equals a TRAIN session program
260fn tgintr to bool
261for r ulong get TGT 8
262if tgrowis r
263ret true
264end
265end
266ret false
267end
268
269fn tgshtr sh ulong to bool
270for r ulong get TGT 8
271fam = get TGTR add mul r 64 1
272if and eq fam 1 eq get TGTS r sh
273ret true
274end
275end
276ret false
277end
278
279fn tgshtp sh ulong to bool
280for r ulong get TGT 9
281if eq get TGPS r sh
282ret true
283end
284end
285ret false
286end
287
288note ---- per-session checks ----
289
290fn tgrec i ulong to ulong
291ret get TGSS add mul get TGCU 7 16 i
292end
293
294note the op at position j (1-based after BEGIN) of a session of type t, family f; 0 = past the end
295fn tgpat t ulong f ulong j ulong to ulong
296if eq t 1
297if le j 32
298ret 2
299end
300ret 0
301end
302if eq t 7
303if gt j 20
304ret 0
305end
306if eq rem j 5 4
307ret 8
308end
309ret 2
310end
311if and eq t 6 eq f 1
312if gt j 192
313ret 0
314end
315r = rem j 3
316if eq r 1
317ret 5
318end
319if eq r 2
320ret 4
321end
322ret 2
323end
324lim = ulong 128
325if eq t 3
326lim = 16
327end
328if gt j lim
329ret 0
330end
331if eq rem j 2 0
332ret 2
333end
334if eq t 3
335ret 7
336end
337if eq t 4
338ret 6
339end
340if eq t 5
341if eq rem div sub j 1 2 2 0
342ret 5
343end
344ret 4
345end
346ret 3
347end
348
349fn tgendsess to void
350if eq get TGCU 0 0
351ret
352end
353put TGCU 0 0
354nr = get TGCU 1
355if or ne tgrec 12 nr ne tgrec 13 get TGCU 2
356tgerr 20
357end
358t = get TGCU 4
359f = get TGCU 5
360if ne get TGOP 0 1
361tgerr 21
362end
363for j ulong 255
364want = tgpat t f add j 1
365got = ulong 0
366if lt add j 1 nr
367got = get TGOP add j 1
368end
369if ne want got
370tgerr 21
371end
372end
373end
374
375fn tgnewsess k ulong to void
376tgendsess
377ord = add mul get TGCU 12 8 get TGCU 11
378put TGCU 11 add get TGCU 11 1
379put TGCU 7 ord
380put TGCU 0 1
381put TGCU 1 0
382put TGCU 2 0
383if ge ord 192
384tgerr 22
385put TGCU 7 0
386ret
387end
388if or ne tgrec 0 ord ne tgrec 1 get TGCU 12
389tgerr 22
390end
391if or ne tgrec 14 k ne tgrec 15 0
392tgerr 22
393end
394put TGCU 4 tgrec 3
395put TGCU 5 tgrec 2
396put TGCU 6 tgrec 4
397end
398
399note every symbol's transition of RFP is a permutation of the states
400fn tgperm to bool
401s = get RFP 2
402a = get RFP 3
403for x ulong a
404seen = ulong 0
405for st ulong s
406t = rfdelta st x
407b = shl ulong 1 t
408if ne and seen b 0
409ret false
410end
411seen = or seen b
412end
413end
414ret true
415end
416
417fn tgnovchk nov ulong t ulong sh ulong to void
418if eq nov 1
419if not tgintr
420tgerr 30
421end
422end
423if eq nov 2
424if or not tgshtr sh tgintr
425tgerr 31
426end
427end
428if eq nov 3
429if or tgshtr sh tgshtp sh
430tgerr 32
431end
432end
433if eq nov 4
434if not tgintr
435tgerr 33
436end
437end
438if eq nov 5
439if tgintr
440tgerr 34
441end
442end
443f = get RFP 1
444if eq f 1
445if or lt nov 1 gt nov 3
446tgerr 35
447end
448if and eq t 8 ne nov 3
449tgerr 35
450end
451if eq t 6
452if and ne get RFP 3 3 ne get RFP 3 4
453tgerr 36
454end
455end
456else
457if or lt nov 4 gt nov 5
458tgerr 35
459end
460if and eq t 8 ne nov 5
461tgerr 35
462end
463if eq t 6
464if not tgperm
465tgerr 37
466end
467end
468end
469end
470
471fn tgbegpost to void
472n = get RFN 0
473if or ne tgrec 2 get RFP 1 ne tgrec 6 n
474tgerr 23
475end
476nc = tgrec 5
477if gt nc 2
478tgerr 24
479ret
480end
481want = ulong 64
482if eq nc 1
483want = 512
484end
485if eq nc 2
486want = 4096
487end
488if ne n want
489tgerr 24
490end
491sh = rfshape
492if ne tgrec 7 sh
493tgerr 25
494end
495rfpdig
496for j ulong 4
497if ne tgrec add 8 j get RFPD j
498tgerr 26
499end
500end
501t = get TGCU 4
502if or lt t 1 gt t 8
503tgerr 27
504ret
505end
506f = get RFP 1
507nov = get TGCU 6
508tgnovchk nov t sh
509c = add mul sub f 1 24 add mul sub t 1 3 nc
510put TGCN c add get TGCN c 1
511v = add mul c 6 nov
512put TGNV v add get TGNV v 1
513end
514
515fn tgtraj to void
516q = get RFP 4
517put TGQ 0 q
518n = get RFN 0
519for t ulong n
520q = rfdelta q get RFX t
521put TGQ add t 1 q
522end
523end
524
525fn tgdiverge to bool
526q = get RFP 4
527n = get RFN 0
528for t ulong n
529q = rfdelta q get RFX t
530if eq q get TGQ add t 1
531ret false
532end
533end
534ret true
535end
536
537fn tgextr i ulong to bool
538rffull
539ex = get RFR 0
540if ge i get RFN 0
541ret false
542end
543for j ulong i
544if eq rflane get RFX j ex
545ret false
546end
547end
548ret eq rflane get RFX i ex
549end
550
551fn tgpre op ulong to void
552t = get TGCU 4
553f = get TGCU 5
554if and eq t 6 eq op 5
555if eq f 1
556if not tgextr get RFRQ 2
557tgerr 40
558end
559end
560end
561if and eq t 6 eq op 3
562if eq f 2
563if ne get RFRQ 2 0
564tgerr 41
565end
566tgtraj
567end
568end
569if eq op 7
570if ne get RFRQ 2 1024
571tgerr 42
572end
573m = get RFRQ 2
574for i ulong m
575if ne get RFRQ add 3 mul i 3 3
576tgerr 42
577end
578end
579end
580if eq op 8
581for j ulong 64
582put TGOLD j get RFP j
583end
584end
585end
586
587fn tgpost op ulong to void
588t = get TGCU 4
589if eq op 1
590tgbegpost
591end
592if and eq t 6 eq op 3
593if eq get TGCU 5 2
594if not tgdiverge
595tgerr 43
596end
597end
598end
599if eq op 8
600same = true
601for j ulong 64
602if ne get TGOLD j get RFP j
603same = false
604end
605end
606if same
607tgerr 44
608end
609if eq get RFP 1 1
610if ne get RFP 1 get TGOLD 1
611tgerr 45
612end
613for x ulong 17
614if or lt x 6 eq rem x 2 1
615if ne get RFP x get TGOLD x
616tgerr 45
617end
618end
619end
620else
621if ne get TGOLD 1 2
622tgerr 45
623end
624if ne get RFP 2 get TGOLD 2
625tgerr 45
626end
627if ne get RFP 3 get TGOLD 3
628tgerr 45
629end
630end
631end
632end
633
634note the expected record k against the reference's response
635fn tgexpchk k ulong op ulong st ulong to void
636b = mul k 8
637if ne st 0
638tgerr 50
639end
640if or ne tgwc b 0 ne tgwc add b 1 get RFRS 1
641tgerr 51
642end
643if or ne tgwc add b 2 get RFRS 2 ne tgwc add b 3 get RFRS 3
644tgerr 52
645end
646if or ne tgwc add b 4 op ne tgwc add b 5 get TGCU 7
647tgerr 53
648end
649cold = ulong 0
650if eq op 2
651if eq get TGCU 3 1
652cold = 1
653end
654put TGCU 3 0
655put TGCU 2 add get TGCU 2 1
656put TGCU 10 add get TGCU 10 1
657end
658if or eq op 1 eq op 8
659put TGCU 3 1
660end
661if or ne tgwc add b 6 cold ne tgwc add b 7 0
662tgerr 54
663end
664end
665
666fn tgstep w ulong k ulong to ulong
667op = tgwb w
668p = tgwb add w 1
669if gt p 7234
670tgerr 55
671ret 18446744073709551615
672end
673for j ulong add p 2
674put RFRQ j tgwb add w j
675end
676if eq op 1
677tgnewsess k
678end
679tgpre op
680st = ulong rfreq
681tgpost op
682tgexpchk k op st
683r = get TGCU 1
684if lt r 256
685put TGOP r op
686end
687put TGCU 1 add r 1
688put TGCU 9 add get TGCU 9 1
689ret add w add p 2
690end
691
692fn tgabs nb ulong to void
693off = ulong 0
694while lt off nb bound 999
695k = sub nb off
696if gt k 65536
697k = 65536
698end
699for i ulong k
700put RFHB i get TGB add off i
701end
702rfhabs 0 k
703off = add off k
704end
705end
706
707fn tggroup c ulong g ulong to void
708tgdir c
709tggfile g 0
710nb = tgreadb
711tgdir c
712tggfile g 1
713ne8 = tgreadc
714tgabs nb
715nw = div nb 8
716put TGCU 12 g
717put TGCU 11 0
718rfreset
719w = ulong 0
720k = ulong 0
721while lt w nw bound 99999
722w = tgstep w k
723k = add k 1
724end
725tgendsess
726if ne w nw
727tgerr 56
728end
729if ne mul k 64 ne8
730tgerr 56
731end
732if ne get TGCU 11 8
733tgerr 57
734end
735gc = get TGIX add 16 g
736if ne k gc
737tgerr 57
738end
739end
740
741note index and sessions of directory c into TGIX / TGSS; 0 or a failure code
742fn tgload c ulong sid ulong to ulong
743tgdir c
744tgfile 517097156201 5
745if ne tgreadb 320
746ret 60
747end
748for i ulong 40
749put TGIX i tgwb i
750end
751tgdir c
752tgfile 8317708060499076467 8
753if ne tgreadb 24576
754ret 61
755end
756for j ulong 3072
757put TGSS j tgwb j
758end
759if ne get TGIX 0 3544386032354079058
760ret 62
761end
762if ne get TGIX 1 1
763ret 62
764end
765if ne get TGIX 2 sid
766ret 62
767end
768if ne get TGIX 3 24
769ret 62
770end
771if ne get TGIX 4 192
772ret 63
773end
774if ne get TGIX 5 17952
775ret 63
776end
777if ne get TGIX 6 9024
778ret 63
779end
780for z ulong 5
781if ne get TGIX add 11 z 0
782ret 62
783end
784end
785ret 0
786end
787
788fn tgclear to void
789for u ulong 64
790put TGCN u 0
791end
792for v ulong 384
793put TGNV v 0
794end
795put TGCU 8 0
796put TGCU 9 0
797put TGCU 10 0
798end
799
800fn tgsplit c ulong sid ulong to ulong
801e = tgload c sid
802if ne e 0
803ret e
804end
805tgclear
806rfhini 0
807tot = ulong 0
808for g ulong 24
809tggroup c g
810tot = add tot get TGIX add 16 g
811end
812if ne get TGCU 8 0
813ret get TGCU 8
814end
815rfhfin 0
816for d ulong 4
817if ne get RFHD d get TGIX add 7 d
818ret 64
819end
820end
821if ne tot 17952
822ret 65
823end
824if ne get TGCU 9 17952
825ret 65
826end
827if ne get TGCU 10 9024
828ret 65
829end
830e = tgcounts
831if ne e 0
832ret e
833end
834ret tgmixed
835end
836
837note novelty counts of cell v: classes 1..5 must be a b c d e
838fn tgnvok v ulong a ulong b ulong c ulong d ulong e ulong to bool
839x = mul v 6
840if ne get TGNV add x 1 a
841ret false
842end
843if ne get TGNV add x 2 b
844ret false
845end
846if ne get TGNV add x 3 c
847ret false
848end
849if ne get TGNV add x 4 d
850ret false
851end
852ret eq get TGNV add x 5 e
853end
854
855note the seeded dealing: no group holds 8 sessions of one family and type (the composition order,
856note dealt without a permutation, would)
857fn tgmixed to ulong
858for g ulong 24
859b = mul g 128
860k0 = add mul get TGSS add b 2 16 get TGSS add b 3
861same = true
862for i ulong 8
863r = add b mul i 16
864k = add mul get TGSS add r 2 16 get TGSS add r 3
865if ne k k0
866same = false
867end
868end
869if same
870ret 69
871end
872end
873ret 0
874end
875
876note 4 sessions per family x type x n class, novelty counts of contract 7.2 and K8
877fn tgcounts to ulong
878for f ulong 2
879for t ulong 8
880for nc ulong 3
881c = add mul f 24 add mul t 3 nc
882if ne get TGCN c 4
883ret 66
884end
885ok = false
886if eq f 0
887if eq t 7
888ok = tgnvok c 0 0 4 0 0
889else
890ok = tgnvok c 1 2 1 0 0
891end
892else
893if eq t 7
894ok = tgnvok c 0 0 0 0 4
895else
896ok = tgnvok c 0 0 0 2 2
897end
898end
899if not ok
900ret 67
901end
902end
903end
904end
905ret 0
906end
907
908fn main to int
909if lt argcnt 3
910ret 1
911end
912l = argread 1 TGS 0 3000
913m = argread 2 TGA 0 3000
914if or le l 0 le m 0
915ret 1
916end
917put TGT 0 ulong l
918put TGT 1 ulong m
919r = tggen 336236466772 5 84 0
920r = or r tggen 88297166688852 6 80 0
921r = or r tggen 5653828 3 68 0
922r = or r tggen 327513164102 5 70 1
923if ne r 0
924ret 2
925end
926tgtrain 84 1
927tgtrain 80 5
928if or ne get TGT 8 240 ne get TGT 9 240
929ret 3
930end
931e = tgsplit 68 3
932if ne e 0
933ret int e
934end
935e = tgsplit 70 4
936ret int e
937end