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 / om / runtime / rx_projection.om
| 1 | om2 |
| 2 | note rx_projection.om -- Cognitive state projection core in pure OM-2. |
| 3 | note Replaces pj_summarize, section_of, and form_of in src/runtime/rx_projection.c. |
| 4 | |
| 5 | const U64_MAX ulong 18446744073709551615 |
| 6 | |
| 7 | const CX_CLAIM ulong 2 |
| 8 | const CX_EVIDENCE ulong 6 |
| 9 | |
| 10 | const PJ_LIVE ulong 2 |
| 11 | const PJ_RECALLABLE ulong 4 |
| 12 | const PJ_COMPRESSIBLE ulong 5 |
| 13 | const PJ_REFERENCE_ONLY ulong 6 |
| 14 | |
| 15 | const PJ_T_LATEST ulong 2 |
| 16 | |
| 17 | const PJ_SEC_WORLD ulong 1 |
| 18 | const PJ_SEC_CORTEX ulong 2 |
| 19 | const PJ_SEC_HYPOTHESIS ulong 3 |
| 20 | const PJ_SEC_EVIDENCE ulong 4 |
| 21 | |
| 22 | const PJ_FORM_FULL ulong 1 |
| 23 | const PJ_FORM_SUMMARY ulong 2 |
| 24 | const PJ_FORM_REF ulong 3 |
| 25 | |
| 26 | note Compute [count, sum, sum_sq, min, max] over w[0..len-1] into dst[0..4]. |
| 27 | export fn rx_pj_summarize w view ulong * dst edit ulong 5 to void |
| 28 | n = len w |
| 29 | s = ulong 0 |
| 30 | sq = ulong 0 |
| 31 | mn = U64_MAX |
| 32 | mx = ulong 0 |
| 33 | note The public C count is uint32_t. |
| 34 | for i ulong n bound 4294967295 |
| 35 | v = get w i |
| 36 | s = add s v |
| 37 | sq = add sq mul v v |
| 38 | if lt v mn |
| 39 | mn = v |
| 40 | end |
| 41 | if gt v mx |
| 42 | mx = v |
| 43 | end |
| 44 | end |
| 45 | put dst 0 n |
| 46 | put dst 1 s |
| 47 | put dst 2 sq |
| 48 | if eq n 0 |
| 49 | put dst 3 0 |
| 50 | else |
| 51 | put dst 3 mn |
| 52 | end |
| 53 | put dst 4 mx |
| 54 | end |
| 55 | |
| 56 | note Classify a Cortex object into its projection section. |
| 57 | export fn rx_pj_section_of protect ulong cls ulong treatment ulong temporal ulong to ulong |
| 58 | if eq treatment PJ_LIVE |
| 59 | if eq temporal PJ_T_LATEST |
| 60 | ret PJ_SEC_WORLD |
| 61 | end |
| 62 | end |
| 63 | if ne protect 0 |
| 64 | ret PJ_SEC_EVIDENCE |
| 65 | end |
| 66 | if eq cls CX_EVIDENCE |
| 67 | ret PJ_SEC_EVIDENCE |
| 68 | end |
| 69 | if eq cls CX_CLAIM |
| 70 | ret PJ_SEC_HYPOTHESIS |
| 71 | end |
| 72 | ret PJ_SEC_CORTEX |
| 73 | end |
| 74 | |
| 75 | note Map treatment class to representation form (FULL, SUMMARY, REF). |
| 76 | export fn rx_pj_form_of treatment ulong to ulong |
| 77 | if eq treatment PJ_COMPRESSIBLE |
| 78 | ret PJ_FORM_SUMMARY |
| 79 | end |
| 80 | if eq treatment PJ_RECALLABLE |
| 81 | ret PJ_FORM_REF |
| 82 | end |
| 83 | if eq treatment PJ_REFERENCE_ONLY |
| 84 | ret PJ_FORM_REF |
| 85 | end |
| 86 | ret PJ_FORM_FULL |
| 87 | end |