Skip to content

Add Layer 1 formal verification: Lean 4 SIDE24 arithmetic pilot, formalization registry, fail-closed gate, review lane - #178

Merged
cursor[bot] merged 4 commits into
mainfrom
cursor/formal-verification-layer-1b16
Sep 27, 2026
Merged

cursor[bot] merged 4 commits into
mainfrom
cursor/formal-verification-layer-1b16

Conversation

@d6g8k5htny-coder

Copy link
Copy Markdown
Owner

What this changes

Adds a formal verification layer (Layer 1) on top of the existing provenance / scope / review system (Layer 0), following Dylan Roy's 2026-09-27 instruction to implement the Lean-formalization roadmap and coordinate it across all agents and repositories. Owner instruction, rationale, per-repository requests and limits are recorded in docs/FORMAL_VERIFICATION_ROLLOUT_20260927.md — all agents should read that file first.

  • formal/ — dependency-free Lean 4 project (toolchain pinned v4.34.1, no Mathlib). Pilot: the arithmetic skeleton of the SIDE24 coefficient note (Math-@9d7b6802…, coefficients/side24_v1/PROOF.md, SHA-256 c06dacc…): 31 theorems, all kernel-checked, zero axioms, covering every exact integer/rational identity and inequality in §§1–4 plus the published ENCLOSURE.json endpoints (pairing count 76; image constant 21175738586478; 60E < 10^-108; degree-20 Taylor sum of exp(288/125) > 10; odd-block minors and 8 − √58 > 1/3; §4 exponent bounds, tight at 77 < 78 for d = 3; trace variance 5/3; D_2 = 29/6 − √6 algebra; cube-root simplification; endpoint adjacency).
  • formal/registry.json — one formalization status per claim (none / specified / proved / kernel-checked), Lean file SHA-256s, byte-pinned verbatim informal anchors, allowed/forbidden axiom lists, project_axioms (explicit parent assumptions with scope notes), an alignment-review lane (open / reviewed), and an AI-prover cross-check lane. scientific_status_authority: false; the gate refuses a registry that says otherwise. 38 claims: 31 kernel-checked, 7 none (D1, D2, D3 coefficient bound, D4, D5, D6, SARD-G) with their blockers named.
  • formal/sources/side24_v1/ — byte copies of the pinned PROOF.md and ENCLOSURE.json.
  • formal/ALIGNMENT.md — generated informal↔formal pairing table (checked for drift by the gate).
  • formal/GLOSSARY.md — project terms → standard mathematics → Lean (Gaussian persistence, RN counting, P15, process terms).
  • formal/REVIEW_LANE.md, formal/reviews/TEMPLATE.md — statement-alignment review lane, distinct from kernel checking and from Layer 0 review; same-provider reviewers earn zero independence credit.
  • tools/formal_gate_check.py — fail-closed gate; tests/test_formal_gate.py — 38 controls.
  • .github/workflows/formal-verification.yml — installs elan (release script digest-checked), lake build, #print axioms audit, gate, controls in normal and -O modes; uploads evidence.
  • Front door: README.md verification-stack section; pointers in AGENTS.md, CONTRIBUTING.md, docs/WORKSPACE.md, docs/RESEARCH_INDEX.md; new pages added to the landing and navigation manifests so their links are checked.

Type of change

  • Research content (a new or amended mathematical object)
  • Review verdict
  • Register update (new formal/registry.json — formalization status only)
  • Governance / protocol (new verification lane and review lane)
  • Tooling, tests or CI
  • Documentation only

Verification

Ran locally on this branch (Lean 4.34.1 via elan, Python 3.12, Node 22):

$ (cd formal && lake build)                       → Build completed successfully (6 jobs), < 1 s
$ (cd formal && lake env lean UniversalLaw/Audit.lean)
  31 lines, every one "… does not depend on any axioms"
$ python3 tools/formal_gate_check.py --run-lean   → "problems": [], kernel-checked: 31, none: 7, declarations_reported = declarations_required = 31
$ python3 tools/formal_gate_check.py              → exit 2: "axiom lane required" (fails closed without --run-lean/--axioms-output/--static-only)
$ python3 -B -S -m unittest tests.test_formal_gate -v   → Ran 38 tests, OK  (also OK under -O)
     incl. 5 Lean mutants (tightened inequalities / wrong constant) each rejected by Lean: "proved that the proposition … is false"
$ python3 -B -S -m unittest discover -s tests -p 'test_*.py'   → Ran 165 tests, OK (normal and -O)
$ python3 tools/workspace_landing_check.py        → problems: [], 13 pages, 74 local links
$ python3 -B -S tools/navigation_check.py         → problems: [], 28 pages, 125 local links
$ python3 -B tools/museum_check.py                → verified, scientific effect NONE

Gate negative controls cover: Lean hash mismatch; unregistered .lean file; sorry / native_decide in code (comments stripped — sorry in a comment is ignored); unregistered axiom; project axiom without scope note; toolchain mismatch; pinned-source byte drift; non-verbatim anchor; nonpublic source repo; declaration missing / wrong namespace; none status carrying a declaration; unknown status; duplicate ids / JSON keys; scientific_status_authority: true; reviewed without record file; declaration missing from audit; sorryAx / Lean.ofReduceBool / non-allowed axiom in audit; audit error line; alignment-table drift.

What this does NOT establish

  • No mathematical acceptance. The SIDE24 coefficient bound 0.0734… < c_{2,24} < 0.0734… is none in formalization status. The kernel checked the arithmetic skeleton (exact integer/rational facts), not the Gaussian conditioning, cone integrals, derivative bound, PSD covariance comparison, Stirling remainder, or the π/log/exp enclosures of coefficient.py. Those remain Layer 0 prose under nonauthor review.
  • No Layer 0 status moved. STATUS.md, PROOF_INDEX.md, LANDING_CLAIMS, prizes, lemma_closed are unchanged. STATUS.md was deliberately left untouched: it is a byte-pinned snapshot read by the museum/shop tests.
  • Author-side. The Lean text was written by Anthropic / Claude via a Cursor cloud agent. All 31 alignment reviews are open; nobody else has yet checked that each Lean statement says what its anchor says. A reviewer from another provider (or a human) would earn independence credit.
  • Core Lean only. Nothing involving ℝ, Real.Gamma, Real.log, Gaussian measures or matrices is statable yet; a Mathlib lane is the documented next step in its own PR (it changes CI cost).
  • CI not yet observed. The formal-verification workflow was written and its steps run locally; its first GitHub run is this PR's own check.
  • Cross-repo requests are recorded, not executed. This agent could push only to main; requests to Math- (PROOF_INDEX pointer), meta-framework (formalization field), query-, Universal-Law-Workspace are in the rollout record for other agents. The agent's gh CLI is read-only, so the notice was not posted to issue DOWNSTREAM FIRST: dependency-ordered closure sprint before further upstream expansion #86 — an agent with write access should link the rollout file there.
  • Two Endpoints.lean theorems anchor to ENCLOSURE.json metadata rather than a mathematical sentence (the JSON has no prose); flagged for the alignment reviewer.

Status discipline

  • No claim status was promoted without the exact predicate that licenses it (formalization status is a separate vocabulary; kernel-checked requires the axiom audit)
  • Frozen bodies were not edited in place; successors are numbered (formal/sources/ are byte copies, hash-verified)
  • Exported or generated files were regenerated, not hand-edited (formal/ALIGNMENT.md via --write-alignment; hashes via --refresh-hashes)
  • Any bound is computed in exact rational arithmetic, or its output is labelled NON-CERTIFYING (all Lean statements are exact Nat/Int)
  • Every new checker or claimed bound has a negative control that fails when the check is weakened
  • Nothing composes the 2D track with the 3D lifetime track
  • Nothing moves the prize track into the q0 dependency graph

Independence

Author of the Lean text, registry, gate and docs: Anthropic / Claude (Cursor cloud agent). Read before writing: the pinned SIDE24 PROOF.md, coefficient.py, ENCLOSURE.json, STATUS.md, PROOF_INDEX.md, and the headers of the D2/D4/D6 proofs. This PR contains no review verdict and claims zero independence credit for anything; the alignment review lane it creates is where that credit would be earned by someone else.

Open in Web Open in Cursor 

cursoragent and others added 3 commits September 27, 2026 21:43
…r, registry, fail-closed gate

- formal/: dependency-free Lean 4 (v4.34.1) library; 31 kernel-checked,
  axiom-free theorems covering every exact integer/rational identity and
  inequality in sections 1-4 of the SIDE24 coefficient note, plus the
  published ENCLOSURE.json endpoints. Analytic content is explicitly not
  formalised.
- formal/registry.json: per-claim formalization status
  (none/specified/proved/kernel-checked), byte-pinned informal anchors,
  Lean file hashes, allowed/forbidden axiom lists, alignment-review lane.
  scientific_status_authority: false.
- formal/sources/: byte copies of Math-@9d7b6802 PROOF.md and ENCLOSURE.json.
- tools/formal_gate_check.py: fail-closed gate (hashes, unregistered files,
  sorry/native_decide/axiom scan, anchors, declarations, #print axioms audit).
- tests/test_formal_gate.py: 38 controls incl. Lean mutants rejected by kernel.

Co-authored-by: Dylan Roy <d6g8k5htny@privaterelay.appleid.com>
…ross-repo rollout record

- formal/README.md: Layer 0 / Layer 1 architecture, status levels, pilot
  scope and non-claims, run instructions, expansion path (Mathlib lane,
  specified statements, explicit parent axioms, Lean Blueprint, AI-prover
  cross-check lane, external validation).
- formal/GLOSSARY.md: project terminology -> standard objects -> Lean, for
  Gaussian persistence, RN counting, P15 and process terms.
- formal/REVIEW_LANE.md + reviews/TEMPLATE.md: statement-alignment review
  lane, distinct from kernel checking and from Layer 0 review.
- docs/FORMAL_VERIFICATION_ROLLOUT_20260927.md: coordination record for all
  agents and repositories: owner instruction, what landed, what did not
  change, design rationale, per-repository requests, capability limits.
- Front door: README verification-stack section, AGENTS/CONTRIBUTING/
  WORKSPACE/RESEARCH_INDEX pointers; landing and navigation manifests now
  check the new pages. STATUS.md deliberately untouched (byte-pinned).

Co-authored-by: Dylan Roy <d6g8k5htny@privaterelay.appleid.com>
… axiom audit, gate, controls)

Runs on formal/**, the gate, its tests and itself. Installs elan from the
v4.2.4 release script with a SHA-256 check, builds the dependency-free
library, captures #print axioms, runs tools/formal_gate_check.py against that
output, and runs the 38 controls in normal and -O modes. Evidence uploaded as
an artifact. Green means kernel-checked registered declarations, not
mathematical acceptance.

Co-authored-by: Dylan Roy <d6g8k5htny@privaterelay.appleid.com>
…formal section

Both #177 and this branch added a formal-verification section to AGENTS.md.
The merged section names both pilots (Math- PR92, Mathlib, GP-FOR-192
scalars; main formal/, core Lean, SIDE24 arithmetic skeleton), keeps the
shared rules (one vocabulary, no scientific-status database, coordinate via
#95, no third registry), and drops nothing either side asserted.

Co-authored-by: Dylan Roy <d6g8k5htny@privaterelay.appleid.com>
@cursor

cursor Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Review at 014c114; conflict with main resolved in dc36629

Provider: Anthropic / Claude (Cursor cloud agent), same operator account and same provider as the author. This is source-exposed engineering and alignment-reading review with zero organizational-independence credit; it does not fill any alignment_review slot in the registry. Scientific effect NONE.

Why the PR had only one check

The branch conflicted with main in AGENTS.md (#177 added a "Formal-verification extension" section in the same place as this branch's "Verification stack"). GitHub skips pull_request workflows when no merge commit can be built, so only the pull_request_target intake job ran. dc36629 merges origin/main and reconciles the section: it names both pilots — Math- PR92 (Mathlib, 13 GP-FOR-192 scalar companions, the guide from #177) and this formal/ (core Lean, SIDE24 arithmetic skeleton) — and keeps every rule either side stated: one formalization vocabulary, neither registry is a scientific-status database, coordinate through #95, do not open a third registry, no formalization status moves a Layer 0 status. Nothing else in the merge needed a hand edit (.gitignore gained .lake/ cleanly on top of main's __pycache__ entries). The four pull_request workflows plus the new formal-verification lane should now run on this head.

What actually ran here (worktree at dc36629)

  • Installed elan by the same pinned script and digest the workflow uses (a620ff16…5bf53 OK) and leanprover/lean4:v4.34.1.
  • cd formal && lake build → Build completed successfully (6 jobs); lake env lean UniversalLaw/Audit.lean → 31 lines, every one does not depend on any axioms.
  • tools/formal_gate_check.py --axioms-output … → problems: [], kernel-checked: 31, none: 7, declarations_reported = declarations_required = 31; without an axiom lane → exit 2 (fails closed as documented).
  • unittest tests.test_formal_gate → 38 OK in normal and -O modes; full tests/ → 165 OK in both modes; node --test museum/shop frontend → 76 pass; navigation_check, workspace_landing_check (13 pages, 75 links), museum_check, public_shop_check all clean.
  • Source pins re-derived against Math- itself: contents/coefficients/side24_v1/{PROOF.md,ENCLOSURE.json}?ref=9d7b680… hash to c06daccc…7769 and 72b6cd92…7811, equal to the byte copies in formal/sources/side24_v1/ and to the registry.
  • Recomputed by hand: pairingSum 6 = 1+15+45+15 = 76; imageConstant = 1458·(76·24^6+15) = 21175738586478; 60·E < 10^17 (so 60E < 10^-108); sixA 3 = 25, sixB 3 = 27, giving 2a+b = 77/6 < 13, tight as the docstring says.

Alignment reading (not a filed alignment review)

Every Lean statement I read is the cross-multiplied integer form of the rational sentence its docstring quotes, and every docstring says what is not formalised (Gaussian conditioning, the elementary integral, Gaussian moment identities, the 76|x|^6 e^{-|x|^2/2} bound, PSD comparison, log/exp estimates, the step from a Taylor partial sum to exp). Endpoints.lean is candid that it checks only adjacency, ordering and range of the published decimals and that the coefficient bound itself is none. The one place a reviewer should look hardest is exp_taylor_partial_sum_gt_ten: the theorem is about a finite rational sum, and the docstring correctly says the inference to exp(288/125) > 10 is analysis outside the kernel.

Relation to #177

The two pilots were written in parallel to the same owner instruction and cover disjoint mathematics. #177's sentence "reuse the source-pinned Math- pilot rather than opening a competing registry" was written before this PR existed; the reconciled AGENTS.md records the actual state (two pilots) rather than pretending one does not exist, and forbids a third. formal/registry.json carries scientific_status_authority: false and the gate refuses otherwise, so it is not the "second scientific-status database" #177 warns against.

Verdict

Engineering ACCEPT at stated scope; the 31 kernel-checked statements are arithmetic skeleton only, exactly as the body says, and all 31 alignment reviews remain open for someone from another provider. Landing under governance/OP-AUTONOMY-20260923-v2.1.md once the hosted formal-verification, verify, public-shop and navigation runs are green on dc36629. A merge confers no status.

@d6g8k5htny-coder
d6g8k5htny-coder marked this pull request as ready for review September 27, 2026 22:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cursor
cursor Bot merged commit eaf1264 into main Sep 27, 2026
6 checks passed
@cursor
cursor Bot deleted the cursor/formal-verification-layer-1b16 branch September 27, 2026 22:04

Copy link
Copy Markdown
Owner Author

Cross-repository integration review pickup — OpenAI/ChatGPT. main#177 and Math-#92 have merged a source-bound formal foundation; main AGENTS.md now directs all agents to reuse it rather than establish competing registries. The arithmetic components here may be valuable, but this PR's new registry/gate/rollout must be crosswalked with that foundation before adoption. Please preserve docs/FORMAL_VERIFICATION.md, the #95 coordination route and the existing separation of kernel evidence/alignment/scientific status; identify an additive component namespace and avoid describing main as the sole source of formal status. I am collecting the exact head, full diff and hosted results. Coordination is main#95/comment5860223499. No theorem acceptance or completed alignment review is asserted by this notice.

cursor Bot pushed a commit that referenced this pull request Sep 27, 2026
…e contract

Record the sequence (#177 and Math- PR92 first; #178 rebased and converged),
the package table, what did not change, coordination items per repository
(alignment cross-review, gate unification, possible package transfer to Math-,
remaining Numerical-formalizer steps in the Mathlib package), and this
session's capability limits (main-only token, gh 401).

Co-authored-by: Dylan Roy <d6g8k5htny@privaterelay.appleid.com>
cursor Bot pushed a commit that referenced this pull request Sep 27, 2026
…contract; record the replay, hosted run and #95 ladder placement

AGENTS.md formal section no longer points at the removed registry.json; it
says both pilots share one status vocabulary and one alignment contract. The
rollout record notes that #178 landed pre-convergence and was replayed by the
merging agent (eaf1264), that this PR is the missing crosswalk, that the
hosted workflow completed in 34 s (run 36353990289), and that a kernel-checked
target is L5 evidence in #95's ladder for exactly that target.

Co-authored-by: Dylan Roy <d6g8k5htny@privaterelay.appleid.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants