Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/train/omega-llm/tools/combined/combined.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / train / omega-llm / tools / combined / combined.om` 657 lines ยท 9982 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note Linked with the existing benchmark path, process, and execpure grading primitives. 3 text formal "om_formalize" 4 text sk "om_sketch" 5 text sy "om_synth" 6 text neural "ollm" 7 text spec "input.spec" 8 text source "function.om" 9 text promptfile "prompt" 10 text logname "status" 11 text raw "answer" 12 text formcmd "formalize" 13 text solvecmd "solve" 14 text specsample "spsamp" 15 text r6 "r6.ck" 16 text r3 "r3.ck" 17 text r11 "r11.ck" 18 text fast "base.ck" 19 text traceck "trace.ck" 20 text merges "merges.bin" 21 text s1 "S1_arith.sp" 22 text s2 "S2_fold.sp" 23 text s3 "S3_rewrite.sp" 24 text s4 "S4_repair.sp" 25 text missform "FORMALIZE_ABSTAIN\n" 26 text misssk "SKETCH_FAIL\n" 27 text misssy "SYNTH_FAIL nodes=" 28 text noStrand "" 29 text size64 "64" 30 text heat "700" 31 text badinput "combined: malformed prompt or numeric examples\n" 32 text failure "combined: component or file failed\n" 33 text absent "combined: no candidate passed the supplied examples\n" 34 text from "route " 35 text linefeed "\n" 36 text arity "arity " 37 text knobs "\ndepth 2\nconsts 0 1 2 3\n" 38 text cs "case" 39 text fs "fold" 40 text rs "rew" 41 text setarr "put arr " 42 text calcwords "add sub mul div rem and or xor shl shr eq ne lt le gt ge not true false if else end while for bound break continue ret put get new int uint ulong long uchar bool =" 43 text paramTo "to" 44 text paramView "view" 45 text paramEdit "edit" 46 text equalSign "=" 47 text bindFor "for " 48 text bindEnd " ulong 0\nend\n" 49 global names ulong * 50 global cfg ulong 8 51 note cfg: prompt size, signature start/end, shape, example count. 52 global cases ulong 1088 53 54 fn kfile t view uchar * to void 55 pclr 56 parg 1 57 pch 47 58 ptx t 59 end 60 61 fn kitarg t view uchar * to void 62 kfile t 63 kpath 64 end 65 66 fn workarg t view uchar * to void 67 wpath t 68 kpath 69 end 70 71 fn present t view uchar * to bool 72 kfile t 73 f = fopen pth 0 get st 3 0 0 74 if lt f 0 75 ret false 76 end 77 x = fclose int f 78 ret true 79 end 80 81 fn cbRun dest view uchar * to long 82 wpath dest 83 fo = popen true 384 84 pclr 85 ptx tnull 86 fi = popen false 0 87 p = spawn fi fo false 88 x = fclose fi 89 y = fclose fo 90 ret waitp p 60000 91 end 92 93 note Load a bounded regular file through one descriptor. Each input stays in its own mem range. 94 fn cbLoad limit ulong to ulong 95 fd = popen false 0 96 sz = fseek fd 0 2 97 if or lt sz 0 gt ulong sz limit 98 die badinput 65 99 end 100 if ne fseek fd 0 0 0 101 die failure 70 102 end 103 b = get st 6 104 e = add b ulong sz 105 grow = enlarge mem add e 1 106 if lt grow 0 107 die failure 70 108 end 109 p = b 110 while lt p e bound 65536 111 k = read fd mem p sub e p 112 if le k 0 113 die failure 70 114 end 115 p = add p ulong k 116 end 117 if ne read fd mem e 1 0 118 die failure 70 119 end 120 cl = fclose fd 121 put st 6 e 122 ret b 123 end 124 125 fn wload t view uchar * to ulong 126 wpath t 127 ret cbLoad 65535 128 end 129 130 fn resolved rc long miss view uchar * to bool 131 if eq rc 0 132 ret true 133 end 134 b = wload logname 135 if and eq rc 1 sw b get st 6 miss 136 ret false 137 end 138 die failure 70 139 ret false 140 end 141 142 fn readprompt to void 143 pclr 144 parg 4 145 b = cbLoad 4095 146 e = get st 6 147 if or lt e 18 gt e 4095 148 die badinput 65 149 end 150 p = lend 0 e 151 s = add p 1 152 q = lend s e 153 if or not sw 0 p gnote not sw s q gsolve 154 die badinput 65 155 end 156 if or le p len gnote gt e add q 1 157 die badinput 65 158 end 159 for i ulong e bound 4095 160 v = get mem i 161 if and lt v 32 ne v 10 162 die badinput 65 163 end 164 end 165 put cfg 0 q 166 put cfg 1 s 167 put cfg 2 q 168 put cfg 3 shapeof add s len gsolve q 169 put st 2 0 170 gmem 0 q 171 gc 10 172 wpath promptfile 173 fsave 384 174 end 175 176 fn canonical a ulong w ulong to ulong 177 v = dec a w 178 di = udec v 179 note Canonical decimal round trip also rejects unsigned overflow and leading zeroes. 180 if ne sub w a sub 24 di 181 die badinput 65 182 end 183 for z ulong sub w a bound 20 184 if ne get mem add a z get dg add di z 185 die badinput 65 186 end 187 end 188 ret v 189 end 190 191 fn readrow p ulong q ulong width ulong to void 192 a = skipsp p q 193 r = get cfg 4 194 if or ge r 64 ne nwords a q width 195 die badinput 65 196 end 197 for j ulong width bound 17 198 w = wordend a q 199 v = canonical a w 200 if and and ge get cfg 3 4 eq j 0 gt v 8 201 die badinput 65 202 end 203 put cases add mul r 17 j v 204 a = skipsp w q 205 end 206 put cfg 4 add r 1 207 end 208 209 fn readcases to void 210 pclr 211 parg 5 212 p = cbLoad 24576 213 e = get st 6 214 sh = get cfg 3 215 width = add sh 1 216 if eq sh 4 217 width = 10 218 end 219 if eq sh 5 220 width = 17 221 end 222 while lt p e bound 65 223 q = lend p e 224 readrow p q width 225 p = add q 1 226 end 227 if eq get cfg 4 0 228 die badinput 65 229 end 230 end 231 232 fn numberarg x ulong to void 233 gc 32 234 gu x 235 end 236 237 fn exampleSpec to void 238 sh = get cfg 3 239 put st 2 0 240 gtx arity 241 gu sh 242 gtx knobs 243 for i ulong get cfg 4 bound 64 244 if eq i 8 245 break 246 end 247 b = mul i 17 248 n = add sh 1 249 if le sh 3 250 gtx cs 251 else 252 if eq sh 5 253 gtx rs 254 n = 17 255 else 256 gtx fs 257 n = add get cases b 1 258 end 259 end 260 for j ulong n bound 17 261 numberarg get cases add b j 262 end 263 if eq sh 4 264 numberarg get cases add b 9 265 end 266 gc 10 267 end 268 wpath spec 269 fsave 384 270 end 271 272 note Allowed instruction words. The seeded compiler checks their grammar, types and scope. 273 fn instruction p ulong q ulong to bool 274 w = ulong 0 275 while lt w len calcwords bound 512 276 z = w 277 while lt z len calcwords bound 512 278 if eq get calcwords z 32 279 break 280 end 281 z = add z 1 282 end 283 if meq p q part calcwords w sub z w 284 ret true 285 end 286 w = add z 1 287 end 288 ret false 289 end 290 291 fn digitsOnly p ulong q ulong to bool 292 for i ulong sub q p 293 c = get mem add p i 294 if or lt c 48 gt c 57 295 ret false 296 end 297 end 298 ret gt q p 299 end 300 301 fn knownName p ulong q ulong to bool 302 for i ulong get cfg 5 303 start = get names mul i 2 304 size = get names add mul i 2 1 305 if mm p sub q p start size 306 ret true 307 end 308 end 309 ret false 310 end 311 312 fn bindName p ulong q ulong to bool 313 if or eq p q gt sub q p 63 314 ret false 315 end 316 c = get mem p 317 if or eq c 45 and ge c 48 le c 57 318 ret false 319 end 320 for i ulong sub q p 321 c = get mem add p i 322 if or le c 32 or eq c 34 or eq c 40 eq c 41 323 ret false 324 end 325 end 326 if instruction p q 327 ret false 328 end 329 if not knownName p q 330 i = mul get cfg 5 2 331 capacity = enlarge names add i 2 332 if lt capacity 0 333 die failure 70 334 end 335 put names i p 336 put names add i 1 sub q p 337 put cfg 5 add get cfg 5 1 338 end 339 ret true 340 end 341 342 note readprompt already checked the signature. Consume each scalar or sized-array parameter. 343 fn bindParams to void 344 p = add get cfg 1 len gsolve 345 q = get cfg 2 346 while lt p q 347 w = wordend p q 348 if meq p w paramTo 349 break 350 end 351 if not bindName p w 352 die failure 70 353 end 354 p = skipsp w q 355 w = wordend p q 356 if or meq p w paramView meq p w paramEdit 357 p = skipsp w q 358 p = skipsp wordend p q q 359 w = wordend p q 360 end 361 p = skipsp w q 362 end 363 end 364 365 fn mathbody b ulong e ulong to bool 366 put cfg 5 0 367 bindParams 368 p = b 369 while lt p e bound 65536 370 q = lend p e 371 a = skipsp p q 372 w = wordend a q 373 nextWord = skipsp w q 374 nextEnd = wordend nextWord q 375 if meq nextWord nextEnd equalSign 376 if not bindName a w 377 ret false 378 end 379 end 380 if meq a w twfor 381 if not bindName nextWord nextEnd 382 ret false 383 end 384 end 385 while lt a q bound 65536 386 w = wordend a q 387 if not or digitsOnly a w or instruction a w knownName a w 388 ret false 389 end 390 a = skipsp w q 391 end 392 p = add q 1 393 end 394 ret true 395 end 396 397 note Check every proposed identifier in an unambiguous declaration position. 398 note This asks the same compiler that executes the checker which names are reserved. 399 fn validateNames to void 400 for i ulong get cfg 5 401 gtx bindFor 402 gmem get names mul i 2 get names add mul i 2 1 403 gtx bindEnd 404 end 405 end 406 407 fn checkbody b ulong e ulong to bool 408 z = bodyend b e 409 if eq z 0 410 ret false 411 end 412 if or more sub z 1 e not mathbody b e 413 ret false 414 end 415 put st 2 0 416 gmem get cfg 1 sub get cfg 2 get cfg 1 417 gc 10 418 gmem b sub e b 419 gc 10 420 gtx gmain0 421 validateNames 422 sh = get cfg 3 423 if ge sh 4 424 gtx garr0 425 end 426 for i ulong get cfg 4 bound 64 427 o = mul i 17 428 if le sh 3 429 gtx gifne 430 for j ulong sh bound 3 431 gtx gsul 432 gu get cases add o j 433 end 434 gtx gsul 435 gu get cases add o sh 436 gtx gfail 437 else 438 for j ulong 8 439 gtx setarr 440 gu j 441 numberarg get cases add add o 1 j 442 gc 10 443 end 444 if eq sh 4 445 gtx gifne 446 gtx garrul 447 gu get cases o 448 gtx gsul 449 gu get cases add o 9 450 gtx gfail 451 else 452 gtx gcall 453 gtx garrul 454 gu get cases o 455 gc 10 456 for j ulong 8 457 gtx gifget 458 gu j 459 gtx gsul 460 gu get cases add add o 9 j 461 gtx gfail 462 end 463 end 464 end 465 end 466 gtx gret77 467 rc = compile 468 if eq rc 127 469 die failure 70 470 end 471 if ne rc 0 472 ret false 473 end 474 ret eq runp false 77 475 end 476 477 fn emitbody b ulong e ulong route view uchar * to bool 478 if ge b e 479 ret false 480 end 481 if gt get cfg 4 0 482 if not checkbody b e 483 ret false 484 end 485 end 486 w = write 2 from 0 len from 487 w = write 2 route 0 len route 488 w = write 2 linefeed 0 1 489 p = b 490 while lt p e bound 65536 491 n = write 1 mem p sub e p 492 if le n 0 493 die failure 70 494 end 495 p = add p ulong n 496 end 497 ret true 498 end 499 500 fn symbol exe view uchar * miss view uchar * to bool 501 kclr 502 kitarg exe 503 ktx solvecmd 504 workarg spec 505 workarg source 506 if not resolved cbRun logname miss 507 ret false 508 end 509 b = wload source 510 e = get st 6 511 q = lend b e 512 if not mm b sub q b get cfg 1 sub get cfg 2 get cfg 1 513 ret false 514 end 515 body = add q 1 516 if ge body e 517 die failure 70 518 end 519 z = bodyend body e 520 if eq z 0 521 die failure 70 522 end 523 if more sub z 1 e 524 die failure 70 525 end 526 ret emitbody body e exe 527 end 528 529 fn solveSpec to bool 530 if symbol sk misssk 531 ret true 532 end 533 if le get cfg 3 4 534 ret symbol sy misssy 535 end 536 ret false 537 end 538 539 fn draw ck view uchar * strand view uchar * seed ulong to bool 540 kclr 541 kitarg neural 542 if eq len strand 0 543 ktx csample 544 kitarg ck 545 ktx a42 546 ktx a128 547 ktx a0 548 else 549 ktx specsample 550 kitarg ck 551 kitarg strand 552 ktx size64 553 ktx heat 554 end 555 put st 2 0 556 gmem 0 get cfg 0 557 if ne len strand 0 558 gc 10 559 end 560 kprog 561 if ne len strand 0 562 put st 2 0 563 gu seed 564 kprog 565 end 566 kitarg merges 567 if ne cbRun raw 0 568 die failure 70 569 end 570 b = wload raw 571 if eq len strand 0 572 ret emitbody b get st 6 ck 573 end 574 ret emitbody b get st 6 strand 575 end 576 577 fn strandDraw s view uchar * first ulong to bool 578 if not present s 579 ret false 580 end 581 for j ulong 4 582 if draw r3 s add first j 583 ret true 584 end 585 end 586 ret false 587 end 588 589 fn main to int 590 if and ne argcnt 5 ne argcnt 6 591 die badinput 2 592 end 593 put st 26 2 594 put st 27 3 595 readprompt 596 if eq argcnt 6 597 readcases 598 end 599 kclr 600 kitarg formal 601 ktx formcmd 602 workarg promptfile 603 workarg spec 604 if resolved cbRun logname missform 605 if solveSpec 606 ret 0 607 end 608 end 609 if eq argcnt 6 610 exampleSpec 611 if solveSpec 612 ret 0 613 end 614 end 615 if draw r6 noStrand 0 616 ret 0 617 end 618 if eq argcnt 5 619 die absent 1 620 end 621 if present r3 622 if draw r3 noStrand 0 623 ret 0 624 end 625 end 626 if present fast 627 if draw fast noStrand 0 628 ret 0 629 end 630 end 631 if present traceck 632 if draw traceck noStrand 0 633 ret 0 634 end 635 end 636 if present r11 637 if draw r11 noStrand 0 638 ret 0 639 end 640 end 641 if present r3 642 if strandDraw s1 1000 643 ret 0 644 end 645 if strandDraw s2 1100 646 ret 0 647 end 648 if strandDraw s3 1200 649 ret 0 650 end 651 if strandDraw s4 1300 652 ret 0 653 end 654 end 655 die absent 1 656 ret 1 657 end