interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / om / runtime / rx_projection.om

87 lines · 1885 bytes Raw Blame History
1om2
2note rx_projection.om -- Cognitive state projection core in pure OM-2.
3note Replaces pj_summarize, section_of, and form_of in src/runtime/rx_projection.c.
4
5const U64_MAX ulong 18446744073709551615
6
7const CX_CLAIM ulong 2
8const CX_EVIDENCE ulong 6
9
10const PJ_LIVE ulong 2
11const PJ_RECALLABLE ulong 4
12const PJ_COMPRESSIBLE ulong 5
13const PJ_REFERENCE_ONLY ulong 6
14
15const PJ_T_LATEST ulong 2
16
17const PJ_SEC_WORLD ulong 1
18const PJ_SEC_CORTEX ulong 2
19const PJ_SEC_HYPOTHESIS ulong 3
20const PJ_SEC_EVIDENCE ulong 4
21
22const PJ_FORM_FULL ulong 1
23const PJ_FORM_SUMMARY ulong 2
24const PJ_FORM_REF ulong 3
25
26note Compute [count, sum, sum_sq, min, max] over w[0..len-1] into dst[0..4].
27export 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
54end
55
56note Classify a Cortex object into its projection section.
57export 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
73end
74
75note Map treatment class to representation form (FULL, SUMMARY, REF).
76export 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
87end