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 / gpu / nvidia / native / learn53 / moe-closure.om

935 lines · 16189 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note #35/#53/#159 joint operation instance binding, NOT qualification or authentication.
3note Dependencies: authoritative moe_windows/moe_alias, compose_check/launchread and kc SHA.
4note Canonical LE64 scalar128, SHA256 groups64, ordered window LE64 cells1024.
5note Exact active11264 in capacity16384; all reserved/inactive/capacity bytes zero.
6fn mc_word b view uchar 16384 i ulong to ulong
7v = ulong 0
8for j ulong 8
9v = or v shl ulong get b add mul i 8 j mul j 8
10end
11ret v
12end
13fn mc_put b edit uchar 16384 i ulong v ulong to void
14for j ulong 8
15put b add mul i 8 j uchar and shr v mul j 8 255
16end
17end
18fn mc_hash b view uchar 16384 i ulong h view uchar 32 to bool
19if ge i 64
20ret false
21end
22for j ulong 32
23if ne get b add add 1024 mul i 32 j get h j
24ret false
25end
26end
27ret true
28end
29fn mc_base i ulong to ulong
30if lt i 8
31ret add 32 mul i 4
32end
33ret add 80 mul sub i 8 4
34end
35fn mc_need b view uchar 16384 i ulong to ulong
36n = mc_word b 5
37if lt i 4
38width = ulong 144
39if lt i 2
40width = 32
41end
42ret add mul sub n 1 mc_word b 16 width
43end
44if lt i 6
45ret mul mc_word b 74 32
46end
47if lt i 8
48ret mul mc_word b 73 4
49end
50if eq i 8
51ret mul mul n mc_word b 9 4
52end
53if eq i 9
54ret mul mul mul n 9 mc_word b 10 8
55end
56if lt i 12
57ret mul mul mul n 9 mc_word b 10 4
58end
59if eq i 12
60ret mul mul mul n 9 mc_word b 9 4
61end
62if eq i 13
63ret mul mul n mc_word b 9 4
64end
65note Tensor extents come from immutable tensor/directory owner, not a guessed packing.
66ret 1
67end
68fn mc_ranges b view uchar 16384 to long
69r = new ulong 16 0
70for i ulong 16
71p = mc_base i
72va = mc_word b p
73size = mc_word b add p 1
74if or eq va 0 ne rem va 8 0
75ret 3
76end
77if lt size mc_need b i
78ret 3
79end
80if gt va sub ulong 18446744073709551615 size
81ret 3
82end
83wantgen = mc_word b 19
84if ge i 14
85wantgen = mc_word b 22
86end
87if ne mc_word b add p 2 wantgen
88ret 3
89end
90if eq mc_word b add p 3 0
91ret 3
92end
93end
94note GROUP's existing span/alias checker is authoritative; no alternate overlap algorithm.
95put r 0 add mc_word b 32 mul mc_word b 6 mc_word b 16
96put r 1 add mc_word b 40 mul mc_word b 6 mc_word b 16
97put r 2 add mc_word b 44 mul mc_word b 6 mc_word b 16
98put r 3 mc_word b 48
99put r 4 mc_word b 52
100put r 5 mc_word b 56
101put r 6 mc_word b 60
102put r 7 mc_word b 16
103put r 8 mc_word b 7
104if moe_alias r
105ret 3
106end
107for i ulong 4
108if ne mc_word b add mc_base i 3 mc_word b 16
109ret 3
110end
111end
112for i ulong 2
113if ne mc_word b add mc_base add i 4 3 32
114ret 3
115end
116if ne mc_word b add mc_base add i 6 3 4
117ret 3
118end
119end
120if ne mc_word b 83 mul mc_word b 9 4
121ret 3
122end
123if ne mc_word b 87 mul mul ulong 9 mc_word b 10 8
124ret 3
125end
126for i ulong 2
127if ne mc_word b add 91 mul i 4 mul mul ulong 9 mc_word b 10 4
128ret 3
129end
130end
131if ne mc_word b 99 mul mul ulong 9 mc_word b 9 4
132ret 3
133end
134if ne mc_word b 103 mul mc_word b 9 4
135ret 3
136end
137ret 0
138end
139fn mc_windows b view uchar 16384 to long
140cfg = new ulong 8 0
141rows = new ulong 1024 0
142meta = new ulong 4 0
143put cfg 0 1
144put cfg 1 mc_word b 5
145put cfg 2 mc_word b 9
146put cfg 3 mc_word b 10
147put cfg 4 mc_word b 13
148put cfg 5 mc_word b 16
149put cfg 6 mc_word b 15
150put cfg 7 mc_word b 75
151if ne moe_windows cfg edit rows edit meta 0
152ret 2
153end
154if ne get meta 0 mc_word b 3
155ret 2
156end
157for i ulong 1024
158if ne mc_word b add 384 i get rows i
159ret 2
160end
161end
162p = mul mc_word b 4 8
163for i ulong 3
164if ne mc_word b add 6 i get rows add p i
165ret 2
166end
167end
168ret 0
169end
170fn mc_valid b view uchar 16384 n ulong to long
171if ne n 11264
172ret 1
173end
174if or ne mc_word b 0 2 ne mc_word b 1 159
175ret 1
176end
177if ne mc_word b 2 n
178ret 1
179end
180if or eq mc_word b 3 0 gt mc_word b 3 128
181ret 1
182end
183if ge mc_word b 4 mc_word b 3
184ret 1
185end
186if or eq mc_word b 5 0 gt mc_word b 5 128
187ret 1
188end
189if or ne mc_word b 9 2048 ne mc_word b 10 512
190ret 2
191end
192if or ne mc_word b 11 256 ne mc_word b 12 8
193ret 2
194end
195if or ne mc_word b 13 9 ne mc_word b 14 256
196ret 2
197end
198if ne mc_word b 15 128
199ret 2
200end
201if or lt mc_word b 16 144 gt mc_word b 16 4294967295
202ret 2
203end
204if ne rem mc_word b 16 16 0
205ret 2
206end
207note Epoch0 is valid; identities match owner context separately.
208if ne mc_word b 18 121
209ret 2
210end
211if eq mc_word b 20 0
212ret 1
213end
214if or eq mc_word b 77 0 ge mc_word b 21 mc_word b 77
215ret 1
216end
217lastly = ulong 0
218if eq add mc_word b 21 1 mc_word b 77
219lastly = 1
220end
221if ne mc_word b 78 lastly
222ret 2
223end
224if ne mc_word b 23 0
225ret 2
226end
227for i ulong 8
228if ne mc_word b add 24 i 1
229ret 2
230end
231end
232for i ulong 9
233if ne mc_word b add 64 i i
234ret 2
235end
236end
237if or ne mc_word b 73 add mul mc_word b 5 9 8 ne mc_word b 74 128
238ret 2
239end
240if or ne mc_word b 75 0 gt mc_word b 76 1
241ret 2
242end
243if ne mc_word b 79 1
244ret 2
245end
246note Window-local X/Y, GU X/Y, DN Y/Y, padding8, duplicate-preserving sort.
247if or ne mc_word b 112 1 ne mc_word b 113 2
248ret 2
249end
250if or ne mc_word b 114 2 ne mc_word b 115 2
251ret 2
252end
253if ne mc_word b 116 8
254ret 2
255end
256for i ulong 5
257if ne mc_word b add 117 i 1
258ret 2
259end
260end
261for i ulong 2
262v = mc_word b add 122 i
263if or eq v 0 gt v 16384
264ret 1
265end
266if ne rem v 16 0
267ret 1
268end
269end
270for i ulong 4
271if ne mc_word b add 124 i 0
272ret 1
273end
274end
275for i ulong 64
276nz = uchar 0
277for j ulong 32
278nz = or nz get b add add 1024 mul i 32 j
279end
280if eq nz 0
281ret 1
282end
283end
284for i ulong 5120
285if ne get b add 11264 i 0
286ret 1
287end
288end
289s = mc_windows b
290if ne s 0
291ret s
292end
293ret mc_ranges b
294end
295fn mc_bind want view uchar 16384 got view uchar 16384 n ulong out edit uchar 32 to long
296for i ulong 32
297put out i 0
298end
299s = mc_valid want n
300if ne s 0
301ret s
302end
303s = mc_valid got n
304if ne s 0
305ret s
306end
307for i ulong 11264
308if ne get want i get got i
309ret 4
310end
311end
312if ne kc_codesha got n edit out 0
313ret 1
314end
315ret 0
316end
317fn mc_limb b view uchar 16384 group ulong limb ulong to ulong
318ret mc_word b add add 128 mul group 4 limb
319end
320fn mc_context b view uchar 16384 q view ulong 64 row view ulong 64 role ulong to long
321if ne mc_valid b 11264 0
322ret 1
323end
324if or gt role 1 ne get q 0 1
325ret 5
326end
327if ne get row 0 3
328ret 5
329end
330for i ulong 4
331if ne get q add i 3 mc_word b add i 17
332ret 5
333end
334if ne get row add i 17 get q add i 3
335ret 5
336end
337end
338for i ulong 6
339group = add i 38
340if and eq role 1 ge i 4
341group = add i 49
342end
343for j ulong 4
344v = mc_limb b group j
345if ne get q add add 14 mul i 4 j v
346ret 5
347end
348if ne get row add add 33 mul i 4 j v
349ret 5
350end
351end
352end
353for i ulong 4
354if ne get row add 21 i mc_limb b add 22 mul role 8 i
355ret 5
356end
357if ne get row add 25 i mc_limb b add 24 mul role 8 i
358ret 5
359end
360if ne get row add 29 i mc_limb b 44 i
361ret 5
362end
363if ne get row add 57 i mc_limb b add 23 mul role 8 i
364ret 5
365end
366end
367ret 0
368end
369fn mc_bindctx want view uchar 16384 got view uchar 16384 q view ulong 64 row view ulong 64 role ulong out edit uchar 32 to long
370for i ulong 32
371put out i 0
372end
373s = mc_context got q row role
374if ne s 0
375ret s
376end
377ret mc_bind want got 11264 edit out
378end
379fn mc_chashes b view uchar 16384 c view uchar 4096 role ulong to long
380h = new uchar 32 0
381q = new uchar 4096 0
382for k ulong 3
383pos = add 544 mul k 32
384for i ulong 32
385put h i get c add pos i
386end
387if not mc_hash b add k 4 h
388ret 6
389end
390end
391for i ulong 32
392put h i get c add 512 i
393end
394if not mc_hash b add 61 role h
395ret 6
396end
397if ne kc_sha c 1152 edit h 0
398ret 6
399end
400if not mc_hash b add 22 mul role 8 h
401ret 6
402end
403for i ulong 384
404put q i get c add 768 i
405end
406if ne kc_sha q 384 edit h 0
407ret 6
408end
409if not mc_hash b add 29 mul role 8 h
410ret 6
411end
412ret 0
413end
414fn mc_codeblob b view uchar 16384 c view uchar 4096 code view uchar 16384 n ulong role ulong to long
415h = new uchar 32 0
416if ne kc_codesha code n edit h 0
417ret 6
418end
419if not compose_codeid c h
420ret 6
421end
422if not mc_hash b add 23 mul role 8 h
423ret 6
424end
425ret 0
426end
427fn mc_launchblob b view uchar 16384 c view uchar 4096 l view uchar 256 role ulong to long
428h = new uchar 32 0
429lw = new uchar 4096 0
430for i ulong 256
431put lw i get l i
432end
433if ne compose_launchread c lw 256 0
434ret 6
435end
436if ne kc_sha lw 256 edit h 0
437ret 6
438end
439if not compose_launchid c h
440ret 6
441end
442if not mc_hash b add 24 mul role 8 h
443ret 6
444end
445for k ulong 3
446pos = add 120 mul k 32
447for i ulong 32
448put h i get l add pos i
449end
450group = add add 26 mul role 8 k
451if not mc_hash b group h
452ret 6
453end
454end
455ret 0
456end
457fn mc_blob b view uchar 16384 c view uchar 4096 code view uchar 16384 n ulong l view uchar 256 role ulong to long
458if gt role 1
459ret 1
460end
461if ne mc_valid b 11264 0
462ret 1
463end
464note Preserve canonical family3 refusal. No host result can replace that gate.
465if ne compose_word c 19 3
466ret 6
467end
468if ne compose_check c 1152 0
469ret 6
470end
471if or eq n 0 gt n 16384
472ret 6
473end
474if ne rem n 16 0
475ret 6
476end
477if ne n mc_word b add 122 role
478ret 6
479end
480if ne compose_word c 4 mc_word b 8
481ret 6
482end
483if eq role 0
484if or ne compose_word c 5 mul mc_word b 10 2 ne compose_word c 6 mc_word b 9
485ret 6
486end
487else
488if or ne compose_word c 5 mc_word b 9 ne compose_word c 6 mc_word b 10
489ret 6
490end
491end
492if ne mc_chashes b c role 0
493ret 6
494end
495if ne mc_codeblob b c code n role 0
496ret 6
497end
498ret mc_launchblob b c l role
499end
500note Custody identities are frozen executor metadata, not candidate claims or signed receipts.
501note ctx/got32: version1,class1HOST_ONLY,instance4,evaluator4,source4,resultprotocol4,
502note approved subject4,independently frozen qualification-context4,reserved6zero.
503note No device class accepted here; existing independent owner handles actual qualification.
504fn mc_custody b view uchar 16384 held view uchar 32 ctx view ulong 32 got view ulong 32 to long
505h = new uchar 32 0
506if ne mc_valid b 11264 0
507ret 1
508end
509if ne kc_codesha b 11264 edit h 0
510ret 1
511end
512for i ulong 32
513if ne get held i get h i
514ret 5
515end
516end
517if or ne get ctx 0 1 ne get ctx 1 1
518ret 5
519end
520for i ulong 32
521if ne get ctx i get got i
522ret 5
523end
524end
525for i ulong 4
526v = ulong 0
527for j ulong 8
528v = or v shl ulong get h add mul i 8 j mul j 8
529end
530if ne get ctx add i 2 v
531ret 5
532end
533if ne get ctx add i 6 mc_limb b 7 i
534ret 5
535end
536if ne get ctx add i 10 mc_limb b 3 i
537ret 5
538end
539end
540for i ulong 4
541if ne get ctx add i 14 mc_limb b 63 i
542ret 5
543end
544if ne get ctx add i 18 mc_limb b 39 i
545ret 5
546end
547if ne get ctx add i 22 mc_limb b 44 i
548ret 5
549end
550end
551for i ulong 6
552if ne get ctx add i 26 0
553ret 5
554end
555end
556ret 0
557end
558fn mc_pack scalars view ulong 128 hashes view uchar 2048 windows view ulong 1024 out edit uchar 16384 to long
559for i ulong 16384
560put out i 0
561end
562for i ulong 128
563mc_put edit out i get scalars i
564end
565for i ulong 2048
566put out add 1024 i get hashes i
567end
568for i ulong 1024
569mc_put edit out add 384 i get windows i
570end
571s = mc_valid out 11264
572if ne s 0
573for i ulong 16384
574put out i 0
575end
576end
577ret s
578end
579note Nested live-instance preimages, not admitted native artifact template identities.
580note All input arrays and out32 MUST be disjoint; existing owner supplies actual retained snapshots.
581fn mc_clear out edit uchar 32 to void
582for i ulong 32
583put out i 0
584end
585end
586fn mc_code code view uchar 16384 n ulong out edit uchar 32 to long
587mc_clear edit out
588if or eq n 0 or gt n 16384 ne rem n 16 0
589ret 1
590end
591if ne kc_codesha code n edit out 0
592ret 6
593end
594ret 0
595end
596fn mc_submit m view ulong 32 s view ulong 16 to long
597if or ne get s 0 1 or ne get s 1 159 ne get s 2 4
598ret 1
599end
600if or eq get s 3 0 ne get s 3 get m 7
601ret 1
602end
603if or gt get s 4 1 gt get s 5 4
604ret 2
605end
606if or eq get s 6 0 gt get s 7 1000000
607ret 1
608end
609if or gt get s 8 1 or ne get s 9 0 gt get s 10 1
610ret 2
611end
612if or eq get s 11 0 or gt get s 11 4096 ge get m 6 get s 11
613ret 1
614end
615for i ulong 4
616if ne get s add 12 i 0
617ret 1
618end
619end
620ret 0
621end
622fn mc_qword q view uchar 1024 off ulong to ulong
623v = ulong 0
624for i ulong 4
625v = or v shl ulong get q add off i mul i 8
626end
627ret v
628end
629fn mc_qcode q view uchar 1024 to ulong
630low = shl mc_qword q 128 4
631high = and mc_qword q 132 sub shl ulong 1 21 1
632ret or low shl high 36
633end
634fn mc_lmeta m view ulong 32 qmd view uchar 1024 to long
635if or ne get m 0 1 or ne get m 1 159 ne get m 2 1
636ret 1
637end
638if or gt get m 3 5 or eq get m 4 0 gt get m 4 32
639ret 1
640end
641n = get m 5
642if eq n 0
643ret 1
644end
645if gt n 16384
646ret 1
647end
648if ne rem n 16 0
649ret 1
650end
651if or eq get m 7 0 gt get m 8 1
652ret 1
653end
654if ne rem get m 9 8 0
655ret 3
656end
657if eq get m 10 0
658ret 3
659end
660if ne rem get m 10 16 0
661ret 3
662end
663if ne mc_qcode qmd get m 10
664ret 3
665end
666for i ulong 21
667if ne get m add 11 i 0
668ret 1
669end
670end
671ret 0
672end
673fn mc_lbytes bank view uchar 1024 qmd view uchar 1024 n ulong b edit uchar 16384 to ulong
674off = ulong 384
675for i ulong add 896 mul n 4
676put b add off i get bank i
677end
678off = add off add 896 mul n 4
679for i ulong 384
680put b add off i get qmd i
681end
682off = add off 384
683for i ulong 384
684put b add off i get qmd add 512 i
685end
686ret add off 384
687end
688fn mc_launch m view ulong 32 bank view uchar 1024 qmd view uchar 1024 s view ulong 16 out edit uchar 32 to long
689mc_clear edit out
690st = mc_lmeta m qmd
691if ne st 0
692ret st
693end
694st = mc_submit m s
695if ne st 0
696ret st
697end
698b = new uchar 16384 0
699for i ulong 32
700mc_put edit b i get m i
701end
702for i ulong 16
703mc_put edit b add 32 i get s i
704end
705n = mc_lbytes bank qmd get m 4 edit b
706if ne kc_codesha b n edit out 0
707ret 6
708end
709ret 0
710end
711fn mc_dir m view ulong 8 entries view ulong 1024 out edit uchar 32 to long
712mc_clear edit out
713if or ne get m 0 1 or ne get m 1 159 ne get m 2 2
714ret 1
715end
716if or gt get m 3 1 or ne get m 4 257 eq get m 5 0
717ret 1
718end
719if or gt get m 6 4294967295 ne get m 7 0
720ret 1
721end
722b = new uchar 16384 0
723for i ulong 8
724mc_put edit b i get m i
725end
726for i ulong 1024
727if lt i 514
728if or eq get entries i 0 ne rem get entries i 8 0
729ret 3
730end
731mc_put edit b add 8 i get entries i
732else
733if ne get entries i 0
734ret 1
735end
736end
737end
738if ne kc_codesha b 4176 edit out 0
739ret 6
740end
741ret 0
742end
743fn mc_record r view ulong 1024 i ulong to long
744p = mul i 16
745if ge get r p 64
746ret 1
747end
748if ne i 0
749if le get r p get r sub p 16
750ret 1
751end
752end
753if or gt get r add p 1 4294967295 or eq get r add p 2 0 gt get r add p 2 4294967295
754ret 1
755end
756if or lt get r add p 3 2 gt get r add p 3 4
757ret 1
758end
759va = get r add p 4
760size = get r add p 5
761rv = get r add p 6
762avail = get r add p 7
763if or eq va 0 ne rem va 8 0
764ret 3
765end
766if or eq size 0 gt va sub ulong 18446744073709551615 size
767ret 3
768end
769if or lt rv va ge rv add va size
770ret 3
771end
772if or eq avail 0 gt avail sub add va size rv
773ret 3
774end
775if or ne rem rv 8 0 eq get r add p 8 0
776ret 3
777end
778for j ulong 7
779if ne get r add add p 9 j 0
780ret 1
781end
782end
783ret 0
784end
785fn mc_backing r view ulong 1024 i ulong to long
786p = mul i 16
787for j ulong i
788q = mul j 16
789if eq get r add p 1 get r add q 1
790if ne get r add p 2 get r add q 2
791ret 3
792end
793for k ulong 3
794if ne get r add add p 3 k get r add add q 3 k
795ret 3
796end
797end
798end
799end
800ret 0
801end
802fn mc_alloc m view ulong 8 r view ulong 1024 out edit uchar 32 to long
803mc_clear edit out
804if or ne get m 0 1 or ne get m 1 159 ne get m 2 3
805ret 1
806end
807if or eq get m 3 0 gt get m 3 64
808ret 1
809end
810for i ulong 3
811if eq get m add 4 i 0
812ret 1
813end
814end
815if ne get m 7 0
816ret 1
817end
818for i ulong get m 3
819st = mc_record r i
820if ne st 0
821ret st
822end
823st = mc_backing r i
824if ne st 0
825ret st
826end
827end
828base = mul get m 3 16
829for i ulong sub ulong 1024 base
830if ne get r add base i 0
831ret 1
832end
833end
834b = new uchar 16384 0
835for i ulong 8
836mc_put edit b i get m i
837end
838for i ulong 1024
839mc_put edit b add 8 i get r i
840end
841if ne kc_codesha b 8256 edit out 0
842ret 6
843end
844ret 0
845end
846note Every occurrence is retained; code and launch series share the owner's actual-entry order.
847fn mc_smeta m view ulong 8 ord view ulong 128 to long
848if or ne get m 0 1 or ne get m 1 159 ne get m 2 5
849ret 1
850end
851if or gt get m 3 5 gt get m 4 1
852ret 1
853end
854if or eq get m 5 0 gt get m 5 128
855ret 1
856end
857if eq get m 4 0
858if or ne get m 6 0 ne get m 7 0
859ret 1
860end
861for i ulong 128
862if ne get ord i 0
863ret 1
864end
865end
866ret 0
867end
868if or eq get m 6 0 or eq get m 7 0 gt get m 7 4096
869ret 1
870end
871for i ulong 128
872if lt i get m 5
873if ge get ord i get m 7
874ret 1
875end
876if gt i 0
877if le get ord i get ord sub i 1
878ret 1
879end
880end
881else
882if ne get ord i 0
883ret 1
884end
885end
886end
887ret 0
888end
889fn mc_sdigs hashes view uchar 4096 n ulong to long
890for i ulong 128
891v = uchar 0
892for j ulong 32
893if lt i n
894v = or v get hashes add mul i 32 j
895else
896if ne get hashes add mul i 32 j 0
897ret 1
898end
899end
900end
901if and lt i n eq v 0
902ret 3
903end
904end
905ret 0
906end
907fn mc_series m view ulong 8 hashes view uchar 4096 ord view ulong 128 out edit uchar 32 to long
908mc_clear edit out
909if ne mc_smeta m ord 0
910ret 1
911end
912st = mc_sdigs hashes get m 5
913if ne st 0
914ret st
915end
916b = new uchar 16384 0
917for i ulong 8
918mc_put edit b i get m i
919end
920off = ulong 64
921if eq get m 4 1
922for i ulong 128
923mc_put edit b add 8 i get ord i
924end
925off = ulong 1088
926end
927for i ulong 4096
928put b add off i get hashes i
929end
930if ne kc_codesha b add off 4096 edit out 0
931mc_clear edit out
932ret 6
933end
934ret 0
935end