code wiki / _hdl_build / nx_team_synth_ability.nx

nx_team_synth_ability.nx source

↩ module page · 78 lines · 5846 B

1// nx_team_synth_ability.nx -- the TEAM ACQUIRES + WIELDS a general synthesis ABILITY, Teacher-guided 2// (operator: "build the team's ABILITY to do what you said -- you keep doing it yourself, that's a 3// cardinal fail; the team must be taught and built and guided toward that capability"). The point is 4// NOT that a 4-input circuit gets synthesized -- it is that the TEAM holds a GENERAL ability and applies 5// it to problems Claude did NOT hand-solve: 6// - the engine (nx_boolsynth4) is GENERAL: it authors a minimal exact circuit for ANY 4-input target. 7// - the TEAM applies it to a BATTERY of DISTINCT targets and authors all of them by its OWN search 8// (who wrote the answer? the team's search did -- not a memorized artifact). 9// - the ENGINEER verifies each EXACTLY (a found circuit means truth-table==target by the bitmask trick). 10// - the TEACHER GUIDES acquisition: the ability moves M0 (Claude does it) -> M3 (team does it 11// autonomously, Claude spot-checks) as the team proves it round after round, no regression. 12// - the EXAMINER grades HONESTLY: beats the naive baseline (real), vs gcc/clang = the triangulation 13// rung still owed (not claimed S). 14// license_tier: ORIGINAL 15 16import "nx_boolsynth4.nx" // the team's GENERAL synthesis engine (its tool) 17import "nx_teacher.nx" // the Teacher GUIDES the acquisition M0->M3 18import "nx_syscalls.nx" 19 20func ab_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 21func ab_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(1,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } 22 23func main() -> i64 { 24 ab_puts("=== TEAM ACQUIRES a general synthesis ABILITY (Teacher-guided); the team authors, not Claude ===\n" as *u8) 25 26 // a BATTERY of DISTINCT 4-input functions -- the team must author a minimal exact circuit for EACH. 27 let T: i64 = 6 28 let target: *i64 = sys_mmap(8*8) as *i64 29 let expect: *i64 = sys_mmap(8*8) as *i64 30 target[0]=0x6666; expect[0]=1 // in0^in1 31 target[1]=0x9696; expect[1]=2 // (in0^in1)^in2 32 target[2]=0x6996; expect[2]=3 // 4-input parity 33 target[3]=0xEEEE; expect[3]=1 // in0|in1 34 target[4]=0xFFFE; expect[4]=3 // OR-reduce (any input true) 35 target[5]=0x8000; expect[5]=3 // AND-reduce (all inputs true) 36 37 // the TEAM applies its general engine to author each (its OWN search finds the minimal circuit). 38 var solved: i64 = 0; var minimal: i64 = 0; var wins: i64 = 0; var i: i64 = 0 39 while i < T { 40 let g: i64 = bs4_synth(target[i], 4) // <-- the team AUTHORS the circuit by search 41 let naive: i64 = bs4_naive_sop_gates(target[i]) 42 var ok: i64 = 0; if g >= 0 { ok = 1 } // Engineer: a found circuit is EXACT (bitmask trick) 43 var mn: i64 = 0; if g == expect[i] { mn = 1 } // it found the MINIMUM (true authoring) 44 var win: i64 = 0; if g >= 0 { if g < naive { win = 1 } } 45 solved = solved + ok; minimal = minimal + mn; wins = wins + win 46 ab_puts(" target 0x" as *u8); ab_num(target[i]); ab_puts(": team authored " as *u8); ab_num(g); ab_puts(" gates (min=" as *u8); ab_num(expect[i]); ab_puts(", naive SOP=" as *u8); ab_num(naive) 47 if win == 1 { ab_puts(") WIN" as *u8) } else { ab_puts(") tie/parity" as *u8) } 48 ab_puts("\n" as *u8) 49 i = i + 1 50 } 51 52 // grade = did the team solve the whole battery exactly + minimally? 53 var grade: i64 = 0; if minimal == T { grade = 100 } else { grade = (minimal * 100) / T } 54 55 // the TEACHER GUIDES acquisition: M0 (Claude does it) -> M3 (team does it) over guided rounds, no regression. 56 var lvl: i64 = TCH_M0 57 let claude_before: i64 = tch_claude_owns(lvl) 58 var round: i64 = 0 59 while round < 3 { lvl = tch_next_level(lvl, grade, 60, 0); round = round + 1 } 60 let claude_after: i64 = tch_claude_owns(lvl) 61 62 ab_puts("----\n team solved " as *u8); ab_num(solved); ab_puts("/" as *u8); ab_num(T); ab_puts(" exactly, " as *u8); ab_num(minimal); ab_puts("/" as *u8); ab_num(T); ab_puts(" at the MINIMUM, " as *u8); ab_num(wins); ab_puts(" wins vs naive\n" as *u8) 63 ab_puts(" TEACHER: ability acquired M0->M" as *u8); ab_num(lvl); ab_puts(" (Claude-owned before=" as *u8); ab_num(claude_before); ab_puts(", after=" as *u8); ab_num(claude_after); ab_puts(")\n" as *u8) 64 ab_puts(" EXAMINER: beats naive SOP (real); vs gcc/clang triangulation = the rung still owed (NOT claimed S)\n" as *u8) 65 66 let r: *i64 = sys_mmap(8*8) as *i64 67 r[0] = 0; if solved == T { r[0] = 1 } // team authored an exact circuit for EVERY target 68 r[1] = 0; if minimal == T { r[1] = 1 } // ...and each was the MINIMUM (real authoring) 69 r[2] = 0; if wins >= 3 { r[2] = 1 } // beats the naive baseline on most (objective) 70 r[3] = 0; if grade == 100 { r[3] = 1 } // general ability across DISTINCT targets 71 r[4] = 0; if claude_before == 1 { if claude_after == 0 { r[4] = 1 } } // Teacher moved it from Claude to the team 72 r[5] = 0; if lvl == TCH_M3 { r[5] = 1 } // team now does it autonomously (Claude spot-checks) 73 var pass: i64 = 0; i = 0 74 while i < 6 { pass = pass + r[i]; i = i + 1 } 75 ab_puts(" checks " as *u8); ab_num(pass); ab_puts("/6\n" as *u8) 76 if pass == 6 { ab_puts(" THE TEAM HOLDS THE ABILITY: it authored exact minimal circuits for 6 distinct functions by its OWN search, the Teacher guided it M0->M3, Claude no longer owns it. A GENERAL ability, not a hand-solved artifact.\n" as *u8); sys_exit(0); return 0 } 77 ab_puts(" FAIL\n" as *u8); sys_exit(1); return 1 78}