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/src/turing/turing_core.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 / src / turing / turing_core.om` 93 lines ยท 2245 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Pure seeded OM-2 core logic backing src/turing/ (field.c, history_selector.c): 3 note hex digest formatting, digest equality, SplitMix64, online running mean 4 note observation, minimum-cost spec ranking, and seeded Fisher-Yates shuffle. 5 om2 6 7 fn tur_hex_nib v ulong to uchar 8 if lt v 10 9 ret uchar add 48 v 10 end 11 ret uchar add 87 v 12 end 13 14 fn tur_sm64 st edit ulong 1 to ulong 15 z = add get st 0 0x9e3779b97f4a7c15 16 put st 0 z 17 z = mul xor z shr z 30 0xbf58476d1ce4e5b9 18 z = mul xor z shr z 27 0x94d049bb133111eb 19 ret xor z shr z 31 20 end 21 22 export fn turing_om_hex d view uchar 32 dst edit uchar 64 to void 23 for i ulong 32 24 b = ulong get d i 25 put dst mul i 2 tur_hex_nib shr b 4 26 put dst add mul i 2 1 tur_hex_nib and b 15 27 end 28 end 29 30 export fn turing_om_digest_eq a view uchar 32 b view uchar 32 to ulong 31 for i ulong 32 32 if ne get a i get b i 33 ret 0 34 end 35 end 36 ret 1 37 end 38 39 export fn turing_om_splitmix64 st edit ulong 1 to ulong 40 ret tur_sm64 st 41 end 42 43 export fn turing_om_bucket_observe cnt edit uint 1 mean_b edit ulong 1 cost_ps ulong to void 44 c = add ulong get cnt 0 1 45 put cnt 0 uint c 46 m = bitcast f64 get mean_b 0 47 m = add m div sub f64 cost_ps m f64 c 48 put mean_b 0 bitcast ulong m 49 end 50 51 export fn turing_om_rank_min_cost cnt view uint 32 means view ulong 32 allowed view uint 32 nspec ulong to ulong 52 lim = nspec 53 if gt lim 32 54 lim = 32 55 end 56 best = ulong 0xffffffffffffffff 57 best_m = bitcast f64 ulong 0 58 for k ulong lim 59 if ne ulong get allowed k 0 60 if ne ulong get cnt k 0 61 mk = bitcast f64 get means k 62 if eq best 0xffffffffffffffff 63 best = k 64 best_m = mk 65 else 66 if lt mk best_m 67 best = k 68 best_m = mk 69 end 70 end 71 end 72 end 73 end 74 ret best 75 end 76 77 export fn turing_om_fisher_yates ord edit uint 32 nspec ulong seed ulong to void 78 st = ulong seed 79 k = nspec 80 while gt k 1 81 z = add st 0x9e3779b97f4a7c15 82 st = z 83 z = mul xor z shr z 30 0xbf58476d1ce4e5b9 84 z = mul xor z shr z 27 0x94d049bb133111eb 85 r = xor z shr z 31 86 j = rem r k 87 km1 = sub k 1 88 t = get ord km1 89 put ord km1 get ord j 90 put ord j t 91 k = km1 92 end 93 end