code wiki / _hdl_build / nx_synth.nx
nx_synth.nx
buildroot/runtime/_hdl_build/nx_synth.nx
about
nx_synth.nx -- a PROGRAM SYNTHESIZER: the team WRITES a program from a spec, by
search. Given only input/output examples (NOT the formula), it enumerates small
straight-line programs over {ADD,SUB,MUL,SHL} and returns the shortest one that
reproduces every example -- then the caller checks it on held-out inputs so it is
a real program, not an overfit. This is "writing code on its own": the search
discovers the program; I only wrote the searcher + the DSL.
Enumerative program synthesis (Massalin superoptimizer, AFIPS 1987; modern: CEGIS
-- Solar-Lezama, ASPLOS 2006). Slots: 0=x (input), 1=1 (a constant), 2.. computed.
Bounded to length <= 2 over a few ops -- small, but genuinely authored from a goal.
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_synth_test.nxnx_team_selfdirect_test.nxnx_team_selfsufficient_test.nx
structs
| none |
consts
| 14 | const OP_ADD: i64 = 0 |
| 15 | const OP_SUB: i64 = 1 |
| 16 | const OP_MUL: i64 = 2 |
| 17 | const OP_SHL: i64 = 3 |
functions
| 23 | func synth_eval(op: *i64, a: *i64, b: *i64, L: i64, x: i64, s: *i64) -> i64 |
| 41 | func synth_matches(op: *i64, a: *i64, b: *i64, L: i64, ex_x: *i64, ex_y: *i64, nex: i64, s: *i64) -> i64 |
| 52 | func synth_find(ex_x: *i64, ex_y: *i64, nex: i64, op: *i64, a: *i64, b: *i64) -> i64 |