code wiki / _hdl_build / nx_evo_pbe.nx

nx_evo_pbe.nx

buildroot/runtime/_hdl_build/nx_evo_pbe.nx

11122 B210 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic evo
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_evo_pbe.nx

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

main pbe_p sys_write pbe_atoi sys_mmap pbe_randfill pbe_rand pbe_fit pbe_abs pbe_eval pbe_target pbe_tourney pbe_rand ↻ pbe_rand ↻ pbe_eval ↻ pbe_target ↻ pbe_pn sys_mmap ↻ pbe_catn pbe_catn ↻ sys_mmap ↻ sys_write ↻ pbe_op_txt pbe_p ↻ pbe_pn ↻ pbe_cat pbe_catn ↻ sys_openat_wr sys_write ↻ sys_close

structs

none

consts

30const EVO_MAGIC_2862933555777941757: i64 = 2862933555777941757
31const EVO_MAGIC_3037000493: i64 = 3037000493
32const EVO_MAGIC_2654435761: i64 = 2654435761
33const EVO_MAGIC_12345: i64 = 12345
34const EVO_MAGIC_1000000000: i64 = 1000000000
35const EVO_MAGIC_65536: i64 = 65536
37const EVO_L: i64 = 5
38const EVO_P: i64 = 128
39const EVO_G: i64 = 600
40const EVO_T: i64 = 5
41const NTRAIN: i64 = 6
42const NHELD: i64 = 4

functions

44func pbe_rand(state: *i64) -> i64
48func pbe_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: pbe_fit
51func pbe_target(id: i64, x: i64) -> i64
called by 2: pbe_fitmain
59func pbe_eval(pop: *i64, base: i64, x: i64) -> i64
called by 2: pbe_fitmain
75func pbe_fit(pop: *i64, base: i64, id: i64) -> i64
called by 1: main calls 3: pbe_abspbe_evalpbe_target
81func pbe_randfill(pop: *i64, base: i64, state: *i64) -> i64
called by 1: main calls 1: pbe_rand
86func pbe_tourney(fit: *i64, state: *i64) -> i64
called by 1: main calls 1: pbe_rand
91func 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
92func pbe_catn(dst: *u8, off: i64, v: i64) -> i64
called by 3: pbe_catnpbe_pnmain calls 2: pbe_catnsys_mmap
102func 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 }
called by 2: pbe_op_txtmain calls 1: sys_write
103func 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 }
104func pbe_atoi(s: *u8) -> i64
called by 1: main
112func pbe_op_txt(op: i64, n: i64) -> i64
called by 1: main calls 2: pbe_ppbe_pn
117func main(argc: i64, argv: *i64) -> i64