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
omega-mv / seed / qualification / security673 / game / check.om
| 1 | note Independent SC1-G-v3 enumerator and rename safety monitor. |
| 2 | note Reverse-order in-place losing attractor, versus synchronous solver bitmaps. |
| 3 | global fields uint 5 |
| 4 | global costs uint 18 |
| 5 | global rules uint 18 |
| 6 | global submit uint 2593 |
| 7 | global chosen uint 2593 |
| 8 | global alive uchar 2593 |
| 9 | global counts ulong 3 |
| 10 | global pairs ulong 4 |
| 11 | global variant uint 1 |
| 12 | global claim uint 1 |
| 13 | fn refuse id uint to void |
| 14 | if eq id 8 |
| 15 | label 17 |
| 16 | exit 78 |
| 17 | end |
| 18 | label add id 8 |
| 19 | exit add int id 70 |
| 20 | end |
| 21 | fn witness s uint u uint d uint raw uint effect uint to void |
| 22 | label 26 |
| 23 | number ulong s |
| 24 | number ulong u |
| 25 | number ulong d |
| 26 | number ulong raw |
| 27 | number ulong effect |
| 28 | end |
| 29 | fn unpack s uint to void |
| 30 | put fields 0 rem s 18 |
| 31 | put fields 1 rem div s 18 18 |
| 32 | put fields 2 and div s 324 1 |
| 33 | put fields 3 and div s 648 1 |
| 34 | put fields 4 div s 1296 |
| 35 | end |
| 36 | fn pack to uint |
| 37 | n = get fields 4 |
| 38 | n = add mul n 2 get fields 3 |
| 39 | n = add mul n 2 get fields 2 |
| 40 | n = add mul n 18 get fields 1 |
| 41 | ret add mul n 18 get fields 0 |
| 42 | end |
| 43 | fn localok s uint to bool |
| 44 | if eq s 2592 |
| 45 | ret false |
| 46 | end |
| 47 | x = rem s 18 |
| 48 | y = rem div s 18 18 |
| 49 | if or eq x 17 eq y 17 |
| 50 | ret false |
| 51 | end |
| 52 | if gt add get costs x get costs y 3 |
| 53 | ret false |
| 54 | end |
| 55 | if ne rem div s 324 4 0 |
| 56 | if and ge x 15 le x 16 |
| 57 | ret false |
| 58 | end |
| 59 | if and ge y 15 le y 16 |
| 60 | ret false |
| 61 | end |
| 62 | end |
| 63 | ret true |
| 64 | end |
| 65 | fn actions s uint to uint |
| 66 | if not localok s |
| 67 | ret 0 |
| 68 | end |
| 69 | if ge s 1296 |
| 70 | ret 2 |
| 71 | end |
| 72 | x = rem s 18 |
| 73 | y = rem div s 18 18 |
| 74 | m = shl get rules x 2 |
| 75 | m = or m shl get rules y 10 |
| 76 | if gt add get costs x get costs y 1 |
| 77 | m = and m not uint 1028 |
| 78 | end |
| 79 | if ne rem div s 324 4 0 |
| 80 | m = and m not uint 131584 |
| 81 | end |
| 82 | if and or eq x 0 eq x 14 or eq y 0 eq y 14 |
| 83 | m = or m 1 |
| 84 | end |
| 85 | ret m |
| 86 | end |
| 87 | fn init to void |
| 88 | for p uint 18 |
| 89 | put costs p 2 |
| 90 | end |
| 91 | put costs 0 0 |
| 92 | put costs 1 0 |
| 93 | put costs 12 1 |
| 94 | put costs 13 1 |
| 95 | put costs 14 1 |
| 96 | put rules 1 3 |
| 97 | put rules 2 6 |
| 98 | for p uint 4 |
| 99 | put rules add p 3 138 |
| 100 | put rules add p 7 18 |
| 101 | end |
| 102 | put rules 11 32 |
| 103 | put rules 12 64 |
| 104 | put rules 13 64 |
| 105 | put rules 15 48 |
| 106 | put rules 16 128 |
| 107 | for s uint 2593 |
| 108 | put alive s 0 |
| 109 | if localok s |
| 110 | put alive s 1 |
| 111 | end |
| 112 | end |
| 113 | end |
| 114 | fn disturb d uint to void |
| 115 | if eq d 4 |
| 116 | put fields 3 1 |
| 117 | end |
| 118 | if eq d 3 |
| 119 | put fields 2 1 |
| 120 | end |
| 121 | if eq d 2 |
| 122 | if eq get fields 1 0 |
| 123 | put fields 1 1 |
| 124 | end |
| 125 | end |
| 126 | if eq d 1 |
| 127 | if eq get fields 0 0 |
| 128 | put fields 0 1 |
| 129 | end |
| 130 | end |
| 131 | end |
| 132 | fn special c uint k uint d uint to uint |
| 133 | p = get fields c |
| 134 | if or eq d 7 and eq p 15 eq d 6 |
| 135 | ret pack |
| 136 | end |
| 137 | if eq d 5 |
| 138 | put fields c 0 |
| 139 | put fields 4 1 |
| 140 | ret pack |
| 141 | end |
| 142 | if or eq d 3 eq d 4 |
| 143 | if eq p 15 |
| 144 | if eq add k d 8 |
| 145 | ret 2592 |
| 146 | end |
| 147 | end |
| 148 | put fields c 0 |
| 149 | disturb d |
| 150 | ret pack |
| 151 | end |
| 152 | if eq p 16 |
| 153 | put fields c 15 |
| 154 | else |
| 155 | put fields c 14 |
| 156 | end |
| 157 | disturb d |
| 158 | ret pack |
| 159 | end |
| 160 | fn reconc to uint |
| 161 | for c uint 2 |
| 162 | p = get fields c |
| 163 | if ge p 15 |
| 164 | ret 2592 |
| 165 | end |
| 166 | if and ge p 2 lt p 11 |
| 167 | put fields c 0 |
| 168 | end |
| 169 | if eq p 11 |
| 170 | put fields c 12 |
| 171 | end |
| 172 | end |
| 173 | put fields 4 0 |
| 174 | ret pack |
| 175 | end |
| 176 | fn enact c uint k uint d uint to uint |
| 177 | p = get fields c |
| 178 | q = p |
| 179 | if eq k 7 |
| 180 | if eq add get fields 2 get fields 3 0 |
| 181 | q = 16 |
| 182 | end |
| 183 | end |
| 184 | if eq k 6 |
| 185 | q = 14 |
| 186 | if eq d 8 |
| 187 | q = 13 |
| 188 | end |
| 189 | end |
| 190 | if eq k 5 |
| 191 | if ne d 6 |
| 192 | q = 12 |
| 193 | if eq d 8 |
| 194 | q = 13 |
| 195 | end |
| 196 | end |
| 197 | end |
| 198 | if eq k 4 |
| 199 | t = add get fields 2 mul get fields 3 2 |
| 200 | if eq sub p 7 t |
| 201 | q = 11 |
| 202 | end |
| 203 | end |
| 204 | if eq k 3 |
| 205 | if ne d 6 |
| 206 | q = add p 4 |
| 207 | end |
| 208 | end |
| 209 | if eq k 2 |
| 210 | q = add uint 3 add get fields 2 mul get fields 3 2 |
| 211 | end |
| 212 | if eq k 1 |
| 213 | q = 0 |
| 214 | end |
| 215 | if eq k 0 |
| 216 | q = 2 |
| 217 | end |
| 218 | put fields c q |
| 219 | ret pack |
| 220 | end |
| 221 | fn oracle s uint u uint d uint to uint |
| 222 | if eq and actions s shl uint 1 u 0 |
| 223 | ret 2592 |
| 224 | end |
| 225 | unpack s |
| 226 | if ge u 2 |
| 227 | c = uint 0 |
| 228 | if ge u 10 |
| 229 | c = 1 |
| 230 | end |
| 231 | p = get fields c |
| 232 | if and ge p 15 le p 16 |
| 233 | ret special c rem sub u 2 8 d |
| 234 | end |
| 235 | end |
| 236 | if eq d 7 |
| 237 | ret s |
| 238 | end |
| 239 | if eq d 5 |
| 240 | put fields 4 1 |
| 241 | ret pack |
| 242 | end |
| 243 | disturb d |
| 244 | if eq u 1 |
| 245 | ret reconc |
| 246 | end |
| 247 | if eq u 0 |
| 248 | ret pack |
| 249 | end |
| 250 | ret enact div sub u 2 8 rem sub u 2 8 d |
| 251 | end |
| 252 | fn clientphase s uint c uint to uint |
| 253 | if eq c 1 |
| 254 | s = div s 18 |
| 255 | end |
| 256 | ret rem s 18 |
| 257 | end |
| 258 | fn monitor s uint u uint d uint got uint to uint |
| 259 | if or lt u 2 ge got 2592 |
| 260 | ret 0 |
| 261 | end |
| 262 | c = div sub u 2 8 |
| 263 | p = clientphase s c |
| 264 | q = clientphase got c |
| 265 | if and eq p 11 eq q 17 |
| 266 | ret 4 |
| 267 | end |
| 268 | if ne rem sub u 2 8 4 |
| 269 | ret 0 |
| 270 | end |
| 271 | if or lt p 7 gt p 10 |
| 272 | ret 0 |
| 273 | end |
| 274 | if ne q 11 |
| 275 | ret 0 |
| 276 | end |
| 277 | e = and div s 324 1 |
| 278 | v = and div s 648 1 |
| 279 | if eq d 3 |
| 280 | e = 1 |
| 281 | end |
| 282 | if eq d 4 |
| 283 | v = 1 |
| 284 | end |
| 285 | if ne sub p 7 add e mul v 2 |
| 286 | ret 3 |
| 287 | end |
| 288 | ret 0 |
| 289 | end |
| 290 | fn readstate s uint to void |
| 291 | m = recvword |
| 292 | if ne m actions s |
| 293 | refuse 7 |
| 294 | end |
| 295 | put submit s recvword |
| 296 | put chosen s recvword |
| 297 | for u uint 18 |
| 298 | if ne and m shl uint 1 u 0 |
| 299 | for d uint 9 |
| 300 | got = recvword |
| 301 | if ge got 2593 |
| 302 | refuse 7 |
| 303 | end |
| 304 | bad = monitor s u d got |
| 305 | if ne bad 0 |
| 306 | witness s u d got 2592 |
| 307 | refuse bad |
| 308 | end |
| 309 | want = oracle s u d |
| 310 | put counts 0 add get counts 0 1 |
| 311 | if ne got want |
| 312 | witness s u d got want |
| 313 | label 27 |
| 314 | exit 79 |
| 315 | end |
| 316 | end |
| 317 | end |
| 318 | end |
| 319 | end |
| 320 | fn allwithin s uint u uint nd uint to bool |
| 321 | if or eq nd 0 gt nd 9 |
| 322 | ret false |
| 323 | end |
| 324 | if eq and actions s shl uint 1 u 0 |
| 325 | ret false |
| 326 | end |
| 327 | d = nd |
| 328 | while gt d 0 bound 9 |
| 329 | d = sub d 1 |
| 330 | y = oracle s u d |
| 331 | if eq get alive y 0 |
| 332 | ret false |
| 333 | end |
| 334 | end |
| 335 | ret true |
| 336 | end |
| 337 | fn allsafe s uint u uint to bool |
| 338 | ret allwithin s u 9 |
| 339 | end |
| 340 | fn actionmask s uint to uint |
| 341 | m = uint 0 |
| 342 | u = uint 18 |
| 343 | while gt u 0 bound 18 |
| 344 | u = sub u 1 |
| 345 | if allsafe s u |
| 346 | m = or m shl uint 1 u |
| 347 | end |
| 348 | end |
| 349 | ret m |
| 350 | end |
| 351 | fn attractor to void |
| 352 | change = true |
| 353 | while change bound 2594 |
| 354 | change = false |
| 355 | put counts 1 add get counts 1 1 |
| 356 | s = uint 2593 |
| 357 | while gt s 0 bound 2593 |
| 358 | s = sub s 1 |
| 359 | if ne get alive s 0 |
| 360 | if eq actionmask s 0 |
| 361 | put alive s 0 |
| 362 | change = true |
| 363 | end |
| 364 | end |
| 365 | end |
| 366 | end |
| 367 | end |
| 368 | fn closurefail s uint u uint d uint y uint to void |
| 369 | witness s u d y y |
| 370 | label 28 |
| 371 | note Untrusted experiment label annotates an observed closure violation, not its inferred cause. |
| 372 | v = get claim 0 |
| 373 | if or eq v 1 or eq v 2 eq v 6 |
| 374 | refuse v |
| 375 | end |
| 376 | exit 80 |
| 377 | end |
| 378 | fn closeone s uint to void |
| 379 | m = get submit s |
| 380 | if eq m 0 |
| 381 | ret |
| 382 | end |
| 383 | if not localok s |
| 384 | witness s 18 9 s s |
| 385 | label 29 |
| 386 | exit 81 |
| 387 | end |
| 388 | if ne and m not actions s 0 |
| 389 | witness s 18 9 m actions s |
| 390 | label 30 |
| 391 | exit 82 |
| 392 | end |
| 393 | for u uint 18 |
| 394 | if ne and m shl uint 1 u 0 |
| 395 | for d uint 9 |
| 396 | y = oracle s u d |
| 397 | if eq get submit y 0 |
| 398 | closurefail s u d y |
| 399 | end |
| 400 | end |
| 401 | end |
| 402 | end |
| 403 | end |
| 404 | fn validate to void |
| 405 | if eq get submit fixture 0 0 |
| 406 | refuse 7 |
| 407 | end |
| 408 | for s uint 2593 |
| 409 | closeone s |
| 410 | end |
| 411 | for s uint 2593 |
| 412 | m = uint 0 |
| 413 | if ne get alive s 0 |
| 414 | m = actionmask s |
| 415 | put counts 2 add get counts 2 1 |
| 416 | end |
| 417 | if ne get submit s m |
| 418 | witness s 18 9 get submit s m |
| 419 | label 31 |
| 420 | exit 83 |
| 421 | end |
| 422 | end |
| 423 | end |
| 424 | fn require b bool to void |
| 425 | if not b |
| 426 | refuse 7 |
| 427 | end |
| 428 | end |
| 429 | fn rank s uint identity uint to uint |
| 430 | if ne identity 1 |
| 431 | ret 18 |
| 432 | end |
| 433 | best = uint 18 |
| 434 | price = uint 99 |
| 435 | for u uint 18 |
| 436 | if ne and get submit s shl uint 1 u 0 |
| 437 | p = uint 2 |
| 438 | if lt u 2 |
| 439 | p = 1 |
| 440 | else |
| 441 | k = rem sub u 2 8 |
| 442 | if eq k 7 |
| 443 | p = 0 |
| 444 | end |
| 445 | if eq k 1 |
| 446 | p = 4 |
| 447 | end |
| 448 | end |
| 449 | if lt p price |
| 450 | price = p |
| 451 | best = u |
| 452 | end |
| 453 | end |
| 454 | end |
| 455 | ret best |
| 456 | end |
| 457 | fn selections to void |
| 458 | for s uint 2593 |
| 459 | u = get chosen s |
| 460 | if eq get submit s 0 |
| 461 | require eq u 18 |
| 462 | else |
| 463 | if ge u 18 |
| 464 | witness s u 9 2592 2592 |
| 465 | refuse 5 |
| 466 | end |
| 467 | if eq and get submit s shl uint 1 u 0 |
| 468 | witness s u 9 u get submit s |
| 469 | refuse 5 |
| 470 | end |
| 471 | if ne u rank s 1 |
| 472 | witness s u 9 u rank s 1 |
| 473 | label 32 |
| 474 | exit 84 |
| 475 | end |
| 476 | if ge u 2 |
| 477 | require ne rem sub u 2 8 7 |
| 478 | end |
| 479 | require eq rank s 0 18 |
| 480 | require eq rank s 2 18 |
| 481 | end |
| 482 | end |
| 483 | end |
| 484 | fn serial s uint u uint d uint to uint |
| 485 | require ne get submit s 0 |
| 486 | require ne and get submit s shl uint 1 u 0 |
| 487 | y = oracle s u d |
| 488 | require ne get submit y 0 |
| 489 | ret y |
| 490 | end |
| 491 | fn observation secret uint protect bool to uint |
| 492 | used = secret |
| 493 | if protect |
| 494 | used = 2 |
| 495 | end |
| 496 | note Public envelope size2 within public capacity3 and fixed release identity1. |
| 497 | ret add sub uint 3 used 16 |
| 498 | end |
| 499 | fn witnesses to void |
| 500 | require localok fixture 1 |
| 501 | require eq get alive fixture 1 0 |
| 502 | require eq get alive fixture 2 0 |
| 503 | require eq oracle fixture 1 6 4 fixture 8 |
| 504 | require eq oracle fixture 1 7 3 fixture 8 |
| 505 | require eq oracle fixture 3 6 0 fixture 3 |
| 506 | require eq oracle fixture 4 7 6 fixture 4 |
| 507 | require eq and actions fixture 5 shl uint 1 10 0 |
| 508 | require ne and actions fixture 6 shl uint 1 10 0 |
| 509 | note Every step uses the submitted safe certificate, not only the transition relation. |
| 510 | s = serial fixture 0 0 1 |
| 511 | s = serial s 2 2 |
| 512 | require eq s fixture 5 |
| 513 | s = serial s 4 0 |
| 514 | s = serial s 5 0 |
| 515 | s = serial s 6 0 |
| 516 | s = serial s 7 0 |
| 517 | s = serial s 8 0 |
| 518 | require eq s fixture 6 |
| 519 | s = serial s 10 0 |
| 520 | s = serial s 12 0 |
| 521 | s = serial s 13 0 |
| 522 | s = serial s 14 0 |
| 523 | s = serial s 15 0 |
| 524 | s = serial s 16 0 |
| 525 | require eq s fixture 7 |
| 526 | require eq add get costs rem s 18 get costs rem div s 18 18 2 |
| 527 | require eq actions fixture 8 0 |
| 528 | require eq oracle fixture 8 0 0 fixture 8 |
| 529 | require eq oracle fixture 0 0 0 fixture 0 |
| 530 | require not allwithin 0 0 0 |
| 531 | require not allwithin 0 0 10 |
| 532 | require eq observation 1 true observation 2 true |
| 533 | require ne observation 1 false observation 2 false |
| 534 | label 16 |
| 535 | end |
| 536 | fn envelope s uint to bool |
| 537 | if ge s 2592 |
| 538 | ret false |
| 539 | end |
| 540 | ret or eq get costs rem s 18 2 eq get costs rem div s 18 18 2 |
| 541 | end |
| 542 | fn hidden s uint h uint to bool |
| 543 | if envelope s |
| 544 | ret or eq h 1 eq h 2 |
| 545 | end |
| 546 | ret eq h 0 |
| 547 | end |
| 548 | fn pairmask s uint h uint to uint |
| 549 | if not hidden s h |
| 550 | refuse 8 |
| 551 | end |
| 552 | m = actions s |
| 553 | note Negative baseline incorrectly uses physical hidden occupancy instead of full reservation. |
| 554 | if and eq get variant 0 8 eq h 1 |
| 555 | if eq rem s 18 1 |
| 556 | m = or m 4 |
| 557 | end |
| 558 | if eq rem div s 18 18 1 |
| 559 | m = or m 1024 |
| 560 | end |
| 561 | end |
| 562 | ret m |
| 563 | end |
| 564 | fn pairnext s uint u uint d uint h uint to uint |
| 565 | if not hidden s h |
| 566 | refuse 8 |
| 567 | end |
| 568 | note Actual game relation, independently compared to every submitted solver edge. |
| 569 | ret oracle s u d |
| 570 | end |
| 571 | fn publicob s uint h uint to uint |
| 572 | if not hidden s h |
| 573 | refuse 8 |
| 574 | end |
| 575 | if eq s 2592 |
| 576 | ret 2592 |
| 577 | end |
| 578 | q = add get costs rem s 18 get costs rem div s 18 18 |
| 579 | if gt q 3 |
| 580 | ret 2592 |
| 581 | end |
| 582 | note Available public capacity plus whole-service ready/recovery class. |
| 583 | ret add sub uint 3 q mul div s 1296 4 |
| 584 | end |
| 585 | fn newlabel s uint old uint to uint |
| 586 | if envelope s |
| 587 | if eq old 0 |
| 588 | ret 1 |
| 589 | end |
| 590 | ret old |
| 591 | end |
| 592 | ret 0 |
| 593 | end |
| 594 | fn pairselect s uint h uint to uint |
| 595 | m = pairmask s h |
| 596 | if ne and get submit s not m 0 |
| 597 | witness s 18 9 get submit s m |
| 598 | refuse 8 |
| 599 | end |
| 600 | ret get chosen s |
| 601 | end |
| 602 | fn pairrun s uint h1 uint h2 uint to void |
| 603 | m = pairmask s h1 |
| 604 | if ne m pairmask s h2 |
| 605 | witness s 18 9 m pairmask s h2 |
| 606 | refuse 8 |
| 607 | end |
| 608 | if ne pairselect s h1 pairselect s h2 |
| 609 | refuse 8 |
| 610 | end |
| 611 | m = get submit s |
| 612 | if ne publicob s h1 publicob s h2 |
| 613 | refuse 8 |
| 614 | end |
| 615 | for u uint 18 |
| 616 | if ne and m shl uint 1 u 0 |
| 617 | for d uint 9 |
| 618 | x = pairnext s u d h1 |
| 619 | y = pairnext s u d h2 |
| 620 | if ne x y |
| 621 | refuse 8 |
| 622 | end |
| 623 | if eq get submit x 0 |
| 624 | refuse 8 |
| 625 | end |
| 626 | if ne publicob x newlabel x h1 publicob y newlabel y h2 |
| 627 | refuse 8 |
| 628 | end |
| 629 | if eq h1 h2 |
| 630 | put pairs 3 add get pairs 3 1 |
| 631 | else |
| 632 | put pairs 1 add get pairs 1 1 |
| 633 | end |
| 634 | end |
| 635 | end |
| 636 | end |
| 637 | end |
| 638 | fn product to void |
| 639 | for s uint 2593 |
| 640 | if localok s |
| 641 | if envelope s |
| 642 | put pairs 0 add get pairs 0 1 |
| 643 | pairrun s 1 2 |
| 644 | else |
| 645 | put pairs 2 add get pairs 2 1 |
| 646 | pairrun s 0 0 |
| 647 | end |
| 648 | end |
| 649 | end |
| 650 | end |
| 651 | fn checkonce to void |
| 652 | for i ulong 3 |
| 653 | put counts i 0 |
| 654 | end |
| 655 | for i ulong 4 |
| 656 | put pairs i 0 |
| 657 | end |
| 658 | init |
| 659 | if ne recvword 1396912455 |
| 660 | refuse 7 |
| 661 | end |
| 662 | if ne recvword 3 |
| 663 | refuse 7 |
| 664 | end |
| 665 | if ne recvword 2593 |
| 666 | refuse 7 |
| 667 | end |
| 668 | put claim 0 recvword |
| 669 | if gt get claim 0 6 |
| 670 | refuse 7 |
| 671 | end |
| 672 | for s uint 2593 |
| 673 | readstate s |
| 674 | end |
| 675 | endinput |
| 676 | attractor |
| 677 | validate |
| 678 | selections |
| 679 | product |
| 680 | end |
| 681 | fn main to int |
| 682 | m = mode |
| 683 | if and ne m 0 ne m 7 |
| 684 | ret 90 |
| 685 | end |
| 686 | put variant 0 fault |
| 687 | start = monons |
| 688 | checkonce |
| 689 | label 2 |
| 690 | number ulong sub monons start |
| 691 | witnesses |
| 692 | label 3 |
| 693 | number 2593 |
| 694 | label 4 |
| 695 | number get counts 0 |
| 696 | label 5 |
| 697 | number get counts 2 |
| 698 | label 6 |
| 699 | number get counts 1 |
| 700 | label 7 |
| 701 | number 28517 |
| 702 | label 18 |
| 703 | number get pairs 0 |
| 704 | label 19 |
| 705 | number get pairs 1 |
| 706 | label 24 |
| 707 | number get pairs 2 |
| 708 | label 25 |
| 709 | number get pairs 3 |
| 710 | if eq m 7 |
| 711 | for i ulong 101 |
| 712 | if ne fseek 0 0 0 0 |
| 713 | ret 90 |
| 714 | end |
| 715 | put pos 0 0 |
| 716 | put avail 0 0 |
| 717 | start = monons |
| 718 | checkonce |
| 719 | put samples i ulong sub monons start |
| 720 | end |
| 721 | percentiles |
| 722 | end |
| 723 | label 8 |
| 724 | ret 0 |
| 725 | end |