Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/patches/2c582a566b1a81b6 # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/omega-mv#247 (code only) closed derived `2c582a566b1a81b6` #247 Imported from GitHub aien-dev/omega-mv#247 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `4ff8f0b1b7c1cdeec0105a912cccbf374a265706` · Head `bd3f1a639912a105925192a1e0899ef4ff6723e0` ### Apply it ``` git checkout -b patch-2c582a566b1a81b6 4ff8f0b1b7c1cdeec0105a912cccbf374a265706 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/2c582a566b1a81b6.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/omega-mv 247 bd3f1a639912a105925192a1e0899ef4ff6723e0 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":247,"url":"https://github.com/aien-dev/omega-mv/pull/247","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:57Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/docs/physics0/CALIBRATION.md b/docs/physics0/CALIBRATION.md index 4895cf45e..7db154edd 100644 --- a/docs/physics0/CALIBRATION.md +++ b/docs/physics0/CALIBRATION.md @@ -27,7 +27,7 @@ Bounds (section 6.1 to 6.3): in-box 0.02 (L6 0.03), extrapolation 0.06 (L6 0.08) | L3 | PASS, <= 5e-6 | PASS, coef <= 35 ppm | PASS, size 8, exact support | 0.032 (one seed, 1 of 31 episodes) | PASS | | L4 | PASS, <= 5e-6 | PASS, coef <= 35 ppm | PASS, size 4 | **0.57** (0.00 to 0.57; 14 of 20 seeds above 5 %) | **FAIL** | | L5 | PASS | PASS: in-box 0.002 to 0.010, extrap 0.002 to 0.007, one-step 0.0002 to 0.0013, coef 0.9 % to 1.9 % | in-box 0.002 to 0.014, coef 0.6 % to 2.4 %, size 4 (one seed 5) | 0.000 | PASS | -| L6 | PASS: in-box <= 3e-6, extrap <= 3e-6 | NOT_RUN (latent estimation not in this cut) | latent-free: in-box 0.021, 0.028, 0.033, 0.035, 0.072 | 0.000 | PASS | +| L6 | PASS: in-box <= 3e-6, extrap <= 3e-6 | PASS (latent estimator, see L6 detail below): in-box <= 3e-6, extrap <= 4e-6 | latent-free: in-box 0.021, 0.028, 0.033, 0.035, 0.072 | 0.000 | PASS | Mutant control: with the L1 spring sign flipped in the generator (`-DPD0_MUTANT_SIGN`) the oracle check reports `PHYSICS0_G1_V1_L1-mutant: FAIL`, so the check bites (`build/physics0/mutant.out`, copied into the G0 receipt). @@ -51,7 +51,21 @@ Mutant control: with the L1 spring sign flipped in the generator (`-DPD0_MUTANT_ ## 4. Limits of this calibration - Seeds 1..5 for V1, 1..20 for V3 (as the spec's development set). No scored-seed commitments were made. -- `oracle_fit` for L6 is NOT_RUN: fitting constants with a hidden state needs a latent estimator, not written in this cut. `oracle_exact` covers the "is the bound reachable by the true map" question for L6. +- `oracle_fit` for L6 uses the latent estimator of substrate cut 2 (detail below). The h scale is not identifiable (spec 4.1), so it is fixed to q = 1 and only the product m*q is compared; the oracle also checks that the fitted k, w, m*q lie in the generator ranges, which is what catches a wrong latent sign. - The sparse reference solver is deterministic and has no tuning knobs beyond the spec's `description_bits` rule; it is a reference, not a learner. - Nothing here ran a ladder, a planner, a negative control over the ladder or a learner. `PD0_CONTROLS_PASS` is not claimed. - Floating point enters only in the calibration code (least squares, NRMSE); every world value, record byte and relation coefficient is an integer. + +## L6 latent estimator (substrate cut 2) + +Method: the generator form is known to the oracle. With a = 1 - w*dt the latent is g' = a*g + dt*s0 (g = 0 at the first step of every episode, h = q*g), so (ds1 - u*dt) = (-k*dt)*s0 + (m*q*dt)*g is linear in (k, m*q) for each candidate w. The estimator solves that 2-parameter least squares over a w grid (0.2 to 4.0, step 0.05) and refines the best w by golden section. FIT and SELECT data only; thresholds untouched; scored by the section 6.1 rule (20 episodes of 20 steps, half in-box, half extrapolation, h = 0 at start). + +| seed | in-box NRMSE | extrap NRMSE | k err (ppm) | w err (ppm) | m*q err (ppm) | +| --- | --- | --- | --- | --- | --- | +| 1 | 2e-6 | 2e-6 | 2 | 16 | 15 | +| 2 | 2e-6 | 1e-6 | 0 | 3 | 28 | +| 3 | 3e-6 | 4e-6 | 3 | 9 | 6 | +| 4 | 2e-6 | 2e-6 | 1 | 17 | 12 | +| 5 | 2e-6 | 2e-6 | 2 | 6 | 6 | + +Bounds 0.03 in-box and 0.08 extrapolation: met by a wide margin; `oracle_fit` L6 PASS on 5 of 5 seeds. Mutant: with the sign of m*h flipped in the generator (`PD0_MUTANT_LATENT_SIGN`), `oracle_fit` FAILs on 5 of 5 seeds because the fitted m*q comes out negative (about -0.4 to -0.9, declared range 0.25 to 1). Note the refitted model still predicts the mutant world well; it is the declared-range check that fails, not the prediction bound. Numbers above come from evidence/physics0/pd0-oracle-L6-fit.json (cut 2; the cut 1 file pd0-oracle-L6.json is immutable and keeps oracle_fit NOT_RUN). Cut 2 G0 receipt: evidence/physics0/pd0-g0-receipt-cut2.txt. diff --git a/evidence/physics0/pd0-g0-receipt-cut2.txt b/evidence/physics0/pd0-g0-receipt-cut2.txt new file mode 100644 index 000000000..6a7d82674 --- /dev/null +++ b/evidence/physics0/pd0-g0-receipt-cut2.txt @@ -0,0 +1,22 @@ +receipt: PD0_G0 +spec: aien-dev/physics docs/PD0_HIDDEN_EQUATION_BENCHMARK.md @ 2f881b1 (rev 2) +recorder: STAND_IN +range_guard: STAND_IN +commit: 7afd30f77100f8752f519bdab47aa58bc05abaf8 +date_utc: 2026-10-03T23:58:02Z +--- test_pd0_world +checks=1094 failures=0 +PHYSICS0_G0: PASS +--- isolation +PHYSICS0_ISOLATION: PASS (4 learner-side objects clean) +--- osc differential +osc differential: runs=200000 mismatches=0 native=yes +PHYSICS0_OSC_DIFF: PASS +--- mutant +PHYSICS0_G1_V1_L1-mutant: FAIL (oracle_exact FAIL, oracle_fit FAIL) +PHYSICS0_G1_V3_L1-mutant: FAIL (worst breach rate 0.9907 over seeds 1..20) +PHYSICS0_ORACLE-mutant: FAIL +--- mutant latent sign +PHYSICS0_G1_V1_L6-mutlat: FAIL (oracle_exact FAIL, oracle_fit FAIL) +PHYSICS0_G1_V3_L6-mutlat: PASS (worst breach rate 0.0370 over seeds 1..20) +PHYSICS0_ORACLE-mutlat: FAIL diff --git a/evidence/physics0/pd0-oracle-L6-fit.json b/evidence/physics0/pd0-oracle-L6-fit.json new file mode 100644 index 000000000..e1f98d9ab --- /dev/null +++ b/evidence/physics0/pd0-oracle-L6-fit.json @@ -0,0 +1,43 @@ +{ + "receipt": "PD0_G1", + "level": "L6", + "spec": "aien-dev/physics docs/PD0_HIDDEN_EQUATION_BENCHMARK.md @ 2f881b1 (rev 2)", + "recorder": "STAND_IN", + "range_guard": "STAND_IN", + "bounds": {"inbox": 0.030, "extrap": 0.080, "onestep": -1.000, "coef_ppm": -1, "size": 9}, + "instances": [ + {"seed": 1, "constants_micro": [2553302, 905570, 1643841, 584554], "fit_transitions": 8000, "fit_episodes": 80, + "oracle_exact": {"nrmse_inbox": 0.000003, "nrmse_extrap": 0.000003, "nrmse_onestep": 0.005233, "truth_oob_episodes": 0, "coef_err_ppm": 0, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit": {"nrmse_inbox": 0.000002, "nrmse_extrap": 0.000002, "nrmse_onestep": 0.005233, "truth_oob_episodes": 0, "coef_err_ppm": 710746, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit_l6_estimate": {"k": 2.553295, "w": 1.643814, "m_times_q": 0.529344, "h_scale": "q=1 convention", "fit_sse": 1.426e-09, "err_ppm": {"k": 2, "w": 16, "m_times_q": 15}, "in_declared_ranges": "PASS"}, + "sparse_ref": {"nrmse_inbox": 0.035298, "nrmse_extrap": 0.034693, "nrmse_onestep": 0.003649, "truth_oob_episodes": 0, "coef_err_ppm": -1, "size": 4, "description_bits": 192, "support": false, "checks": {"inbox": "FAIL", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "FAIL"}, "verdict": "FAIL"} + }, + {"seed": 2, "constants_micro": [3692588, 885899, 1687648, 967737], "fit_transitions": 8000, "fit_episodes": 80, + "oracle_exact": {"nrmse_inbox": 0.000003, "nrmse_extrap": 0.000002, "nrmse_onestep": 0.008794, "truth_oob_episodes": 0, "coef_err_ppm": 0, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit": {"nrmse_inbox": 0.000002, "nrmse_extrap": 0.000001, "nrmse_onestep": 0.008794, "truth_oob_episodes": 0, "coef_err_ppm": 33356, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit_l6_estimate": {"k": 3.692581, "w": 1.687636, "m_times_q": 0.857308, "h_scale": "q=1 convention", "fit_sse": 1.284e-09, "err_ppm": {"k": 0, "w": 3, "m_times_q": 28}, "in_declared_ranges": "PASS"}, + "sparse_ref": {"nrmse_inbox": 0.033297, "nrmse_extrap": 0.026396, "nrmse_onestep": 0.003504, "truth_oob_episodes": 0, "coef_err_ppm": -1, "size": 4, "description_bits": 192, "support": false, "checks": {"inbox": "FAIL", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "FAIL"}, "verdict": "FAIL"} + }, + {"seed": 3, "constants_micro": [3191717, 685972, 1936071, 764346], "fit_transitions": 8000, "fit_episodes": 80, + "oracle_exact": {"nrmse_inbox": 0.000002, "nrmse_extrap": 0.000003, "nrmse_onestep": 0.004151, "truth_oob_episodes": 0, "coef_err_ppm": 0, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit": {"nrmse_inbox": 0.000003, "nrmse_extrap": 0.000004, "nrmse_onestep": 0.004151, "truth_oob_episodes": 0, "coef_err_ppm": 308318, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit_l6_estimate": {"k": 3.191709, "w": 1.936043, "m_times_q": 0.524310, "h_scale": "q=1 convention", "fit_sse": 1.299e-09, "err_ppm": {"k": 3, "w": 9, "m_times_q": 6}, "in_declared_ranges": "PASS"}, + "sparse_ref": {"nrmse_inbox": 0.027706, "nrmse_extrap": 0.023133, "nrmse_onestep": 0.002598, "truth_oob_episodes": 0, "coef_err_ppm": -1, "size": 4, "description_bits": 192, "support": false, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "FAIL"}, "verdict": "FAIL"} + }, + {"seed": 4, "constants_micro": [4104743, 522824, 1264029, 770582], "fit_transitions": 8000, "fit_episodes": 80, + "oracle_exact": {"nrmse_inbox": 0.000001, "nrmse_extrap": 0.000001, "nrmse_onestep": 0.003031, "truth_oob_episodes": 0, "coef_err_ppm": 0, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit": {"nrmse_inbox": 0.000002, "nrmse_extrap": 0.000002, "nrmse_onestep": 0.003031, "truth_oob_episodes": 0, "coef_err_ppm": 297723, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit_l6_estimate": {"k": 4.104735, "w": 1.263999, "m_times_q": 0.402870, "h_scale": "q=1 convention", "fit_sse": 1.350e-09, "err_ppm": {"k": 1, "w": 17, "m_times_q": 12}, "in_declared_ranges": "PASS"}, + "sparse_ref": {"nrmse_inbox": 0.020864, "nrmse_extrap": 0.020414, "nrmse_onestep": 0.001858, "truth_oob_episodes": 0, "coef_err_ppm": -1, "size": 4, "description_bits": 192, "support": false, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "FAIL"}, "verdict": "FAIL"} + }, + {"seed": 5, "constants_micro": [2438672, 990681, 1430304, 907476], "fit_transitions": 8000, "fit_episodes": 80, + "oracle_exact": {"nrmse_inbox": 0.000002, "nrmse_extrap": 0.000002, "nrmse_onestep": 0.010138, "truth_oob_episodes": 0, "coef_err_ppm": 0, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit": {"nrmse_inbox": 0.000002, "nrmse_extrap": 0.000002, "nrmse_onestep": 0.010138, "truth_oob_episodes": 0, "coef_err_ppm": 101976, "size": 7, "description_bits": 344, "support": true, "checks": {"inbox": "PASS", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "PASS"}, "verdict": "PASS"}, + "oracle_fit_l6_estimate": {"k": 2.438665, "w": 1.430291, "m_times_q": 0.899008, "h_scale": "q=1 convention", "fit_sse": 1.531e-09, "err_ppm": {"k": 2, "w": 6, "m_times_q": 6}, "in_declared_ranges": "PASS"}, + "sparse_ref": {"nrmse_inbox": 0.071561, "nrmse_extrap": 0.076498, "nrmse_onestep": 0.007777, "truth_oob_episodes": 0, "coef_err_ppm": -1, "size": 4, "description_bits": 192, "support": false, "checks": {"inbox": "FAIL", "extrap": "PASS", "onestep": "NOT_SCORED", "coef": "NOT_SCORED", "size": "PASS", "support": "FAIL"}, "verdict": "FAIL"} + } + ], + "v3_breach": [{"seed": 1, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 2, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 3, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 4, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 5, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 6, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 7, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 8, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 9, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 10, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 11, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 12, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 13, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 14, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 15, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 16, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 17, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 18, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 19, "episodes": 80, "oob": 0, "rate": 0.0000}, {"seed": 20, "episodes": 80, "oob": 0, "rate": 0.0000}], + "v3_worst_rate": 0.0000, + "verdicts": {"V1_oracle_exact": "PASS", "V1_oracle_fit": "PASS", "V3": "PASS"} +} diff --git a/mk/physics0.mk b/mk/physics0.mk index faa4099f5..3385cb7a7 100644 --- a/mk/physics0.mk +++ b/mk/physics0.mk @@ -61,6 +61,11 @@ $(P0_DIR)/pd0-oracle-mutant: tests/physics0/pd0_oracle.c $(P0_CALIB) $(P0_SRCS) @mkdir -p $(P0_DIR) $(CC) $(P0_CFLAGS) -DPD0_MUTANT_SIGN -o $@ tests/physics0/pd0_oracle.c $(P0_CALIB) $(P0_SRCS) -lm +# wrong-latent-sign mutant: L6 generator uses -m*h; oracle_fit must FAIL (its fitted m*q leaves the declared range) +$(P0_DIR)/pd0-oracle-mutant-latent: tests/physics0/pd0_oracle.c $(P0_CALIB) $(P0_SRCS) $(P0_HDRS) $(P0_CALIB_HDRS) + @mkdir -p $(P0_DIR) + $(CC) $(P0_CFLAGS) -DPD0_MUTANT_LATENT_SIGN -o $@ tests/physics0/pd0_oracle.c $(P0_CALIB) $(P0_SRCS) -lm + $(P0_DIR)/test_pd0_osc: tests/physics0/test_pd0_osc.c $(P0_OSC_LIB) $(P0_LEARNER_SRCS) src/sha256.c $(P0_HDRS) @mkdir -p $(P0_DIR) $(CC) $(P0_OSC_CFLAGS) -o $@ tests/physics0/test_pd0_osc.c $(P0_OSC_LIB) $(P0_LEARNER_SRCS) src/sha256.c -lm @@ -69,7 +74,7 @@ $(P0_DIR)/test_pd0_osc_asan: tests/physics0/test_pd0_osc.c $(P0_OSC_LIB) $(P0_LE $(CC) $(P0_OSC_CFLAGS) $(P0_ASAN) -o $@ tests/physics0/test_pd0_osc.c $(P0_OSC_LIB) $(P0_LEARNER_SRCS) src/sha256.c -lm physics0-test: $(P0_DIR)/test_pd0_world $(P0_DIR)/test_pd0_world_asan $(P0_LEARNER_OBJS) $(P0_DIR)/learner/pd0_gen.o \ - $(P0_DIR)/pd0-oracle $(P0_DIR)/pd0-oracle_asan $(P0_DIR)/pd0-oracle-mutant \ + $(P0_DIR)/pd0-oracle $(P0_DIR)/pd0-oracle_asan $(P0_DIR)/pd0-oracle-mutant $(P0_DIR)/pd0-oracle-mutant-latent \ $(P0_DIR)/test_pd0_osc $(P0_DIR)/test_pd0_osc_asan $(P0_DIR)/pd0-world @mkdir -p $(P0_DIR)/receipts ./$(P0_DIR)/test_pd0_world > $(P0_DIR)/g0.out; tail -1 $(P0_DIR)/g0.out; grep -q '^PHYSICS0_G0: PASS$$' $(P0_DIR)/g0.out @@ -80,13 +85,17 @@ physics0-test: $(P0_DIR)/test_pd0_world $(P0_DIR)/test_pd0_world_asan $(P0_LEARN cmp $(P0_DIR)/receipts/pd0-oracle-L1.json $(P0_DIR)/pd0-oracle-L1-asan.json -./$(P0_DIR)/pd0-oracle-mutant 1 $(P0_DIR) -mutant > $(P0_DIR)/mutant.out @grep -q '^PHYSICS0_G1_V1_L1-mutant: FAIL' $(P0_DIR)/mutant.out && echo "PHYSICS0_MUTANT_SIGN: PASS (wrong generator sign is caught by the oracle check)" || { echo "PHYSICS0_MUTANT_SIGN: FAIL"; exit 1; } + -./$(P0_DIR)/pd0-oracle-mutant-latent 6 $(P0_DIR) -mutlat > $(P0_DIR)/mutant_latent.out + @grep -q "^PHYSICS0_G1_V1_L6-mutlat: FAIL (oracle_exact FAIL, oracle_fit FAIL)" $(P0_DIR)/mutant_latent.out && echo "PHYSICS0_MUTANT_LATENT_SIGN: PASS (wrong latent sign makes oracle_fit FAIL)" || { echo "PHYSICS0_MUTANT_LATENT_SIGN: FAIL"; exit 1; } ./$(P0_DIR)/test_pd0_osc tests/physics0/osc/pd0_helpers.osc 20000 > $(P0_DIR)/osc.out; tail -2 $(P0_DIR)/osc.out; grep -q '^PHYSICS0_OSC_DIFF: PASS$$' $(P0_DIR)/osc.out ./$(P0_DIR)/test_pd0_osc_asan tests/physics0/osc/pd0_helpers.osc 2000 > $(P0_DIR)/osc_asan.out; tail -1 $(P0_DIR)/osc_asan.out; grep -q '^PHYSICS0_OSC_DIFF: PASS$$' $(P0_DIR)/osc_asan.out @echo "physics0-test: PASS (G0, G5 isolation, G1 V1 oracle all levels, V3 breach rates recorded, mutant caught, OSC differential; substrate only, no learner)" +# Receipts are immutable: existing evidence files are never rewritten (cp -n); each cut adds new files. physics0-evidence: physics0-test - cp $(P0_DIR)/receipts/pd0-oracle-*.json evidence/physics0/ + for f in $(P0_DIR)/receipts/pd0-oracle-*.json; do cp -n "$$f" evidence/physics0/; done + cp $(P0_DIR)/receipts/pd0-oracle-L6.json evidence/physics0/pd0-oracle-L6-fit.json { echo "receipt: PD0_G0"; echo "spec: aien-dev/physics docs/PD0_HIDDEN_EQUATION_BENCHMARK.md @ 2f881b1 (rev 2)"; echo "recorder: STAND_IN"; echo "range_guard: STAND_IN"; \ echo "commit: $$(git rev-parse HEAD)"; echo "date_utc: $$(date -u +%Y-%m-%dT%H:%M:%SZ)"; echo "--- test_pd0_world"; cat $(P0_DIR)/g0.out; \ - echo "--- isolation"; cat $(P0_DIR)/isolation.out; echo "--- osc differential"; cat $(P0_DIR)/osc.out; echo "--- mutant"; cat $(P0_DIR)/mutant.out; } > evidence/physics0/pd0-g0-receipt.txt + echo "--- isolation"; cat $(P0_DIR)/isolation.out; echo "--- osc differential"; cat $(P0_DIR)/osc.out; echo "--- mutant"; cat $(P0_DIR)/mutant.out; echo "--- mutant latent sign"; cat $(P0_DIR)/mutant_latent.out; } > evidence/physics0/pd0-g0-receipt-cut2.txt endif diff --git a/src/physics0/pd0_gen.c b/src/physics0/pd0_gen.c index 567ec0fb0..340d6cddd 100644 --- a/src/physics0/pd0_gen.c +++ b/src/physics0/pd0_gen.c @@ -2,7 +2,7 @@ * revision 2) verbatim in integer micro-units. Discrete maps: the law is the * map written here, not the differential equation it resembles. * Build with -DPD0_MUTANT_SIGN to flip the sign of the spring term in L1 - * (NC-3 style mutation: the oracle check must then FAIL). */ + * (NC-3 style mutation: the oracle check must then FAIL). -DPD0_MUTANT_LATENT_SIGN flips the sign of m*h in L6. */ #include "physics0/pd0_gen.h" #include "physics0/pd0_guard.h" @@ -107,7 +107,12 @@ int pd0_gen_step(const pd0_gen *g, const int64_t *s, int64_t h, const int64_t *u case PD0_L6: { const int64_t m = g->k[1], w = g->k[2], q = g->k[3]; o[0] = s[0] + pd0_mul(s[1], dt); - o[1] = s[1] + pd0_mul(-pd0_mul(k, s[0]) + pd0_mul(m, h) + u[0], dt); +#ifdef PD0_MUTANT_LATENT_SIGN + const int64_t lat = -pd0_mul(m, h); /* wrong latent sign: the spec says +m*h */ +#else + const int64_t lat = pd0_mul(m, h); +#endif + o[1] = s[1] + pd0_mul(-pd0_mul(k, s[0]) + lat + u[0], dt); hn = h + pd0_mul(-pd0_mul(w, h) + pd0_mul(q, s[0]), dt); break; } diff --git a/tests/physics0/pd0_oracle.c b/tests/physics0/pd0_oracle.c index 2f882d50d..8f2eb4a69 100644 --- a/tests/physics0/pd0_oracle.c +++ b/tests/physics0/pd0_oracle.c @@ -20,6 +20,7 @@ #include "pd0_calib.h" #include "pd0_sparse.h" + #define SEEDS 5 static const double BOUND_IN[PD0_LEVELS] = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.03, 0}; @@ -27,11 +28,84 @@ static const double BOUND_EX[PD0_LEVELS] = {0.06, 0.06, 0.06, 0.06, 0.06, 0.06, static const double BOUND_ONE[PD0_LEVELS] = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, -1, 0}; static const int64_t COEF_PPM[PD0_LEVELS] = {50000, 50000, 50000, 50000, 50000, 100000, -1, 0}; +/* L6 latent estimator. The oracle knows the generator FORM (spec 4.1): + * ds1 = (-k s0 + m h + u) dt, dh = (-w h + q s0) dt, h = 0 at every reset. + * The scale of h is not identifiable, so h is fixed to the q = 1 convention + * (h_hat = h / q) and the product m*q is what is fitted. Given a = 1 - w dt the + * latent trajectory is a linear recursion of observed s0 alone, + * g' = a g + dt s0, g = 0 at the first step of every episode, + * and (ds1 - u dt) = (-k dt) s0 + (m q dt) g is linear in (k, m q). So: for each + * candidate w solve a 2-parameter least squares, keep the w with least squared + * residual (coarse grid over a wide w range, then golden-section refinement). + * Exact and deterministic; no alternation needed. FIT/SELECT data only. */ +typedef struct { double k, mq, w, sse; } l6_est; + +static double l6_eval(const pd0_gather *g, double w, double dt, double *k_out, double *mq_out) { + int n = g->n; + double a = 1.0 - w * dt, hh = 0, sxx = 0, sxg = 0, sgg = 0, sxy = 0, sgy = 0, syy = 0; + uint32_t ep = 0; + for (int i = 0; i < n; i++) { + const pd0_transition *t = &g->t[i]; + if (i == 0 || t->episode != ep) { hh = 0; ep = t->episode; } + double s0 = (double)t->before[0] / 1e6; + double y = (double)(t->after[1] - t->before[1]) / 1e6 - dt * ((double)t->u[0] / 1e6); + sxx += s0 * s0; sxg += s0 * hh; sgg += hh * hh; sxy += s0 * y; sgy += hh * y; syy += y * y; + hh = a * hh + dt * s0; + } + double det = sxx * sgg - sxg * sxg; + if (fabs(det) < 1e-18) return -1; + double bx = (sxy * sgg - sgy * sxg) / det, bg = (sgy * sxx - sxy * sxg) / det; + if (k_out) *k_out = -bx / dt; + if (mq_out) *mq_out = bg / dt; + return syy - 2 * (bx * sxy + bg * sgy) + bx * bx * sxx + 2 * bx * bg * sxg + bg * bg * sgg; +} + +static int l6_estimate(const pd0_gather *g, double dt, l6_est *e) { + double best = -1, bw = 0; + for (double w = 0.2; w <= 4.0001; w += 0.05) { + double s = l6_eval(g, w, dt, NULL, NULL); + if (s >= 0 && (best < 0 || s < best)) { best = s; bw = w; } + } + if (best < 0) return -1; + double lo = bw - 0.05, hi = bw + 0.05, gr = 0.6180339887498949; + for (int it = 0; it < 60; it++) { + double c = hi - gr * (hi - lo), d = lo + gr * (hi - lo); + if (l6_eval(g, c, dt, NULL, NULL) < l6_eval(g, d, dt, NULL, NULL)) hi = d; else lo = c; + } + e->w = 0.5 * (lo + hi); + e->sse = l6_eval(g, e->w, dt, &e->k, &e->mq); + return e->sse < 0 ? -1 : 0; +} + +/* per-coefficient errors in ppm vs truth (k, w directly; m*q as the identifiable product) */ +static l6_est g_l6_est; +static int64_t g_l6_err[3]; +static int g_l6_in_range; +static int64_t l6_ppm(double est, double tru) { return (int64_t)llround(fabs(est - tru) / fabs(tru) * 1e6); } + +static int oracle_fit_l6(const pd0_relation *truth, const pd0_gather *g, pd0_relation *out) { + *out = *truth; + double dt = (double)truth->eq[0].t[0].coef / 1e6, ktr = -(double)truth->eq[1].t[0].coef / 1e6 / dt; + double m = (double)truth->eq[1].t[1].coef / 1e6 / dt, w_tr = -(double)truth->eq[2].t[0].coef / 1e6 / dt; + double q = (double)truth->eq[2].t[1].coef / 1e6 / dt; + l6_est e; + if (l6_estimate(g, dt, &e)) return -1; + g_l6_est = e; + g_l6_err[0] = l6_ppm(e.k, ktr); g_l6_err[1] = l6_ppm(e.w, w_tr); g_l6_err[2] = l6_ppm(e.mq, m * q); + /* the form's declared constant ranges (spec 4.1): k [2,5], w [1,2], m*q [0.25,1] */ + g_l6_in_range = e.k >= 2.0 && e.k <= 5.0 && e.w >= 1.0 && e.w <= 2.0 && e.mq >= 0.25 && e.mq <= 1.0; + out->eq[1].t[0].coef = -(int64_t)llround(e.k * dt * 1e6); + out->eq[1].t[1].coef = (int64_t)llround(e.mq * dt * 1e6); /* h scale: q = 1 */ + out->eq[2].t[0].coef = -(int64_t)llround(e.w * dt * 1e6); + out->eq[2].t[1].coef = (int64_t)llround(dt * 1e6); + return 0; +} + /* fit only the constants of the true form: per equation, least squares of * D target on the true monomials over FIT transitions (observed vars only) */ static int oracle_fit(const pd0_relation *truth, const pd0_gather *g, pd0_relation *out) { *out = *truth; - if (truth->n_latent) return -1; /* latent estimation not implemented in this cut */ + if (truth->n_latent) return oracle_fit_l6(truth, g, out); for (int e = 0; e < truth->n_eq; e++) { const pd0_eq *te = &truth->eq[e]; int p = te->n_terms, n = g->n; @@ -61,7 +135,9 @@ static void emit_result(FILE *f, const char *name, const pd0_calib_result *r, co int ok_coef = COEF_PPM[level] < 0 || (ppm >= 0 && ppm <= COEF_PPM[level]); int ok_size = pd0_relation_size(rel) <= pd0_gen_true_size(level) + 2; int ok_support = pd0_relation_supports(rel, truth); - int ok = ok_in && ok_ex && ok_one && ok_coef && ok_size && ok_support; + int is_l6fit = level == PD0_L6 && strcmp(name, "oracle_fit") == 0; + int ok_range = !is_l6fit || g_l6_in_range; + int ok = ok_in && ok_ex && ok_one && ok_coef && ok_size && ok_support && ok_range; if (all_ok) *all_ok &= ok; fprintf(f, " \"%s\": {\"nrmse_inbox\": %.6f, \"nrmse_extrap\": %.6f, \"nrmse_onestep\": %.6f, " "\"truth_oob_episodes\": %d, \"coef_err_ppm\": %lld, \"size\": %d, \"description_bits\": %u, " @@ -71,6 +147,10 @@ static void emit_result(FILE *f, const char *name, const pd0_calib_result *r, co pd0_relation_size(rel), pd0_relation_description_bits(rel), ok_support ? "true" : "false", pf(ok_in), pf(ok_ex), BOUND_ONE[level] < 0 ? "NOT_SCORED" : pf(ok_one), COEF_PPM[level] < 0 ? "NOT_SCORED" : pf(ok_coef), pf(ok_size), pf(ok_support), pf(ok)); + if (is_l6fit) + fprintf(f, ", \n \"oracle_fit_l6_estimate\": {\"k\": %.6f, \"w\": %.6f, \"m_times_q\": %.6f, \"h_scale\": \"q=1 convention\", \"fit_sse\": %.3e, " + "\"err_ppm\": {\"k\": %lld, \"w\": %lld, \"m_times_q\": %lld}, \"in_declared_ranges\": \"%s\"}", + g_l6_est.k, g_l6_est.w, g_l6_est.mq, g_l6_est.sse, (long long)g_l6_err[0], (long long)g_l6_err[1], (long long)g_l6_err[2], pf(ok_range)); } int main(int argc, char **argv) { @@ -111,7 +191,7 @@ int main(int argc, char **argv) { emit_result(f, "oracle_exact", &r_exact, &truth, &truth, level, &v1_exact); fprintf(f, ",\n"); if (have_fit) emit_result(f, "oracle_fit", &r_fit, &fit, &truth, level, &v1_fit); - else fprintf(f, " \"oracle_fit\": \"NOT_RUN (latent estimation not in this cut)\""); + else fprintf(f, " \"oracle_fit\": \"NOT_RUN\""); fprintf(f, ",\n"); if (have_sparse) emit_result(f, "sparse_ref", &r_sparse, &sparse, &truth, level, NULL); else fprintf(f, " \"sparse_ref\": \"NOT_RUN\""); @@ -130,10 +210,10 @@ int main(int argc, char **argv) { free(gg.t); } fprintf(f, "],\n \"v3_worst_rate\": %.4f,\n \"verdicts\": {\"V1_oracle_exact\": \"%s\", \"V1_oracle_fit\": \"%s\", \"V3\": \"%s\"}\n}\n", - worst_breach, pf(v1_exact), level == PD0_L6 ? "NOT_RUN" : pf(v1_fit), pf(v3)); + worst_breach, pf(v1_exact), pf(v1_fit), pf(v3)); fclose(f); printf("PHYSICS0_G1_V1_%s%s: %s (oracle_exact %s, oracle_fit %s)\n", pd0_gen_level_name(level), tag, - pf(v1_exact && (level == PD0_L6 || v1_fit)), pf(v1_exact), level == PD0_L6 ? "NOT_RUN" : pf(v1_fit)); + pf(v1_exact && v1_fit), pf(v1_exact), pf(v1_fit)); printf("PHYSICS0_G1_V3_%s%s: %s (worst breach rate %.4f over seeds 1..20)\n", pd0_gen_level_name(level), tag, pf(v3), worst_breach); overall &= v1_exact; } ```