code wiki / _hdl_build / nx_paper_emit_test.nx

nx_paper_emit_test.nx source

↩ module page · 51 lines · 3890 B

1// nx_paper_emit_test.nx -- the team captures a proven result in BOTH formats (data + paper), gated. 2// The honest VQ result publishes (data record has the fields, paper has the scientific sections); an 3// OVERCLAIM emits NOTHING (not captured -> can't meet outside critics). Exit 0 if both hold. 4// license_tier: ORIGINAL 5 6import "nx_paper_emit.nx" 7import "nx_syscalls.nx" 8 9func et_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 10func et_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; 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 } 11 12func main() -> i64 { 13 et_puts("=== CAPTURE OUTPUT: data record + research paper, gated by no-overclaim ===\n" as *u8) 14 let data: *u8 = sys_mmap(4096); let paper: *u8 = sys_mmap(8192) 15 let cap: *u8 = "vector-quantization" as *u8 16 let claim: *u8 = "A team-authored Lloyd vector codebook beats scalar quantization 83% on correlated weights." as *u8 17 let method: *u8 = "Lloyd search over weight pairs, 16 codewords, vs a scalar 4x4 grid; MSE vs the Shannon bound." as *u8 18 let gw: *u8 = "A-parity: beats scalar, NOT SOTA (SOTA is also vector/trellis quantization)." as *u8 19 let cav: *u8 = "Beating scalar != beating SOTA; the iid bound over-estimates on correlated data; trellis VQ is the next lever." as *u8 20 let gate: *u8 = "nx_vector_quant_test 4/4 (deterministic, re-runnable)." as *u8 21 22 // honest paper: claim A-parity (3), honest grade A-parity (3) -> PUBLISH, both formats captured 23 let d1: i64 = pe_publish(data, paper, 1, 1, 1, cap, claim, method, 3, 20, 124, 15, 3, gw, cav, gate) 24 et_puts(" honest result -> decision=" as *u8); et_num(d1); et_puts(" (2=PUBLISH)\n" as *u8) 25 et_puts(" --- DATA RECORD ---\n " as *u8); et_puts(data) 26 et_puts(" --- PAPER (head) ---\n" as *u8); et_puts(paper); et_puts("\n" as *u8) 27 28 let has_fields: i64 = 0 29 if pe_contains(data, "RESULT cap=" as *u8) == 1 { if pe_contains(data, "grade=" as *u8) == 1 { if pe_contains(data, "reproducible=" as *u8) == 1 { } } } 30 // section checks on the paper 31 let s_claim: i64 = pe_contains(paper, "## Claim" as *u8) 32 let s_method: i64 = pe_contains(paper, "## Method" as *u8) 33 let s_grade: i64 = pe_contains(paper, "## Honest grade" as *u8) 34 let s_repro: i64 = pe_contains(paper, "## Reproducibility" as *u8) 35 36 // overclaim: claim S (4), honest A (3) -> REJECT, nothing captured 37 let data2: *u8 = sys_mmap(4096); let paper2: *u8 = sys_mmap(8192) 38 let d2: i64 = pe_publish(data2, paper2, 1, 0, 1, cap, claim, method, 4, 20, 124, 15, 3, gw, cav, gate) 39 et_puts(" overclaim result -> decision=" as *u8); et_num(d2); et_puts(" (0=REJECT) paper-bytes captured=" as *u8); et_num(pe_slen(paper2)); et_puts("\n" as *u8) 40 41 let r: *i64 = sys_mmap(8*8) as *i64 42 r[0] = 0; if d1 == SCI_PUBLISH { r[0] = 1 } // honest -> published 43 r[1] = 0; if pe_contains(data, "RESULT cap=" as *u8) == 1 { if pe_contains(data, "grade=" as *u8) == 1 { r[1] = 1 } } // data record fields 44 r[2] = 0; if s_claim == 1 { if s_method == 1 { if s_grade == 1 { if s_repro == 1 { r[2] = 1 } } } } // paper sections 45 r[3] = 0; if d2 == SCI_REJECT { if pe_slen(paper2) == 0 { r[3] = 1 } } // overclaim -> nothing captured 46 var pass: i64 = 0; var i: i64 = 0 47 while i < 4 { pass = pass + r[i]; i = i + 1 } 48 et_puts("----\n passed " as *u8); et_num(pass); et_puts("/4\n" as *u8) 49 if pass == 4 { et_puts(" CAPTURE LIVE: every honest result -> a data record + a publishable paper; overclaims captured as NOTHING. The team can publish.\n" as *u8); sys_exit(0); return 0 } 50 et_puts(" FAIL\n" as *u8); sys_exit(1); return 1 51}