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 / si / benchmarks / native / neuralese / learnscore.om
| 1 | om2 |
| 2 | note Independent NL1 raw-carrier scorer for frozen NL6 design 8ee0a494. |
| 3 | note Does not trust reported predictions, abstentions, correctness or expected bits. |
| 4 | note Public synthetic fixture only; not an independent secret-task campaign. |
| 5 | const CHUNK ulong 16384 |
| 6 | global Buf uchar CHUNK |
| 7 | global Io ulong 4 |
| 8 | global Row ulong 21 |
| 9 | global Seen ulong 135 |
| 10 | global Count ulong 135 |
| 11 | global Good ulong 135 |
| 12 | global Refuse ulong 135 |
| 13 | text BAD "NL6RAW INVALID\n" |
| 14 | text COMMA "," |
| 15 | text LF "\n" |
| 16 | text HEAD "NL6RAW1,seed,partition,arm,quant,total,correct,refused,wrong\n" |
| 17 | text TAG "S," |
| 18 | text FIN "NL6RAW END\n" |
| 19 | text ENDREC "NL1LEARN END\n" |
| 20 | |
| 21 | fn putout a view uchar * n ulong to void |
| 22 | o = ulong 0 |
| 23 | while lt o n |
| 24 | z = write 1 a o sub n o |
| 25 | if le z 0 |
| 26 | exit 93 |
| 27 | end |
| 28 | o = add o ulong z |
| 29 | end |
| 30 | end |
| 31 | fn invalid to void |
| 32 | putout BAD len BAD |
| 33 | exit 90 |
| 34 | end |
| 35 | fn num n ulong to void |
| 36 | b = new uchar 20 0 |
| 37 | p = ulong 20 |
| 38 | while true bound 20 |
| 39 | p = sub p 1 |
| 40 | put b p uchar add rem n 10 48 |
| 41 | n = div n 10 |
| 42 | if eq n 0 |
| 43 | break |
| 44 | end |
| 45 | end |
| 46 | putout part b p sub ulong 20 p sub ulong 20 p |
| 47 | end |
| 48 | fn sep to void |
| 49 | putout COMMA 1 |
| 50 | end |
| 51 | fn next to long |
| 52 | if eq get Io 1 get Io 2 |
| 53 | z = read int get Io 0 Buf 0 CHUNK |
| 54 | if lt z 0 |
| 55 | invalid |
| 56 | end |
| 57 | if eq z 0 |
| 58 | ret -1 |
| 59 | end |
| 60 | put Io 1 0 |
| 61 | put Io 2 ulong z |
| 62 | end |
| 63 | p = get Io 1 |
| 64 | put Io 1 add p 1 |
| 65 | ret long get Buf p |
| 66 | end |
| 67 | fn value delim long to ulong |
| 68 | v = ulong 0 |
| 69 | n = ulong 0 |
| 70 | first = long -1 |
| 71 | while true bound 21 |
| 72 | c = next |
| 73 | if eq c delim |
| 74 | if eq n 0 |
| 75 | invalid |
| 76 | end |
| 77 | if and gt n 1 eq first 48 |
| 78 | invalid |
| 79 | end |
| 80 | ret v |
| 81 | end |
| 82 | if or lt c 48 gt c 57 |
| 83 | invalid |
| 84 | end |
| 85 | if eq n 0 |
| 86 | first = c |
| 87 | end |
| 88 | if or gt v 1844674407370955161 and eq v 1844674407370955161 gt c 53 |
| 89 | invalid |
| 90 | end |
| 91 | v = add mul v 10 ulong sub c 48 |
| 92 | n = add n 1 |
| 93 | if gt n 20 |
| 94 | invalid |
| 95 | end |
| 96 | end |
| 97 | ret 0 |
| 98 | end |
| 99 | fn parity id ulong to ulong |
| 100 | ret and xor xor xor id shr id 1 shr id 2 shr id 3 1 |
| 101 | end |
| 102 | fn mask phase ulong to ulong |
| 103 | m = ulong 0 |
| 104 | for id ulong 16 |
| 105 | if or eq phase 0 eq parity id sub phase 1 |
| 106 | m = or m shl 1 id |
| 107 | end |
| 108 | end |
| 109 | ret m |
| 110 | end |
| 111 | fn group si ulong phase ulong arm ulong mode ulong to ulong |
| 112 | ret add mul add mul add mul si 3 phase 5 arm 3 mode |
| 113 | end |
| 114 | fn grade id ulong arm ulong idx ulong to void |
| 115 | bit = shl 1 id |
| 116 | if ne and get Seen idx bit 0 |
| 117 | invalid |
| 118 | end |
| 119 | put Seen idx or get Seen idx bit |
| 120 | put Count idx add get Count idx 1 |
| 121 | status = ulong 0 |
| 122 | if ne arm 3 |
| 123 | for k ulong 3 |
| 124 | h = bitcast f64 get Row add k 6 |
| 125 | if not le fabs h 1.0f64 |
| 126 | status = 2 |
| 127 | end |
| 128 | end |
| 129 | end |
| 130 | if ne get Row 20 status |
| 131 | invalid |
| 132 | end |
| 133 | abst = ulong 0 |
| 134 | same = true |
| 135 | if ne status 0 |
| 136 | abst = 1 |
| 137 | same = false |
| 138 | end |
| 139 | for j ulong 4 |
| 140 | score = bitcast f64 get Row add j 9 |
| 141 | pred = ulong 0 |
| 142 | if eq status 0 |
| 143 | if not and ge score 0.0f64 le score 1.0f64 |
| 144 | invalid |
| 145 | end |
| 146 | if ge score 0.5f64 |
| 147 | pred = 1 |
| 148 | end |
| 149 | if lt fabs sub score 0.5f64 0.1f64 |
| 150 | abst = 1 |
| 151 | end |
| 152 | else |
| 153 | pred = 9 |
| 154 | end |
| 155 | if ne pred get Row add j 13 |
| 156 | invalid |
| 157 | end |
| 158 | if ne pred and shr id j 1 |
| 159 | same = false |
| 160 | end |
| 161 | end |
| 162 | if ne get Row 17 abst |
| 163 | invalid |
| 164 | end |
| 165 | if ne abst 0 |
| 166 | same = false |
| 167 | put Refuse idx add get Refuse idx 1 |
| 168 | end |
| 169 | if same |
| 170 | put Good idx add get Good idx 1 |
| 171 | end |
| 172 | end |
| 173 | fn row to void |
| 174 | for j ulong 21 |
| 175 | d = long 44 |
| 176 | if eq j 20 |
| 177 | d = 10 |
| 178 | end |
| 179 | put Row j value d |
| 180 | end |
| 181 | seed = get Row 0 |
| 182 | si = ulong 0 |
| 183 | if eq seed 29 |
| 184 | si = 1 |
| 185 | else |
| 186 | if eq seed 43 |
| 187 | si = 2 |
| 188 | else |
| 189 | if ne seed 17 |
| 190 | invalid |
| 191 | end |
| 192 | end |
| 193 | end |
| 194 | split = get Row 1 |
| 195 | arm = get Row 2 |
| 196 | id = get Row 3 |
| 197 | mode = get Row 4 |
| 198 | ctx = get Row 5 |
| 199 | if or gt split 1 or gt arm 4 or gt id 15 or gt mode 17 gt ctx 1 |
| 200 | invalid |
| 201 | end |
| 202 | note Only frozen precision arms and trained receiver context are scored here. |
| 203 | if or ne ctx 1 gt mode 2 |
| 204 | ret |
| 205 | end |
| 206 | if and eq arm 3 ne mode 0 |
| 207 | invalid |
| 208 | end |
| 209 | phase = ulong 0 |
| 210 | if eq split 1 |
| 211 | phase = add parity id 1 |
| 212 | end |
| 213 | idx = group si phase arm mode |
| 214 | grade id arm idx |
| 215 | end |
| 216 | fn finish to void |
| 217 | for si ulong 3 |
| 218 | for phase ulong 3 |
| 219 | for arm ulong 5 |
| 220 | for mode ulong 3 |
| 221 | if and eq arm 3 ne mode 0 |
| 222 | continue |
| 223 | end |
| 224 | idx = add mul add mul add mul si 3 phase 5 arm 3 mode |
| 225 | if ne get Seen idx mask phase |
| 226 | invalid |
| 227 | end |
| 228 | end |
| 229 | end |
| 230 | end |
| 231 | end |
| 232 | putout HEAD len HEAD |
| 233 | for si ulong 3 |
| 234 | seed = ulong 17 |
| 235 | if eq si 1 |
| 236 | seed = 29 |
| 237 | else |
| 238 | if eq si 2 |
| 239 | seed = 43 |
| 240 | end |
| 241 | end |
| 242 | for phase ulong 3 |
| 243 | for arm ulong 5 |
| 244 | for mode ulong 3 |
| 245 | if and eq arm 3 ne mode 0 |
| 246 | continue |
| 247 | end |
| 248 | idx = add mul add mul add mul si 3 phase 5 arm 3 mode |
| 249 | putout TAG len TAG |
| 250 | num seed |
| 251 | sep |
| 252 | num phase |
| 253 | sep |
| 254 | num arm |
| 255 | sep |
| 256 | num mode |
| 257 | sep |
| 258 | num get Count idx |
| 259 | sep |
| 260 | num get Good idx |
| 261 | sep |
| 262 | num get Refuse idx |
| 263 | sep |
| 264 | num sub sub get Count idx get Good idx get Refuse idx |
| 265 | putout LF 1 |
| 266 | end |
| 267 | end |
| 268 | end |
| 269 | end |
| 270 | putout FIN len FIN |
| 271 | end |
| 272 | fn learnrun to int |
| 273 | if ne argcnt 2 |
| 274 | invalid |
| 275 | end |
| 276 | path = new uchar 4096 0 |
| 277 | n = argread 1 path 0 len path |
| 278 | if le n 0 |
| 279 | invalid |
| 280 | end |
| 281 | fd = fopen path 0 ulong n 524288 0 |
| 282 | if lt fd 0 |
| 283 | invalid |
| 284 | end |
| 285 | put Io 0 ulong fd |
| 286 | while true |
| 287 | c = next |
| 288 | if eq c 82 |
| 289 | if ne next 44 |
| 290 | invalid |
| 291 | end |
| 292 | row |
| 293 | else |
| 294 | if or eq c 80 eq c 84 |
| 295 | note Parameter/timing records are not recovery evidence. Skip bounded metadata only. |
| 296 | while true bound 256 |
| 297 | c = next |
| 298 | if eq c 10 |
| 299 | break |
| 300 | end |
| 301 | if lt c 0 |
| 302 | invalid |
| 303 | end |
| 304 | end |
| 305 | else |
| 306 | if eq c 78 |
| 307 | for j ulong sub len ENDREC 1 |
| 308 | if ne next long get ENDREC add j 1 |
| 309 | invalid |
| 310 | end |
| 311 | end |
| 312 | if ne next -1 |
| 313 | invalid |
| 314 | end |
| 315 | break |
| 316 | else |
| 317 | invalid |
| 318 | end |
| 319 | end |
| 320 | end |
| 321 | end |
| 322 | z = fclose int fd |
| 323 | if ne z 0 |
| 324 | invalid |
| 325 | end |
| 326 | finish |
| 327 | ret 0 |
| 328 | end |