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/docs/TEACH_OMEGA.md # 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 / docs / TEACH_OMEGA.md` 196 lines ยท 11121 bytes Raw Blame History Rendered 1 # One small Omega program: source, executable, and the identity boundary 2 3 This lesson follows the existing seeded `.om` forward-call fixture. It also 4 explains where the older semantic-identity machinery lives **without pretending 5 that the two pipelines are integrated**. It is a bounded contribution to 6 [#619](https://github.com/aien-dev/omega-mv/issues/619), not its closure. 7 8 ## What problem is being solved? 9 10 The [2026-09-29 decision record](adr/OMEGA-SYSTEMS-CORE-0000.md) 11 sets the goal: replace convention-dependent C/assembly with explicit machine 12 semantics, reproducible compilation, and separate semantic, runtime, wire and 13 device layouts. The later seed work makes compiler ancestry inspectable: explicit 14 instruction words build small translators, then a compiler written in Omega. 15 See the existing [seed-birth walkthrough](https://github.com/aien-dev/omega-mv/blob/`b30ba6cf729eb9295c7f8883cfff0519b90a63e1`/docs/SEED_BIRTH.md) 16 and its [recorded replay](https://github.com/aien-dev/omega-mv/blob/`b30ba6cf729eb9295c7f8883cfff0519b90a63e1`/evidence/seed-birth-`20261022`/README.md). 17 Those are development-branch documents, not files already integrated on `main`. 18 19 Published Arm instruction and ELF formats are upstream specifications, not 20 Omega inventions. The seed notes attribute them. Existing Linux, the shell and 21 host utilities remain dependencies. [CONTRIBUTORS](../CONTRIBUTORS.md) attributes 22 project implementation to AI models orchestrated by Drake Stapleton; this lesson 23 does not invent a personal account of who typed the compiler. 24 25 ## Pin and prerequisites 26 27 Use the teaching pin ``29b12760f4c962606411d6bf25032aedef063301``, the R5 28 compiler described by the existing replay above. This is **not the newest compiler, 29 a production recommendation, or a combined profile**. Later native-host and 30 device work has separate review and qualification, including 31 [PR #678](https://github.com/aien-dev/omega-mv/pull/678) and 32 [PR #676](https://github.com/aien-dev/omega-mv/pull/676). 33 Do not substitute one profile's compiler hash or evidence for another's. 34 35 Execution requires **AArch64 Linux**, Git, a POSIX shell, and ordinary utilities 36 used by the bootstrap (`printf`, `tr`, `cat`, `sed`, GNU-compatible `stat`, `cmp`, 37 `chmod`, `mkdir`, `cp`, `wc`, `cut`, `grep`, `sha256sum`). No model, GPU, CUDA 38 installation, physics checkout, or package download is part of this example. 39 Cloning needs network access; after checkout the recipe is offline. An x86 host 40 can inspect source but cannot natively execute these AArch64 binaries. 41 42 Use a disposable checkout: the bootstrap writes `build/seed/birth`, `seed/out`, 43 and rung-4 generated files, including a measured-size field in `om4.s`. 44 Inspect the [bootstrap](https://github.com/aien-dev/omega-mv/blob/`29b12760f4c962606411d6bf25032aedef063301`/seed/omega-from-seed.sh) 45 and [rung-4 builder](https://github.com/aien-dev/omega-mv/blob/`29b12760f4c962606411d6bf25032aedef063301`/seed/rung4/mk4.sh) 46 before executing them. Never run historical receipt-writing gates in a checkout 47 whose evidence you intend to preserve. 48 49 ## Follow the source 50 51 The unchanged input is 52 [`seed/rung4/tests/r5b_fwd.om`](https://github.com/aien-dev/omega-mv/blob/`29b12760f4c962606411d6bf25032aedef063301`/seed/rung4/tests/r5b_fwd.om): 53 54 ```text 55 fn main to int 56 ret later 57 end 58 fn later to int 59 ret 7 60 end 61 ``` 62 63 `main` returns the result of `later`, even though its declaration follows the 64 call. The expected observable result is **process exit 7**, not printed text. 65 A nonzero program result is not automatically a compiler/test failure. 66 67 In the pinned 68 [`seed/omc/omc.om`](https://github.com/aien-dev/omega-mv/blob/`29b12760f4c962606411d6bf25032aedef063301`/seed/omc/omc.om), 69 follow these function names: 70 71 | Stage | Implementation and intermediate representation | 72 | --- | --- | 73 | Read source | `main` reads stdin into bounded `inp`; `tok` scans tokens. | 74 | Discover/check names | `prescan` and `namescan` collect declarations; `stmt`, `s_name`, `s_assign` and expression readers enforce this subset's rules. This is not a claim of the full OSC contract system. | 75 | Emit and resolve | Statement/expression handlers emit instruction words into `out`; `resolve` fills call offsets after addresses are known. | 76 | Make the executable | `eof_prog` constructs the entry/exit sequence; `elfhdr` writes the ELF64 little-endian AArch64 header; `writeout` sends the image to stdout. | 77 | Run | Linux loads that ELF; the generated entry calls `main` and passes its result to the Linux exit syscall. | 78 79 There is no C compilation or linking step in this construction path. The 80 bootstrap's fixed-point comparisons establish self-consistency of the tested 81 compiler builds, not general semantic correctness or diverse-compilation trust. 82 83 ## Replay on a suitable CPU host 84 85 These are **expected results derived from source and the linked historical 86 replay**, not a claim that this lesson's author reran them. Execute each block 87 in order in the same shell. Each block fails closed on an unexpected result. 88 89 ```sh 90 set -eu 91 git clone https://github.com/aien-dev/omega-mv.git omega-teaching-replay 92 cd omega-teaching-replay 93 git checkout --detach `29b12760f4c962606411d6bf25032aedef063301` 94 test "$(git rev-parse HEAD)" = `29b12760f4c962606411d6bf25032aedef063301` 95 sh seed/omega-from-seed.sh 96 printf '%s %s\n' \ 97 `191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9` \ 98 seed/out/omc | sha256sum -c - 99 mkdir build/teaching 100 seed/out/omc < seed/rung4/tests/r5b_fwd.om > build/teaching/fwd 101 chmod +x build/teaching/fwd 102 rc=0 103 build/teaching/fwd > build/teaching/fwd.stdout || rc=$? 104 test "$rc" -eq 7 105 test ! -s build/teaching/fwd.stdout 106 printf 'forward-call exit=%s\n' "$rc" 107 ``` 108 109 Expected: bootstrap exits 0 and prints `RC=0`; hash check prints 110 `seed/out/omc: OK`; compilation exits 0; program exits 7 with no stdout; 111 the last line is `forward-call exit=7` and the block exits 0. 112 113 ### A meaning-preserving change 114 115 Rename the internal function consistently; keep the externally required `main`. 116 This changes source bytes but not the intended call/result. Byte equality is a 117 stronger, implementation-specific expectation for this exact rename, **not a 118 universal test of semantic equivalence** and not a `SEMANTIC_ID` computation. 119 120 ```sh 121 sed 's/later/after/g' seed/rung4/tests/r5b_fwd.om > build/teaching/renamed.om 122 seed/out/omc < build/teaching/renamed.om > build/teaching/renamed 123 cmp build/teaching/fwd build/teaching/renamed 124 chmod +x build/teaching/renamed 125 rc=0 126 build/teaching/renamed > build/teaching/renamed.stdout || rc=$? 127 test "$rc" -eq 7 128 test ! -s build/teaching/renamed.stdout 129 printf 'renamed exit=%s\n' "$rc" 130 ``` 131 132 Expected: compiler and `cmp` exit 0, program exit 7, no program stdout, 133 `renamed exit=7`. The new rename experiment is **NOT_RUN** here; if comparison 134 fails, preserve its output and report FAIL rather than changing expected bytes. 135 136 ### A safe refusal already in the bootstrap 137 138 [`r5b_assign.om`](https://github.com/aien-dev/omega-mv/blob/`29b12760f4c962606411d6bf25032aedef063301`/seed/rung4/tests/r5b_assign.om) 139 tries `later = 2` where `later` is a function. The names pass makes that an 140 invalid assignment, rather than silently treating the function name as a variable. 141 142 ```sh 143 rc=0 144 seed/out/omc < seed/rung4/tests/r5b_assign.om \ 145 > build/teaching/refused.bin 2> build/teaching/refused.stderr || rc=$? 146 test "$rc" -eq 7 147 grep -q 'error 7' build/teaching/refused.stderr 148 printf 'invalid-assignment compiler-exit=%s\n' "$rc" 149 ``` 150 151 Expected: compiler exit 7, diagnostic containing `error 7`, final line 152 `invalid-assignment compiler-exit=7`. **Do not execute refused.bin.** The 153 bootstrap already asserts this exact exit and diagnostic. The program result 7 154 above and compiler refusal 7 here are different events from different processes. 155 156 ## Where semantic identity and receipts fit: and do not yet fit 157 158 The seeded fixture above does **not** travel through the legacy C 159 `OmegaProgram` pipeline. No canonical semantic encoding, `SEMANTIC_ID`, 160 `REALIZATION_ID`, or signed qualification receipt is emitted by this recipe. 161 A SHA-256 of the executable is an artifact fingerprint, not semantic identity. 162 For this lesson, the missing native integration is **MISSING_IMPLEMENTATION**, 163 not an invitation to revive the legacy C path as the permanent foundation. 164 165 The existing legacy implementation supplies a precise comparison and source map: 166 167 | Concept | Existing source, format and test | 168 | --- | --- | 169 | Parse/check a restricted unary function | `omega_language_parse_line` and `omega_language_lower_program`, exercised by `lower_fn` in [test_program_id.c](../tests/program/test_program_id.c). This is a different source grammar from `.om`. | 170 | Bind meaning, not spelling/cost | [program identity v2](../spec/program-identity.md): `omega_program_compute_id` hashes a domain tag, canonical body-root id, input/output type ids and pre/postcondition ids. [omega_program.c](../src/omega_program.c) and [omega_canonical.c](../src/omega_canonical.c) implement it. | 171 | Inspect intermediate bytes | [canonical object encoding](../spec/canonical-encoding.md) and [program IR layout](../src/omega_program_ir.h); [IR tests](../tests/test_omega_program_ir.c) exercise round trips and refusals. These are distinct encodings, not the emitted ELF. | 172 | Realize and compare | [program realization V0](../spec/program-realization.md) links `omega_program_realize_check`, scheduling, emission and `omega_realization_verify_program`; unsupported bodies and stale ids fail closed. Native comparison requires AArch64. | 173 | Receipt binding | [omega_receipt.h](../src/omega_receipt.h) defines receipt canonicalization/identity; an execution log alone does not satisfy that schema or establish qualification. | 174 175 For example, the identity test compares `fn f(x: u64) -> u64 { x + 1 }` 176 with changed names/representation and separately with `x + 2`. Equality is 177 about the supported canonical body and contract, **not every mathematically 178 equivalent arbitrary program**. The documented v1 failure was omission of the 179 body from the hash, allowing different programs to share an id; v2 fixes that. 180 The realization design also records the earlier error of emitting `3x - 2` 181 regardless of the requested program. These are attributed design records, not 182 newly reproduced failures or claims that all compiler defects are solved. 183 184 ## Evidence and remaining work 185 186 - Historical AArch64 bootstrap replay: linked above, exact R5 pin and compiler 187 fingerprint; not a fresh run of this whole lesson. 188 - This documentation pass: source/path/snippet and shell-syntax inspection only. 189 Execution, the new rename comparison, and repository judges: **NOT_RUN**. 190 - Full #619 acceptance still needs an independent fresh CPU replay with revision, 191 OS/architecture, commands, stdout/stderr and exit statuses, plus an honestly 192 scoped native identity/receipt story. Preserve failures and never rewrite old 193 receipts to make the example pass. 194 - GB10/device/model qualification is outside this CPU lesson. It requires its own 195 exact compiler/profile, hardware, operator scheduling and evidence; a host pass 196 cannot establish it. No hardware extension is necessary to learn this example.