code wiki / _hdl_build / nx_evo_pbe.nx
nx_evo_pbe.nx
buildroot/runtime/_hdl_build/nx_evo_pbe.nx
about
nx_evo_pbe.nx -- EVOLUTIONARY SYNTHESIS roadmap RUNG 3 (THE HEADLINE):
PROGRAMMING-BY-EXAMPLE / INDUCTIVE PROGRAM SYNTHESIS (X-AUT-006N).
006L/006M evolved a constant (hit one numeric target). This evolves a FUNCTION
f(x): the genome computes over an INPUT x, fitness = total error across MANY
(x_i -> y_i) TRAINING examples, and the champion is VERIFIED on HELD-OUT examples
(x the search never trained on). Matching held-out = the engine INDUCED the true
function from data (generalization), not memorized points. This is the research-
leading capability: discover x*x, 2x*x+3, 3x+5 from EXAMPLES ALONE. It uses the
006M crossover GA as the searcher and an op set rich enough for polynomials.
nx_evo_pbe <champion_basename> <target_id> <seed>
target_id selects a hidden function used ONLY to GENERATE the dataset + the
held-out ground truth (the SEARCH only ever sees the (x,y) pairs, never the
formula): 0=x*x 1=2*x*x+3 2=3*x+5 3=x*x+x.
op set (genome): 0 add n | 1 mul n | 2 sub n | 3 mul-by-x (acc*x) |
4 add-x (acc+x) | 5 square (acc*acc). start acc = x.
-> trains on x in 1..NTRAIN minimizing sum|f(x)-y|; verifies on x in
NTRAIN+1..NTRAIN+NHELD; prints train_err + heldout M/NHELD + GENERALIZES/
OVERFIT/NEAR; MATERIALIZES the champion as a real organ computing f at one
held-out x (compile+run must equal the held-out ground truth).
no-false-green: train_err=0 with heldout=NHELD/NHELD = induced the TRUE function
(a memoriser would fail held-out); DIFFERENT target_id -> DIFFERENT discovered
function, each generalising + champion compiles+runs. Sovereign, no gcc/.sh.
HONEST SCOPE: polynomial op set, distance fitness, single i64 input; the seed of
inductive synthesis -- branches/loops genomes (for abs/gcd) are a later rung.
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 30 | const EVO_MAGIC_2862933555777941757: i64 = 2862933555777941757 |
| 31 | const EVO_MAGIC_3037000493: i64 = 3037000493 |
| 32 | const EVO_MAGIC_2654435761: i64 = 2654435761 |
| 33 | const EVO_MAGIC_12345: i64 = 12345 |
| 34 | const EVO_MAGIC_1000000000: i64 = 1000000000 |
| 35 | const EVO_MAGIC_65536: i64 = 65536 |
| 37 | const EVO_L: i64 = 5 |
| 38 | const EVO_P: i64 = 128 |
| 39 | const EVO_G: i64 = 600 |
| 40 | const EVO_T: i64 = 5 |
| 41 | const NTRAIN: i64 = 6 |
| 42 | const NHELD: i64 = 4 |
functions
| 44 | func pbe_rand(state: *i64) -> i64 |
| 48 | func pbe_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x } called by 1: pbe_fit |
| 51 | func pbe_target(id: i64, x: i64) -> i64 |
| 59 | func pbe_eval(pop: *i64, base: i64, x: i64) -> i64 |
| 75 | func pbe_fit(pop: *i64, base: i64, id: i64) -> i64 |
| 81 | func pbe_randfill(pop: *i64, base: i64, state: *i64) -> i64 |
| 86 | func pbe_tourney(fit: *i64, state: *i64) -> i64 |
| 91 | func pbe_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i } called by 1: main |
| 92 | func pbe_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 102 | func pbe_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 103 | func pbe_pn(v: i64) -> i64 { let b: *u8 = sys_mmap(32); let n: i64 = pbe_catn(b, 0, v); sys_write(1, b, n); return 0 } |
| 104 | func pbe_atoi(s: *u8) -> i64 called by 1: main |
| 112 | func pbe_op_txt(op: i64, n: i64) -> i64 |
| 117 | func main(argc: i64, argv: *i64) -> i64 |