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 / train / aien-train / native / collective / shared_bank_p0.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note aien-train#26: first native .om sparse-collective algebraic experiment. |
| 3 | note ONE shared 2x3 matrix + EIGHT rank-one signed specialist differences. |
| 4 | note All data and scores are synthetic. No model checkpoint is loaded. |
| 5 | note This is neither a trained specialist nor a GPU/runtime dispatch implementation. |
| 6 | note Seeded omc names are at most 8 characters (error 13). bscore replaces bestscore. |
| 7 | note Full reference numbers independently calculated in Wolfram Language. |
| 8 | |
| 9 | global B long 6 |
| 10 | global U long 16 |
| 11 | global V long 24 |
| 12 | global X long 3 |
| 13 | global Shared long 2 |
| 14 | global Out long 2 |
| 15 | global Scores long 8 |
| 16 | global Allowed uchar 8 |
| 17 | global Counts ulong 2 |
| 18 | global Plus long 16 |
| 19 | global Minus long 16 |
| 20 | |
| 21 | fn init to void |
| 22 | put B 0 2 |
| 23 | put B 1 -1 |
| 24 | put B 2 3 |
| 25 | put B 3 1 |
| 26 | put B 4 0 |
| 27 | put B 5 -2 |
| 28 | put X 0 2 |
| 29 | put X 1 3 |
| 30 | put X 2 5 |
| 31 | put Scores 0 4 |
| 32 | put Scores 1 11 |
| 33 | put Scores 2 7 |
| 34 | put Scores 3 9 |
| 35 | put Scores 4 8 |
| 36 | put Scores 5 0 |
| 37 | put Scores 6 3 |
| 38 | put Scores 7 2 |
| 39 | for id ulong 8 |
| 40 | put Allowed id 1 |
| 41 | sid = long id |
| 42 | ui = mul id 2 |
| 43 | vi = mul id 3 |
| 44 | put U ui sub sid 3 |
| 45 | put U add ui 1 add sid 1 |
| 46 | put V vi 1 |
| 47 | put V add vi 1 sub 3 sid |
| 48 | put V add vi 2 -1 |
| 49 | end |
| 50 | put Counts 0 0 |
| 51 | put Counts 1 0 |
| 52 | put Plus 0 -2 |
| 53 | put Plus 1 -2 |
| 54 | put Plus 2 10 |
| 55 | put Plus 3 -2 |
| 56 | put Plus 4 16 |
| 57 | put Plus 5 -8 |
| 58 | put Plus 6 16 |
| 59 | put Plus 7 -20 |
| 60 | put Plus 8 10 |
| 61 | put Plus 9 -38 |
| 62 | put Plus 10 -2 |
| 63 | put Plus 11 -62 |
| 64 | put Plus 12 -20 |
| 65 | put Plus 13 -92 |
| 66 | put Plus 14 -44 |
| 67 | put Plus 15 -128 |
| 68 | put Minus 0 34 |
| 69 | put Minus 1 -14 |
| 70 | put Minus 2 22 |
| 71 | put Minus 3 -14 |
| 72 | put Minus 4 16 |
| 73 | put Minus 5 -8 |
| 74 | put Minus 6 16 |
| 75 | put Minus 7 4 |
| 76 | put Minus 8 22 |
| 77 | put Minus 9 22 |
| 78 | put Minus 10 34 |
| 79 | put Minus 11 46 |
| 80 | put Minus 12 52 |
| 81 | put Minus 13 76 |
| 82 | put Minus 14 76 |
| 83 | put Minus 15 112 |
| 84 | end |
| 85 | |
| 86 | fn makebase to void |
| 87 | for row ulong 2 |
| 88 | acc = long 0 |
| 89 | for col ulong 3 |
| 90 | idx = add mul row 3 col |
| 91 | z = mul get B idx get X col |
| 92 | acc = add acc z |
| 93 | end |
| 94 | put Shared row acc |
| 95 | end |
| 96 | put Counts 0 add get Counts 0 1 |
| 97 | end |
| 98 | |
| 99 | note Tiny synthetic admission only. Capability authority remains Omega/AEGIS. |
| 100 | note Returns index 8 if no candidate allowed, rather than silently dispatching. |
| 101 | fn pick used ulong to ulong |
| 102 | best = ulong 8 |
| 103 | bscore = long -9999 |
| 104 | for id ulong 8 |
| 105 | if eq get Allowed id 1 |
| 106 | flag = and used shl ulong 1 id |
| 107 | if eq flag 0 |
| 108 | score = get Scores id |
| 109 | if gt score bscore |
| 110 | bscore = score |
| 111 | best = id |
| 112 | end |
| 113 | end |
| 114 | end |
| 115 | end |
| 116 | ret best |
| 117 | end |
| 118 | |
| 119 | note Status 0=success; -1=bad index; -2=refused; -3=bad phase. |
| 120 | note Outputs are written only for successful calls. |
| 121 | note Formula: y = B*x + phase*U[id]*(V[id]^T*x), phase in {-1,+1}. |
| 122 | fn apply id ulong phase long to long |
| 123 | if ge id 8 |
| 124 | ret -1 |
| 125 | end |
| 126 | if ne get Allowed id 1 |
| 127 | ret -2 |
| 128 | end |
| 129 | if ne phase 1 |
| 130 | if ne phase -1 |
| 131 | ret -3 |
| 132 | end |
| 133 | end |
| 134 | dot = long 0 |
| 135 | vi = mul id 3 |
| 136 | for col ulong 3 |
| 137 | v = get V add vi col |
| 138 | dot = add dot mul v get X col |
| 139 | end |
| 140 | ui = mul id 2 |
| 141 | for row ulong 2 |
| 142 | diff = mul get U add ui row dot |
| 143 | result = add get Shared row mul phase diff |
| 144 | put Out row result |
| 145 | end |
| 146 | put Counts 1 add get Counts 1 1 |
| 147 | ret 0 |
| 148 | end |
| 149 | |
| 150 | fn main to int |
| 151 | init |
| 152 | makebase |
| 153 | if ne get Shared 0 16 |
| 154 | ret 1 |
| 155 | end |
| 156 | if ne get Shared 1 -8 |
| 157 | ret 2 |
| 158 | end |
| 159 | for id ulong 8 |
| 160 | idx = mul id 2 |
| 161 | a = apply id 1 |
| 162 | if ne a 0 |
| 163 | ret 3 |
| 164 | end |
| 165 | if ne get Out 0 get Plus idx |
| 166 | ret 4 |
| 167 | end |
| 168 | if ne get Out 1 get Plus add idx 1 |
| 169 | ret 5 |
| 170 | end |
| 171 | b = apply id -1 |
| 172 | if ne b 0 |
| 173 | ret 6 |
| 174 | end |
| 175 | if ne get Out 0 get Minus idx |
| 176 | ret 7 |
| 177 | end |
| 178 | if ne get Out 1 get Minus add idx 1 |
| 179 | ret 8 |
| 180 | end |
| 181 | end |
| 182 | if ne get Counts 0 1 |
| 183 | ret 9 |
| 184 | end |
| 185 | if ne get Counts 1 16 |
| 186 | ret 10 |
| 187 | end |
| 188 | first = pick 0 |
| 189 | if ne first 1 |
| 190 | ret 11 |
| 191 | end |
| 192 | used = shl ulong 1 first |
| 193 | second = pick used |
| 194 | if ne second 3 |
| 195 | ret 12 |
| 196 | end |
| 197 | put Allowed 1 0 |
| 198 | if ne pick 0 3 |
| 199 | ret 13 |
| 200 | end |
| 201 | a = apply 1 1 |
| 202 | if ne a -2 |
| 203 | ret 14 |
| 204 | end |
| 205 | if ne apply 8 1 -1 |
| 206 | ret 15 |
| 207 | end |
| 208 | if ne apply 3 0 -3 |
| 209 | ret 16 |
| 210 | end |
| 211 | for id ulong 8 |
| 212 | put Allowed id 0 |
| 213 | end |
| 214 | if ne pick 0 8 |
| 215 | ret 17 |
| 216 | end |
| 217 | if ne get Counts 0 1 |
| 218 | ret 18 |
| 219 | end |
| 220 | if ne get Counts 1 16 |
| 221 | ret 19 |
| 222 | end |
| 223 | ret 0 |
| 224 | end |