code wiki / _hdl_build / nx_synth.nx

nx_synth.nx

buildroot/runtime/_hdl_build/nx_synth.nx

3838 B104 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic synth
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_synth.nx nx_synth_test.nx nx_team_selfdirect_test.nx nx_team_selfsufficient_test.nx

imports: nx_syscalls.nx

imported by: nx_synth_test.nxnx_team_selfdirect_test.nxnx_team_selfsufficient_test.nx

structs

none

consts

14const OP_ADD: i64 = 0
15const OP_SUB: i64 = 1
16const OP_MUL: i64 = 2
17const OP_SHL: i64 = 3

functions

23func synth_eval(op: *i64, a: *i64, b: *i64, L: i64, x: i64, s: *i64) -> i64
41func synth_matches(op: *i64, a: *i64, b: *i64, L: i64, ex_x: *i64, ex_y: *i64, nex: i64, s: *i64) -> i64
called by 1: synth_find calls 1: synth_eval
52func synth_find(ex_x: *i64, ex_y: *i64, nex: i64, op: *i64, a: *i64, b: *i64) -> i64