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 / tests / arboris / locality.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Four Entity records. Edges 0->1,0->3,3->0 (parallel),3->3 |
| 3 | note give degrees 3,1,0,4. Distinct weights exercise payload alignment. |
| 4 | fn al_fixture records edit uint 34 to void |
| 5 | put records 0 ar_record_v1 |
| 6 | put records 1 1 |
| 7 | put records 2 4 |
| 8 | put records 3 4 |
| 9 | put records 4 3 |
| 10 | put records 5 ar_one |
| 11 | for i ulong 4 |
| 12 | pos = add 18 mul 4 i |
| 13 | put records add pos 1 1 |
| 14 | put records add pos 3 sub ar_one uint shl i 21 |
| 15 | end |
| 16 | put records 20 1 |
| 17 | put records 24 3 |
| 18 | put records 26 3 |
| 19 | put records 30 3 |
| 20 | put records 32 3 |
| 21 | end |
| 22 | |
| 23 | fn al_bank_matches a view uint 12 b view uint 12 plan view uint 12 to bool |
| 24 | bank = add 4 mul 4 ulong get a 1 |
| 25 | for i ulong 4 |
| 26 | if ne get a add bank i get b add bank ulong get plan i |
| 27 | ret false |
| 28 | end |
| 29 | end |
| 30 | ret true |
| 31 | end |
| 32 | |
| 33 | fn al_equivalent records view uint 34 packed view uint 34 plan view uint 12 to bool |
| 34 | logical = new uint 16 0 |
| 35 | physical = new uint 16 0 |
| 36 | lw = new uint 8 0 |
| 37 | pw = new uint 8 0 |
| 38 | a = new uint 12 0 |
| 39 | b = new uint 12 0 |
| 40 | if or ne arboris_load_records records logical lw 0 ne arboris_load_records packed physical pw 0 |
| 41 | ret false |
| 42 | end |
| 43 | put a 0 1 |
| 44 | put b 0 1 |
| 45 | put a 2 0x3f000000 |
| 46 | put b 2 0x3f000000 |
| 47 | put a 5 ar_one |
| 48 | put b add 4 ulong get plan 1 ar_one |
| 49 | for hop ulong 3 |
| 50 | if or ne arboris_relax_step logical lw a 0 ne arboris_relax_step physical pw b 0 |
| 51 | ret false |
| 52 | end |
| 53 | if not al_bank_matches a b plan |
| 54 | ret false |
| 55 | end |
| 56 | end |
| 57 | ret true |
| 58 | end |
| 59 | |
| 60 | fn al_test to int |
| 61 | records = new uint 34 0 |
| 62 | packed = new uint 34 0 |
| 63 | plan = new uint 12 0 |
| 64 | order = new uint 4 0 |
| 65 | al_fixture records |
| 66 | for i ulong 4 |
| 67 | put order i uint sub 3 i |
| 68 | end |
| 69 | if ne arboris_plan_locality records order plan 0 |
| 70 | ret 31 |
| 71 | end |
| 72 | if or ne get plan 4 2 or ne get plan 5 1 or ne get plan 6 0 ne get plan 7 3 |
| 73 | ret 32 |
| 74 | end |
| 75 | if or ne arboris_pack_locality records plan packed 0 not al_equivalent records packed plan |
| 76 | ret 33 |
| 77 | end |
| 78 | put plan 0 0 |
| 79 | put packed 0 17 |
| 80 | if or ne arboris_pack_locality records plan packed 2 ne get packed 0 17 |
| 81 | ret 34 |
| 82 | end |
| 83 | put order 0 get order 1 |
| 84 | if ne arboris_plan_locality records order plan 3 |
| 85 | ret 35 |
| 86 | end |
| 87 | note With two degree-one pairs, every vertex stays in the same degree band. |
| 88 | put records 24 1 |
| 89 | put records 26 2 |
| 90 | put records 28 3 |
| 91 | put records 30 2 |
| 92 | put records 32 3 |
| 93 | put order 0 3 |
| 94 | if ne arboris_plan_locality records order plan 0 |
| 95 | ret 36 |
| 96 | end |
| 97 | for i ulong 4 |
| 98 | if ne get plan add 4 i get order i |
| 99 | ret 37 |
| 100 | end |
| 101 | end |
| 102 | ret 0 |
| 103 | end |