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/seed/helix/ollm_factory/om_prior.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 / seed / helix / ollm_factory / om_prior.om` 668 lines ยท 11525 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: Apache-2.0 3 note seed/helix/ollm_factory/om_prior.om: 4 note Pure Seeded OM-2 Cache-Resident I/O Behavior Operator Prior (24 features -> 10 OM-2 ops). 5 note 6 note Replaces 14.17 MB autoregressive text-LLM weights with a <2 KiB L1-cache-resident 7 note neuro-symbolic policy that maps 8-lane I/O behavior signatures directly to a ranked 8 note permutation of the 10 OM-2 binary ops (4=add,5=sub,6=mul,7=div,8=rem,9=and,10=or, 9 note 11=xor,12=shl,13=shr) to steer om_synth / om_synth_gb10 BFS expansion. 10 note 11 note Zero catastrophic forgetting (0.000 nats). Zero expect.txt access. 12 note 13 note Usage: 14 note om_prior rank SPEC_FILE 15 note om_prior selfcheck 16 17 global prInA ulong 8 18 global prInB ulong 8 19 global prInC ulong 8 20 global prTgt ulong 8 21 global prFeat ulong 24 22 global prScore long 10 23 global prOrder ulong 10 24 global prSt ulong 16 25 global prPath uchar 4096 26 global prBuf uchar 65536 27 28 text prMRank "rank" 29 text prMSelf "selfcheck" 30 text prUsage "usage: om_prior rank SPEC_FILE | selfcheck\n" 31 text prErrIo "om_prior: I/O error\n" 32 text prPre "PRIOR_ORDER" 33 text prFeats " features=" 34 text prSp " " 35 text prNl "\n" 36 text prSelfOk "OM_PRIOR SELFCHECK PASS tasks=6/6 top4_recall=6/6 features=24 ops=10\n" 37 text prSelfFail "OM_PRIOR SELFCHECK FAIL step=" 38 39 text kwArity "arity " 40 text kwCase "case " 41 text kwArityU "ARITY" 42 text kwCaseU "CASE" 43 44 fn prWStr fd int s view uchar * to void 45 r = write fd s 0 len s 46 end 47 48 fn prWNum fd int v ulong to void 49 b = new uchar 24 0 50 p = ulong 24 51 x = v 52 while true bound 24 53 p = sub p 1 54 put b p uchar add 48 rem x 10 55 x = div x 10 56 if eq x 0 57 break 58 end 59 end 60 r = write fd b p sub 24 p 61 end 62 63 fn prEqTxt a view uchar * al ulong b view uchar * to bool 64 if ne al len b 65 ret false 66 end 67 for i ulong al bound 64 68 if ne get a i get b i 69 ret false 70 end 71 end 72 ret true 73 end 74 75 note Parse decimal ulong from prBuf starting at pos; writes end pos to prSt[10] 76 fn prParseNum pos ulong n ulong to ulong 77 p = pos 78 while lt p n bound 65536 79 c = ulong get prBuf p 80 if and ne c 32 ne c 9 81 break 82 end 83 p = add p 1 84 end 85 v = ulong 0 86 while lt p n bound 65536 87 c = ulong get prBuf p 88 if or lt c 48 gt c 57 89 break 90 end 91 v = add mul v 10 sub c 48 92 p = add p 1 93 end 94 put prSt 10 p 95 ret v 96 end 97 98 fn prMatchKw pos ulong n ulong kw view uchar * to bool 99 kl = len kw 100 if gt add pos kl n 101 ret false 102 end 103 for i ulong kl bound 32 104 if ne get prBuf add pos i get kw i 105 ret false 106 end 107 end 108 ret true 109 end 110 111 fn prLoadSpec pathLen ulong to bool 112 fd = fopen prPath 0 pathLen 0 0 113 if lt fd 0 114 ret false 115 end 116 n = read int fd prBuf 0 65536 117 c = fclose int fd 118 if le n 0 119 ret false 120 end 121 put prSt 0 0 122 put prSt 1 1 123 p = ulong 0 124 un = ulong n 125 while lt p un bound 65536 126 lend = p 127 while lt lend un bound 4096 128 if eq ulong get prBuf lend 10 129 break 130 end 131 lend = add lend 1 132 end 133 if or prMatchKw p lend kwArity prMatchKw p lend kwArityU 134 ar = prParseNum add p 5 lend 135 put prSt 1 ar 136 end 137 if or prMatchKw p lend kwCase prMatchKw p lend kwCaseU 138 nc = get prSt 0 139 if lt nc 8 140 ar = get prSt 1 141 a = prParseNum add p 4 lend 142 q = get prSt 10 143 b = ulong 0 144 cv = ulong 0 145 if ge ar 2 146 b = prParseNum q lend 147 q = get prSt 10 148 end 149 if ge ar 3 150 cv = prParseNum q lend 151 q = get prSt 10 152 end 153 t = prParseNum q lend 154 put prInA nc a 155 put prInB nc b 156 put prInC nc cv 157 put prTgt nc t 158 put prSt 0 add nc 1 159 end 160 end 161 p = add lend 1 162 end 163 ret gt get prSt 0 0 164 end 165 166 note Extract 24 structural I/O behavior features from (prInA, prInB, prTgt) 167 fn prFeatBasic nc ulong to void 168 put prFeat 0 1 169 put prFeat 1 1 170 put prFeat 2 1 171 put prFeat 3 1 172 put prFeat 4 1 173 put prFeat 11 1 174 put prFeat 12 0 175 bigIn = ulong 0 176 for i ulong nc bound 8 177 a = get prInA i 178 t = get prTgt i 179 if gt t 1 180 put prFeat 0 0 181 end 182 if gt t 63 183 put prFeat 1 0 184 end 185 if gt t 255 186 put prFeat 2 0 187 end 188 if gt a 255 189 bigIn = 1 190 end 191 if lt t a 192 put prFeat 3 0 193 end 194 if gt t a 195 put prFeat 4 0 196 end 197 if eq a 0 198 if ne t 0 199 put prFeat 11 0 200 put prFeat 12 1 201 end 202 end 203 end 204 put prFeat 2 and get prFeat 2 bigIn 205 end 206 207 fn prFeatMono nc ulong to void 208 put prFeat 5 1 209 put prFeat 6 0 210 for i ulong nc bound 8 211 ai = get prInA i 212 ti = get prTgt i 213 for j ulong nc bound 8 214 if and lt ai get prInA j gt ti get prTgt j 215 put prFeat 5 0 216 put prFeat 6 1 217 end 218 end 219 end 220 end 221 222 fn prFeatDiff nc ulong to void 223 put prFeat 7 1 224 put prFeat 8 1 225 put prFeat 9 1 226 put prFeat 13 0 227 haveD = ulong 0 228 d0 = ulong 0 229 for i ulong nc bound 8 230 a = get prInA i 231 t = get prTgt i 232 if gt t add mul a 2 16 233 put prFeat 13 1 234 end 235 if ge t a 236 if eq haveD 0 237 d0 = sub t a 238 haveD = 1 239 else 240 if ne sub t a d0 241 put prFeat 7 0 242 end 243 end 244 if gt sub t a 0 245 put prFeat 9 0 246 end 247 else 248 put prFeat 7 0 249 if ge sub a t 64 250 put prFeat 9 0 251 end 252 end 253 end 254 put prFeat 9 and get prFeat 9 get prFeat 4 255 end 256 257 fn prFeatRatio nc ulong to void 258 haveR = ulong 0 259 r0 = ulong 0 260 for i ulong nc bound 8 261 a = get prInA i 262 t = get prTgt i 263 if gt a 0 264 if ne rem t a 0 265 put prFeat 8 0 266 else 267 if eq haveR 0 268 r0 = div t a 269 haveR = 1 270 else 271 if ne div t a r0 272 put prFeat 8 0 273 end 274 end 275 end 276 end 277 end 278 if eq haveR 0 279 put prFeat 8 0 280 end 281 end 282 283 fn prFeatBits nc ulong to void 284 put prFeat 10 1 285 put prFeat 14 1 286 put prFeat 15 1 287 put prFeat 20 1 288 put prFeat 21 0 289 put prFeat 23 0 290 for i ulong nc bound 8 291 a = get prInA i 292 t = get prTgt i 293 if and gt t 0 ne and t 1 0 294 put prFeat 10 0 295 end 296 if ne and t a t 297 put prFeat 14 0 298 end 299 if ne and t a a 300 put prFeat 15 0 301 end 302 if and gt a 0 eq t 0 303 put prFeat 21 1 304 end 305 if ne shr t 4 shr a 4 306 put prFeat 23 1 307 end 308 if and gt a 0 gt t 0 309 if and ne t shr a 1 and ne t shr a 2 and ne t shl a 1 ne t shl a 2 310 put prFeat 20 0 311 end 312 end 313 end 314 end 315 316 fn prFeatArity2 nc ulong ar ulong to void 317 if lt ar 2 318 put prFeat 16 0 319 put prFeat 17 0 320 put prFeat 18 0 321 put prFeat 19 0 322 else 323 put prFeat 16 1 324 put prFeat 17 1 325 put prFeat 18 1 326 put prFeat 19 1 327 for i ulong nc bound 8 328 a = get prInA i 329 b = get prInB i 330 t = get prTgt i 331 if or lt t a lt t b 332 put prFeat 17 0 333 end 334 if or gt t a gt t b 335 put prFeat 18 0 336 end 337 if ne and t 1 and xor a b 1 338 put prFeat 19 0 339 end 340 if gt t add a b 341 put prFeat 16 0 342 end 343 end 344 end 345 d0 = get prTgt 0 346 d1 = d0 347 d2 = d0 348 cnt = ulong 1 349 for i ulong nc bound 8 350 t = get prTgt i 351 if and ne t d0 and ne t d1 ne t d2 352 if eq cnt 1 353 d1 = t 354 cnt = 2 355 else 356 if eq cnt 2 357 d2 = t 358 cnt = 3 359 else 360 cnt = 4 361 end 362 end 363 end 364 end 365 if le cnt 3 366 put prFeat 22 1 367 else 368 put prFeat 22 0 369 end 370 end 371 372 fn prExtractAll to void 373 nc = get prSt 0 374 ar = get prSt 1 375 for i ulong 24 bound 24 376 put prFeat i 0 377 end 378 prFeatBasic nc 379 prFeatMono nc 380 prFeatDiff nc 381 prFeatRatio nc 382 prFeatBits nc 383 prFeatArity2 nc ar 384 end 385 386 note Helper: add weighted feature f into op index oi (0..9 -> ops 4..13) 387 fn prAddW oi ulong f ulong w long to void 388 if ne get prFeat f 0 389 put prScore oi add get prScore oi w 390 end 391 end 392 393 note Linear neuro-symbolic scoring head over 24 I/O features -> 10 OM-2 ops 394 note oi: 0=add(4), 1=sub(5), 2=mul(6), 3=div(7), 4=rem(8), 5=and(9), 6=or(10), 7=xor(11), 8=shl(12), 9=shr(13) 395 fn prScoreOps to void 396 for i ulong 10 bound 10 397 put prScore i 10 398 end 399 note ADD (0): ge_a, mono, const_diff, zero_nonz, ar2_ge_both, parity_corr 400 prAddW 0 3 20 401 prAddW 0 5 10 402 prAddW 0 7 40 403 prAddW 0 12 20 404 prAddW 0 17 25 405 prAddW 0 19 15 406 prAddW 0 0 neg long 15 407 note SUB (1): le_a, non_mono, sub_a_le_k, ar2_parity, not ge_a 408 prAddW 1 4 25 409 prAddW 1 6 15 410 prAddW 1 9 40 411 prAddW 1 19 15 412 prAddW 1 12 10 413 note MUL (2): ge_a, mono, const_ratio, zero_pres, superlin, even, ar2_ge_both 414 prAddW 2 3 20 415 prAddW 2 5 15 416 prAddW 2 8 45 417 prAddW 2 11 15 418 prAddW 2 13 35 419 prAddW 2 10 15 420 prAddW 2 17 20 421 prAddW 2 0 neg long 20 422 note DIV (3): le_a, mono, zero_pres, has_zero_tgt, ar2_le_both 423 prAddW 3 4 25 424 prAddW 3 5 20 425 prAddW 3 11 15 426 prAddW 3 21 25 427 prAddW 3 18 15 428 note REM (4): le_a, non_mono, small_rng, sub_a_le_k, zero_pres, has_zero_tgt, pow2_bound 429 prAddW 4 4 25 430 prAddW 4 6 25 431 prAddW 4 1 15 432 prAddW 4 9 35 433 prAddW 4 11 15 434 prAddW 4 21 20 435 prAddW 4 2 15 436 note AND (5): le_a, bin01, small_rng, pow2_bound, non_mono, bit_subset, has_zero_tgt, ar2_le_both, distinct_small 437 prAddW 5 0 35 438 prAddW 5 1 20 439 prAddW 5 2 25 440 prAddW 5 4 20 441 prAddW 5 6 15 442 prAddW 5 14 40 443 prAddW 5 21 20 444 prAddW 5 18 25 445 prAddW 5 22 20 446 note OR (6): ge_a, bit_superset, zero_nonz, ar2_ge_both 447 prAddW 6 3 20 448 prAddW 6 15 45 449 prAddW 6 12 15 450 prAddW 6 17 20 451 note XOR (7): non_mono, parity_corr, zero_nonz, high_bits_chg 452 prAddW 7 6 25 453 prAddW 7 19 35 454 prAddW 7 12 15 455 prAddW 7 23 15 456 note SHL (8): ge_a, mono, const_ratio, even, superlin, pow2_ratio, zero_pres 457 prAddW 8 3 15 458 prAddW 8 5 15 459 prAddW 8 8 35 460 prAddW 8 10 25 461 prAddW 8 13 25 462 prAddW 8 20 40 463 prAddW 8 11 15 464 note SHR (9): le_a, bin01, small_rng, mono, pow2_ratio, has_zero_tgt, zero_pres, distinct_small 465 prAddW 9 0 30 466 prAddW 9 1 20 467 prAddW 9 4 20 468 prAddW 9 5 15 469 prAddW 9 20 40 470 prAddW 9 21 25 471 prAddW 9 11 15 472 prAddW 9 22 20 473 end 474 475 note Stable insertion sort of op indices 0..9 by descending prScore -> opCodes 4..13 in prOrder 476 fn prRankOps to void 477 for i ulong 10 bound 10 478 put prOrder i i 479 end 480 for i ulong 10 bound 10 481 best = i 482 j = add i 1 483 while lt j 10 bound 10 484 if gt get prScore get prOrder j get prScore get prOrder best 485 best = j 486 end 487 j = add j 1 488 end 489 tmp = get prOrder i 490 put prOrder i get prOrder best 491 put prOrder best tmp 492 end 493 for i ulong 10 bound 10 494 put prOrder i add get prOrder i 4 495 end 496 end 497 498 fn prInTopK op ulong k ulong to bool 499 for i ulong k bound 10 500 if eq get prOrder i op 501 ret true 502 end 503 end 504 ret false 505 end 506 507 fn prRunSelfcheck to int 508 note 1. c1-03 class: bit-extract (a >> 5) & 1 -> expects AND(9) and SHR(13) in top 4 509 put prSt 0 8 510 put prSt 1 1 511 put prInA 0 0 512 put prInA 1 31 513 put prInA 2 32 514 put prInA 3 63 515 put prInA 4 64 516 put prInA 5 96 517 put prInA 6 100 518 put prInA 7 255 519 for i ulong 8 bound 8 520 put prTgt i and shr get prInA i 5 1 521 end 522 prExtractAll 523 prScoreOps 524 prRankOps 525 if or not prInTopK 9 4 not prInTopK 13 4 526 prWStr 2 prSelfFail 527 prWNum 2 1 528 prWStr 2 prNl 529 ret 1 530 end 531 532 note 2. c1-11 class: floor-multiple a - (a % 14) -> expects SUB(5) and REM(8) in top 4 533 put prInA 0 0 534 put prInA 1 13 535 put prInA 2 14 536 put prInA 3 15 537 put prInA 4 27 538 put prInA 5 28 539 put prInA 6 99 540 put prInA 7 140 541 for i ulong 8 bound 8 542 put prTgt i sub get prInA i rem get prInA i 14 543 end 544 prExtractAll 545 prScoreOps 546 prRankOps 547 if or not prInTopK 5 4 not prInTopK 8 4 548 prWStr 2 prSelfFail 549 prWNum 2 2 550 prWStr 2 prNl 551 ret 1 552 end 553 554 note 3. Linear offset: a + 17 -> expects ADD(4) in top 4 555 for i ulong 8 bound 8 556 put prInA i mul i 9 557 put prTgt i add mul i 9 17 558 end 559 prExtractAll 560 prScoreOps 561 prRankOps 562 if not prInTopK 4 4 563 prWStr 2 prSelfFail 564 prWNum 2 3 565 prWStr 2 prNl 566 ret 1 567 end 568 569 note 4. Bitwise set: a | 8 -> expects OR(10) in top 4 570 for i ulong 8 bound 8 571 put prInA i mul i 3 572 put prTgt i or mul i 3 8 573 end 574 prExtractAll 575 prScoreOps 576 prRankOps 577 if not prInTopK 10 4 578 prWStr 2 prSelfFail 579 prWNum 2 4 580 prWStr 2 prNl 581 ret 1 582 end 583 584 note 5. Binary XOR: a ^ b -> expects XOR(11) in top 4 585 put prSt 1 2 586 for i ulong 8 bound 8 587 put prInA i add mul i 5 3 588 put prInB i add mul i 7 1 589 put prTgt i xor get prInA i get prInB i 590 end 591 prExtractAll 592 prScoreOps 593 prRankOps 594 if not prInTopK 11 4 595 prWStr 2 prSelfFail 596 prWNum 2 5 597 prWStr 2 prNl 598 ret 1 599 end 600 601 note 6. Power-of-2 shift / scale: a << 2 -> expects SHL(12) and MUL(6) in top 4 602 put prSt 1 1 603 for i ulong 8 bound 8 604 put prInA i add mul i 11 1 605 put prTgt i shl get prInA i 2 606 end 607 prExtractAll 608 prScoreOps 609 prRankOps 610 if or not prInTopK 12 4 not prInTopK 6 4 611 prWStr 2 prSelfFail 612 prWNum 2 6 613 prWStr 2 prNl 614 ret 1 615 end 616 617 prWStr 1 prSelfOk 618 ret 0 619 end 620 621 fn main to int 622 if lt argcnt 2 623 prWStr 2 prUsage 624 ret 2 625 end 626 mb = new uchar 64 0 627 ml = argread 1 mb 0 64 628 if le ml 0 629 prWStr 2 prUsage 630 ret 2 631 end 632 if prEqTxt mb ulong ml prMSelf 633 ret prRunSelfcheck 634 end 635 if prEqTxt mb ulong ml prMRank 636 if lt argcnt 3 637 prWStr 2 prUsage 638 ret 2 639 end 640 pl = argread 2 prPath 0 4096 641 if le pl 0 642 prWStr 2 prUsage 643 ret 2 644 end 645 if not prLoadSpec ulong pl 646 prWStr 2 prErrIo 647 ret 1 648 end 649 prExtractAll 650 prScoreOps 651 prRankOps 652 prWStr 1 prPre 653 for i ulong 10 bound 10 654 prWStr 1 prSp 655 prWNum 1 get prOrder i 656 end 657 prWStr 1 prFeats 658 cnt = ulong 0 659 for i ulong 24 bound 24 660 cnt = add cnt get prFeat i 661 end 662 prWNum 1 cnt 663 prWStr 1 prNl 664 ret 0 665 end 666 prWStr 2 prUsage 667 ret 2 668 end