Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
f325f3f
LSA-02H: Lean-authoritative recoverable off-reference state extractor…
patrickdugan Nov 23, 2026
8ebfdf4
LSA-02H: same-host matched reference/offpath/sham CPU fit with exact …
patrickdugan Nov 23, 2026
d610e7c
LSA-02H: native Lean evaluator authenticates offreference source proo…
patrickdugan Nov 23, 2026
9a40853
LSA-02H: simulate recoverable and dead alternative Lean branches, ver…
patrickdugan Nov 23, 2026
e1eb6d6
LSA-02H: post-native Lean calibration of recoverable offpath states a…
patrickdugan Nov 23, 2026
77ba410
LSA-02H preregistration: certified recoverable deviations, same-root …
patrickdugan Nov 23, 2026
8aabfb5
LSA-02H test matched root/switch schedules and same-start offreferenc…
patrickdugan Nov 23, 2026
820e69c
LSA-02H: use direct public state encoder in frozen calibration scorer
patrickdugan Nov 23, 2026
33b372b
LSA-02H CI: 96 train roots, independently compiled offpath proofs, ma…
patrickdugan Nov 23, 2026
2663bbb
Index Lean off-reference state coverage and native CPU competence pro…
patrickdugan Nov 23, 2026
b3b0567
LSA-02H: filter unprovable native dead-end edges when reconstructing …
patrickdugan Nov 23, 2026
76f0117
LSA-02H: regression that finite shortest native script ignores accept…
patrickdugan Nov 23, 2026
4d60953
LSA-02H: use defined optimizer-trace reader in same-worker matched sa…
patrickdugan Nov 23, 2026
61b27b4
LSA-02H: persist completed one-worker checkpoint manifest through the…
patrickdugan Nov 23, 2026
6f02959
LSA-02H: regression-test full same-worker receipt creation without sy…
patrickdugan Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
391 changes: 391 additions & 0 deletions .github/workflows/lsa02h-offpath-cpu.yml

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions docs/lsa02h_offpath_native_cpu_protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# LSA-02H: Native Lean recoverable off-reference proof states

**Registration:** November 23, 2026. **Evidence scope:** development-only, CPU/RAM before a full gym. This study follows [LSA-02G](../reports/lsa02g_native_fork_competence_20261123.md), where 4× emphasis on training-reference forks failed the root-weighted Lean calibration fork-accuracy gate twice. The previous verified proof policies visited states outside their shortest-reference training trajectories, motivating a falsifiable *state-coverage* experiment.

## Hypothesis and source validity

**Hypothesis:** adding truly novel, independently certified **recoverable off-reference proof states** to training improves theorem completion and decision accuracy at such states more than an equal-compute control using another already-known reference-path state of the same theorem root.

The existing native teacher derives shortest-continuation labels on the exact reference proof trajectory. LSA-02H takes a controlled, legal alternative tactic from that path. It uses the actual Lean 4.19 tactic prover to reach the alternative successor and then computes the shortest finite completion using the Lean-reported AND/OR action graph. The collector retains a correction state only if:

- the alternative tactic is in the public menu and succeeds in real Lean;
- the full *root-to-correction-to-terminal* proof has a finite continuation requiring at most **eight tactic checks**;
- the public state fingerprint is absent from that theorem's certified reference trajectory;
- the model-visible action menu has at least one native shortest-continuation witness;
- the **entire altered theorem proof**, including the deviation, is replayed in Lean, kernel-closed, and compiled separately as an axiom-free Lean declaration.

**Unrecoverable alternatives are recorded as misses.** We never manufacture success labels from the generator's private hints or treat an unprovable dead end as a solvable training example. An off-reference state is a controlled, recoverable deviation from a known shortest proof, not a claim that a particular neural model visited that state. This distinction remains explicit in every receipt.

The source collector can retain **at most two** successful distinct alternative recovery scripts per training root. Repeated public state/menu/budget identities within a theorem are deduplicated before training. Reference-only states are not relabeled as off-reference. Native source hash, independent terminal certificate status, proof script and lineage are frozen into a supplemental dataset.

## Fresh theorem roots

Freeze a **new** Lean-CGRT Horn suite with generator seed `20261201` and 96 independent roots in each of its train, calibration, ordinary-test and OOD-family shards. Compile and freeze a reference-path training teacher from **all 96 training theorem roots**, then collect at most two recoverable legal alternatives per root. The source's precise coverage is a measured outcome.

Reserve the first **32 independent calibration roots** for the development experiment. The model/native proof evaluation runs first; only when all six checkpoints have completed their Lean proof evaluations does a separate job use native Lean to discover correction states on those calibration roots. Its results are **read-only and never used for optimizer updates or model policy selection**. Ordinary-test and OOD proof outcomes remain sealed.

A source corpus with zero independently certified novel states fails the training gate. The calibration audit permits a valid low-coverage negative result and registers the absence of independent off-reference forks explicitly.

## Same-worker training controls

All models share the original Plan B architecture: **57,475 parameters**, width 32, four attention heads, two AB tied recurrent passes, fixed 384-byte input and the **`pp96`** public typed-plus-pretty representation. Training seeds are **157 and 163**, each with 720 CPU FP32 AdamW updates, learning rate 0.001 and gradient clipping 1. Every seed receives the **identical starting parameter tensors and theorem-root/reference-index/switch sampling schedule** across arms.

| Arm | Training state used |
| --- | --- |
| `reference` | Only the existing native shortest-reference trajectory frame |
| `offpath` | On a registered switch draw, a **novel certified correction state** from that same theorem root; otherwise the original frame |
| `sham` | On the identical registered switch draw, another certified **reference-trajectory frame from that same theorem root**; otherwise the original frame |

The sampler picks a theorem root uniformly and then a reference-path index uniformly. A half-probability switch is eligible only when the root has certified off-reference corrections. Switch/supplement indices are selected from a source-only seeded RNG shared across all arms. The sham reproduces the *number and root locations of opportunities* for new state exposure while keeping supervision on the old reference support. For a single-reference-frame theorem, a sham draw necessarily duplicates that frame.

Each of the six cells is fitted **twice consecutively on one physical GitHub-hosted CPU worker**: 12 fits. Torch deterministic algorithms, one CPU thread, pinned CPU Torch 2.5.1, disabled MKLDNN, and environment fingerprints accompany exact tensor, checkpoint-byte and optimizer-trace equality gates. All actual switched/novel/sham draws are counted. Cross-runner bitwise agreement is an outstanding separate issue and cannot be inferred from within-host duplication.

## Native outcome authority

Each trained model evaluates on the same **32 fresh calibration theorem roots** under the real pinned Lean 4.19 `lgym` toolchain, eight tactic attempts, no fine-tuning, and real kernel closure. All closed model proofs undergo independent standalone axiom-free compilation and a second model-free tactic replay. Frozen AB/BA and `auto8` policies are retained as controls, as is the native minimum-proof attainability ceiling.

A registered five-stream **uniform live public-menu** policy on those same roots (seeds 17/31/47/61/83) supplies the independent model-free proof baseline. Its proof scripts are also kernel-checked, independently compiled and replayed; all policy decisions depend only on public state/menu/seed.

**Only after these proof outcomes are frozen**, a separate Lean reference evaluator builds the calibration support corpus, independently certifying all 32 reference proofs and every recoverable alternate script. On these states, each checkpoint is scored by frozen AB argmax against native shortest-continuation labels. It reports:

- **off-reference discriminating fork accuracy**, root weighted (primary state-coverage endpoint);
- **off-reference all-state accuracy**, including forced singleton menus, separately;
- reference-path discriminating fork accuracy, distinct from offpath support;
- complete root-level proof closure and signed paired contrasts to reference/sham.

An eligible **off-reference discriminating fork** has a public menu with at least two tactics, with both optimal and nonoptimal verified continuations. Off-reference forced states must not inflate the primary endpoint.

## Registered decision gates

The primary development screen requires at least **16 independently certified off-reference fork frames spanning at least 8 independent calibration theorem roots**. If that coverage floor fails, the study reports `INSUFFICIENT_OFFPATH_FORK_COVERAGE` and does not claim a fork-action improvement, regardless of any whole-proof changes.

When eligible, success requires the offpath-trained arm's root-weighted off-reference fork accuracy to exceed **both reference and sham by at least +5 absolute percentage points**, with nonnegative mean whole-proof effects against both. This is a development screen; every root-level contrast is accompanied by a **descriptive 2,000-draw theorem-root bootstrap** and the precise denominator. Seeds are paired within roots and do not increase the number of independent theorems.

The separate **native competence floor** remains at least 32 independent roots, **≥40% standalone-verified full-proof closure**, and **≥+10 points over the finite native uniform-menu policy**. Only a passing competence preflight may justify registering fresh sealed confirmation and FSI-01, subject to external corpus-ancestry checks. It never directly authorizes architecture promotion or claims Mathlib transfer.

The experiment does not equate synthetic or deterministic controlled deviations with model-policy on-policy rollout. If recoverable off-reference states are scarce or forced choices dominate them, that is the scientific finding, and the next research mechanism may require explicit backtracking or richer verifier feedback.

## CPU GitHub Actions and provenance

The [LSA-02H CI workflow](../.github/workflows/lsa02h-offpath-cpu.yml) runs public/unit tests, builds the frozen teacher, collects and certifies recoverable train-only branches, trains same-host reference/offpath/sham cells, scores independent native random and neural proof episodes, and **then** collects calibration reference/off-reference states for read-only root-paired scoring.

It records the original native teacher hash, all alternative full-proof compiler certificates, exact lineage and public-state identities, budget adequacy, initial/final weights and source draws, full proof kernel receipts, independent replay receipts and random-menu baseline provenance. Any failed proof or lineage gate aborts the corresponding scientific result. GitHub Actions artifacts retain raw receipts for 14 days and a Markdown report should be committed after successful verification.

No GPU, local private machine, paid inference, or sealed evaluation is needed.
1 change: 1 addition & 0 deletions research/lean_cgrt_hrm400/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Start with these documents:
- [LSA-02E typed-plus-pretty CPU experiment](../../docs/lsa02e_typed_pretty_cpu_protocol.md): fresh Lean proof roots, three matched 384-byte public input views, same-worker duplicate training, and native root-paired certification.
- [LSA-02F pretty-text dosage and native uniform-menu CPU pilot](../../docs/lsa02f_pretty_dose_cpu_protocol.md): new Lean training/calibration roots, matched 0/48/96/160-byte view fits, independently compiled model-free random proof baseline and root-level competence gate.
- [LSA-02G native Lean fork-choice competence pilot](../../docs/lsa02g_fork_competence_protocol.md): weighted train-only discriminating forks versus equal-mass shuffled sham, fresh verified reference-state fork decisions, and independently certified proof completion.
- [LSA-02H native recoverable off-reference CPU study](../../docs/lsa02h_offpath_native_cpu_protocol.md): Lean-verified alternate proof states, matched reference and same-root sham training, and separately certified calibration decision coverage.
- [PPT-G03 live Lean search and verifier-checked data accretion](PPT_G03_RUNBOOK.md): native Lean 4.19 stepper, frozen theorem suites, independent compiled certificates, train-support DRAM updates and replay-gated export.
- [PPT-G03B bounded backtracking gym](PPT_G03B_BACKTRACKING.md): saved Lean-state rollback on unprovable branches, separate tactic and host-cost accounting, and exact independent replay.
- [`LOCAL_SCALING_RESULTS.md`](LOCAL_SCALING_RESULTS.md): campaign c1, Lean-certified results;
Expand Down
41 changes: 39 additions & 2 deletions research/lean_cgrt_hrm400/ppt_gym/native_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def _interval(deltas: list[int]) -> list[float] | None:


def _checkpoint_provenance(checkpoint: dict, training_pack: Path | None, cases,
native_teacher: Path | None = None) -> dict:
native_teacher: Path | None = None,
offpath_source: Path | None = None) -> dict:
"""Keep prior training ancestry independent of native query proof outcomes."""
result = {
"checkpoint_evidence_class": checkpoint.get("source_evidence_class", "unknown"),
Expand Down Expand Up @@ -129,6 +130,37 @@ def _checkpoint_provenance(checkpoint: dict, training_pack: Path | None, cases,
result["native_teacher_manifest_sha256"] = sha256_file(native_teacher)
result["training_lineages"] = len(lineages)
result["training_evidence"] = "native Lean shortest-continuation labels"
if checkpoint.get("offreference_source_manifest_sha256") or offpath_source is not None:
if offpath_source is None:
raise ValueError("offreference checkpoint requires its attested source manifest")
pack = json.loads(offpath_source.read_text(encoding="utf-8"))
if (
pack.get("schema") != "lsa02h.recoverable_offreference_train.v1"
or pack.get("source_teacher_sha256") != sha256_file(native_teacher)
or pack.get("suite_manifest_sha256") != teacher["source"]["suite_manifest_sha256"]
or pack.get("backend", {}).get("actual_lean_process") is not True
or pack.get("independent_compiler_passed") is not True
or pack.get("train_split_only") is not True
or pack.get("model_calls_during_collection") != 0
or pack.get("locked_test_opened") is not False
or checkpoint.get("offreference_source_schema") != pack["schema"]
or checkpoint.get("offreference_source_manifest_sha256") != sha256_file(offpath_source)
):
raise ValueError("offreference checkpoint source manifest or Lean proof custody differs")
for name, checksum in pack.get("artifacts", {}).items():
if name != Path(name).name or sha256_file(offpath_source.parent / name) != checksum:
raise ValueError("offreference source artifact checksum changed")
off_rows = _rows(offpath_source.parent / "offreference_frames.jsonl")
if len(off_rows) != pack.get("novel_offreference_training_states"):
raise ValueError("offreference source count differs")
if not all(r["lineage"] in set(lineages) for r in off_rows):
raise ValueError("offreference state lineage crossed native training teacher")
if {r["lineage"] for r in off_rows} & {c.lineage for c in cases}:
raise ValueError("offreference source overlaps native query roots")
result["offreference_source_verified"] = True
result["offreference_states"] = len(off_rows)
result["offreference_manifest_sha256"] = sha256_file(offpath_source)
result["training_evidence"] += " + certified recoverable offreference states"
return result
if training_pack is None:
return result
Expand Down Expand Up @@ -213,6 +245,7 @@ def run(
cert_timeout: int = 120,
training_pack: Path | None = None,
native_teacher: Path | None = None,
offpath_source: Path | None = None,
certified_backend: bool = False,
certifier=certify,
) -> dict:
Expand Down Expand Up @@ -247,7 +280,9 @@ def run(
training, _ = load_suite(suite, "train", 1024)
if {c.lineage for c in training} & {c.lineage for c in selected}:
raise ValueError("training suite lineages overlap queried Lean theorem roots")
provenance = _checkpoint_provenance(checkpoint, training_pack, selected, native_teacher)
provenance = _checkpoint_provenance(
checkpoint, training_pack, selected, native_teacher, offpath_source,
)
checkpoint_hash = sha256_file(checkpoint_path)
initial_weights = _weight_fingerprint(model)
out.mkdir(parents=True)
Expand Down Expand Up @@ -525,6 +560,7 @@ def main(argv: list[str] | None = None):
run_cmd.add_argument("--checkpoint", type=Path, required=True)
run_cmd.add_argument("--training-pack", type=Path)
run_cmd.add_argument("--native-teacher", type=Path, help="frozen native teacher manifest.json")
run_cmd.add_argument("--offpath-source", type=Path, help="compiled offreference supplement manifest.json")
run_cmd.add_argument("--out", type=Path, required=True)
run_cmd.add_argument("--split", choices=("calibration", "ordinary_test", "ood_family"),
default="calibration")
Expand All @@ -547,6 +583,7 @@ def main(argv: list[str] | None = None):
depth=args.depth, max_seconds=args.max_seconds,
cert_timeout=args.cert_timeout,
training_pack=args.training_pack, native_teacher=args.native_teacher,
offpath_source=args.offpath_source,
certified_backend=True,
)
else:
Expand Down
Loading
Loading