code wiki / _hdl_build / nx_self_compose.nx

nx_self_compose.nx

buildroot/runtime/_hdl_build/nx_self_compose.nx

7366 B154 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic self
docsdependenciesstructsconstsfunctions

about

nx_self_compose.nx -- AUTONOMOUS compose+derive (the rung up: the team composes its OWN targets, no Claude posing them). For each seed: COMPOSE a RANDOM non-trivial target program T (random op-list over {a,b,+a,+b,*a,*b}; rerolled until it depends on BOTH inputs), then DERIVE a program G that nmatches T's examples (search sees only (a,b)->T(a,b) points, not T), then VERIFY G == T on HELD-OUT points. So the team picks WHAT to build (random T) AND builds it (derives G), zero Claude per-target. Proves the machinery is GENERAL (arbitrary targets, not hardcoded) AND that specs can be team-composed. Claude authored only the grammar/eval/ search (substrate). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_self_compose.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sc_run sys_mmap sc_compose sc_rand sc_eval sc_p sys_write sc_pn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap sc_derive sys_mmap ↻ sc_rand ↻ sc_fit sc_pa sc_pb sc_eval ↻ sc_abs sc_tourney sc_rand ↻ sc_eval ↻ sc_pa ↻ sc_pb ↻ sc_ops sc_p ↻ sc_pn ↻ sc_p ↻ sc_pn ↻ sys_exit

structs

none

consts

11const EVO_MAGIC_2862933555777941757: i64 = 2862933555777941757
12const EVO_MAGIC_3037000493: i64 = 3037000493
13const EVO_MAGIC_4000000: i64 = 4000000
14const EVO_MAGIC_2000000: i64 = 2000000
15const EVO_MAGIC_1000000000: i64 = 1000000000
16const EVO_MAGIC_2654435761: i64 = 2654435761
17const EVO_MAGIC_12345: i64 = 12345
19const GLEN: i64 = 4
20const EVO_P: i64 = 256
21const EVO_G: i64 = 1500
22const EVO_T: i64 = 5
23const NTRAIN: i64 = 6
24const NPTS: i64 = 10

functions

26func sc_rand(s: *i64) -> i64 { s[0] = s[0] * EVO_MAGIC_2862933555777941757 + EVO_MAGIC_3037000493; return (s[0] >> 17) & 0x3fffffff }
27func sc_abs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: sc_fit
28func sc_pa(i: i64) -> i64 { if i==0 {return 2} if i==1 {return 4} if i==2 {return 3} if i==3 {return 5} if i==4 {return 6} if i==5 {return 1} if i==6 {return 7} if i==7 {return 3} if i==8 {return 8} return 4 }
called by 2: sc_fitsc_run
29func sc_pb(i: i64) -> i64 { if i==0 {return 3} if i==1 {return 5} if i==2 {return 2} if i==3 {return 1} if i==4 {return 2} if i==5 {return 4} if i==6 {return 2} if i==7 {return 3} if i==8 {return 1} return 4 }
called by 2: sc_fitsc_run
32func sc_eval(gen: *i64, base: i64, a: i64, b: i64) -> i64
48func sc_compose(state: *i64, T: *i64) -> i64
called by 1: sc_run calls 2: sc_randsc_eval
63func sc_fit(pop: *i64, base: i64, T: *i64) -> i64
called by 1: sc_derive calls 4: sc_pasc_pbsc_evalsc_abs
75func sc_tourney(fit: *i64, state: *i64) -> i64
called by 1: sc_derive calls 1: sc_rand
82func sc_derive(T: *i64, state: *i64, G: *i64) -> i64
115func sc_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 3: sc_opssc_runmain calls 1: sys_write
120func sc_pn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 3: sc_opssc_runmain calls 1: nxi_out
121func sc_ops(label: *u8, gen: *i64) -> i64
called by 1: sc_run calls 2: sc_psc_pn
129func sc_run(seed: i64) -> i64
143func main() -> i64