From 0dd0cb17bfa12bab6983bc4b068a38fed5a9df9c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 11 Oct 2026 18:36:03 +0000 Subject: [PATCH 1/5] Companion torus_filtration_20261011: the C254 torus quotient and closed-superlevel modules, compile-fixed at the pin, with their own gate Isolated Lean companion for the two modules the OpenAI/Codex lane proposed under C254 (Math- PR #419 comments 6111056103, 6111059166, 6111059498, 6111059848) as NOT_COMPILED source. Nothing under formal/ changes, so the three D2 companions' pins on the formal tree 38b6d1a7 and manifest 40cb6ffc are untouched (C255 finding, comments 6111255007 / 6111350170). Modules (namespace TorusFiltration; every theorem, definition name, order and statement text as in the handoff; 41 theorems, 17 definitions): the handoff bytes did not elaborate at Lean v4.34.1 / Mathlib d13f23b7; the successor bytes differ only by the compile fixes recorded in README.md (Basis -> Module.Basis, Module.Basis.unitsSMul_apply, an explicit SetLike.isDiscrete_iff_discreteTopology witness, inferInstanceAs for the quotient's path-connectedness, three unused simp arguments removed, the strict-implicit binders of ZerothHomotopy.lift in superlevel_componentMap). Original SHA-256s efa80d28... / 1fed3eda...; successor SHA-256s in SOURCE_FILES.json. Gate: check.py (source identity bound to HEAD, exact declaration inventory via a whitelist scanner, Lean version and all nine installed package HEADs checked against formal/lake-manifest.json, axiom audit of all 58 declarations, exact type inventory, leanchecker in modules mode, three Lean-level false-statement controls and three injection controls refused by the audit, receipt with the C254 provenance); test_torus_filtration.py (26 tests, weakening controls); replay.sh; .github/workflows/torus-filtration.yml (companion paths and the three formal/ environment pins only). Scientific effect NONE: no claim, label, disposition or status changes; the modules prove topology scaffolding only (quotient, descent, path lifting with an existential endpoint, closed-superlevel inclusions and component/H0 maps) and none of the C253 endpoint, finiteness, bar or elder results; alignment PENDING_INDEPENDENT_REVIEW; organizational-independence credit 0 for the source lane and for this lane. The receipt comes only from the hosted run. Source author: OpenAI/Codex lane for Dylan Roy (C254). Compile fixes and companion: Anthropic/Claude lane. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Cz7WZybv8znP64SpPj6sWY --- .github/workflows/torus-filtration.yml | 55 ++ .../ClosedSuperlevel.lean | 197 ++++ .../torus_filtration_20261011/README.md | 286 ++++++ companions/torus_filtration_20261011/SCOPE.md | 94 ++ .../SOURCE_FILES.json | 161 +++ .../TorusFiltration.lean | 2 + .../TorusTopology.lean | 247 +++++ companions/torus_filtration_20261011/check.py | 523 ++++++++++ .../torus_filtration_20261011/replay.sh | 72 ++ .../test_torus_filtration.py | 918 ++++++++++++++++++ 10 files changed, 2555 insertions(+) create mode 100644 .github/workflows/torus-filtration.yml create mode 100644 companions/torus_filtration_20261011/ClosedSuperlevel.lean create mode 100644 companions/torus_filtration_20261011/README.md create mode 100644 companions/torus_filtration_20261011/SCOPE.md create mode 100644 companions/torus_filtration_20261011/SOURCE_FILES.json create mode 100644 companions/torus_filtration_20261011/TorusFiltration.lean create mode 100644 companions/torus_filtration_20261011/TorusTopology.lean create mode 100644 companions/torus_filtration_20261011/check.py create mode 100644 companions/torus_filtration_20261011/replay.sh create mode 100644 companions/torus_filtration_20261011/test_torus_filtration.py diff --git a/.github/workflows/torus-filtration.yml b/.github/workflows/torus-filtration.yml new file mode 100644 index 000000000..becc58ff7 --- /dev/null +++ b/.github/workflows/torus-filtration.yml @@ -0,0 +1,55 @@ +name: C254 torus filtration (isolated Lean companion) +'on': + pull_request: + paths: + - 'companions/torus_filtration_20261011/**' + - '.github/workflows/torus-filtration.yml' + - 'formal/lakefile.toml' + - 'formal/lake-manifest.json' + - 'formal/lean-toolchain' + push: + branches: [main] + paths: + - 'companions/torus_filtration_20261011/**' + - '.github/workflows/torus-filtration.yml' + - 'formal/lakefile.toml' + - 'formal/lake-manifest.json' + - 'formal/lean-toolchain' + workflow_dispatch: +permissions: + contents: read +jobs: + torus-filtration: + runs-on: ubuntu-latest + # Provisional until one hosted dry run records the duration in the companion README: twelve `lean` + # invocations each load the full Mathlib .olean set, plus `leanchecker` on the companion modules + # (the whole-closure leanchecker re-check does not fit a hosted job; see replay.sh and the README). + timeout-minutes: 45 + env: + LEAN_NUM_THREADS: 2 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - name: Install pinned Lean and retrieve dependency cache + uses: leanprover/lean-action@f061402b660e0c34644504b324e830f2991d4865 + with: + lake-package-directory: formal + auto-config: 'false' + build: 'false' + test: 'false' + lint: 'false' + use-mathlib-cache: 'true' + use-github-cache: 'false' + - name: Replay the torus-filtration companion with exact negative controls + shell: bash + run: bash companions/torus_filtration_20261011/replay.sh + - name: Preserve original execution evidence on success or failure + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + with: + name: torus-filtration-${{ github.run_id }}-${{ github.run_attempt }} + path: .lake/torus-filtration-evidence/ + include-hidden-files: true + if-no-files-found: error + retention-days: 30 diff --git a/companions/torus_filtration_20261011/ClosedSuperlevel.lean b/companions/torus_filtration_20261011/ClosedSuperlevel.lean new file mode 100644 index 000000000..a4323cb50 --- /dev/null +++ b/companions/torus_filtration_20261011/ClosedSuperlevel.lean @@ -0,0 +1,197 @@ +import Mathlib + +/-! +# Closed superlevels and their actual component and singular H0 functors + +C254 proposed source. Compilation and kernel audit: NOT_RUN. +The parameter is `t = -h`; endpoint membership uses `≤`. +This file supplies no Morse theorem, labels, bars, or H0/component naturality. +Compile fix at the pin (Lean v4.34.1, Mathlib d13f23b7), altering no statement: in +`superlevel_componentMap` the `ZerothHomotopy.lift` witness binds its two strict-implicit +points before the `Path` argument (`fun _ _ p => ...`), as `ZerothHomotopy.lift` requires here. +-/ + +noncomputable section + +open CategoryTheory + +universe w v u + +namespace TorusFiltration +/-- The increasing closed-superlevel family, with parameter `t = -h`. -/ +def superlevel_set {X : Type*} (g : X → ℝ) (t : ℝ) : Set X := + {x | -t ≤ g x} + +/-- Control: the point at the threshold belongs to the closed superlevel. +Changing `≤` to `<` invalidates this statement. -/ +theorem superlevel_control_closed_endpoint (b : ℝ) : + () ∈ superlevel_set (fun _ : Unit => b) (-b) := by + simp [superlevel_set] + +/-- Control: the strict condition fails at that same threshold. -/ +theorem superlevel_control_strict_endpoint (b : ℝ) : + ¬ (-(-b) < (fun _ : Unit => b) ()) := by + simp + +/-- Control: at parameter `1` the constant height `0` is present. +Changing `-t` to `t` invalidates this statement. -/ +theorem superlevel_control_parameter_sign : + () ∈ superlevel_set (fun _ : Unit => (0 : ℝ)) 1 := by + norm_num [superlevel_set] + +/-- Control: inclusion cannot run from parameter `1` back to `-1`. -/ +theorem superlevel_control_inclusion_direction : + ¬ superlevel_set (fun _ : Unit => (0 : ℝ)) 1 ⊆ + superlevel_set (fun _ : Unit => (0 : ℝ)) (-1) := by + intro h + have hc := h superlevel_control_parameter_sign + norm_num [superlevel_set] at hc + +/-- A global maximum has no strictly higher endpoint, regardless of paths. -/ +theorem superlevel_control_essential {X : Type*} (g : X → ℝ) (M : X) + (hM : ∀ y, g y ≤ g M) : ¬ ∃ y, g M < g y := by + rintro ⟨y, hy⟩ + exact (not_lt_of_ge (hM y)) hy + +/-- Increasing parameters give increasing closed superlevels. -/ +theorem superlevel_mono {X : Type*} (g : X → ℝ) {s t : ℝ} (hst : s ≤ t) : + superlevel_set g s ⊆ superlevel_set g t := by + intro x hx + exact le_trans (neg_le_neg hst) hx + +/-- Each level is closed when the function is continuous. -/ +theorem superlevel_isClosed {X : Type*} [TopologicalSpace X] + (g : X → ℝ) (hg : Continuous g) (t : ℝ) : IsClosed (superlevel_set g t) := by + exact isClosed_le continuous_const hg + +/-- Continuity of the inclusion is independent of continuity of the height function. -/ +def superlevel_inclusion {X : Type w} [TopologicalSpace X] + (g : X → ℝ) {s t : ℝ} (hst : s ≤ t) : + C(superlevel_set g s, superlevel_set g t) := + ContinuousMap.inclusion (superlevel_mono g hst) + +theorem superlevel_inclusion_id {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (t : ℝ) : + superlevel_inclusion g (le_refl t) = ContinuousMap.id (superlevel_set g t) := by + ext x + rfl + +theorem superlevel_inclusion_comp {X : Type w} [TopologicalSpace X] + (g : X → ℝ) {r s t : ℝ} (hrs : r ≤ s) (hst : s ≤ t) : + (superlevel_inclusion g hst).comp (superlevel_inclusion g hrs) = + superlevel_inclusion g (hrs.trans hst) := by + ext x + rfl + +/-- Point membership at its own height; this is not a component-birth theorem. -/ +theorem superlevel_mem_at_own_height {X : Type*} (g : X → ℝ) (x : X) : + x ∈ superlevel_set g (-g x) := by + simp [superlevel_set] + +theorem superlevel_neg_height {X : Type*} (g : X → ℝ) (h : ℝ) : + superlevel_set g (-h) = {x | h ≤ g x} := by + ext x + simp [superlevel_set] + +/-- An explicit threshold countercontrol; it is not a compact Morse counterexample. -/ +theorem superlevel_control_strict_thresholds : + (∀ h : ℝ, h < 0 → ∃ k : ℝ, h < k ∧ k < 0) ∧ + ¬ ∃ k : ℝ, 0 ≤ k ∧ k < 0 := by + constructor + · intro h hh + exact ⟨h / 2, by linarith, by linarith⟩ + · rintro ⟨k, hk, hk'⟩ + exact (not_lt_of_ge hk) hk' + +/-- The induced map on actual path-component quotients. -/ +def superlevel_componentMap {X Y : Type w} [TopologicalSpace X] [TopologicalSpace Y] + (f : C(X, Y)) : ZerothHomotopy X → ZerothHomotopy Y := + ZerothHomotopy.lift (fun x => ZerothHomotopy.mk (f x)) + (fun _ _ p => ZerothHomotopy.sound (p.map f.continuous)) + +theorem superlevel_componentMap_mk {X Y : Type w} + [TopologicalSpace X] [TopologicalSpace Y] (f : C(X, Y)) (x : X) : + superlevel_componentMap f (ZerothHomotopy.mk x) = ZerothHomotopy.mk (f x) := rfl + +theorem superlevel_componentMap_id {X : Type w} [TopologicalSpace X] : + superlevel_componentMap (ContinuousMap.id X) = id := by + funext q + obtain ⟨x, rfl⟩ := ZerothHomotopy.mk_surjective q + rfl + +theorem superlevel_componentMap_comp {X Y Z : Type w} + [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] + (f : C(X, Y)) (g : C(Y, Z)) : + superlevel_componentMap (g.comp f) = + superlevel_componentMap g ∘ superlevel_componentMap f := by + funext q + obtain ⟨x, rfl⟩ := ZerothHomotopy.mk_surjective q + rfl + +def superlevel_componentInclusion {X : Type w} [TopologicalSpace X] + (g : X → ℝ) {s t : ℝ} (hst : s ≤ t) : + ZerothHomotopy (superlevel_set g s) → ZerothHomotopy (superlevel_set g t) := + superlevel_componentMap (superlevel_inclusion g hst) + +theorem superlevel_componentInclusion_id {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (t : ℝ) : superlevel_componentInclusion g (le_refl t) = id := by + funext q + obtain ⟨x, rfl⟩ := ZerothHomotopy.mk_surjective q + rfl + +theorem superlevel_componentInclusion_comp {X : Type w} [TopologicalSpace X] + (g : X → ℝ) {r s t : ℝ} (hrs : r ≤ s) (hst : s ≤ t) : + superlevel_componentInclusion g (hrs.trans hst) = + superlevel_componentInclusion g hst ∘ superlevel_componentInclusion g hrs := by + funext q + obtain ⟨x, rfl⟩ := ZerothHomotopy.mk_surjective q + rfl + +/-- Actual component equality is precisely a path in the ambient closed superlevel. -/ +theorem superlevel_component_eq_iff_joinedIn {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (t : ℝ) (x y : superlevel_set g t) : + ZerothHomotopy.mk x = ZerothHomotopy.mk y ↔ + JoinedIn (superlevel_set g t) x.val y.val := by + constructor + · intro h + have hxy : Joined x y := Quotient.exact h + exact (joinedIn_iff_joined x.property y.property).2 hxy + · intro h + obtain ⟨p⟩ := (joinedIn_iff_joined x.property y.property).1 h + exact ZerothHomotopy.sound p + +/-- The topological filtration in the preorder category of real numbers. -/ +def superlevel_filtration {X : Type w} [TopologicalSpace X] + (g : X → ℝ) : ℝ ⥤ TopCat.{w} where + obj t := TopCat.of (superlevel_set g t) + map f := TopCat.ofHom (superlevel_inclusion g (leOfHom f)) + map_id t := by + ext x + rfl + map_comp f k := by + ext x + rfl + +variable {C : Type u} [Category.{v} C] + [CategoryTheory.Limits.HasCoproducts.{w} C] + [Preadditive C] [CategoryWithHomology C] + +/-- Actual singular H0 with coefficient object R, including the inclusion maps. -/ +def superlevel_h0Filtration {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (R : C) : ℝ ⥤ C := + superlevel_filtration g ⋙ (AlgebraicTopology.singularHomologyFunctor C 0).obj R + +/-- This target includes the actual H0 definition in the transitive dependency audit. -/ +theorem superlevel_h0Filtration_map_id {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (R : C) (t : ℝ) : + (superlevel_h0Filtration g R).map (𝟙 t) = + 𝟙 ((superlevel_h0Filtration g R).obj t) := + (superlevel_h0Filtration g R).map_id t + +theorem superlevel_h0Filtration_map_comp {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (R : C) {r s t : ℝ} (f : r ⟶ s) (k : s ⟶ t) : + (superlevel_h0Filtration g R).map (f ≫ k) = + (superlevel_h0Filtration g R).map f ≫ (superlevel_h0Filtration g R).map k := + (superlevel_h0Filtration g R).map_comp f k + +end TorusFiltration \ No newline at end of file diff --git a/companions/torus_filtration_20261011/README.md b/companions/torus_filtration_20261011/README.md new file mode 100644 index 000000000..942f02e82 --- /dev/null +++ b/companions/torus_filtration_20261011/README.md @@ -0,0 +1,286 @@ +# C254 torus quotient and closed-superlevel filtration (isolated Lean companion) + +Dylan Roy — delegated AI work. Source author: OpenAI/Codex lane (C254). Compile fixes and +companion: Anthropic/Claude lane. Scientific effect **NONE**. Organizational-independence +credit **0** for both lanes; no human review. Alignment status `PENDING_INDEPENDENT_REVIEW`. +Nothing here promotes, discharges or reclassifies any claim. + +## Purpose and route rationale + +The C254 handoff (claim `8a5c7a24-784b-4aaa-b951-cd9f37b0dc64`, Math- PR #419) proposed two +Lean modules, `TorusTopology.lean` and `ClosedSuperlevel.lean`, as **NOT_COMPILED** source under +namespace `ResearchFormalCoreR1`, intended for `formal/`. The handoff's own nonauthor source +review (comment 6111059498) ended in **COMPILATION HOLD**: no known required correction, but no +elaboration either. The local elaboration report (6111093545) then observed the first real +elaboration failures at the pin (`Basis` is `Module.Basis` at Mathlib `d13f23b7`, among others). + +Placing the modules in `formal/` would change the whole `formal/` tree. The three D2 companions +(`companions/d2_*_20261006`) pin that tree at `38b6d1a7746075b560349d184a461933745c11ce`, the +primary manifest at SHA-256 `40cb6ffc…` and the gate at `278989bb…`; any change there is a new +review scope for all three. The C255 route finding (6111255007) therefore recommended an +isolated companion. This directory is that companion: + +- it holds the compile-fixed modules under namespace `TorusFiltration` and a two-line root module; +- it compiles them against the **same** pinned toolchain and dependency lock as `formal/` + (`formal/lean-toolchain`, `formal/lakefile.toml`, `formal/lake-manifest.json`), which it reads + but never edits; +- it consumes nothing from the core: no import of `ResearchFormalCoreR1`, no pin on the core + tree, manifest or gate, and its replay runs neither `formal/gate.py` nor the formal tests. + +## Bound sources + +| Item | Identity | +|---|---| +| Claim | `8a5c7a24-784b-4aaa-b951-cd9f37b0dc64` (R17 Work Events 1559) | +| Handoff | Math- PR #419, comments 6111056103 (modules), 6111059166 (overlay), 6111059498 (nonauthor source review, COMPILATION HOLD), 6111059848 (implementer report), 6111255007 (C255 route finding: D2 pins, companion route) | +| This lane | local elaboration report 6111093545; pickup 6111139060 | +| Original `TorusTopology.lean` (NOT_COMPILED) | SHA-256 `efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4`, 11542 bytes | +| Original `ClosedSuperlevel.lean` (NOT_COMPILED) | SHA-256 `1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e`, 7827 bytes | +| Namespace mapping | `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion); no other name changes | +| Toolchain | `leanprover/lean4:v4.34.1`, release commit `5045d0056413266e57c625dcd7c365b10e377c52`; Mathlib `d13f23b723b8a846827a245b89c10fc7d3f11612` via `formal/lake-manifest.json` | + +`SOURCE_FILES.json` records bytes, SHA-256 and Git blob of every tracked companion file and the +workflow, the per-module declaration inventory and this provenance. `check.py source` refuses to +run unless the tracked tree, the working bytes and that manifest agree. + +## What the 41 theorems and 17 definitions establish + +Topology and scaffolding only: the period-lattice quotient, descent of periodic functions, path +lifting with an **existential** endpoint, closed superlevel inclusions and their path-component +and singular-H0 maps. The source labels these `proved`; the hosted receipt may call them +`kernel-checked`; neither label is alignment or acceptance. + +### `TorusTopology` (21 theorems; 2 abbrevs, 6 defs, 3 instances) + +| Theorem | What it states | +|---|---| +| `torus_field_latticeVec_formula` | `torus_latticeVec d L n` is literally `∑ i, EuclideanSpace.single i (L * n i)` (by `rfl`) | +| `torus_basis_sum_eq_latticeVec` | the integer combination of the `L`-scaled standard basis equals that lattice vector | +| `torus_lattice_mem_iff` | lattice membership iff some integer vector produces the point | +| `torus_proj_surjective`, `torus_proj_continuous` | the quotient projection is surjective and continuous | +| `torus_proj_eq_iff` | equal images iff `y = x + torus_latticeVec d L n` (orientation fixed) | +| `torus_control_lattice_translate` | control: a lattice translate has the same image | +| `torus_proj_isCoveringMap` | the projection is a covering map | +| `torus_compact` | `IsCompact (Set.univ : Set (torus_quotient d L hL))`; not a registered `CompactSpace` instance | +| `torus_pathConnectedSpace` | the quotient is path connected | +| `torus_field_periodic_formula` | the periodicity predicate is literally the Field formula (`Iff.rfl`) | +| `torus_periodic_respects` | a periodic function respects the quotient relation | +| `torus_descend_proj` | descent composed with projection is the function (`rfl`) | +| `torus_descend_continuous` | the descended function is continuous when `g` is | +| `torus_path_lift_from` | a quotient path from `proj M` lifts to a path from `M`; the endpoint `z` is existential, with `proj z` the path's endpoint | +| `torus_control_constant_path_endpoint` | control: a lift of a constant projected path from `M` ends at `M` | +| `torus_control_no_arbitrary_endpoint` | control: a nonzero lattice translate shares the image yet no lift of the constant path ends there | +| `torus_higher_path_iff` | a strictly higher endpoint reached by a path whose heights satisfy a predicate `P` exists in `E` iff it exists in the quotient for the descended function | +| `torus_strict_higher_path_iff`, `torus_closed_higher_path_iff` | the same with `h < g` and `h ≤ g` | +| `torus_global_max_iff` | `M` is a global maximum of `g` iff `proj M` is one of the descended function | + +### `ClosedSuperlevel` (20 theorems; 6 defs) + +`superlevel_set g t = {x | -t ≤ g x}`, parameter `t = -h`, endpoint membership with `≤`. + +| Theorem | What it states | +|---|---| +| `superlevel_control_closed_endpoint`, `superlevel_control_strict_endpoint` | the threshold point belongs to the closed level; the strict inequality fails there | +| `superlevel_control_parameter_sign`, `superlevel_control_inclusion_direction` | height `0` lies in `F(1)`; `F(1) ⊄ F(-1)` for the constant `0` | +| `superlevel_control_essential` | a global maximum has no strictly higher endpoint | +| `superlevel_mono` | `s ≤ t → F(s) ⊆ F(t)` | +| `superlevel_isClosed` | `F(t)` is closed when `g` is continuous | +| `superlevel_inclusion_id`, `superlevel_inclusion_comp` | the continuous inclusions satisfy the identity and composition laws | +| `superlevel_mem_at_own_height` | `x ∈ F(-g x)`; point membership, not component birth | +| `superlevel_neg_height` | `F(-h) = {x | h ≤ g x}` | +| `superlevel_control_strict_thresholds` | scalar control: below `0` there are intermediate witnesses; no `k` with `0 ≤ k < 0` | +| `superlevel_componentMap_mk`, `superlevel_componentMap_id`, `superlevel_componentMap_comp` | the induced map on `ZerothHomotopy` acts on representatives and is functorial | +| `superlevel_componentInclusion_id`, `superlevel_componentInclusion_comp` | the induced component inclusions are functorial | +| `superlevel_component_eq_iff_joinedIn` | equal path components iff `JoinedIn` the closed superlevel | +| `superlevel_h0Filtration_map_id`, `superlevel_h0Filtration_map_comp` | functor laws of the singular-H0 filtration; they put the H0 definition into the axiom audit | + +Audited definitions: `torus_E`, `torus_quotient` (abbrev); `torus_latticeVec`, `torus_periodBasis`, +`torus_periodLattice`, `torus_proj`, `torus_isPeriodic`, `torus_descend`; instances +`torus_lattice_discrete`, `torus_lattice_addSubgroup_discrete`, `torus_lattice_isZLattice`; +`superlevel_set`, `superlevel_inclusion`, `superlevel_componentMap`, `superlevel_componentInclusion`, +`superlevel_filtration`, `superlevel_h0Filtration`. Every one of the 58 declarations is a +`#print axioms` target. + +## What is NOT established + +Copied from the handoff's own exclusions (TORUS_FILTRATION.md, source review F3–F4): + +- critical-level attainment: no theorem produces a witness at the critical height; strict + thresholds `h < 0` have no witness at `0`, and the path correspondence transfers predicates + only; +- finitely many critical events; compactness plus closedness does not give finitely many path + components for an arbitrary continuous height; +- label tracking, elder events, once-counting; +- naturality comparing the displayed component maps with singular-H0 generators beyond the + functor laws actually proved; +- any interval decomposition, tameness, finiteness, barcode or endpoint-preserving bar bijection; +- any identification of `PairLawInterface.p`, or any other interface predicate of C253; +- smooth quotient charts, Morse index transfer, handle analysis, critical-free band invariance; +- a compiled theorem naming the externally owned `Specifications.Field` module: the companion + carries the literal formulas (`torus_field_latticeVec_formula`, `torus_field_periodic_formula`) + and does not import that file. + +Compile success, the axiom audit, `leanchecker` and the negative controls say that Lean +elaborated these statements with these proofs at this pin. They do not say that the statements +are the ones the research programme needs; that is the pending independent alignment review. + +## Compile fixes at the pin + +The C254 handoff delivered both modules as NOT_COMPILED. At the pin they did not elaborate; the successor bytes in +this companion differ from the handoff bytes only as listed here. No theorem or lemma statement changed (all 41 +statement lines are byte-identical before `:=`); the 21 + 20 theorem names and the 11 + 6 definition names keep their +order; no `sorry`, `axiom`, `native_decide` or `set_option` was added; every declaration's axioms are within +`propext`, `Classical.choice`, `Quot.sound`. + +`TorusTopology.lean` (handoff sha256 `efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4`): +- `def torus_periodBasis`: declared type `Basis (Fin d) ℝ (torus_E d)` → `Module.Basis (Fin d) ℝ (torus_E d)`. At the + pin the structure is `Module.Basis` (`Mathlib/LinearAlgebra/Basis/Defs.lean`, `namespace Module` line 76, `structure + Basis` line 90); bare `Basis` was an unknown identifier that `autoImplicit` turned into a variable, the root of the + first-run cascade. Same object; the body is unchanged. +- `theorem torus_basis_sum_eq_latticeVec`, proof: `Basis.unitsSMul_apply` → `Module.Basis.unitsSMul_apply` in both + `simp` calls (`Mathlib/LinearAlgebra/Basis/SMul.lean` line 107); three unused simp arguments removed + (`PiLp.single_apply` twice, `hij`) so the file elaborates with warnings as errors. +- `theorem torus_proj_isCoveringMap`, proof term: the discreteness witness `DiscreteTopology.isDiscrete` (which needs an + instance on the set-coercion subtype that instance search did not bridge) → `SetLike.isDiscrete_iff_discreteTopology.mpr + (torus_lattice_addSubgroup_discrete d L hL)` (`Mathlib/Topology/Constructions.lean` line 268), passed to the same + lemma `AddSubgroup.isAddQuotientCoveringMap_of_comm`. +- `theorem torus_pathConnectedSpace`, proof: `infer_instance` → `exact inferInstanceAs <| PathConnectedSpace (Quotient _)` + (the pattern Mathlib uses for `AddCircle`; `infer_instance` does not unfold `HasQuotient.Quotient` to reach + `Quotient.instPathConnectedSpace`). +- Module docstring: two lines recording the above; `namespace ResearchFormalCoreR1` → `namespace TorusFiltration` + (companion namespace; no qualified self-reference existed). + +`ClosedSuperlevel.lean` (handoff sha256 `1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e`): +- `def superlevel_componentMap`: the second argument of `ZerothHomotopy.lift` is `∀ ⦃x y : X⦄, Path x y → f x = f y` + (`Mathlib/Topology/Connected/PathConnected.lean` lines 153-157); strict-implicit binders are not introduced by `fun`, + so `fun p => …` bound `p` to a point. Fixed to `fun _ _ p => ZerothHomotopy.sound (p.map f.continuous)`; the witness + and the defined map are the same. +- Module docstring: three lines recording the above; `namespace ResearchFormalCoreR1` → `namespace TorusFiltration`. + +Evidence of the fixes themselves is local (`lean -DwarningAsError=true --root=` inside the pinned `formal/` +Lake environment, exit 0 for both modules, `#print axioms` of all 58 declarations within the three allowed axioms): a +record of a computation on an unverified worktree, not a receipt. The receipt is the hosted companion run. + +Both module docstrings still read `C254 proposed source. Compilation and kernel audit: NOT_RUN.` +(line 6 of each file). That line is the handoff's own status label, retained verbatim as a +transcribed source label; it is not updated by this companion. Whether the modules compiled and +were replayed through the kernel is recorded in the hosted `receipt.json` +(`formalization_status`, `leanchecker`), never in the module text, so the module line +under-states and the receipt is the record. + +## Namespace mapping + +Every declaration keeps its handoff name: `ResearchFormalCoreR1.` (handoff) -> +`TorusFiltration.` (companion). The inventory lists in `SOURCE_FILES.json` are derived from +the originals by column-0 scans (`^theorem`, `^(noncomputable )?def`, `^abbrev`, `^instance`). +`check.py source` re-derives them from the companion modules with a whitelist scanner +(`scan_module`, not a Lean parser) and refuses any module whose scan differs. The scanner strips +comments (`--`, nested `/- -/`, `/-- -/`, `/-! -/`) and then permits, at column 0, only: +`import Mathlib` or `import Mathlib.…` (before the namespace), `noncomputable section`, +`open `, `universe …`, `variable …`, exactly one `namespace TorusFiltration` / +`end TorusFiltration` pair, and inside it a named `theorem`, `def`, `noncomputable def`, `abbrev` +or `instance` whose name matches `[A-Za-z][A-Za-z0-9_]*`. Everything else is refused: any other +command keyword anywhere outside comments (`lemma`, `example`, `axiom`, `opaque`, `structure`, +`inductive`, `class`, `private`, `protected`, `noncomputable instance`, an anonymous `instance`, +`attribute`, `set_option`, `section`, `end`, `mutual`, `deriving`, `macro`, `macro_rules`, +`syntax`, `elab`, `notation`, `scoped`, `local`, `export`, `include`, `omit`, `run_cmd`, +`initialize`, `… in`, a second command on a declaration line, an indented command), any `@[` +or `#`, any string literal (`"`), a primed or dotted declaration name, a declaration outside +the namespace or after `end TorusFiltration`, any remaining `namespace ResearchFormalCoreR1`, +and any admission token (`sorry`, `sorryAx`, `admit`, `axiom`, `native_decide`, +`ofReduceBool`, `trustCompiler`, `unsafe`, `opaque`, `partial`, `implemented_by`, `extern`, +`skipKernelTC`, `autoImplicit`) in comment-free code. A compile fix that needs a refused form +must extend the scanner and the inventory explicitly; nothing escapes the `#print axioms` audit +by being written in a shape the scanner does not count. + +## Vocabulary + +- `proved` is the source's own label for a declaration whose proof text it supplies; it is + transcribed, not awarded here. +- `kernel-checked` appears only in `receipt.json`, written by `check.py finish` after a hosted + run in which every build exited `0`, `leanchecker` replayed the companion modules' declarations + through the kernel without output (the exact invocation is recorded in `leanchecker.cmd` and + copied into the receipt), and every axiom report lies in `{propext, Classical.choice, Quot.sound}`. +- The words `verified`, `closed` (as a status) and `accepted` do not describe anything in this + companion. `alignment_status` stays `PENDING_INDEPENDENT_REVIEW`; `scientific_acceptance` is + `false`; a same-provider review would earn zero independence credit and would be recorded as + such. + +## How to run + +From a checkout with the pinned toolchain installed (`elan`, Lean v4.34.1) and the Mathlib +cache for `formal/` retrieved: + + bash companions/torus_filtration_20261011/replay.sh + +The replay: binds HEAD to the manifest (`check.py source`), runs the Python tests in normal and +`-O` modes, emits the Lean audit files, then inside `lake env bash` from `formal/` records +`lean --version` and every installed package HEAD, compiles `TorusTopology`, `ClosedSuperlevel` +and the root `TorusFiltration` with `-DwarningAsError=true`, compiles `Positive.lean` (six +concrete applications of the companion's theorems), `Audit.lean` (58 `#print axioms`), +`Types.lean` (41 `#check` with `pp.explicit`), runs +`leanchecker TorusTopology ClosedSuperlevel TorusFiltration`, and runs six negative controls. +The emitted statements below are quoted verbatim from `check.py` (`FALSE_CONTROLS`); each is +elaborated as `example : := by ` and must fail with exactly `⊢ False`: + +| Control | Kind | Exact expectation | +|---|---|---| +| `RejectSuperlevelSignFlip` | false statement `() ∈ superlevel_set (fun _ : Unit => (0 : ℝ)) (-1)` (true only if the parameter were `+t`), tactic `norm_num [superlevel_set]` | exit 1, `error: unsolved goals` / `⊢ False` | +| `RejectSuperlevelBelowThreshold` | false statement `(3 : ℝ) ∈ superlevel_set (fun x : ℝ => x) (-4)` (`3 ∈ {x | 4 ≤ x}`), tactic `norm_num [superlevel_set]` | exit 1, `⊢ False` | +| `RejectConstantNotPeriodic` | false statement `¬ torus_isPeriodic 1 (1 : ℝ) (fun _ => (0 : ℝ))`, tactic `simp [torus_isPeriodic]` | exit 1, `⊢ False` | +| `RejectSorry` | `theorem injected : False := by sorry` | exit 0 with the `sorry` warning; audit refuses `sorryAx` | +| `RejectCustomAxiom` | `axiom hiddenPremise : False` behind one intermediate theorem | exit 0; audit refuses `hiddenPremise` | +| `RejectNativeDecide` | `native_decide` proof | exit 0; audit refuses `injected._native.native_decide.ax_1_1` | + +The injection controls run **without** warnings-as-errors on purpose: Lean accepts those files, +and only the axiom audit refuses them, which is what the audit is for. `check.py negative` uses +`re.fullmatch` on each log, so a crash, an extra error or a different exit code is a failed +control, not a passed one. `check.py finish` re-runs the source binding, re-derives the nine +emitted Lean files (`Audit.lean`, `Types.lean`, `Positive.lean`, six controls) and requires byte +equality with the ones Lean consumed, checks every status, the toolchain line, the installed +package HEADs against `formal/lake-manifest.json`, the recorded `leanchecker` invocation, the +axiom and type inventories and the six controls, and writes `receipt.json` with `log_sha256` +over every file in the evidence directory. The evidence directory +`.lake/torus-filtration-evidence` must not pre-exist. + +### What `leanchecker` checks here, and why not `--fresh` + +Both modules `import Mathlib`, so their import closure is all of Mathlib (6.1 GB of `.olean` +files at the pin). `leanchecker --fresh TorusFiltration`, the shape of the D2 companions' step +(`leanchecker --fresh D2MomentBridge`, affordable there only because that module imports +`Mathlib.Tactic` and one Bochner file), re-checks that entire closure from scratch: measured locally against the pinned cache at 4 threads it was still +running at 1500 s with 6.6 GB resident, so it cannot complete inside a hosted job. The hosted +default is therefore `leanchecker TorusTopology ClosedSuperlevel TorusFiltration`: leanchecker +builds the environment from the cached, prebuilt dependency `.olean` files (trusted, exactly as +`lean` itself trusts them when compiling the modules) and replays every declaration of the three +named modules through the kernel. Measured locally at `LEAN_NUM_THREADS=2`: 30 s wall, +6.6 GB resident, no output on success (the same footprint as one `lean` compile of +`ClosedSuperlevel.lean`, 9 s and 6.8 GB). `replay.sh` writes the exact invocation to +`leanchecker.cmd`; `check.py finish` accepts only the two pinned forms, requires the modules-mode +log to be empty, and copies command and mode into `receipt.json` under `leanchecker`. +An operator who wants the whole-closure re-check runs +`TORUS_LEANCHECKER_FRESH=1 bash companions/torus_filtration_20261011/replay.sh` locally with the +time and memory to spare; the receipt then records mode `fresh`. The workflow never sets that +switch. + +Hosted duration: _not yet measured_. The workflow's `timeout-minutes: 45` is provisional; the +integrator records the first green run's duration here and may lower it. Until then this README +does not assert that the hosted route completes. + +The replay writes `TorusTopology.olean`, `ClosedSuperlevel.olean` and `TorusFiltration.olean` +into the companion directory (Lean needs them on `LEAN_PATH` for the root module and the audit +files). They are build artefacts and must never be committed: the repository has no root +`.gitignore`, `git add -A` would stage them, and `check.py source` then refuses the companion +with `tracked companion membership differs` until they are removed in a follow-up commit. +Delete them before committing. + +Local protocol tests: `python3 -B -S companions/torus_filtration_20261011/test_torus_filtration.py` +and the same with `-O`. They exercise `check.py` against a temporary Git fixture with +inventory-exact placeholder modules; they execute no Lean. + +## What this companion does not do + +It does not modify `formal/`, the D2 companions or their workflows. It does not enter the q0 +dependency graph, raise any claim's grade, or substitute for the nonauthor source review, the +independent alignment review or the operator's decisions. The hosted receipt is a record of a +computation, not evidence of alignment with the research programme. diff --git a/companions/torus_filtration_20261011/SCOPE.md b/companions/torus_filtration_20261011/SCOPE.md new file mode 100644 index 000000000..68361d93b --- /dev/null +++ b/companions/torus_filtration_20261011/SCOPE.md @@ -0,0 +1,94 @@ +# Scope note: C254 torus quotient and closed-superlevel filtration companion + +Dylan Roy — delegated AI work. Source author: OpenAI/Codex lane (C254). Compile fixes and +companion: Anthropic/Claude lane. Scientific effect NONE; organizational-independence credit 0; +no human review; alignment `PENDING_INDEPENDENT_REVIEW`. + +This note fixes what the 41 theorem statements and 17 audited definitions of +`TorusTopology.lean` and `ClosedSuperlevel.lean` cover and what they do not. An independent +reviewer must compare each Lean statement with this note and with the handoff's own scope +(TORUS_FILTRATION.md in comment 6111059166) before any alignment record is written. The +compile fixes changed proof terms and resolved names at the pin; whether every statement still +says what the handoff intended is part of that review, not something this note decides. + +## Bound sources + +- Originals (NOT_COMPILED, namespace `ResearchFormalCoreR1`): `TorusTopology.lean` SHA-256 + `efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4`; `ClosedSuperlevel.lean` + SHA-256 `1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e`. +- Claim `8a5c7a24-784b-4aaa-b951-cd9f37b0dc64`; Math- PR #419 comments 6111056103, 6111059166, + 6111059498 (nonauthor source review: COMPILATION HOLD), 6111059848, 6111255007 (route finding); + this lane: 6111093545 (local elaboration report), 6111139060 (pickup). +- Namespace mapping `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion). +- Pinned environment read from `formal/`: `leanprover/lean4:v4.34.1`, Mathlib + `d13f23b723b8a846827a245b89c10fc7d3f11612`; nothing from the core is imported or pinned. + +## Targets, exact coverage, not established + +| Targets | Exact coverage | Not established | +|---|---|---| +| `torus_field_latticeVec_formula`, `torus_basis_sum_eq_latticeVec`, `torus_lattice_mem_iff` | `torus_latticeVec d L n = ∑ i, EuclideanSpace.single i (L * n i)` by `rfl`; the integer combination of the `L`-scaled standard basis is that vector; lattice membership iff an integer vector produces the point | any elaborated theorem naming the externally owned `Specifications.Field` module; the companion carries the literal formula and does not import that file | +| `torus_proj_surjective`, `torus_proj_continuous`, `torus_proj_eq_iff`, `torus_control_lattice_translate` | the quotient projection is surjective and continuous; `proj x = proj y ↔ ∃ n, y = x + torus_latticeVec d L n`; a lattice translate has the same image | a fundamental-domain parametrisation; uniqueness of representatives | +| `torus_proj_isCoveringMap`, `torus_compact`, `torus_pathConnectedSpace` (with the three discreteness/`IsZLattice` instances) | the projection is a covering map; `IsCompact Set.univ` on the quotient; the quotient is path connected | a registered `CompactSpace` instance; smooth charts; any manifold structure | +| `torus_field_periodic_formula`, `torus_periodic_respects`, `torus_descend_proj`, `torus_descend_continuous` | `torus_isPeriodic d L g` is literally the Field periodicity formula; periodic `g` respects the quotient relation; `descend g (proj x) = g x`; the descent is continuous when `g` is | smoothness of descended functions; derivative or Hessian invariance; Morse-index compatibility | +| `torus_path_lift_from`, `torus_control_constant_path_endpoint`, `torus_control_no_arbitrary_endpoint` | a quotient path from `proj M` lifts to a path from the prescribed representative `M` whose endpoint is **existential** and projects to the path's endpoint; a lift of the constant path from `M` ends at `M`; no lift of the constant path ends at a different lattice translate | a lift ending at an arbitrarily chosen representative (the controls refute exactly this) | +| `torus_higher_path_iff`, `torus_strict_higher_path_iff`, `torus_closed_higher_path_iff`, `torus_global_max_iff` | existence of a strictly higher endpoint reached by a path whose heights satisfy `P` (resp. `h < ·`, `h ≤ ·`) transfers between `E` and the quotient for the descended function; global maximality transfers | critical-level attainment at `h = δ`; conversion of strict path predicates into closed critical-level merger; finite critical events | +| `superlevel_control_closed_endpoint`, `superlevel_control_strict_endpoint`, `superlevel_control_parameter_sign`, `superlevel_control_inclusion_direction`, `superlevel_control_essential`, `superlevel_control_strict_thresholds` | the handoff's own controls: closed endpoint membership vs strict failure; parameter sign `t = -h`; inclusion direction; no strictly higher endpoint at a global maximum; density of strict witnesses below `0` with no witness at `0` | a compact Morse counterexample; a supremum theorem; endpoint nonattainment for the research problem; a finite death from an essential maximum | +| `superlevel_mono`, `superlevel_isClosed`, `superlevel_inclusion_id`, `superlevel_inclusion_comp`, `superlevel_mem_at_own_height`, `superlevel_neg_height` | `s ≤ t → F(s) ⊆ F(t)`; `F(t)` closed for continuous `g`; the continuous inclusions are a functor; `x ∈ F(-g x)`; `F(-h) = {x | h ≤ g x}` | component birth at the own height; finiteness of components | +| `superlevel_componentMap_mk`, `superlevel_componentMap_id`, `superlevel_componentMap_comp`, `superlevel_componentInclusion_id`, `superlevel_componentInclusion_comp`, `superlevel_component_eq_iff_joinedIn` | the induced maps on actual `ZerothHomotopy` quotients are functorial; equal classes iff `JoinedIn` the closed superlevel | label tracking, elder events, once-counting, interval decomposition, bar bijection | +| `superlevel_h0Filtration_map_id`, `superlevel_h0Filtration_map_comp` | functor laws of `superlevel_filtration g ⋙ (singularHomologyFunctor C 0).obj R` with the coefficient category's coproduct, preadditive and homology structure stated explicitly | naturality comparing component maps with singular-H0 generators; any identification of `PairLawInterface.p` | + +The audited definitions (`torus_E`, `torus_quotient`, `torus_latticeVec`, `torus_periodBasis`, +`torus_periodLattice`, `torus_proj`, `torus_isPeriodic`, `torus_descend`, the three lattice +instances, `superlevel_set`, `superlevel_inclusion`, `superlevel_componentMap`, +`superlevel_componentInclusion`, `superlevel_filtration`, `superlevel_h0Filtration`) are +constructions, not claims; they are audited so that no hidden axiom enters through a definition. + +## Controls in the replay + +| Control | Detects | +|---|---| +| `RejectSuperlevelSignFlip` | the parameter convention: `() ∈ F(-1)` for the constant `0` would hold if the definition read `t ≤ g x` instead of `-t ≤ g x`; Lean leaves `⊢ False` | +| `RejectSuperlevelBelowThreshold` | a point below the threshold admitted to the closed level (`3 ∈ {x | 4 ≤ x}`); `⊢ False` | +| `RejectConstantNotPeriodic` | the negation of a periodicity instance that `Positive.lean` uses (`fun _ _ => rfl`); `⊢ False` | +| `RejectSorry`, `RejectCustomAxiom`, `RejectNativeDecide` | an admitted proof, a hidden premise behind an intermediate theorem, and a native-code decision each pass Lean (exit 0) and must be refused by the transitive axiom audit (`sorryAx`, `hiddenPremise`, `injected._native.native_decide.ax_1_1`) | + +Each control is matched by `re.fullmatch` against its pinned diagnostic; the false-statement +diagnostics and the three injection reports were pinned from actual Lean 4.34.1 output at the +Mathlib `d13f23b7` pin. A crash, an extra message or a different exit code fails the control. +The Python suite additionally refuses every weakening of `check.py` it knows about (wrong +diagnostic, wrong exit code, unknown control, `sorryAx`, unknown or missing audit target, +unrecognized audit text, missing or extra type, a diagnostic after the type listing, membership +or byte drift, a committed `.olean`, a symlinked source, stale manifest, duplicate JSON key, +renamed theorem, hidden or indented declaration, injected admission, every honesty label and +schema field of `SOURCE_FILES.json` one at a time, wrong or unpinned toolchain and dependency +lock, host identity mismatch, an emitted Lean file altered between `emit` and `finish`, an +unrecognized `leanchecker` invocation, leanchecker output in modules mode, wrong installed +dependency). + +## Evidence boundary + +A green hosted run establishes, for these 58 declarations at this toolchain and dependency +lock, that Lean elaborated them with warnings as errors, that +`leanchecker TorusTopology ClosedSuperlevel TorusFiltration` replayed the companion modules' own +declarations through the kernel against the cached, prebuilt dependency `.olean` files (the +import closure, all of Mathlib, is trusted from that cache and not re-checked; a `--fresh` +re-check of the closure does not fit a hosted job and is available only as an operator's local +run, which the receipt records as mode `fresh`), and that every transitive axiom lies in +`{propext, Classical.choice, Quot.sound}`. It establishes nothing about alignment with the +research programme, nothing about C253 or any q0 claim, and nothing the handoff's own list of exclusions names: critical-level +attainment, finite critical events, label tracking, naturality to singular-H0 generators beyond +the functor laws, interval decomposition, bar bijection, elder events, once-counting, or any +identification of `PairLawInterface.p`. The receipt's `formalization_status: kernel-checked` is a +record of that computation; `alignment_status` remains `PENDING_INDEPENDENT_REVIEW` and +`scientific_acceptance` remains `false` until an independent reviewer with nonzero +organizational-independence credit records otherwise. Aging approves nothing. + +## Reproduction + + bash companions/torus_filtration_20261011/replay.sh + python3 -B -S companions/torus_filtration_20261011/test_torus_filtration.py + python3 -B -O -S companions/torus_filtration_20261011/test_torus_filtration.py + +The replay must start without `.lake/torus-filtration-evidence` present and must not run +`formal/gate.py`, the formal tests, `lake build`, `lake update` or `lake exe cache`. diff --git a/companions/torus_filtration_20261011/SOURCE_FILES.json b/companions/torus_filtration_20261011/SOURCE_FILES.json new file mode 100644 index 000000000..97bebfd4b --- /dev/null +++ b/companions/torus_filtration_20261011/SOURCE_FILES.json @@ -0,0 +1,161 @@ +{ + "alignment_status": "PENDING_INDEPENDENT_REVIEW", + "definitions": { + "ClosedSuperlevel": { + "abbrev": [], + "def": [ + "superlevel_set", + "superlevel_inclusion", + "superlevel_componentMap", + "superlevel_componentInclusion", + "superlevel_filtration", + "superlevel_h0Filtration" + ], + "instance": [] + }, + "TorusTopology": { + "abbrev": [ + "torus_E", + "torus_quotient" + ], + "def": [ + "torus_latticeVec", + "torus_periodBasis", + "torus_periodLattice", + "torus_proj", + "torus_isPeriodic", + "torus_descend" + ], + "instance": [ + "torus_lattice_discrete", + "torus_lattice_addSubgroup_discrete", + "torus_lattice_isZLattice" + ] + } + }, + "files": { + ".github/workflows/torus-filtration.yml": { + "bytes": 2084, + "git_blob": "becc58ff7e8362160c305bcdc8b386221966afad", + "sha256": "3b6b06856bad22f7e9d28f1caf0e1710db3284cd73d65bf6f7330bfbd45dc033" + }, + "companions/torus_filtration_20261011/ClosedSuperlevel.lean": { + "bytes": 8088, + "git_blob": "a4323cb50fb2d5861c4e6240a18684bfb566fb80", + "sha256": "90d1481b75d9c6d14e462c3fbf0bf7c7cdd0efb9eaad68d6732400658753b1c2" + }, + "companions/torus_filtration_20261011/README.md": { + "bytes": 21661, + "git_blob": "942f02e8203e66bebd5beba40ab6c34a449ba283", + "sha256": "5f4ce5f495a0c385ab15a7a7bd0dc5db07866b0fae356ffc85877e04546523bd" + }, + "companions/torus_filtration_20261011/SCOPE.md": { + "bytes": 10073, + "git_blob": "68361d93bb6b701c3c3c6c32ab942db3e4bcedc3", + "sha256": "bcd3c49a8cc05dc33a424092622b0ad1dabc82684bee037cd85ee8c131d33dbb" + }, + "companions/torus_filtration_20261011/TorusFiltration.lean": { + "bytes": 45, + "git_blob": "d8e52f866943d54959cd38d5ec496739f739bc17", + "sha256": "5498eb85d94965073f8cee18fda4bd8a6f4ceef36ed85efd7fb78784ab4f0e58" + }, + "companions/torus_filtration_20261011/TorusTopology.lean": { + "bytes": 12257, + "git_blob": "ed678ea322fe5315b3aaff44e4e2f06b018399d8", + "sha256": "ddb145b3f791c181d4f2a51e54e711937297bd6476ba55bcd5252b7ddb57cfe1" + }, + "companions/torus_filtration_20261011/check.py": { + "bytes": 29134, + "git_blob": "8443ae3192c44b912952b9cd1984a7290e95acc8", + "sha256": "57a75907677e074579b501168ad0a406d51168f41daa96b8627615b037acfc6b" + }, + "companions/torus_filtration_20261011/replay.sh": { + "bytes": 4161, + "git_blob": "c217643224412785a9306600809e43c8e0c5d71f", + "sha256": "74de4c98df96bfa59b879dc79bad78bc708573b1ee16c2582393837cc4e9d189" + }, + "companions/torus_filtration_20261011/test_torus_filtration.py": { + "bytes": 62092, + "git_blob": "6eb9a3eb3b319c59dd27f08463b0679274b06901", + "sha256": "b5102880bd937d13d92e61f2896ec368177d1828113f75565d6471b8fcccfa50" + } + }, + "modules": [ + "TorusTopology", + "ClosedSuperlevel" + ], + "namespace": "TorusFiltration", + "provenance": { + "claim": "8a5c7a24-784b-4aaa-b951-cd9f37b0dc64", + "compile_fixes_and_companion": "Anthropic/Claude lane, delegated AI work for Dylan Roy", + "handoff_comments": { + "c255_route_finding_d2_pins_companion_route": "6111255007", + "implementer_report": "6111059848", + "local_elaboration_report": "6111093545", + "modules": "6111056103", + "nonauthor_source_review_compilation_hold": "6111059498", + "overlay": "6111059166", + "pickup_this_lane": "6111139060" + }, + "handoff_pr": "d6g8k5htny-coder/Math-#419", + "human_review": "none", + "namespace_mapping": "ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion)", + "organizational_independence_credit": 0, + "original_sha256": { + "ResearchFormalCoreR1/ClosedSuperlevel.lean": "1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e", + "ResearchFormalCoreR1/TorusTopology.lean": "efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4" + }, + "original_status": "NOT_COMPILED", + "source_author": "OpenAI/Codex lane (C254), delegated AI work for Dylan Roy" + }, + "root_module": "TorusFiltration", + "schema": 1, + "scientific_effect": "NONE", + "theorems": { + "ClosedSuperlevel": [ + "superlevel_control_closed_endpoint", + "superlevel_control_strict_endpoint", + "superlevel_control_parameter_sign", + "superlevel_control_inclusion_direction", + "superlevel_control_essential", + "superlevel_mono", + "superlevel_isClosed", + "superlevel_inclusion_id", + "superlevel_inclusion_comp", + "superlevel_mem_at_own_height", + "superlevel_neg_height", + "superlevel_control_strict_thresholds", + "superlevel_componentMap_mk", + "superlevel_componentMap_id", + "superlevel_componentMap_comp", + "superlevel_componentInclusion_id", + "superlevel_componentInclusion_comp", + "superlevel_component_eq_iff_joinedIn", + "superlevel_h0Filtration_map_id", + "superlevel_h0Filtration_map_comp" + ], + "TorusTopology": [ + "torus_field_latticeVec_formula", + "torus_basis_sum_eq_latticeVec", + "torus_lattice_mem_iff", + "torus_proj_surjective", + "torus_proj_continuous", + "torus_proj_eq_iff", + "torus_control_lattice_translate", + "torus_proj_isCoveringMap", + "torus_compact", + "torus_pathConnectedSpace", + "torus_field_periodic_formula", + "torus_periodic_respects", + "torus_descend_proj", + "torus_descend_continuous", + "torus_path_lift_from", + "torus_control_constant_path_endpoint", + "torus_control_no_arbitrary_endpoint", + "torus_higher_path_iff", + "torus_strict_higher_path_iff", + "torus_closed_higher_path_iff", + "torus_global_max_iff" + ] + } +} diff --git a/companions/torus_filtration_20261011/TorusFiltration.lean b/companions/torus_filtration_20261011/TorusFiltration.lean new file mode 100644 index 000000000..d8e52f866 --- /dev/null +++ b/companions/torus_filtration_20261011/TorusFiltration.lean @@ -0,0 +1,2 @@ +import TorusTopology +import ClosedSuperlevel diff --git a/companions/torus_filtration_20261011/TorusTopology.lean b/companions/torus_filtration_20261011/TorusTopology.lean new file mode 100644 index 000000000..ed678ea32 --- /dev/null +++ b/companions/torus_filtration_20261011/TorusTopology.lean @@ -0,0 +1,247 @@ +import Mathlib + +/-! +# The actual period-lattice quotient and specified-start path compatibility + +C254 proposed source. Compilation and kernel audit: NOT_RUN. +The ambient space and lattice-vector formula below are exactly those in the +source-bound Field.lean; this module does not import or alter that owner's file. +All quotient, compactness, covering and descent properties are constructed. +The final lift endpoint is existential. No critical-level attainment is claimed. +Compile fixes at the pin (Lean v4.34.1, Mathlib d13f23b7), no statement altered: `Basis` → `Module.Basis`, `Basis.unitsSMul_apply` → `Module.Basis.unitsSMul_apply`, lattice discreteness passed via `SetLike.isDiscrete_iff_discreteTopology.mpr` instead of `DiscreteTopology.isDiscrete`, quotient path-connectedness via `inferInstanceAs (PathConnectedSpace (Quotient _))` instead of `infer_instance`. +Three unused simp arguments (`PiLp.single_apply` twice, `hij`) removed from `torus_basis_sum_eq_latticeVec` so the +file elaborates with warnings as errors; namespace `TorusFiltration` in this companion (handoff: `ResearchFormalCoreR1`). +-/ + +noncomputable section + +open Topology + +namespace TorusFiltration +abbrev torus_E (d : ℕ) := EuclideanSpace ℝ (Fin d) + +/-- The exact `Field.latticeVec` formula, retained without any coordinate rescaling. -/ +def torus_latticeVec (d : ℕ) (L : ℝ) (n : Fin d → ℤ) : torus_E d := + ∑ i, EuclideanSpace.single i (L * (n i : ℝ)) + +theorem torus_field_latticeVec_formula (d : ℕ) (L : ℝ) (n : Fin d → ℤ) : + torus_latticeVec d L n = ∑ i, EuclideanSpace.single i (L * (n i : ℝ)) := rfl + +def torus_periodBasis (d : ℕ) (L : ℝ) (hL : 0 < L) : + Module.Basis (Fin d) ℝ (torus_E d) := + (EuclideanSpace.basisFun (Fin d) ℝ).toBasis.unitsSMul + (fun _ => Units.mk0 L hL.ne') + +def torus_periodLattice (d : ℕ) (L : ℝ) (hL : 0 < L) : Submodule ℤ (torus_E d) := + Submodule.span ℤ (Set.range (torus_periodBasis d L hL)) + +abbrev torus_quotient (d : ℕ) (L : ℝ) (hL : 0 < L) := + torus_E d ⧸ (torus_periodLattice d L hL).toAddSubgroup + +def torus_proj (d : ℕ) (L : ℝ) (hL : 0 < L) : torus_E d → torus_quotient d L hL := + QuotientAddGroup.mk + +/-- Concrete adapter from integer basis coefficients to Field's exact vector formula. -/ +theorem torus_basis_sum_eq_latticeVec (d : ℕ) (L : ℝ) (hL : 0 < L) + (n : Fin d → ℤ) : + ∑ i, n i • torus_periodBasis d L hL i = torus_latticeVec d L n := by + classical + unfold torus_latticeVec + apply Finset.sum_congr rfl + intro i hi + ext j + by_cases hij : i = j + · subst j + simp [torus_periodBasis, Module.Basis.unitsSMul_apply, OrthonormalBasis.coe_toBasis, + EuclideanSpace.basisFun_apply, Units.smul_def, PiLp.smul_apply, + zsmul_eq_mul, mul_comm] + · simp [torus_periodBasis, Module.Basis.unitsSMul_apply, OrthonormalBasis.coe_toBasis, + EuclideanSpace.basisFun_apply, Units.smul_def, PiLp.smul_apply, + Ne.symm hij] + +theorem torus_lattice_mem_iff (d : ℕ) (L : ℝ) (hL : 0 < L) (x : torus_E d) : + x ∈ torus_periodLattice d L hL ↔ ∃ n : Fin d → ℤ, torus_latticeVec d L n = x := by + classical + change x ∈ Submodule.span ℤ (Set.range (torus_periodBasis d L hL)) ↔ _ + rw [Submodule.mem_span_range_iff_exists_fun] + simp only [torus_basis_sum_eq_latticeVec] + +instance torus_lattice_discrete (d : ℕ) (L : ℝ) (hL : 0 < L) : + DiscreteTopology (torus_periodLattice d L hL) := by + unfold torus_periodLattice + infer_instance + +instance torus_lattice_addSubgroup_discrete (d : ℕ) (L : ℝ) (hL : 0 < L) : + DiscreteTopology (torus_periodLattice d L hL).toAddSubgroup := by + unfold torus_periodLattice + infer_instance + +instance torus_lattice_isZLattice (d : ℕ) (L : ℝ) (hL : 0 < L) : + IsZLattice ℝ (torus_periodLattice d L hL) := by + unfold torus_periodLattice + infer_instance + +theorem torus_proj_surjective (d : ℕ) (L : ℝ) (hL : 0 < L) : + Function.Surjective (torus_proj d L hL) := QuotientAddGroup.mk_surjective + +theorem torus_proj_continuous (d : ℕ) (L : ℝ) (hL : 0 < L) : + Continuous (torus_proj d L hL) := continuous_quotient_mk' + +theorem torus_proj_eq_iff (d : ℕ) (L : ℝ) (hL : 0 < L) (x y : torus_E d) : + torus_proj d L hL x = torus_proj d L hL y ↔ + ∃ n : Fin d → ℤ, y = x + torus_latticeVec d L n := by + change (QuotientAddGroup.mk x : torus_quotient d L hL) = QuotientAddGroup.mk y ↔ _ + rw [QuotientAddGroup.eq] + change -x + y ∈ torus_periodLattice d L hL ↔ _ + rw [torus_lattice_mem_iff] + constructor + · rintro ⟨n, hn⟩ + exact ⟨n, by rw [hn]; abel⟩ + · rintro ⟨n, rfl⟩ + exact ⟨n, by abel⟩ + +/-- Duplicate representatives have exactly the same quotient image. -/ +theorem torus_control_lattice_translate (d : ℕ) (L : ℝ) (hL : 0 < L) + (x : torus_E d) (n : Fin d → ℤ) : + torus_proj d L hL (x + torus_latticeVec d L n) = torus_proj d L hL x := + ((torus_proj_eq_iff d L hL x _).2 ⟨n, rfl⟩).symm + +theorem torus_proj_isCoveringMap (d : ℕ) (L : ℝ) (hL : 0 < L) : + IsCoveringMap (torus_proj d L hL) := + ((torus_periodLattice d L hL).toAddSubgroup.isAddQuotientCoveringMap_of_comm + (SetLike.isDiscrete_iff_discreteTopology.mpr + (torus_lattice_addSubgroup_discrete d L hL))).isCoveringMap + +theorem torus_compact (d : ℕ) (L : ℝ) (hL : 0 < L) : + IsCompact (Set.univ : Set (torus_quotient d L hL)) := by + have hc := IsZLattice.isCompact_range_of_periodic (torus_periodLattice d L hL) + (torus_proj d L hL) (torus_proj_continuous d L hL) + (fun z w hw => QuotientAddGroup.mk_add_of_mem z hw) + rwa [Set.range_eq_univ.mpr (torus_proj_surjective d L hL)] at hc + +theorem torus_pathConnectedSpace (d : ℕ) (L : ℝ) (hL : 0 < L) : + PathConnectedSpace (torus_quotient d L hL) := by + exact inferInstanceAs <| PathConnectedSpace (Quotient _) + +/-- Exact Field periodicity predicate with the literal lattice-vector adapter above. -/ +def torus_isPeriodic (d : ℕ) (L : ℝ) (g : torus_E d → ℝ) : Prop := + ∀ (x : torus_E d) (n : Fin d → ℤ), g (x + torus_latticeVec d L n) = g x + +theorem torus_field_periodic_formula (d : ℕ) (L : ℝ) (g : torus_E d → ℝ) : + torus_isPeriodic d L g ↔ + ∀ (x : EuclideanSpace ℝ (Fin d)) (n : Fin d → ℤ), + g (x + ∑ i, EuclideanSpace.single i (L * (n i : ℝ))) = g x := Iff.rfl + +theorem torus_periodic_respects (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) (x y : torus_E d) + (hxy : QuotientAddGroup.leftRel (torus_periodLattice d L hL).toAddSubgroup x y) : + g x = g y := by + have hq : torus_proj d L hL x = torus_proj d L hL y := Quotient.sound hxy + obtain ⟨n, rfl⟩ := (torus_proj_eq_iff d L hL x y).1 hq + exact (hg x n).symm + +def torus_descend (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) : torus_quotient d L hL → ℝ := + Quotient.lift g (torus_periodic_respects d L hL g hg) + +theorem torus_descend_proj (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) (x : torus_E d) : + torus_descend d L hL g hg (torus_proj d L hL x) = g x := rfl + +theorem torus_descend_continuous (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) (hgc : Continuous g) : + Continuous (torus_descend d L hL g hg) := + hgc.quotient_lift (torus_periodic_respects d L hL g hg) + +/-- Lift from a prescribed representative; the endpoint is determined existentially. -/ +theorem torus_path_lift_from (d : ℕ) (L : ℝ) (hL : 0 < L) + {M : torus_E d} {y : torus_quotient d L hL} + (γ : Path (torus_proj d L hL M) y) : + ∃ z : torus_E d, ∃ Γ : Path M z, + torus_proj d L hL z = y ∧ + ∀ t : unitInterval, torus_proj d L hL (Γ t) = γ t := by + let cov := torus_proj_isCoveringMap d L hL + let Γ := cov.liftPath γ M γ.source + refine ⟨Γ 1, ⟨Γ, cov.liftPath_zero γ M γ.source, rfl⟩, ?_, ?_⟩ + · exact (congrFun (cov.liftPath_lifts γ M γ.source) 1).trans γ.target + · intro t + exact congrFun (cov.liftPath_lifts γ M γ.source) t + +/-- Control: a constant projected path cannot be lifted from M to a different lift. +This refutes replacing the existential endpoint by an arbitrary chosen representative. -/ +theorem torus_control_constant_path_endpoint (d : ℕ) (L : ℝ) (hL : 0 < L) + {M z : torus_E d} (Γ : Path M z) + (hΓ : ∀ t : unitInterval, torus_proj d L hL (Γ t) = torus_proj d L hL M) : z = M := by + have heq : (Γ : unitInterval → torus_E d) = fun _ => M := + (torus_proj_isCoveringMap d L hL).eq_of_comp_eq Γ.continuous continuous_const + (funext hΓ) 0 Γ.source + exact Γ.target.symm.trans (congrFun heq 1) + +/-- Combining the duplicate-image and uniqueness controls gives a direct rejection +of any different preselected endpoint for a constant quotient path. -/ +theorem torus_control_no_arbitrary_endpoint (d : ℕ) (L : ℝ) (hL : 0 < L) + (M : torus_E d) (n : Fin d → ℤ) (hn : torus_latticeVec d L n ≠ 0) : + torus_proj d L hL (M + torus_latticeVec d L n) = torus_proj d L hL M ∧ + ¬ ∃ Γ : Path M (M + torus_latticeVec d L n), + ∀ t : unitInterval, torus_proj d L hL (Γ t) = torus_proj d L hL M := by + refine ⟨torus_control_lattice_translate d L hL M n, ?_⟩ + rintro ⟨Γ, hΓ⟩ + have heq := torus_control_constant_path_endpoint d L hL Γ hΓ + apply hn + exact add_left_cancel (show M + torus_latticeVec d L n = M + 0 by simpa using heq) + +/-- Higher-endpoint compatibility for any scalar path predicate, including strict +and closed thresholds. No conclusion here asserts critical-level attainment. -/ +theorem torus_higher_path_iff (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) (M : torus_E d) (P : ℝ → Prop) : + (∃ y : torus_E d, g M < g y ∧ ∃ γ : Path M y, ∀ t : unitInterval, P (g (γ t))) ↔ + (∃ y : torus_quotient d L hL, + torus_descend d L hL g hg (torus_proj d L hL M) < torus_descend d L hL g hg y ∧ + ∃ γ : Path (torus_proj d L hL M) y, + ∀ t : unitInterval, P (torus_descend d L hL g hg (γ t))) := by + constructor + · rintro ⟨y, hy, γ, hγ⟩ + exact ⟨torus_proj d L hL y, hy, γ.map (torus_proj_continuous d L hL), hγ⟩ + · rintro ⟨y, hy, γ, hγ⟩ + obtain ⟨z, Γ, hz, hΓ⟩ := torus_path_lift_from d L hL γ + refine ⟨z, ?_, Γ, ?_⟩ + · have hz' := congrArg (torus_descend d L hL g hg) hz + change g z = torus_descend d L hL g hg y at hz' + change g M < torus_descend d L hL g hg y at hy + rwa [← hz'] at hy + · intro t + have ht := hγ t + rw [← hΓ t] at ht + exact ht + +theorem torus_strict_higher_path_iff (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) (M : torus_E d) (h : ℝ) : + (∃ y : torus_E d, g M < g y ∧ ∃ γ : Path M y, ∀ t : unitInterval, h < g (γ t)) ↔ + (∃ y : torus_quotient d L hL, + torus_descend d L hL g hg (torus_proj d L hL M) < torus_descend d L hL g hg y ∧ + ∃ γ : Path (torus_proj d L hL M) y, + ∀ t : unitInterval, h < torus_descend d L hL g hg (γ t)) := + torus_higher_path_iff d L hL g hg M (fun a => h < a) + +theorem torus_closed_higher_path_iff (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) (M : torus_E d) (h : ℝ) : + (∃ y : torus_E d, g M < g y ∧ ∃ γ : Path M y, ∀ t : unitInterval, h ≤ g (γ t)) ↔ + (∃ y : torus_quotient d L hL, + torus_descend d L hL g hg (torus_proj d L hL M) < torus_descend d L hL g hg y ∧ + ∃ γ : Path (torus_proj d L hL M) y, + ∀ t : unitInterval, h ≤ torus_descend d L hL g hg (γ t)) := + torus_higher_path_iff d L hL g hg M (fun a => h ≤ a) + +theorem torus_global_max_iff (d : ℕ) (L : ℝ) (hL : 0 < L) + (g : torus_E d → ℝ) (hg : torus_isPeriodic d L g) (M : torus_E d) : + (∀ y : torus_E d, g y ≤ g M) ↔ + ∀ y : torus_quotient d L hL, + torus_descend d L hL g hg y ≤ torus_descend d L hL g hg (torus_proj d L hL M) := by + constructor + · intro h y + obtain ⟨z, rfl⟩ := torus_proj_surjective d L hL y + exact h z + · intro h y + exact h (torus_proj d L hL y) + +end TorusFiltration \ No newline at end of file diff --git a/companions/torus_filtration_20261011/check.py b/companions/torus_filtration_20261011/check.py new file mode 100644 index 000000000..8443ae319 --- /dev/null +++ b/companions/torus_filtration_20261011/check.py @@ -0,0 +1,523 @@ +#!/usr/bin/env python3 +"""Source-bound evidence driver for the C254 torus/closed-superlevel companion (stdlib only). + +Not an acceptance engine, not a general Lean parser, not a review. It binds the +companion's bytes to Git HEAD, emits the audit/type/positive/negative Lean files, +refuses negative-control logs that are not the intended diagnostic, and writes a +receipt that records what ran. The companion consumes nothing from formal/ except +the pinned toolchain, lakefile and dependency lock, so it pins no core tree, +manifest or gate. Scientific effect NONE; organizational-independence credit 0. +""" +import argparse +import hashlib +import json +import os +from pathlib import Path +import re +import subprocess +import sys +import tempfile + +SIDE = Path(__file__).resolve().parent +ROOT = SIDE.parents[1] +PACKAGE = 'companions/torus_filtration_20261011' +WORKFLOW = '.github/workflows/torus-filtration.yml' +REPO = 'd6g8k5htny-coder/Math-' +NAMESPACE = 'TorusFiltration' +MODULES = ('TorusTopology', 'ClosedSuperlevel') +ROOT_MODULE = 'TorusFiltration' +ROOT_SOURCE = 'import TorusTopology\nimport ClosedSuperlevel\n' +REQUIRED_FILES = tuple(PACKAGE + '/' + n for n in ( + 'TorusFiltration.lean', 'TorusTopology.lean', 'ClosedSuperlevel.lean', 'check.py', 'replay.sh', + 'test_torus_filtration.py', 'README.md', 'SCOPE.md')) + (WORKFLOW,) +PINNED_CORE = ('formal/lakefile.toml', 'formal/lake-manifest.json', 'formal/lean-toolchain') +TOOLCHAIN = 'leanprover/lean4:v4.34.1' +LEAN_VERSION = re.compile(r'Lean \(version 4\.34\.1, [^()\r\n]+, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release\)') +CLAIM = '8a5c7a24-784b-4aaa-b951-cd9f37b0dc64' +ORIGINAL_SHA256 = { + 'ResearchFormalCoreR1/TorusTopology.lean': 'efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4', + 'ResearchFormalCoreR1/ClosedSuperlevel.lean': '1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e'} +NAMESPACE_MAPPING = 'ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion)' +# Own copy of formal/gate.py's audit rules; the companion imports nothing from the core. +ALLOWED = frozenset({'propext', 'Classical.choice', 'Quot.sound'}) +NAME = r'[A-Za-z_][A-Za-z0-9_.]*' +AXIOM = re.compile(r"'(" + NAME + r")' (?:depends on axioms: \[([^\]]*)\]|does not depend on any axioms)") +IDENT = r'[A-Za-z][A-Za-z0-9_]*' +HEX40 = re.compile(r'[0-9a-f]{40}') +HEX64 = re.compile(r'[0-9a-f]{64}') +BUILDS = ('build-TorusTopology', 'build-ClosedSuperlevel', 'build-TorusFiltration', 'positive', 'axioms', 'types', 'leanchecker') +# The leanchecker invocations replay.sh may record in leanchecker.cmd. Both modules `import Mathlib`, so +# `--fresh` (kernel re-check of the whole import closure) exceeds a hosted job: measured locally at 4 threads +# it was still running at 1500 s with 6.6 GB resident. The hosted default replays the companion's own +# declarations against the cached, prebuilt dependency .oleans (33 s at 2 threads locally). +LEANCHECKER = {'leanchecker TorusTopology ClosedSuperlevel TorusFiltration': 'modules', + 'leanchecker --fresh TorusFiltration': 'fresh'} +ADMISSION = ('sorry', 'sorryAx', 'admit', 'axiom', 'native_decide', 'ofReduceBool', 'trustCompiler', 'unsafe', + 'opaque', 'partial', 'implemented_by', 'extern', 'skipKernelTC', 'autoImplicit') +# Module scanner (scan_module): a whitelist of what may start a column-0 code line. Lean itself accepts a +# command anywhere (indented, after another command on the same line, behind `open … in`), so every other +# command keyword is refused wherever it appears outside comments; the scanner refuses what it cannot place. +COMMANDS = ('theorem', 'lemma', 'def', 'abbrev', 'instance', 'axiom', 'axioms', 'example', 'structure', 'inductive', + 'class', 'opaque', 'macro', 'macro_rules', 'syntax', 'elab', 'elab_rules', 'notation', 'infix', 'infixl', + 'infixr', 'prefix', 'postfix', 'set_option', 'attribute', 'namespace', 'section', 'end', 'universe', + 'variable', 'import', 'private', 'protected', 'noncomputable', 'unsafe', 'partial', 'scoped', 'local', + 'mutual', 'deriving', 'initialize', 'builtin_initialize', 'declare_syntax_cat', 'register_option', + 'open', 'export', 'include', 'omit', 'run_cmd', 'run_tac', 'run_elab', 'in') +COMMAND_TOKEN = re.compile(r'(? (0 : ℝ)) (-1)', 'norm_num [superlevel_set]'), + 'RejectSuperlevelBelowThreshold': ('(3 : ℝ) ∈ superlevel_set (fun x : ℝ => x) (-4)', 'norm_num [superlevel_set]'), + 'RejectConstantNotPeriodic': ('¬ torus_isPeriodic 1 (1 : ℝ) (fun _ => (0 : ℝ))', 'simp [torus_isPeriodic]')} +# Admission injections; Lean accepts each file (exit 0), the transitive axiom audit must refuse it. +# Diagnostics pinned from Lean 4.34.1 at the Mathlib d13f23b7 pin: the sorry warning uses backticks, and +# native_decide introduces the auxiliary axiom `injected._native.native_decide.ax_1_1` (not Lean.ofReduceBool). +INJECTIONS = { + 'RejectSorry': ("theorem injected : False := by sorry\n", 'sorryAx', + r"(?:[^\r\n]*[/\\])?RejectSorry\.lean:[0-9]+:[0-9]+: warning: declaration uses `sorry`\n"), + 'RejectCustomAxiom': ("axiom hiddenPremise : False\ntheorem middle : False := hiddenPremise\n" + "theorem injected : False := middle\n", 'hiddenPremise', ''), + 'RejectNativeDecide': ("theorem injected : (2 : Nat) + 2 = 4 := by native_decide\n", + 'injected._native.native_decide.ax_1_1', '')} +CONTROLS = tuple(FALSE_CONTROLS) + tuple(INJECTIONS) +POSITIVE = '''import TorusFiltration +open TorusFiltration + +-- Lattice membership of the literal Field lattice vector (torus_lattice_mem_iff). +example (d : ℕ) (L : ℝ) (hL : 0 < L) (n : Fin d → ℤ) : + torus_latticeVec d L n ∈ torus_periodLattice d L hL := + (torus_lattice_mem_iff d L hL _).2 ⟨n, rfl⟩ + +-- A concrete lattice translate of the origin has the same quotient image (torus_control_lattice_translate). +example : torus_proj 2 1 one_pos (0 + torus_latticeVec 2 1 ![3, -5]) = torus_proj 2 1 one_pos 0 := + torus_control_lattice_translate 2 1 one_pos 0 ![3, -5] + +-- Constants are periodic and descend to themselves (torus_descend_proj). +example (d : ℕ) (L : ℝ) (hL : 0 < L) (c : ℝ) (x : torus_E d) : + torus_descend d L hL (fun _ => c) (fun _ _ => rfl) (torus_proj d L hL x) = c := + torus_descend_proj d L hL (fun _ => c) (fun _ _ => rfl) x + +-- The path-component map on a representative (superlevel_componentMap_mk). +example {X Y : Type} [TopologicalSpace X] [TopologicalSpace Y] (f : C(X, Y)) (x : X) : + superlevel_componentMap f (ZerothHomotopy.mk x) = ZerothHomotopy.mk (f x) := + superlevel_componentMap_mk f x + +-- Closed-superlevel monotonicity at concrete parameters (superlevel_mono). +example : superlevel_set (fun x : ℝ => x) (-2) ⊆ superlevel_set (fun x : ℝ => x) 1 := + superlevel_mono (fun x : ℝ => x) (by norm_num) + +-- Closed endpoint membership for the identity height: 2 ≤ 3, so 3 ∈ F(-2). +example : (3 : ℝ) ∈ superlevel_set (fun x : ℝ => x) (-2) := by + norm_num [superlevel_set] +''' + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def blob(raw): + return hashlib.sha1(b'blob %d\0' % len(raw) + raw).hexdigest() + + +def identity(raw): + return {'bytes': len(raw), 'sha256': sha(raw), 'git_blob': blob(raw)} + + +def strict(raw): + def pairs(items): + result = {} + for key, value in items: + require(key not in result, 'duplicate JSON key: ' + str(key)) + result[key] = value + return result + + def reject(_): + raise ValueError('nonfinite or noninteger JSON number') + return json.loads(raw, object_pairs_hook=pairs, parse_constant=reject, parse_float=reject) + + +def git(*args): + run = subprocess.run(['git', *args], cwd=ROOT, capture_output=True, text=True, timeout=60) + require(run.returncode == 0, 'git ' + ' '.join(args) + ' failed: ' + run.stderr.strip()) + return run.stdout.strip() + + +def metadata(): + meta = strict((SIDE / 'SOURCE_FILES.json').read_bytes()) + require(set(meta) == {'schema', 'scientific_effect', 'alignment_status', 'namespace', 'root_module', 'modules', + 'definitions', 'theorems', 'files', 'provenance'}, 'SOURCE_FILES schema keys') + require(type(meta['schema']) is int and meta['schema'] == 1, 'SOURCE_FILES schema version') + require(meta['scientific_effect'] == 'NONE', 'scientific effect must be NONE') + require(meta['alignment_status'] == 'PENDING_INDEPENDENT_REVIEW', 'alignment status cannot self-award review') + require(meta['namespace'] == NAMESPACE and meta['root_module'] == ROOT_MODULE, 'namespace or root module') + require(meta['modules'] == list(MODULES), 'module list') + require(set(meta['theorems']) == set(MODULES) and set(meta['definitions']) == set(MODULES), 'per-module inventory keys') + seen = [] + for module in MODULES: + theorems = meta['theorems'][module] + require(isinstance(theorems, list) and theorems, 'empty theorem list: ' + module) + kinds = meta['definitions'][module] + require(isinstance(kinds, dict) and set(kinds) == {'abbrev', 'def', 'instance'}, 'definition kinds: ' + module) + for names in (theorems, kinds['abbrev'], kinds['def'], kinds['instance']): + require(isinstance(names, list) and all(isinstance(n, str) and re.fullmatch(IDENT, n) for n in names), + 'invalid declaration name in ' + module) + seen.extend(names) + require(len(seen) == len(set(seen)), 'duplicate declaration name') + files = meta['files'] + require(isinstance(files, dict) and files and set(files) <= set(REQUIRED_FILES), 'files inventory outside the companion') + for path, entry in files.items(): + require(isinstance(entry, dict) and set(entry) == {'bytes', 'sha256', 'git_blob'}, 'file entry keys: ' + path) + require(type(entry['bytes']) is int and entry['bytes'] >= 0, 'file bytes: ' + path) + require(isinstance(entry['sha256'], str) and HEX64.fullmatch(entry['sha256']), 'file sha256: ' + path) + require(isinstance(entry['git_blob'], str) and HEX40.fullmatch(entry['git_blob']), 'file git blob: ' + path) + prov = meta['provenance'] + require(isinstance(prov, dict), 'provenance object') + for key in ('claim', 'handoff_pr', 'handoff_comments', 'original_sha256', 'original_status', 'namespace_mapping', + 'source_author', 'compile_fixes_and_companion', 'organizational_independence_credit', 'human_review'): + require(key in prov, 'provenance key missing: ' + key) + require(prov['claim'] == CLAIM and prov['original_sha256'] == ORIGINAL_SHA256, 'provenance identity') + require(prov['original_status'] == 'NOT_COMPILED' and prov['namespace_mapping'] == NAMESPACE_MAPPING, 'provenance labels') + require(prov['organizational_independence_credit'] == 0 and prov['human_review'] == 'none', 'credit must stay zero') + return meta + + +def theorem_targets(meta): + return [NAMESPACE + '.' + n for module in MODULES for n in meta['theorems'][module]] + + +def definition_targets(meta): + return [NAMESPACE + '.' + n for module in MODULES for kind in ('abbrev', 'def', 'instance') + for n in meta['definitions'][module][kind]] + + +def targets(meta): + result = theorem_targets(meta) + definition_targets(meta) + require(result and len(result) == len(set(result)), 'duplicate or empty target list') + return result + + +def code_lines(text): + """The comment-free text of a Lean source, line by line (a comment lexer, not a Lean parser). + + Handles `--` to end of line and nested `/- … -/` blocks (`/--` and `/-!` included). String + literals are not modelled, so scan_module refuses any `"` left in code; a `-/` outside a comment + or an unterminated block is refused rather than guessed at. + """ + lines = [] + depth = 0 + for raw in text.split('\n'): + code = [] + i = 0 + while i < len(raw): + two = raw[i:i + 2] + if depth: + if two == '/-': + depth += 1 + i += 2 + elif two == '-/': + depth -= 1 + i += 2 + else: + i += 1 + elif two == '/-': + depth = 1 + i += 2 + elif two == '--': + break + elif two == '-/': + raise ValueError('comment closer outside a comment') + else: + code.append(raw[i]) + i += 1 + lines.append(''.join(code)) + require(depth == 0, 'unterminated block comment') + return lines + + +def strip_comments(text): + return '\n'.join(code_lines(text)) + + +def scan_module(text, module): + """Declaration inventory of one companion module by whitelist; refuses every line it cannot place. + + Outside comments, a column-0 line may only be `import Mathlib[.…]` (before the namespace), + `noncomputable section`, `open `, `universe …`, `variable …`, the single + `namespace TorusFiltration` / `end TorusFiltration` pair, or a named `theorem`, `def`, + `noncomputable def`, `abbrev` or `instance` inside that namespace. Any other command keyword + anywhere in code (indented, after a declaration on the same line, `… in`), any `@[` or `#`, + any string literal and any admission token is refused. Not a Lean parser. + """ + lines = code_lines(text) + for number, code in enumerate(lines, 1): + require('"' not in code, 'string literal in code: ' + module + ':' + str(number)) + code_text = '\n'.join(lines) + for token in ADMISSION: + require(re.search(r'(? --control C --status N') + result = {'negative': args.control, 'outcome': negative(args.path.read_text(), args.control, args.status)} + except (ValueError, KeyError, TypeError, OSError, subprocess.SubprocessError) as failure: + print('TORUS_FILTRATION_FAIL: ' + str(failure), file=sys.stderr) + return 1 + print(json.dumps(result, indent=2, sort_keys=True)) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/companions/torus_filtration_20261011/replay.sh b/companions/torus_filtration_20261011/replay.sh new file mode 100644 index 000000000..c21764322 --- /dev/null +++ b/companions/torus_filtration_20261011/replay.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# Replay of the C254 torus-filtration companion. It runs neither formal/gate.py nor the formal +# tests: the companion consumes only the pinned toolchain, lakefile and dependency lock from +# formal/, and its evidence is kernel-checked declarations, not alignment or acceptance. +set -euo pipefail +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +SIDE="$ROOT/companions/torus_filtration_20261011" +OUT="$ROOT/.lake/torus-filtration-evidence" +cd "$ROOT" +test ! -e "$OUT" +mkdir -p "$OUT" +python3 -B -S "$SIDE/check.py" source > "$OUT/source.json" +python3 -B -S "$SIDE/test_torus_filtration.py" 2>&1 | tee "$OUT/tests.log" +python3 -B -O -S "$SIDE/test_torus_filtration.py" 2>&1 | tee "$OUT/tests-optimized.log" +python3 -B -S "$SIDE/check.py" emit "$OUT" +export TORUS_SIDE="$SIDE" TORUS_OUT="$OUT" TORUS_ROOT="$ROOT" +cd "$ROOT/formal" +lake env bash <<'INNER' +set -euo pipefail +export LEAN_PATH="$TORUS_SIDE:${LEAN_PATH:-}" +export LEAN_SRC_PATH="$TORUS_SIDE:${LEAN_SRC_PATH:-}" +lean --version > "$TORUS_OUT/toolchain.log" +cat "$TORUS_OUT/toolchain.log" +: > "$TORUS_OUT/packages.log" +for pkg in "$TORUS_ROOT"/formal/.lake/packages/*/; do + printf '%s %s\n' "$(basename "$pkg")" "$(git -C "$pkg" rev-parse HEAD)" >> "$TORUS_OUT/packages.log" +done +cat "$TORUS_OUT/packages.log" +run_lean() { + local label="$1"; shift + local code=0 + "$@" >"$TORUS_OUT/$label.log" 2>&1 || code=$? + printf '%s\n' "$code" >"$TORUS_OUT/$label.status" + cat "$TORUS_OUT/$label.log" + test "$code" -eq 0 +} +run_lean build-TorusTopology lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/TorusTopology.olean" "$TORUS_SIDE/TorusTopology.lean" +run_lean build-ClosedSuperlevel lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/ClosedSuperlevel.olean" "$TORUS_SIDE/ClosedSuperlevel.lean" +run_lean build-TorusFiltration lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/TorusFiltration.olean" "$TORUS_SIDE/TorusFiltration.lean" +run_lean positive lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Positive.lean" +run_lean axioms lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Audit.lean" +run_lean types lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Types.lean" +# Kernel replay of the companion modules' own declarations against the cached, prebuilt dependency +# .oleans (30 s at 2 threads locally). Both modules `import Mathlib`, so `--fresh` (re-check of the whole +# import closure) does not fit a hosted job: still running at 1500 s with 6.6 GB resident at 4 threads. +# TORUS_LEANCHECKER_FRESH=1 selects it for an operator's local run; the receipt records which mode ran. +if [ "${TORUS_LEANCHECKER_FRESH:-0}" = 1 ]; then + LEANCHECKER_COMMAND='leanchecker --fresh TorusFiltration' +else + LEANCHECKER_COMMAND='leanchecker TorusTopology ClosedSuperlevel TorusFiltration' +fi +printf '%s\n' "$LEANCHECKER_COMMAND" > "$TORUS_OUT/leanchecker.cmd" +# shellcheck disable=SC2086 +run_lean leanchecker $LEANCHECKER_COMMAND +# False statements about the companion's own definitions: Lean itself must refuse each with exactly `⊢ False`. +for control in RejectSuperlevelSignFlip RejectSuperlevelBelowThreshold RejectConstantNotPeriodic; do + code=0 + lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/$control.lean" >"$TORUS_OUT/$control.log" 2>&1 || code=$? + printf '%s\n' "$code" >"$TORUS_OUT/$control.status" + python3 -B -S "$TORUS_SIDE/check.py" negative "$TORUS_OUT/$control.log" --control "$control" --status "$code" +done +# Admission injections run WITHOUT warnings-as-errors: Lean accepts the file, only the axiom audit refuses it. +for control in RejectSorry RejectCustomAxiom RejectNativeDecide; do + code=0 + lean --root="$TORUS_OUT" "$TORUS_OUT/$control.lean" >"$TORUS_OUT/$control.log" 2>&1 || code=$? + printf '%s\n' "$code" >"$TORUS_OUT/$control.status" + python3 -B -S "$TORUS_SIDE/check.py" negative "$TORUS_OUT/$control.log" --control "$control" --status "$code" +done +INNER +cd "$ROOT" +python3 -B -S "$SIDE/check.py" finish "$OUT" +echo 'PASS: torus-filtration companion replay; kernel-checked declarations only. Alignment review, scientific effect and acceptance are not decided here.' diff --git a/companions/torus_filtration_20261011/test_torus_filtration.py b/companions/torus_filtration_20261011/test_torus_filtration.py new file mode 100644 index 000000000..6eb9a3eb3 --- /dev/null +++ b/companions/torus_filtration_20261011/test_torus_filtration.py @@ -0,0 +1,918 @@ +#!/usr/bin/env python3 +"""Protocol tests and negative controls for the torus-filtration companion driver (stdlib only). + +Nothing here executes Lean. The fixture tests exercise check.py's `source` and `finish` +commands against a temporary Git repository whose Lean modules are inventory placeholders, +so every weakening of a check is caught now, before the hosted replay runs the real modules. +""" +import hashlib +import importlib.util +import json +import os +from pathlib import Path +import re +import shutil +import subprocess +import sys +import tempfile +import unittest + +SIDE = Path(__file__).resolve().parent +ROOT = SIDE.parents[1] +INVENTORY = { + 'TorusTopology': { + 'theorem': '''torus_field_latticeVec_formula torus_basis_sum_eq_latticeVec torus_lattice_mem_iff + torus_proj_surjective torus_proj_continuous torus_proj_eq_iff torus_control_lattice_translate + torus_proj_isCoveringMap torus_compact torus_pathConnectedSpace torus_field_periodic_formula + torus_periodic_respects torus_descend_proj torus_descend_continuous torus_path_lift_from + torus_control_constant_path_endpoint torus_control_no_arbitrary_endpoint torus_higher_path_iff + torus_strict_higher_path_iff torus_closed_higher_path_iff torus_global_max_iff'''.split(), + 'abbrev': ['torus_E', 'torus_quotient'], + 'def': ['torus_latticeVec', 'torus_periodBasis', 'torus_periodLattice', 'torus_proj', 'torus_isPeriodic', + 'torus_descend'], + 'instance': ['torus_lattice_discrete', 'torus_lattice_addSubgroup_discrete', 'torus_lattice_isZLattice']}, + 'ClosedSuperlevel': { + 'theorem': '''superlevel_control_closed_endpoint superlevel_control_strict_endpoint + superlevel_control_parameter_sign superlevel_control_inclusion_direction superlevel_control_essential + superlevel_mono superlevel_isClosed superlevel_inclusion_id superlevel_inclusion_comp + superlevel_mem_at_own_height superlevel_neg_height superlevel_control_strict_thresholds + superlevel_componentMap_mk superlevel_componentMap_id superlevel_componentMap_comp + superlevel_componentInclusion_id superlevel_componentInclusion_comp superlevel_component_eq_iff_joinedIn + superlevel_h0Filtration_map_id superlevel_h0Filtration_map_comp'''.split(), + 'abbrev': [], + 'def': ['superlevel_set', 'superlevel_inclusion', 'superlevel_componentMap', 'superlevel_componentInclusion', + 'superlevel_filtration', 'superlevel_h0Filtration'], + 'instance': []}} +HANDOFF_COMMENTS = ('6111056103', '6111059166', '6111059498', '6111059848', '6111255007', '6111093545', '6111139060') +LEAN_VERSION_LINE = 'Lean (version 4.34.1, x86_64-unknown-linux-gnu, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release)\n' +FALSE_LOG = '/tmp/evidence/{0}.lean:4:2: error: unsolved goals\n⊢ False\n' +SORRY_WARNING = "/tmp/evidence/RejectSorry.lean:2:8: warning: declaration uses `sorry`\n" +INJECTED = "'injected' depends on axioms: [{0}]\n" +LEANCHECKER_MODULES = 'leanchecker TorusTopology ClosedSuperlevel TorusFiltration' +LEANCHECKER_FRESH = 'leanchecker --fresh TorusFiltration' +EMITTED = ('Audit.lean', 'Types.lean', 'Positive.lean', 'RejectSuperlevelSignFlip.lean', 'RejectSuperlevelBelowThreshold.lean', + 'RejectConstantNotPeriodic.lean', 'RejectSorry.lean', 'RejectCustomAxiom.lean', 'RejectNativeDecide.lean') + + +def checker(): + spec = importlib.util.spec_from_file_location('torus_filtration_checker', SIDE / 'check.py') + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def placeholder_module(module): + """Inventory-exact Lean text that is never compiled; only the whitelist scan reads it.""" + lines = ['import Mathlib', '', '/-! fixture module; not the companion source -/', '', 'namespace TorusFiltration', ''] + lines += ['theorem %s : True := trivial' % n for n in INVENTORY[module]['theorem']] + lines += ['abbrev %s : Type := Nat' % n for n in INVENTORY[module]['abbrev']] + lines += ['noncomputable def %s : Nat := 0' % n for n in INVENTORY[module]['def']] + lines += ['instance %s : Inhabited Nat := ⟨0⟩' % n for n in INVENTORY[module]['instance']] + lines += ['', 'end TorusFiltration', ''] + return '\n'.join(lines) + + +def good_injection_log(c, control): + _, forbidden, _ = c.INJECTIONS[control] + return (SORRY_WARNING if control == 'RejectSorry' else '') + INJECTED.format(forbidden) + + +class Fixture: + """A committed temporary repository carrying the companion layout and a matching manifest.""" + + def __init__(self, c, tmp): + self.c = c + self.root = Path(tmp) + self.side = self.root / c.PACKAGE + self.side.mkdir(parents=True) + (self.root / c.WORKFLOW).parent.mkdir(parents=True) + (self.root / 'formal').mkdir() + for module in c.MODULES: + (self.side / (module + '.lean')).write_text(placeholder_module(module)) + (self.side / 'TorusFiltration.lean').write_text(c.ROOT_SOURCE) + shutil.copy(SIDE / 'check.py', self.side / 'check.py') + for name in ('replay.sh', 'test_torus_filtration.py', 'README.md', 'SCOPE.md'): + (self.side / name).write_text('# fixture ' + name + '\n') + (self.root / c.WORKFLOW).write_text('name: fixture\n') + (self.root / 'formal/lean-toolchain').write_text('leanprover/lean4:v4.34.1\n') + (self.root / 'formal/lakefile.toml').write_text('name = "fixture"\n') + self.revisions = {'mathlib': 'd1' * 20, 'batteries': 'f2' * 20} + self.write_manifest([{'name': k, 'rev': v} for k, v in self.revisions.items()]) + self.regenerate() + self.git('init', '-q', '-b', 'main') + self.commit() + + def git(self, *args): + return subprocess.run(['git', '-c', 'user.name=fixture', '-c', 'user.email=fixture@example.invalid', + '-c', 'commit.gpgsign=false', *args], cwd=self.root, check=True, + capture_output=True, text=True).stdout + + def commit(self): + self.git('add', '-A') + self.git('commit', '-q', '-m', 'fixture', '--allow-empty') + + def write_manifest(self, packages): + (self.root / 'formal/lake-manifest.json').write_text(json.dumps({'packages': packages})) + + def regenerate(self): + meta = self.c.metadata() + meta['files'] = {p: self.c.identity((self.root / p).read_bytes()) for p in self.c.REQUIRED_FILES + if (self.root / p).is_file()} + (self.side / 'SOURCE_FILES.json').write_text(json.dumps(meta, indent=2, sort_keys=True) + '\n') + + def manifest(self, mutate): + """Commit a SOURCE_FILES.json with one field rewritten (mutate edits the dict, or returns raw text).""" + meta = json.loads((self.side / 'SOURCE_FILES.json').read_text()) + raw = mutate(meta) + text = raw if isinstance(raw, str) else json.dumps(meta, indent=2, sort_keys=True) + '\n' + (self.side / 'SOURCE_FILES.json').write_text(text) + self.commit() + + def restore(self): + self.regenerate() + self.commit() + + def run(self, *args, env=None): + environment = {k: v for k, v in os.environ.items() if not k.startswith('GITHUB_')} + environment.update(env or {}) + return subprocess.run([sys.executable, '-B', '-S', str(self.side / 'check.py'), *args], cwd=self.root, + capture_output=True, text=True, env=environment) + + def evidence(self): + out = self.root / 'evidence' + out.mkdir() + source = self.run('source') + if source.returncode != 0: + raise AssertionError(source.stderr) + (out / 'source.json').write_text(source.stdout) + emitted = self.run('emit', str(out)) + if emitted.returncode != 0: + raise AssertionError(emitted.stderr) + (out / 'toolchain.log').write_text(LEAN_VERSION_LINE) + (out / 'packages.log').write_text(''.join('%s %s\n' % kv for kv in self.revisions.items())) + for label in self.c.BUILDS: + (out / (label + '.status')).write_text('0\n') + (out / (label + '.log')).write_text('') + (out / 'leanchecker.cmd').write_text(LEANCHECKER_MODULES + '\n') + meta = self.c.metadata() + targets = self.c.targets(meta) + lines = ["'%s' depends on axioms: [propext, Classical.choice, Quot.sound]" % n for n in targets[:-1]] + lines.append("'%s' does not depend on any axioms" % targets[-1]) + (out / 'axioms.log').write_text('\n'.join(lines) + '\n') + (out / 'types.log').write_text(''.join('%s (d : ℕ) : True\n' % n for n in self.c.theorem_targets(meta))) + for control in self.c.FALSE_CONTROLS: + (out / (control + '.log')).write_text(FALSE_LOG.format(control)) + (out / (control + '.status')).write_text('1\n') + for control in self.c.INJECTIONS: + (out / (control + '.log')).write_text(good_injection_log(self.c, control)) + (out / (control + '.status')).write_text('0\n') + return out + + +class FixtureCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.c = checker() + + def assertFails(self, run, message): + self.assertEqual(run.returncode, 1, run.stdout + run.stderr) + self.assertIn('TORUS_FILTRATION_FAIL: ' + message, run.stderr) + + +class InventoryTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.c = checker() + + def test_inventory_constants(self): + names = [n for m in INVENTORY.values() for kind in m.values() for n in kind] + self.assertEqual(len(names), len(set(names))) + self.assertEqual(sum(len(m['theorem']) for m in INVENTORY.values()), 41) + self.assertEqual([len(INVENTORY[m]['theorem']) for m in ('TorusTopology', 'ClosedSuperlevel')], [21, 20]) + self.assertEqual(sum(len(m['def']) for m in INVENTORY.values()), 12) + self.assertEqual(sum(len(m['abbrev']) + len(m['instance']) for m in INVENTORY.values()), 5) + self.assertTrue(all(re.fullmatch(self.c.IDENT, n) for n in names)) + self.assertEqual(tuple(INVENTORY), self.c.MODULES) + + def test_source_files_inventory_provenance_and_identities(self): + meta = self.c.metadata() + for module in self.c.MODULES: + self.assertEqual(meta['theorems'][module], INVENTORY[module]['theorem']) + for kind in ('abbrev', 'def', 'instance'): + self.assertEqual(meta['definitions'][module][kind], INVENTORY[module][kind]) + self.assertEqual(len(self.c.targets(meta)), 58) + self.assertEqual(self.c.theorem_targets(meta)[0], 'TorusFiltration.torus_field_latticeVec_formula') + prov = meta['provenance'] + self.assertEqual(set(HANDOFF_COMMENTS), set(prov['handoff_comments'].values())) + self.assertEqual(prov['handoff_pr'], 'd6g8k5htny-coder/Math-#419') + self.assertIn('OpenAI/Codex', prov['source_author']) + self.assertIn('Anthropic/Claude', prov['compile_fixes_and_companion']) + modules = {self.c.PACKAGE + '/' + m + '.lean' for m in self.c.MODULES} + for path in self.c.REQUIRED_FILES: + target = ROOT / path + if target.is_file() and (path in meta['files'] or path not in modules): + self.assertIn(path, meta['files'], 'present companion file without identity: ' + path) + self.assertEqual(meta['files'][path], self.c.identity(target.read_bytes()), 'stale identity: ' + path) + elif not target.is_file(): + self.assertNotIn(path, meta['files'], 'identity listed for an absent file: ' + path) + + def test_lean_modules_match_inventory(self): + self.assertEqual((SIDE / 'TorusFiltration.lean').read_text(), self.c.ROOT_SOURCE) + for module in self.c.MODULES: + path = SIDE / (module + '.lean') + if not path.is_file(): + self.skipTest('module not yet placed by the integrator: ' + module) + scan = self.c.scan_module(path.read_text(encoding='utf-8'), module) + self.assertEqual(scan, INVENTORY[module], module) + + def test_no_admission_tokens_in_comment_stripped_code(self): + self.assertEqual(self.c.strip_comments('a /- sorry\n axiom -/ b -- native_decide\nc').split(), ['a', 'b', 'c']) + for path in sorted(SIDE.glob('*.lean')): + code = self.c.strip_comments(path.read_text(encoding='utf-8')) + for token in self.c.ADMISSION: + self.assertIsNone(re.search(r'(? `(tactic| trivial)'), unexpected), + (inject('macro_rules | `(tactic| foo) => `(tactic| trivial)'), unexpected), + (inject('local instance : Inhabited Nat := ⟨0⟩'), unexpected), + (inject('attribute [simp] superlevel_set'), unexpected), + (inject('set_option maxHeartbeats 0'), unexpected), + (inject('set_option maxHeartbeats 0 in'), unexpected), + (inject('section\n theorem indented_hidden : True := trivial\nend'), unexpected), + (inject(' theorem indented_hidden : True := trivial'), command), + (inject('theorem a_hidden : True := trivial theorem b_hidden : True := trivial'), command), + (inject('theorem a_hidden : True := by\n open Classical in exact trivial'), command), + (inject('variable (h : False) in theorem hidden : True := trivial'), command), + (inject('universe z in'), command), + (inject('open Classical in'), unexpected), + (inject('macro foo : tactic => `(tactic| trivial)'), unexpected), + (inject('elab foo : term => pure (mkConst ``True)'), unexpected), + (inject('syntax foo : tactic'), unexpected), + (inject('notation x ⊕ y => x'), unexpected), + (inject('lemma extra : True := trivial'), unexpected), + (inject('example : True := trivial'), unexpected), + (inject('structure Hidden where\n x : Nat'), unexpected), + (inject('inductive Hidden | a'), unexpected), + (inject('class Hidden (α : Type) where\n k : α'), unexpected), + (inject('instance : Inhabited Nat := ⟨0⟩'), unexpected), + (inject('mutual\ntheorem a_hidden : True := trivial\nend'), unexpected), + (inject('deriving instance Repr for Nat'), unexpected), + (inject('#eval 1'), unexpected), + (inject('#print axioms superlevel_set'), unexpected), + (inject('export Nat (succ)'), unexpected), + (inject('include h'), unexpected), + (inject('run_cmd pure ()'), unexpected), + (inject('initialize hidden : Nat ← pure 0'), unexpected), + (inject('import Hidden'), unexpected), + (inject('import Mathlib'), 'import inside the namespace: ClosedSuperlevel:'), + (inject("theorem hidden' : True := trivial"), unexpected), + (inject('theorem hidden.name : True := trivial'), unexpected), + (inject('theorem'), unexpected), + (inject('end'), unexpected), + (inject('noncomputable section extra'), unexpected), + (inject('variable'), unexpected), + (inject('variable (h : True)\n (h2 : True) in theorem hidden : True := trivial'), command), + (inject('def s : String := "x"'), 'string literal in code: ClosedSuperlevel:'), + (inject('def s : String := "/-"\ndef t : String := "-/"'), 'string literal in code: ClosedSuperlevel:'), + (inject('theorem a_hidden : True := trivial -- fine\n @[simp] theorem b_hidden : True := trivial'), command), + (inject('theorem a_hidden : True := by\n simp #[1]'), 'attribute or #-command in ClosedSuperlevel:'), + (good.replace('namespace TorusFiltration', 'namespace ResearchFormalCoreR1'), 'handoff namespace left in place: ClosedSuperlevel'), + (good.replace('namespace TorusFiltration', ''), 'declaration outside namespace TorusFiltration: ClosedSuperlevel:'), + (good.replace('namespace TorusFiltration\n', 'namespace TorusFiltration\nnamespace TorusFiltration\n'), 'namespace declaration: ClosedSuperlevel:'), + (good.replace('end TorusFiltration', ''), 'namespace TorusFiltration not opened and closed exactly once: ClosedSuperlevel'), + (good + 'theorem after_end : True := trivial\n', 'code after end TorusFiltration: ClosedSuperlevel:'), + (good + '-/\n', 'comment closer outside a comment'), + (good + '/- open forever\n', 'unterminated block comment'), + (good.replace('import Mathlib', 'theorem early : True := trivial\nimport Mathlib'), 'declaration outside namespace TorusFiltration'), + ] + self.assertEqual(self.c.scan_module(good, 'ClosedSuperlevel'), INVENTORY['ClosedSuperlevel']) + for text, message in cases: + with self.subTest(message=message, text=text[-70:]), self.assertRaisesRegex(ValueError, re.escape(message)): + self.c.scan_module(text, 'ClosedSuperlevel') + # Every command keyword the scanner knows is refused somewhere other than the start of a whitelisted line. + for keyword in self.c.COMMANDS: + with self.subTest(keyword=keyword), self.assertRaises(ValueError): + self.c.scan_module(inject('theorem k_hidden : True := trivial ' + keyword), 'ClosedSuperlevel') + + +class ParserControls(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.c = checker() + + def test_negative_false_controls_accept_only_the_intended_diagnostic(self): + for control in self.c.FALSE_CONTROLS: + good = FALSE_LOG.format(control) + self.assertEqual(self.c.negative(good, control, 1), 'REJECTED_BY_LEAN') + for bad, status in [(good, 0), (good, 2), (good, True), (good, '1'), (good.replace('False', 'True'), 1), + (good.replace(control, 'Other'), 1), (good + 'error: unknown identifier\n', 1), + ('Traceback: bad runtime\n', 1), ('error: unsolved goals\n', 1), ('', 1), + ('warning: declaration uses `sorry`\n' + good, 1)]: + with self.subTest(control=control, bad=bad, status=status), self.assertRaises(ValueError): + self.c.negative(bad, control, status) + with self.assertRaises(ValueError): + self.c.negative(FALSE_LOG.format('Unknown'), 'Unknown', 1) + + def test_negative_injection_controls_require_the_audit_to_refuse(self): + for control, (_, forbidden, _) in self.c.INJECTIONS.items(): + good = good_injection_log(self.c, control) + self.assertEqual(self.c.negative(good, control, 0), 'REJECTED_BY_AXIOM_AUDIT') + escaped = good.replace(forbidden, 'propext') + for bad, status in [(good, 1), (good, 2), (escaped, 0), (good.replace('injected', 'other'), 0), + (good + 'extra\n', 0), ('', 0), (good.replace('[' + forbidden + ']', '[]'), 0), + (good.replace("'injected' depends", "'injected' does not depend"), 0)]: + with self.subTest(control=control, bad=bad, status=status), self.assertRaises(ValueError): + self.c.negative(bad, control, status) + sorry_log = good_injection_log(self.c, 'RejectSorry') + with self.assertRaises(ValueError): + self.c.negative(sorry_log.replace('`sorry`', "'sorry'"), 'RejectSorry', 0) + with self.assertRaises(ValueError): + self.c.negative(INJECTED.format('sorryAx'), 'RejectSorry', 0) + with self.assertRaises(ValueError): + self.c.negative(SORRY_WARNING + INJECTED.format('hiddenPremise'), 'RejectCustomAxiom', 0) + + def test_negative_injection_second_refusal_follows_the_audit_rules(self): + # Behind the regex pin, negative() also requires audit_axioms itself to refuse the injected line for the + # intended reason; widening ALLOWED (resolved at call time) must turn the control into an escape. + c = self.c + saved = c.ALLOWED + try: + c.ALLOWED = frozenset(saved | {'sorryAx'}) + with self.assertRaisesRegex(ValueError, 'negative control escaped the axiom audit: RejectSorry'): + c.negative(good_injection_log(c, 'RejectSorry'), 'RejectSorry', 0) + self.assertEqual(c.negative(good_injection_log(c, 'RejectCustomAxiom'), 'RejectCustomAxiom', 0), + 'REJECTED_BY_AXIOM_AUDIT') + finally: + c.ALLOWED = saved + self.assertEqual(c.negative(good_injection_log(c, 'RejectSorry'), 'RejectSorry', 0), 'REJECTED_BY_AXIOM_AUDIT') + + def test_audit_axioms_rules(self): + names = ['TorusFiltration.a', 'TorusFiltration.b', 'TorusFiltration.c'] + good = ("'TorusFiltration.a' depends on axioms: [propext, Classical.choice, Quot.sound]\n" + "'TorusFiltration.b' depends on axioms: [propext]\n'TorusFiltration.c' does not depend on any axioms\n") + self.assertEqual(self.c.audit_axioms(good, names), + {'TorusFiltration.a': ['Classical.choice', 'Quot.sound', 'propext'], + 'TorusFiltration.b': ['propext'], 'TorusFiltration.c': []}) + for bad, message in ((good.replace('[propext]', '[propext, sorryAx]'), 'forbidden transitive axiom'), + (good.replace('[propext]', '[Lean.ofReduceBool]'), 'forbidden transitive axiom'), + (good.replace('TorusFiltration.b', 'TorusFiltration.unknown'), 'unexpected or duplicate axiom target'), + (good.replace("'TorusFiltration.b' depends on axioms: [propext]\n", ''), 'missing target axiom report'), + (good + "'TorusFiltration.a' depends on axioms: [propext]\n", 'unexpected or duplicate axiom target'), + ('warning: something\n' + good, 'unrecognized audit output'), + (good.replace('[propext]', '[prop ext]'), 'malformed axiom name'), + (good.replace('[propext]', '[propext,]'), 'malformed axiom name'), + (good.replace('[propext]', '[hiddenPremise]'), 'forbidden transitive axiom')): + with self.subTest(bad=bad), self.assertRaisesRegex(ValueError, message): + self.c.audit_axioms(bad, names) + for targets in ([], ['TorusFiltration.a', 'TorusFiltration.a'], 'TorusFiltration.a'): + with self.subTest(targets=targets), self.assertRaisesRegex(ValueError, 'empty or duplicate target list'): + self.c.audit_axioms(good, targets) + duplicated = {'theorems': {'TorusTopology': ['a'], 'ClosedSuperlevel': ['a']}, + 'definitions': {m: {'abbrev': [], 'def': [], 'instance': []} for m in self.c.MODULES}} + with self.assertRaisesRegex(ValueError, 'duplicate or empty target list'): + self.c.targets(duplicated) + duplicated['theorems'] = {m: [] for m in self.c.MODULES} + with self.assertRaisesRegex(ValueError, 'duplicate or empty target list'): + self.c.targets(duplicated) + + def test_types_rules(self): + names = ['TorusFiltration.a', 'TorusFiltration.b'] + good = 'TorusFiltration.a : True\nTorusFiltration.b (d : ℕ) :\n ∀ x, x = x\n' + self.assertEqual(self.c.types(good, names), names) + for bad, message in (('TorusFiltration.a : True\n', 'type inventory mismatch'), + (good + 'TorusFiltration.c : True\n', 'type inventory mismatch'), + ('TorusFiltration.a : True\nTorusFiltration.a : True\n', 'type inventory mismatch'), + ('TorusFiltration.b : True\nTorusFiltration.a : True\n', 'type inventory mismatch'), + ('error: crash\n' + good, 'type diagnostic'), (good + 'error: crash\n', 'type diagnostic'), + ('warning: lint\n' + good, 'type diagnostic'), (good + 'warning: lint\n', 'type diagnostic'), + ('preamble\n' + good, 'unrecognized type preamble')): + with self.subTest(bad=bad), self.assertRaisesRegex(ValueError, message): + self.c.types(bad, names) + + def test_lean_version_and_packages(self): + self.assertEqual(self.c.lean_version(LEAN_VERSION_LINE), LEAN_VERSION_LINE.strip()) + for bad in (LEAN_VERSION_LINE.replace('4.34.1', '4.34.0'), LEAN_VERSION_LINE.replace('5045d0056', '5045d005'), + LEAN_VERSION_LINE.replace('Release', 'Debug'), LEAN_VERSION_LINE + 'extra\n', ''): + with self.subTest(bad=bad), self.assertRaises(ValueError): + self.c.lean_version(bad) + expected = {'mathlib': 'd1' * 20, 'batteries': 'f2' * 20} + good = 'batteries %s\nmathlib %s\n' % ('f2' * 20, 'd1' * 20) + self.assertEqual(self.c.packages(good, expected), expected) + for bad in ('mathlib %s\n' % ('d1' * 20), good + 'aesop %s\n' % ('a3' * 20), good.replace('d1' * 20, 'e1' * 20), + good + 'mathlib %s\n' % ('d1' * 20), good.replace('\nmathlib', '\n mathlib'), 'mathlib short\n'): + with self.subTest(bad=bad), self.assertRaises(ValueError): + self.c.packages(bad, expected) + + def test_leanchecker_mode_accepts_exactly_the_two_recorded_invocations(self): + self.assertEqual(self.c.leanchecker_mode(LEANCHECKER_MODULES + '\n'), 'modules') + self.assertEqual(self.c.leanchecker_mode(LEANCHECKER_FRESH + '\n'), 'fresh') + self.assertEqual(self.c.LEANCHECKER, {LEANCHECKER_MODULES: 'modules', LEANCHECKER_FRESH: 'fresh'}) + for bad in ('', 'leanchecker TorusFiltration', 'leanchecker --fresh TorusTopology', 'leanchecker TorusTopology ClosedSuperlevel', + LEANCHECKER_MODULES + ' Extra', 'leanchecker --verbose ' + LEANCHECKER_MODULES[12:], + 'lean ' + LEANCHECKER_MODULES[12:], LEANCHECKER_MODULES + '\n' + LEANCHECKER_FRESH): + with self.subTest(bad=bad), self.assertRaisesRegex(ValueError, 'unrecognized leanchecker invocation'): + self.c.leanchecker_mode(bad) + + def test_emit_writes_exactly_the_audit_types_positive_and_controls(self): + meta = self.c.metadata() + with tempfile.TemporaryDirectory() as tmp: + out = Path(tmp) + self.c.emit(out) + self.assertEqual({p.name for p in out.iterdir()}, set(EMITTED)) + self.assertEqual({p.name for p in out.iterdir()}, + {'Audit.lean', 'Types.lean', 'Positive.lean'} | {n + '.lean' for n in self.c.CONTROLS}) + audit = (out / 'Audit.lean').read_text().splitlines() + self.assertEqual(audit[0], 'import TorusFiltration') + self.assertEqual(audit[1:], ['#print axioms ' + n for n in self.c.targets(meta)]) + self.assertEqual(len(audit[1:]), 58) + types = (out / 'Types.lean').read_text().splitlines() + self.assertEqual(types[:2], ['import TorusFiltration', 'set_option pp.explicit true']) + self.assertEqual(types[2:], ['#check ' + n for n in self.c.theorem_targets(meta)]) + positive = (out / 'Positive.lean').read_text() + self.assertTrue(positive.startswith('import TorusFiltration\n')) + self.assertTrue(3 <= len(re.findall(r'^example', positive, re.M)) <= 6) + for token in ('sorry', 'admit', 'axiom', 'native_decide'): + self.assertIsNone(re.search(r'\b' + token + r'\b', positive)) + for control in self.c.CONTROLS: + text = (out / (control + '.lean')).read_text() + self.assertTrue(text.startswith('import TorusFiltration\n'), control) + self.assertEqual('sorry' in text, control == 'RejectSorry') + self.assertEqual('axiom hiddenPremise' in text, control == 'RejectCustomAxiom') + self.assertEqual('native_decide' in text, control == 'RejectNativeDecide') + if control in self.c.FALSE_CONTROLS: + self.assertIn('example : ' + self.c.FALSE_CONTROLS[control][0] + ' := by', text) + else: + self.assertIn('#print axioms injected', text) + self.assertEqual(set(self.c.FALSE_CONTROLS) | set(self.c.INJECTIONS), set(self.c.CONTROLS)) + self.assertGreaterEqual(len(self.c.FALSE_CONTROLS), 1) + self.assertEqual({v[1] for v in self.c.INJECTIONS.values()}, + {'sorryAx', 'hiddenPremise', 'injected._native.native_decide.ax_1_1'}) + self.assertTrue(all(re.fullmatch(self.c.NAME, v[1]) and v[1] not in self.c.ALLOWED for v in self.c.INJECTIONS.values())) + + +class WorkflowAndReplay(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.c = checker() + cls.workflow = (ROOT / cls.c.WORKFLOW).read_text() + cls.replay = (SIDE / 'replay.sh').read_text() + cls.d2 = (ROOT / '.github/workflows/d2-moment-bridge.yml').read_text() + + def paths(self, event): + marker = ' ' + event + ':\n' + self.assertEqual(self.workflow.count(marker), 1, event) + rest = self.workflow.split(marker, 1)[1] + ends = [i for i in (rest.find('\n push:\n'), rest.find('\n workflow_dispatch:\n')) if i >= 0] + block = rest[:min(ends)] + self.assertEqual(block.count(' paths:\n'), 1, event) + return re.findall(r"^ - '([^']+)'$", block, re.M) + + def test_path_triggers_exclude_the_core_tree(self): + expected = ['companions/torus_filtration_20261011/**', '.github/workflows/torus-filtration.yml', + 'formal/lakefile.toml', 'formal/lake-manifest.json', 'formal/lean-toolchain'] + self.assertEqual(self.paths('pull_request'), expected) + self.assertEqual(self.paths('push'), expected) + self.assertNotIn("'formal/**'", self.workflow) + self.assertIn(' branches: [main]\n', self.workflow) + self.assertIn(' workflow_dispatch:\n', self.workflow) + self.assertIn('permissions:\n contents: read\n', self.workflow) + + def test_action_pins_match_the_d2_companion_workflow(self): + for action in ('actions/checkout@', 'leanprover/lean-action@', 'actions/upload-artifact@'): + mine = re.findall(re.escape(action) + r'([0-9a-f]{40})', self.workflow) + theirs = re.findall(re.escape(action) + r'([0-9a-f]{40})', self.d2) + self.assertEqual(len(mine), 1, action) + self.assertEqual(mine, theirs, action) + for required in ('lake-package-directory: formal', "use-mathlib-cache: 'true'", "build: 'false'", + 'persist-credentials: false', 'run: bash companions/torus_filtration_20261011/replay.sh', + 'name: torus-filtration-${{ github.run_id }}-${{ github.run_attempt }}', + 'path: .lake/torus-filtration-evidence/', 'retention-days: 30', 'if-no-files-found: error', + 'if: always()', 'LEAN_NUM_THREADS: 2'): + self.assertIn(required, self.workflow, required) + self.assertRegex(self.workflow, r'\n timeout-minutes: [0-9]+\n', 'job timeout must be explicit') + self.assertNotIn('continue-on-error', self.workflow) + self.assertNotIn('formal/.lake/formal-evidence', self.workflow) + # The hosted job must run the modules-mode leanchecker: no --fresh and no fresh switch in the workflow. + self.assertNotIn('--fresh', self.workflow) + self.assertNotIn('TORUS_LEANCHECKER_FRESH', self.workflow) + + def test_replay_contract(self): + for required in ('set -euo pipefail', 'test ! -e "$OUT"', 'OUT="$ROOT/.lake/torus-filtration-evidence"', + 'python3 -B -S "$SIDE/check.py" source > "$OUT/source.json"', + 'python3 -B -S "$SIDE/test_torus_filtration.py"', 'python3 -B -O -S "$SIDE/test_torus_filtration.py"', + 'python3 -B -S "$SIDE/check.py" emit "$OUT"', 'lake env bash', 'lean --version > "$TORUS_OUT/toolchain.log"', + 'rev-parse HEAD)" >> "$TORUS_OUT/packages.log"', + 'printf \'%s\\n\' "$LEANCHECKER_COMMAND" > "$TORUS_OUT/leanchecker.cmd"', + 'run_lean leanchecker $LEANCHECKER_COMMAND', + 'run_lean positive lean -DwarningAsError=true', 'run_lean axioms lean -DwarningAsError=true', + 'run_lean types lean -DwarningAsError=true'): + self.assertIn(required, self.replay, required) + for module in ('TorusTopology', 'ClosedSuperlevel', 'TorusFiltration'): + self.assertIn('run_lean build-%s lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/%s.olean" "$TORUS_SIDE/%s.lean"' + % (module, module, module), self.replay) + commands = '\n'.join(line for line in self.replay.splitlines() if not line.lstrip().startswith('#')) + for forbidden in ('gate.py', 'formal/tests', 'lake build', 'lake update', 'lake exe cache', 'formal-evidence', + 'ResearchFormalCoreR1'): + self.assertNotIn(forbidden, commands, forbidden) + # leanchecker: the modules-mode command is the default; --fresh exists only behind the operator switch. + switch = re.search(r'^if \[ "\$\{TORUS_LEANCHECKER_FRESH:-0\}" = 1 \]; then\n LEANCHECKER_COMMAND=\'([^\']+)\'\nelse\n' + r' LEANCHECKER_COMMAND=\'([^\']+)\'\nfi\n', commands, re.M) + self.assertIsNotNone(switch, 'leanchecker mode switch') + self.assertEqual(switch.group(1), LEANCHECKER_FRESH) + self.assertEqual(switch.group(2), LEANCHECKER_MODULES) + self.assertEqual(self.c.LEANCHECKER[switch.group(2)], 'modules') + self.assertEqual(commands.count('--fresh'), 1) + self.assertEqual(commands.count('leanchecker.cmd'), 1) + loops = re.findall(r'^for control in ([^;]+); do\n code=0\n lean ([^\n]*)', self.replay, re.M) + self.assertEqual(len(loops), 2) + self.assertEqual(loops[0][0].split(), list(self.c.FALSE_CONTROLS)) + self.assertIn('-DwarningAsError=true', loops[0][1]) + self.assertEqual(loops[1][0].split(), list(self.c.INJECTIONS)) + self.assertNotIn('warningAsError', loops[1][1]) + finish = [line for line in self.replay.splitlines() if 'check.py" finish' in line] + self.assertEqual(finish, ['python3 -B -S "$SIDE/check.py" finish "$OUT"']) + self.assertTrue(self.replay.strip().splitlines()[-1].startswith("echo 'PASS:")) + + def test_documents_keep_the_status_vocabulary(self): + for name in ('README.md', 'SCOPE.md'): + text = (SIDE / name).read_text(encoding='utf-8') + for required in ('Scientific effect', 'NONE', 'credit', 'PENDING_INDEPENDENT_REVIEW', 'OpenAI/Codex', + 'Anthropic/Claude', '8a5c7a24-784b-4aaa-b951-cd9f37b0dc64', 'efa80d28', '1fed3eda', + 'ResearchFormalCoreR1.', 'TorusFiltration.', 'PairLawInterface.p', + 'critical-level attainment', 'once-counting', LEANCHECKER_MODULES): + self.assertIn(required, text, name + ' lacks ' + required) + self.assertNotIn('`leanchecker --fresh` re-checked', text, name + ' describes the withdrawn --fresh step as run') + self.assertNotIn('runs `leanchecker --fresh TorusFiltration`', text) + prose = re.sub(r'`[^`\n]*`', '', text) + for forbidden in ('verified', 'accepted', 'kernel-checked'): + hits = [m.start() for m in re.finditer(r'(?i)\b' + forbidden + r'\b', prose)] + if forbidden == 'kernel-checked': + # Allowed only when naming the receipt field it belongs to. + hits = [h for h in hits if 'receipt' not in prose[max(0, h - 160):h + 160]] + self.assertEqual(hits, [], name + ' uses the status word ' + forbidden + ' outside code spans') + readme = (SIDE / 'README.md').read_text(encoding='utf-8') + self.assertIn('## Compile fixes at the pin', readme) + self.assertNotIn('formal/**', readme.replace('`formal/`', '')) + # The control table quotes each emitted false statement verbatim, and the .olean hazard is stated. + for statement, _ in self.c.FALSE_CONTROLS.values(): + self.assertIn('`' + statement + '`', readme, 'control statement not quoted verbatim: ' + statement) + for required in ('.olean', 'never be committed', 'NOT_RUN', 'TORUS_LEANCHECKER_FRESH', 'leanchecker.cmd'): + self.assertIn(required, readme, 'README lacks ' + required) + + +class SourceFixture(FixtureCase): + def test_clean_fixture_passes_and_records_identity(self): + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(self.c, tmp) + run = f.run('source') + self.assertEqual(run.returncode, 0, run.stderr) + result = json.loads(run.stdout) + self.assertEqual(result['checked_commit'], f.git('rev-parse', 'HEAD').strip()) + self.assertEqual(set(result['sources']), set(self.c.REQUIRED_FILES) | {self.c.PACKAGE + '/SOURCE_FILES.json'}) + self.assertEqual(len(result['declarations']), 58) + self.assertEqual(result['environment'], {'lean_toolchain': 'leanprover/lean4:v4.34.1', + 'dependency_revisions': f.revisions}) + self.assertEqual(result['run_id'], 'local') + hosted = {'GITHUB_ACTIONS': 'true', 'GITHUB_SHA': result['checked_commit'], 'GITHUB_REPOSITORY': self.c.REPO, + 'GITHUB_RUN_ID': '77', 'GITHUB_RUN_ATTEMPT': '2'} + run = f.run('source', env=hosted) + self.assertEqual(run.returncode, 0, run.stderr) + self.assertEqual(json.loads(run.stdout)['run_id'], '77') + self.assertFails(f.run('source', env={**hosted, 'GITHUB_SHA': '0' * 40}), 'host/source mismatch') + self.assertFails(f.run('source', env={**hosted, 'GITHUB_REPOSITORY': 'someone-else/Math-'}), 'host/source mismatch') + self.assertFails(f.run('source', env={**hosted, 'GITHUB_RUN_ID': ''}), 'run identity absent') + self.assertFails(f.run('source', env={**hosted, 'GITHUB_RUN_ATTEMPT': ''}), 'run identity absent') + (f.side / 'stray.olean').write_bytes(b'untracked build artefact') + self.assertEqual(f.run('source').returncode, 0, 'untracked artefacts are not source') + + def test_membership_and_byte_mutations_are_detected(self): + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(self.c, tmp) + (f.side / 'README.md').write_text('# edited without a commit\n') + self.assertFails(f.run('source'), 'dirty execution/source bytes: ' + self.c.PACKAGE + '/README.md') + f.git('checkout', '--', '.') + (f.root / 'formal/lean-toolchain').write_text('leanprover/lean4:v4.34.0\n') + self.assertFails(f.run('source'), 'uncommitted modification in bound paths') + f.git('checkout', '--', '.') + (f.side / 'EXTRA.md').write_text('tracked but not in the manifest\n') + f.commit() + self.assertFails(f.run('source'), 'tracked companion membership differs') + f.git('rm', '-q', '--', str(f.side / 'EXTRA.md')) + f.commit() + self.assertEqual(f.run('source').returncode, 0) + (f.side / 'TorusTopology.olean').write_bytes(b'committed build artefact') + f.commit() + self.assertFails(f.run('source'), "tracked companion membership differs: ['" + self.c.PACKAGE + "/TorusTopology.olean']") + f.git('rm', '-q', '--', str(f.side / 'TorusTopology.olean')) + f.commit() + (f.side / 'SCOPE.md').write_text('# changed and committed, manifest stale\n') + f.commit() + self.assertFails(f.run('source'), 'manifest source mismatch: ' + self.c.PACKAGE + '/SCOPE.md') + f.restore() + self.assertEqual(f.run('source').returncode, 0) + (f.side / 'README.md').unlink() + os.symlink('SCOPE.md', f.side / 'README.md') + f.restore() + self.assertFails(f.run('source'), 'symlink source: ' + self.c.PACKAGE + '/README.md') + + def test_module_mutations_are_detected(self): + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(self.c, tmp) + module = f.side / 'ClosedSuperlevel.lean' + original = module.read_text() + swapped = original.replace('theorem superlevel_mono : True := trivial\ntheorem superlevel_isClosed : True := trivial', + 'theorem superlevel_isClosed : True := trivial\ntheorem superlevel_mono : True := trivial') + self.assertNotEqual(swapped, original) + cases = [(original.replace('theorem superlevel_mono ', 'theorem superlevel_monotone '), + 'theorem inventory differs from source: ClosedSuperlevel'), + (swapped, 'theorem inventory differs from source: ClosedSuperlevel'), + (original.replace('noncomputable def superlevel_set : Nat := 0\nnoncomputable def superlevel_inclusion : Nat := 0', + 'noncomputable def superlevel_inclusion : Nat := 0\nnoncomputable def superlevel_set : Nat := 0'), + 'def inventory differs from source: ClosedSuperlevel'), + (original.replace('def superlevel_set ', 'def superlevel_family '), + 'def inventory differs from source: ClosedSuperlevel'), + (original.replace(':= trivial', ':= by sorry', 1), 'admission token in ClosedSuperlevel: sorry'), + (original + 'lemma injected : True := trivial\n', 'code after end TorusFiltration: ClosedSuperlevel:'), + (original.replace('\nend TorusFiltration', '\nlemma injected : True := trivial\nend TorusFiltration'), + 'unexpected column-0 line in ClosedSuperlevel:'), + (original.replace('\nend TorusFiltration', '\nnoncomputable instance hidden : Inhabited Nat := ⟨0⟩\nend TorusFiltration'), + 'unexpected column-0 line in ClosedSuperlevel:'), + (original.replace('\nend TorusFiltration', '\n theorem hidden : True := trivial\nend TorusFiltration'), + 'command token outside a column-0 declaration in ClosedSuperlevel:'), + (original.replace('namespace TorusFiltration', 'namespace ResearchFormalCoreR1'), + 'handoff namespace left in place: ClosedSuperlevel')] + for text, message in cases: + with self.subTest(message=message): + module.write_text(text) + f.restore() + self.assertFails(f.run('source'), message) + module.write_text(original + '-- sorry inside a comment is not an admission\n') + f.restore() + self.assertEqual(f.run('source').returncode, 0) + (f.side / 'TorusFiltration.lean').write_text('import TorusTopology\n') + f.restore() + self.assertFails(f.run('source'), 'root module must import exactly the two modules') + (f.side / 'TorusFiltration.lean').write_text(self.c.ROOT_SOURCE) + f.regenerate() + meta = json.loads((f.side / 'SOURCE_FILES.json').read_text()) + del meta['files'][self.c.PACKAGE + '/TorusTopology.lean'] + (f.side / 'SOURCE_FILES.json').write_text(json.dumps(meta, indent=2, sort_keys=True) + '\n') + f.commit() + self.assertFails(f.run('source'), 'files inventory must list every required companion file') + + def test_environment_pins_are_enforced(self): + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(self.c, tmp) + (f.root / 'formal/lean-toolchain').write_text('leanprover/lean4:v4.34.2\n') + f.commit() + self.assertFails(f.run('source'), "wrong Lean toolchain: 'leanprover/lean4:v4.34.2'") + (f.root / 'formal/lean-toolchain').write_text('leanprover/lean4:v4.34.1\n') + f.write_manifest([{'name': 'mathlib', 'rev': 'main'}, {'name': 'batteries', 'rev': 'f2' * 20}]) + f.commit() + self.assertFails(f.run('source'), 'unpinned dependency') + f.write_manifest([{'name': 'mathlib', 'rev': 'd1' * 20}, {'name': 'mathlib', 'rev': 'd1' * 20}]) + f.commit() + self.assertFails(f.run('source'), 'duplicate or empty dependency list') + f.write_manifest([]) + f.commit() + self.assertFails(f.run('source'), 'duplicate or empty dependency list') + f.write_manifest([{'name': k, 'rev': v} for k, v in f.revisions.items()]) + f.commit() + self.assertEqual(f.run('source').returncode, 0) + + +class MetadataFixture(FixtureCase): + """Every honesty label and schema rule of SOURCE_FILES.json is enforced through the CLI, one field at a time.""" + + def test_each_label_and_schema_rule_withholds_source(self): + c = self.c + workflow = c.WORKFLOW + original = c.ORIGINAL_SHA256 + + def setter(path, value): + def mutate(m): + node = m + for key in path[:-1]: + node = node[key] + node[path[-1]] = value + return mutate + + def deleter(path): + def mutate(m): + node = m + for key in path[:-1]: + node = node[key] + del node[path[-1]] + return mutate + cases = [ + (setter(('scientific_effect',), 'LOW'), 'scientific effect must be NONE'), + (setter(('alignment_status',), 'ACCEPTED'), 'alignment status cannot self-award review'), + (setter(('provenance', 'organizational_independence_credit'), 1), 'credit must stay zero'), + (setter(('provenance', 'human_review'), 'self'), 'credit must stay zero'), + (setter(('provenance', 'claim'), c.CLAIM[:-1] + '5'), 'provenance identity'), + (setter(('provenance', 'original_sha256', next(iter(original))), '0' * 64), 'provenance identity'), + (setter(('provenance', 'original_status'), 'COMPILED'), 'provenance labels'), + (setter(('provenance', 'namespace_mapping'), 'TorusFiltration. -> TorusFiltration.'), 'provenance labels'), + (deleter(('provenance', 'human_review')), 'provenance key missing: human_review'), + (setter(('provenance',), 'none'), 'provenance object'), + (setter(('extra',), 1), 'SOURCE_FILES schema keys'), + (deleter(('provenance',)), 'SOURCE_FILES schema keys'), + (setter(('schema',), 2), 'SOURCE_FILES schema version'), + (setter(('schema',), '1'), 'SOURCE_FILES schema version'), + (setter(('schema',), True), 'SOURCE_FILES schema version'), + (lambda m: m['files'].__setitem__('formal/gate.py', m['files'][workflow]), 'files inventory outside the companion'), + (setter(('files',), {}), 'files inventory outside the companion'), + (setter(('theorems', 'Third'), ['x']), 'per-module inventory keys'), + (deleter(('definitions', 'TorusTopology')), 'per-module inventory keys'), + (lambda m: m['theorems']['ClosedSuperlevel'].append('torus_compact'), 'duplicate declaration name'), + (lambda m: m['definitions']['ClosedSuperlevel']['def'].append('superlevel_set'), 'duplicate declaration name'), + (setter(('namespace',), 'ResearchFormalCoreR1'), 'namespace or root module'), + (setter(('root_module',), 'TorusTopology'), 'namespace or root module'), + (setter(('modules',), ['ClosedSuperlevel', 'TorusTopology']), 'module list'), + (deleter(('definitions', 'TorusTopology', 'instance')), 'definition kinds: TorusTopology'), + (setter(('theorems', 'TorusTopology', 0), 'bad-name'), 'invalid declaration name in TorusTopology'), + (setter(('definitions', 'TorusTopology', 'def', 0), 7), 'invalid declaration name in TorusTopology'), + (setter(('theorems', 'ClosedSuperlevel'), []), 'empty theorem list: ClosedSuperlevel'), + (deleter(('files', workflow, 'bytes')), 'file entry keys: ' + workflow), + (setter(('files', workflow, 'bytes'), -1), 'file bytes: ' + workflow), + (setter(('files', workflow, 'bytes'), '1776'), 'file bytes: ' + workflow), + (setter(('files', workflow, 'sha256'), 'zz' * 32), 'file sha256: ' + workflow), + (setter(('files', workflow, 'git_blob'), 'ab' * 19), 'file git blob: ' + workflow), + (lambda m: json.dumps(m, indent=2, sort_keys=True).replace('{\n "alignment_status"', '{\n "schema": 1,\n "alignment_status"', 1) + '\n', + 'duplicate JSON key: schema'), + (lambda m: json.dumps(m, indent=2, sort_keys=True).replace('"schema": 1', '"schema": 1.0', 1) + '\n', + 'nonfinite or noninteger JSON number'), + (lambda m: json.dumps(m, indent=2, sort_keys=True).replace('"schema": 1', '"schema": NaN', 1) + '\n', + 'nonfinite or noninteger JSON number'), + ] + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(c, tmp) + self.assertEqual(f.run('source').returncode, 0) + for mutate, message in cases: + with self.subTest(message=message): + f.manifest(mutate) + self.assertFails(f.run('source'), message) + f.restore() + self.assertEqual(f.run('source').returncode, 0) + + +class FinishFixture(FixtureCase): + def test_complete_evidence_yields_a_bounded_receipt(self): + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(self.c, tmp) + out = f.evidence() + self.assertEqual({p.name for p in out.iterdir() if p.name.endswith('.lean')}, set(EMITTED)) + run = f.run('finish', str(out)) + self.assertEqual(run.returncode, 0, run.stderr) + receipt = json.loads((out / 'receipt.json').read_text()) + self.assertEqual(receipt['schema'], 1) + self.assertEqual(receipt['scientific_effect'], 'NONE') + self.assertEqual(receipt['formalization_status'], 'kernel-checked') + self.assertEqual(receipt['alignment_status'], 'PENDING_INDEPENDENT_REVIEW') + self.assertIs(receipt['scientific_acceptance'], False) + self.assertEqual(receipt['lean_version'], LEAN_VERSION_LINE.strip()) + self.assertEqual(receipt['dependency_revisions'], f.revisions) + self.assertEqual(len(receipt['declarations']), 58) + self.assertEqual(len(receipt['axioms']), 58) + self.assertEqual(receipt['theorem_count'], 41) + self.assertEqual(receipt['definition_count'], {'abbrev': 2, 'def': 12, 'instance': 3}) + self.assertEqual(receipt['negative_controls'], + {**{k: 'REJECTED_BY_LEAN' for k in self.c.FALSE_CONTROLS}, + **{k: 'REJECTED_BY_AXIOM_AUDIT' for k in self.c.INJECTIONS}}) + self.assertEqual(receipt['provenance']['claim'], self.c.CLAIM) + self.assertEqual(receipt['provenance']['original_sha256'], self.c.ORIGINAL_SHA256) + self.assertEqual(receipt['leanchecker'], {'command': LEANCHECKER_MODULES, 'mode': 'modules'}) + self.assertIn('own declarations against the cached', receipt['scope_note']) + self.assertNotIn('--fresh', receipt['scope_note']) + for name, digest in receipt['log_sha256'].items(): + self.assertEqual(hashlib.sha256((out / name).read_bytes()).hexdigest(), digest, name) + self.assertEqual(set(receipt['log_sha256']), {p.name for p in out.iterdir() if p.is_file()} - {'receipt.json'}) + self.assertIn('axioms.log', receipt['log_sha256']) + self.assertIn('leanchecker.cmd', receipt['log_sha256']) + self.assertIn('Positive.lean', receipt['log_sha256']) + # An operator's --fresh run is recorded as such, with leanchecker's own progress line tolerated. + (out / 'receipt.json').unlink() + (out / 'leanchecker.cmd').write_text(LEANCHECKER_FRESH + '\n') + (out / 'leanchecker.log').write_text('replaying TorusFiltration with --fresh\n') + run = f.run('finish', str(out)) + self.assertEqual(run.returncode, 0, run.stderr) + receipt = json.loads((out / 'receipt.json').read_text()) + self.assertEqual(receipt['leanchecker'], {'command': LEANCHECKER_FRESH, 'mode': 'fresh'}) + self.assertIn('--fresh', receipt['scope_note']) + + def test_every_weakening_withholds_the_receipt(self): + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(self.c, tmp) + out = f.evidence() + meta = self.c.metadata() + first = self.c.targets(meta)[0] + axioms = (out / 'axioms.log').read_text() + types_log = (out / 'types.log').read_text() + audit = (out / 'Audit.lean').read_text() + cases = [ + ('build-TorusTopology.status', '1\n', 'missing successful process: build-TorusTopology'), + ('leanchecker.status', '', 'missing successful process: leanchecker'), + ('leanchecker.cmd', 'leanchecker TorusFiltration\n', "unrecognized leanchecker invocation: 'leanchecker TorusFiltration'"), + ('leanchecker.cmd', 'leanchecker --fresh TorusTopology\n', 'unrecognized leanchecker invocation'), + ('leanchecker.log', 'uncaught exception: failed to read module data\n', 'leanchecker reported diagnostics'), + ('toolchain.log', LEAN_VERSION_LINE.replace('4.34.1', '4.34.0'), 'unexpected running Lean version'), + ('packages.log', 'mathlib %s\n' % ('d1' * 20), 'installed dependency HEADs differ'), + ('axioms.log', axioms.replace('[propext, Classical.choice, Quot.sound]', '[propext, sorryAx]', 1), + 'forbidden transitive axiom'), + ('axioms.log', axioms.replace("'%s' depends on axioms: [propext, Classical.choice, Quot.sound]\n" % first, ''), + 'missing target axiom report'), + ('axioms.log', 'warning: noise\n' + axioms, 'unrecognized audit output'), + ('types.log', ''.join(types_log.splitlines(True)[1:]), 'type inventory mismatch'), + ('types.log', types_log + 'error: crash\n', 'type diagnostic'), + ('RejectSuperlevelSignFlip.log', FALSE_LOG.format('RejectSuperlevelSignFlip').replace('False', 'True'), + 'not the intended False-goal diagnostic'), + ('RejectSuperlevelSignFlip.status', '0\n', 'false-statement control must exit exactly one'), + ('RejectSorry.status', '1\n', 'injection control must be accepted by Lean'), + ('RejectSorry.log', SORRY_WARNING + INJECTED.format('propext'), 'not the intended injected axiom report'), + ('RejectNativeDecide.log', INJECTED.format('sorryAx'), 'not the intended injected axiom report'), + ('source.json', json.dumps({**json.loads((out / 'source.json').read_text()), 'run_id': '1'}), + 'source changed across execution'), + ('Positive.lean', 'import TorusFiltration\n', 'emitted Lean file changed across execution: Positive.lean'), + ('Audit.lean', ''.join(audit.splitlines(True)[:-1]), 'emitted Lean file changed across execution: Audit.lean'), + ('Types.lean', (out / 'Types.lean').read_text().replace('set_option pp.explicit true\n', ''), + 'emitted Lean file changed across execution: Types.lean'), + ('RejectSorry.lean', (out / 'RejectSorry.lean').read_text().replace('by sorry', 'trivial'), + 'emitted Lean file changed across execution: RejectSorry.lean'), + ('RejectConstantNotPeriodic.lean', 'import TorusFiltration\n', + 'emitted Lean file changed across execution: RejectConstantNotPeriodic.lean')] + for name, content, message in cases: + with self.subTest(name=name, message=message): + saved = (out / name).read_text() + (out / name).write_text(content) + try: + self.assertFails(f.run('finish', str(out)), message) + self.assertFalse((out / 'receipt.json').exists(), 'receipt written despite refusal') + finally: + (out / name).write_text(saved) + for name, message in (('leanchecker.cmd', 'leanchecker invocation record absent'), + ('Positive.lean', 'emitted Lean file changed across execution: Positive.lean'), + ('RejectSuperlevelBelowThreshold.status', '[Errno 2] No such file or directory')): + with self.subTest(name=name, message=message): + saved = (out / name).read_text() + (out / name).unlink() + try: + self.assertFails(f.run('finish', str(out)), message) + self.assertFalse((out / 'receipt.json').exists(), 'receipt written despite refusal') + finally: + (out / name).write_text(saved) + self.assertEqual(f.run('finish', str(out)).returncode, 0) + + +if __name__ == '__main__': + unittest.main(verbosity=2) From a898bb441700e75b94424a9a0c6e031f2420b9c9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 11 Oct 2026 18:54:11 +0000 Subject: [PATCH 2/5] Record the first green hosted run's measured duration in the torus_filtration companion README Documentation only: the README's "Hosted duration: not yet measured" paragraph now records run 38165155316 (attempt 1, job 114546073697) on PR #428 head 0dd0cb17, tested merge aa288a13: job 4 min 20 s, Lean install plus Mathlib cache 2 min 47 s, replay step 1 min 27 s at LEAN_NUM_THREADS=2; artifact torus-filtration-38165155316-1 (42 files, 22572 bytes, SHA-256 c9bf02d3...). timeout-minutes stays 45. SOURCE_FILES.json regenerated for the README's new identity; no Lean byte, declaration, control or gate logic changes. Scientific effect NONE. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Cz7WZybv8znP64SpPj6sWY --- companions/torus_filtration_20261011/README.md | 13 ++++++++++--- .../torus_filtration_20261011/SOURCE_FILES.json | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/companions/torus_filtration_20261011/README.md b/companions/torus_filtration_20261011/README.md index 942f02e82..19dea18ff 100644 --- a/companions/torus_filtration_20261011/README.md +++ b/companions/torus_filtration_20261011/README.md @@ -263,9 +263,16 @@ An operator who wants the whole-closure re-check runs time and memory to spare; the receipt then records mode `fresh`. The workflow never sets that switch. -Hosted duration: _not yet measured_. The workflow's `timeout-minutes: 45` is provisional; the -integrator records the first green run's duration here and may lower it. Until then this README -does not assert that the hosted route completes. +Hosted duration: measured on the first green run, +[38165155316](https://github.com/d6g8k5htny-coder/Math-/actions/runs/38165155316) (attempt 1, job +114546073697, PR #428 head `0dd0cb17bfa12bab6983bc4b068a38fed5a9df9c`, tested merge +`aa288a1377acc76bfb544de1c5e3d3b4c282a5e3`): the job took 4 min 20 s end to end (2026-10-11T18:45:38Z to +18:49:58Z), of which the pinned-Lean install plus Mathlib cache retrieval took 2 min 47 s and the +replay step itself 1 min 27 s at `LEAN_NUM_THREADS=2`; artifact `torus-filtration-38165155316-1`, +42 files, 22,572 bytes, SHA-256 `c9bf02d33ddd9addb5d2883af982827b44ef3fd5e84d877ed78504efe8f19c0d`. +The workflow's `timeout-minutes: 45` is kept: a cache miss or a slow runner needs the margin and +lowering it buys nothing. One hosted completion is recorded here; every later run's receipt stands +on its own, and a receipt is a record of a computation, not evidence of alignment. The replay writes `TorusTopology.olean`, `ClosedSuperlevel.olean` and `TorusFiltration.olean` into the companion directory (Lean needs them on `LEAN_PATH` for the root module and the audit diff --git a/companions/torus_filtration_20261011/SOURCE_FILES.json b/companions/torus_filtration_20261011/SOURCE_FILES.json index 97bebfd4b..33ddb7d37 100644 --- a/companions/torus_filtration_20261011/SOURCE_FILES.json +++ b/companions/torus_filtration_20261011/SOURCE_FILES.json @@ -45,9 +45,9 @@ "sha256": "90d1481b75d9c6d14e462c3fbf0bf7c7cdd0efb9eaad68d6732400658753b1c2" }, "companions/torus_filtration_20261011/README.md": { - "bytes": 21661, - "git_blob": "942f02e8203e66bebd5beba40ab6c34a449ba283", - "sha256": "5f4ce5f495a0c385ab15a7a7bd0dc5db07866b0fae356ffc85877e04546523bd" + "bytes": 22334, + "git_blob": "19dea18ff92b8a438bd35477e751ed68e02126e7", + "sha256": "c26fbc29b062177f2060e125ed2002e5e5d898c4fccb97c02d8bec8a0ef6e386" }, "companions/torus_filtration_20261011/SCOPE.md": { "bytes": 10073, From 4c33d8cd4a3634da8553207afe88fa82728f8ae7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 11 Oct 2026 19:28:41 +0000 Subject: [PATCH 3/5] Companion torus_filtration_20261011: apply the C262 engineering-gate AMEND (G1 child mode observed, G2 refused keywords and elaborated census, G3 immutable receipt and exact evidence membership) One forward commit after the posted verdict (Math- #428 comments 6112740935 gate review, 6112743879 disposition AMEND_ENGINEERING_GATE on head a898bb44). G1 test_torus_filtration.py: check.py children are spawned with the outer interpreter's optimization level (-O under -O) and without PYTHONOPTIMIZE, ambient or injected. Every check.py invocation prints the mode it runs in (TORUS_FILTRATION_PYTHON: optimize=N) to stderr; the fixture requires exactly one such line per child and refuses a child whose mode differs from the outer mode, on every call; a control rebinds the spawner to drop -O and shows the guard refusing. The suite prints its own mode into tests.log and tests-optimized.log; replay.sh unsets PYTHONOPTIMIZE. The -O transcripts of hosted runs 38165155316 and 38165763430 keep their narrower attribution in the README (CLI children ran unoptimized then). G2 check.py, two layers. The keyword scanner now matches whole tokens, with identifiers and numerals lexed as Lean does (Lean/Parser/Basic.lean numeral grammar: decimal with `_`, fraction, exponent, 0x/0b/0o), and the comment lexer leaves a space where a block comment closes, so the splices `theorem/- -/hidden`, `0alias`, `0x1Ftheorem`, `1e5axiom`, `1_0def`, `0b1axiom` are refused; COMMANDS lists the declaration-producing commands of Lean core, Batteries, Aesop and Mathlib found at the pin (alias, irreducible_def, the simproc families, notation3, unif_hint, recall, binder_predicate, add_decl_doc, library_note, assert_not_exists, register_simp_attr, register_builtin_option, register_linter_set, register_label_attr, declare_aesop_rule_sets, add/erase_aesop_rules, compile_inductive, compile_def, nonrec, mk_iff_of_inductive_prop, run_meta, grind_propagator(s), declare_config_elab*, gen_injective_theorems, declare_*_theorems, elab_stx_quot, declare_eval_bin*, name_poly_vars, name_power_vars, with_weak_namespace, meta, public, aux_def, lrat_proof, reprove, declare_aesop_exception, declare_uint/sint_simprocs, seal, unseal, unset_option, suppress_compilation, grind_pattern, grind_annotated, extend_docs, init_quot, initialize_simps_projections). The list is a first filter, not the guarantee: the guarantee is Census.lean, an elaborated declaration census that Lean prints for the three modules, each constant tagged internal/user (Name.isInternalDetail) and range/generated (whether Lean recorded a declaration range). finish requires the user-named ranged constants to equal the inventory exactly, refuses any ranged constant with an internal-style name (a user-written `proof_1`), and requires the user-named generated constants to equal SOURCE_FILES.json census_auxiliary exactly (today TorusFiltration.torus_periodBasis.congr_simp). A `where` clause, which no keyword list refuses, is refused by that census. G3 check.py finish: refuses a directory already holding receipt.json (a receipt is written once, never replaced), requires exactly the 44 evidence members (EVIDENCE_FILES) as regular files and nothing else, hashes exactly those 44, and creates the receipt through write_new_file (O_EXCL|O_NOFOLLOW); controls for a repeat finish, an existing receipt beside a newly failing input, every member removed in turn, an extra file, a stray directory, a directory as a required member, a symlinked member, a symlinked evidence directory, a symlinked receipt path and write_new_file itself. The module-level 44-member check is an explicit raise, not an assert. Before the push, this lane's own adversarial verification of the first form of this commit (same account, credit 0) refuted G1 and G2 as first repaired; the repairs above are the folded-in result, so the AMEND stays one forward commit. Rounds of that verification are recorded in the README Amendments section. Protocol tests: 28 in both Python modes. SOURCE_FILES.json regenerated (schema key census_auxiliary added). replay.sh changed by `unset PYTHONOPTIMIZE` and the census invocation; no Lean byte, declaration, control statement or workflow line changed. Scientific effect NONE. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Cz7WZybv8znP64SpPj6sWY --- .../torus_filtration_20261011/README.md | 115 ++++++- companions/torus_filtration_20261011/SCOPE.md | 15 +- .../SOURCE_FILES.json | 33 +- companions/torus_filtration_20261011/check.py | 176 +++++++++- .../torus_filtration_20261011/replay.sh | 3 + .../test_torus_filtration.py | 304 +++++++++++++++++- 6 files changed, 584 insertions(+), 62 deletions(-) diff --git a/companions/torus_filtration_20261011/README.md b/companions/torus_filtration_20261011/README.md index 19dea18ff..2f99b8976 100644 --- a/companions/torus_filtration_20261011/README.md +++ b/companions/torus_filtration_20261011/README.md @@ -189,9 +189,50 @@ or `#`, any string literal (`"`), a primed or dotted declaration name, a declara the namespace or after `end TorusFiltration`, any remaining `namespace ResearchFormalCoreR1`, and any admission token (`sorry`, `sorryAx`, `admit`, `axiom`, `native_decide`, `ofReduceBool`, `trustCompiler`, `unsafe`, `opaque`, `partial`, `implemented_by`, `extern`, -`skipKernelTC`, `autoImplicit`) in comment-free code. A compile fix that needs a refused form -must extend the scanner and the inventory explicitly; nothing escapes the `#print axioms` audit -by being written in a shape the scanner does not count. +`skipKernelTC`, `autoImplicit`) in comment-free code, and the declaration-producing commands of +Lean core, Batteries, Aesop and Mathlib found at the pin (the list `COMMANDS` in `check.py`: +`alias`, `irreducible_def`, the `simproc`/`dsimproc`/`cbv_simproc` families with their `_decl` +and `builtin_` forms, `notation3`, `unif_hint`, `recall`, `binder_predicate`, `add_decl_doc`, +`library_note`, `assert_not_exists`, `register_simp_attr`, `register_builtin_option`, +`register_linter_set`, `register_label_attr`, `declare_aesop_rule_sets`, `add_aesop_rules`, +`erase_aesop_rules`, `compile_inductive`, `compile_def`, `nonrec`, `mk_iff_of_inductive_prop`, +`run_meta`, `grind_propagator`, `builtin_grind_propagator`, `declare_config_elab` and its legacy +forms, `gen_injective_theorems`, `declare_uint_theorems`, `declare_int_theorems`, +`declare_bitwise_uint_theorems`, `declare_bitwise_int_theorems`, `elab_stx_quot`, the +`declare_eval_bin` family, `name_poly_vars`, `name_power_vars`, `with_weak_namespace`, `meta`, +`public`, `aux_def`, `lrat_proof`, `reprove`, `declare_aesop_exception`, `declare_uint_simprocs`, +`declare_sint_simprocs`, `seal`, `unseal`, `unset_option`, `suppress_compilation`, `grind_pattern`, +`grind_annotated`, `extend_docs`, `init_quot`, `initialize_simps_projections`; Mathlib spells +`compile_inductive%`, `compile_def%` and `gen_injective_theorems%` with a `%`, which the token scan +does not need; a few listed commands only attach documentation or notes rather than declarations, +and are refused all the same). +The refused keywords are the explicit list `COMMANDS` in `check.py`: a first filter, not a Lean +grammar and not a complete census. A declaration-producing command or form absent from that list +passes an indented or same-line position uncounted: the C262 gate review (Math- #428 comment +6112740935, finding G2) found `alias` absent at head `a898bb44`, the pre-push verification of +the repair found further commands at the pin (`run_meta`, `mk_iff_of_inductive_prop`, the +`cbv_simproc` family, `grind_propagator`, `register_builtin_option`, `register_linter_set`, +`register_label_attr`, `declare_config_elab`, `gen_injective_theorems%`, `declare_uint_theorems`, +`name_poly_vars`, `add_aesop_rules`, `aux_def`, `reprove`, and more, listed as found), and the +`where` clause of a declaration adds a dotted auxiliary declaration that no keyword list can +refuse. The lexer also treats a closed block comment as a token separator (`theorem/- -/hidden` +is `theorem hidden`) and lexes numerals as Lean does (`0alias` is `0` then `alias`; `0x1Ftheorem` +is `0x1F` then `theorem`), both found by that verification. **The declaration census the receipt +stands on is therefore not the scanner but `Census.lean`**, emitted by `check.py emit` and run +by the replay: Lean itself lists every constant the three companion modules add to the +environment, tagged `internal` or `user` (`Name.isInternalDetail`: `_`-prefixed, `eq_n`, +`match_n`, `proof_n`, `omega_n` or numeric components) and `range` or `generated` (whether Lean +recorded a declaration range, which every declaration elaborated from source syntax carries and +compiler-generated constants lack). `check.py finish` requires the user-named ranged constants +to equal the 58 inventoried names exactly, refuses any ranged constant with an internal-style +name (a `where`-clause `proof_1` written by hand), and requires the user-named generated +constants to equal `census_auxiliary` in `SOURCE_FILES.json` exactly (today +`TorusFiltration.torus_periodBasis.congr_simp`, the simp-congruence lemma Lean generates for +`torus_periodBasis`), so that list can name only constants Lean generated; internal generated +constants (abstracted proofs, equation lemmas) are counted and otherwise ignored. A declaration +the scanner missed is refused by the receipt whatever its spelling, because it was elaborated +from source and therefore carries a range. A compile fix that needs a refused form must extend +the scanner, the inventory and, for a new compiler-generated constant, `census_auxiliary`. ## Vocabulary @@ -218,8 +259,12 @@ The replay: binds HEAD to the manifest (`check.py source`), runs the Python test `lean --version` and every installed package HEAD, compiles `TorusTopology`, `ClosedSuperlevel` and the root `TorusFiltration` with `-DwarningAsError=true`, compiles `Positive.lean` (six concrete applications of the companion's theorems), `Audit.lean` (58 `#print axioms`), -`Types.lean` (41 `#check` with `pp.explicit`), runs -`leanchecker TorusTopology ClosedSuperlevel TorusFiltration`, and runs six negative controls. +`Types.lean` (41 `#check` with `pp.explicit`), `Census.lean` (the elaborated declaration census +above), runs `leanchecker TorusTopology ClosedSuperlevel TorusFiltration`, and runs six negative +controls. The replay unsets `PYTHONOPTIMIZE` first, so each Python invocation runs in exactly the +mode its command line names, and every `check.py` invocation prints the mode it runs in +(`TORUS_FILTRATION_PYTHON: optimize=N`) to the job log (an invocation that argparse rejects +exits 2 before that line; the replay never issues one). The emitted statements below are quoted verbatim from `check.py` (`FALSE_CONTROLS`); each is elaborated as `example : := by ` and must fail with exactly `⊢ False`: @@ -235,13 +280,20 @@ elaborated as `example : := by ` and must fail with exactly The injection controls run **without** warnings-as-errors on purpose: Lean accepts those files, and only the axiom audit refuses them, which is what the audit is for. `check.py negative` uses `re.fullmatch` on each log, so a crash, an extra error or a different exit code is a failed -control, not a passed one. `check.py finish` re-runs the source binding, re-derives the nine -emitted Lean files (`Audit.lean`, `Types.lean`, `Positive.lean`, six controls) and requires byte -equality with the ones Lean consumed, checks every status, the toolchain line, the installed -package HEADs against `formal/lake-manifest.json`, the recorded `leanchecker` invocation, the -axiom and type inventories and the six controls, and writes `receipt.json` with `log_sha256` -over every file in the evidence directory. The evidence directory -`.lake/torus-filtration-evidence` must not pre-exist. +control, not a passed one. `check.py finish` refuses an evidence directory that already holds +`receipt.json` (a receipt is written once and never replaced; a new attempt needs a fresh +directory) and requires exactly the 44 evidence files, each a regular file and nothing else: the +ten emitted Lean files (`Audit.lean`, `Types.lean`, `Positive.lean`, `Census.lean` and the six +controls' `.lean`), a `.log` and `.status` pair for each of the eight Lean processes (three +module builds, `positive`, `axioms`, `types`, `census`, `leanchecker`), the six controls' +`.log`/`.status`, `leanchecker.cmd`, `packages.log`, `toolchain.log`, `source.json`, +`tests.log` and `tests-optimized.log` (`EVIDENCE_FILES` in `check.py`; C262 finding G3). It then +re-runs the source binding, re-derives the ten emitted Lean files and requires byte equality +with the ones Lean consumed, checks every status, the toolchain line, the installed package +HEADs against `formal/lake-manifest.json`, the recorded `leanchecker` invocation, the axiom and +type inventories, the declaration census and the six controls, and writes `receipt.json` with +`log_sha256` over exactly those 44 files, created exclusively (`O_EXCL`, `O_NOFOLLOW`). The +evidence directory `.lake/torus-filtration-evidence` must not pre-exist. ### What `leanchecker` checks here, and why not `--fresh` @@ -283,7 +335,44 @@ Delete them before committing. Local protocol tests: `python3 -B -S companions/torus_filtration_20261011/test_torus_filtration.py` and the same with `-O`. They exercise `check.py` against a temporary Git fixture with -inventory-exact placeholder modules; they execute no Lean. +inventory-exact placeholder modules; they execute no Lean. The fixture spawns its `check.py` +children with the outer interpreter's optimization level (`-O` under `-O`) and strips +`PYTHONOPTIMIZE` from their environment; every `check.py` invocation reports the mode it actually +runs in on stderr, and the fixture refuses any child whose report differs from the outer mode, +on every call, accept or refuse (so a fixture that stopped propagating `-O` fails, rather than +passing with unoptimized children). The suite prints its own outer mode into the transcript +(`TORUS_FILTRATION_TESTS: outer optimize=N`), so `tests.log` and `tests-optimized.log` record +which mode each run was. Until head `a898bb44` the children ran unoptimized whatever the outer +mode was in a clean environment, and in the mode of an ambient `PYTHONOPTIMIZE` otherwise (C262 +finding G1); the hosted runners are clean, so the `tests-optimized.log` transcripts of hosted runs 38165155316 and +38165763430 therefore cover the imported helpers under `-O` and the CLI paths unoptimized; that +narrower attribution stands for those runs and is not revised. + +## Amendments + +- C262 (Math- #428, nonauthor engineering gate review [6112740935](https://github.com/d6g8k5htny-coder/Math-/pull/428#issuecomment-6112740935), + disposition [6112743879](https://github.com/d6g8k5htny-coder/Math-/pull/428#issuecomment-6112743879), AMEND_ENGINEERING_GATE on + head `a898bb44`): G1 the test fixture now propagates the outer optimization level to its `check.py` + children, strips `PYTHONOPTIMIZE` and observes the child mode; G2 the scanner refuses `alias` and + the other declaration-producing commands listed above, with indented, same-line and column-0 + negative controls, and the census claim is bounded to the enumeration; G3 `finish` never replaces + a receipt and requires the exact evidence set of regular files (44 members once the census + below was added), with controls for a + repeat `finish`, an existing receipt beside a newly failing input, every removed member, an extra + member and a symlinked member. Before the push, this lane's own adversarial verification of + the repair (same account, credit 0) refuted its first form and the fixes were folded into the + same commit: the child-mode control now observes every fixture child through the CLI's own + report, not a separate probe; the keyword list gained the further declaration-producing + commands found at the pin and the lexer no longer splices tokens across a closed block comment + or a numeral; the elaborated declaration census (`Census.lean`) replaces the scanner as the + census guarantee, with `census_auxiliary` naming the one compiler-generated constant; the + replay unsets `PYTHONOPTIMIZE` and records the outer mode in both test transcripts; the receipt + is created with `O_EXCL`/`O_NOFOLLOW` and a directory as a required member is refused. The + replay script changed by the one census invocation and the `unset`; the Actions workflow file, + every Lean byte, declaration and control statement are unchanged. The same review's Lean source verdict (PASS_SOURCE_SCOPE, + [6112740740](https://github.com/d6g8k5htny-coder/Math-/pull/428#issuecomment-6112740740)) and hosted-evidence verdict + (APPROVE_OBSERVED_EXECUTION_SCOPE, [6112741132](https://github.com/d6g8k5htny-coder/Math-/pull/428#issuecomment-6112741132)) + were of head `a898bb44`; organizational-independence credit 0 throughout. ## What this companion does not do diff --git a/companions/torus_filtration_20261011/SCOPE.md b/companions/torus_filtration_20261011/SCOPE.md index 68361d93b..6f78f7300 100644 --- a/companions/torus_filtration_20261011/SCOPE.md +++ b/companions/torus_filtration_20261011/SCOPE.md @@ -64,12 +64,23 @@ renamed theorem, hidden or indented declaration, injected admission, every hones schema field of `SOURCE_FILES.json` one at a time, wrong or unpinned toolchain and dependency lock, host identity mismatch, an emitted Lean file altered between `emit` and `finish`, an unrecognized `leanchecker` invocation, leanchecker output in modules mode, wrong installed -dependency). +dependency, a second `finish` on a directory already holding a receipt, an existing receipt +beside a newly failing input, any missing, extra or symlinked evidence member, an uninventoried +`alias` indented after the namespace opening, on a declaration line or at column 0, a keyword +spliced to a closed block comment or to a numeral, every refused command keyword indented after +the namespace opening, a declaration census (`Census.lean`) with an extra, missing or unlisted +constant, a user-written declaration with an internal-style name, a `census_auxiliary` entry +that Lean did not generate, a keyword spliced to a hex/binary/octal/exponent numeral, a wrong +census count or terminator, and a `check.py` child running in a different +optimization mode from the outer test interpreter, which the fixture checks on every child). ## Evidence boundary A green hosted run establishes, for these 58 declarations at this toolchain and dependency -lock, that Lean elaborated them with warnings as errors, that +lock, that Lean elaborated them with warnings as errors, that Lean's own census of the +constants the three modules add to the environment (`Census.lean`, with declaration-range and +internal-name tags) has exactly these 58 as its user-written declarations and exactly the one +named compiler-generated auxiliary, that `leanchecker TorusTopology ClosedSuperlevel TorusFiltration` replayed the companion modules' own declarations through the kernel against the cached, prebuilt dependency `.olean` files (the import closure, all of Mathlib, is trusted from that cache and not re-checked; a `--fresh` diff --git a/companions/torus_filtration_20261011/SOURCE_FILES.json b/companions/torus_filtration_20261011/SOURCE_FILES.json index 33ddb7d37..09cb314ab 100644 --- a/companions/torus_filtration_20261011/SOURCE_FILES.json +++ b/companions/torus_filtration_20261011/SOURCE_FILES.json @@ -1,5 +1,8 @@ { "alignment_status": "PENDING_INDEPENDENT_REVIEW", + "census_auxiliary": [ + "TorusFiltration.torus_periodBasis.congr_simp" + ], "definitions": { "ClosedSuperlevel": { "abbrev": [], @@ -45,14 +48,14 @@ "sha256": "90d1481b75d9c6d14e462c3fbf0bf7c7cdd0efb9eaad68d6732400658753b1c2" }, "companions/torus_filtration_20261011/README.md": { - "bytes": 22334, - "git_blob": "19dea18ff92b8a438bd35477e751ed68e02126e7", - "sha256": "c26fbc29b062177f2060e125ed2002e5e5d898c4fccb97c02d8bec8a0ef6e386" + "bytes": 30582, + "git_blob": "2f99b89767fb37648bc0742ed4e8328c245b74b1", + "sha256": "8084b313486bbf72fa32ab57fc604fb88bccb658b21569c225f5b6b68a783f49" }, "companions/torus_filtration_20261011/SCOPE.md": { - "bytes": 10073, - "git_blob": "68361d93bb6b701c3c3c6c32ab942db3e4bcedc3", - "sha256": "bcd3c49a8cc05dc33a424092622b0ad1dabc82684bee037cd85ee8c131d33dbb" + "bytes": 11141, + "git_blob": "6f78f7300475eec8b97455133714310fbdf35a29", + "sha256": "cb7d9cb9929a05fd3b0d07f91dfbc9b2b0f796cbd59da5f1e34bc2ab08a55d7b" }, "companions/torus_filtration_20261011/TorusFiltration.lean": { "bytes": 45, @@ -65,19 +68,19 @@ "sha256": "ddb145b3f791c181d4f2a51e54e711937297bd6476ba55bcd5252b7ddb57cfe1" }, "companions/torus_filtration_20261011/check.py": { - "bytes": 29134, - "git_blob": "8443ae3192c44b912952b9cd1984a7290e95acc8", - "sha256": "57a75907677e074579b501168ad0a406d51168f41daa96b8627615b037acfc6b" + "bytes": 40225, + "git_blob": "afc6492bb39f9830f99b1a28ee16ab04537fd45d", + "sha256": "d8fb2add2ca430b0f935f1578adecc90da798a7fb33f693ada156a09af99077d" }, "companions/torus_filtration_20261011/replay.sh": { - "bytes": 4161, - "git_blob": "c217643224412785a9306600809e43c8e0c5d71f", - "sha256": "74de4c98df96bfa59b879dc79bad78bc708573b1ee16c2582393837cc4e9d189" + "bytes": 4382, + "git_blob": "05602a3f7f5fd2cada98625b27c5268a407cc8f1", + "sha256": "cb6b54e1aabda382c48eca7316d5e892845f68e2a708082a30b5e2acf81fe95c" }, "companions/torus_filtration_20261011/test_torus_filtration.py": { - "bytes": 62092, - "git_blob": "6eb9a3eb3b319c59dd27f08463b0679274b06901", - "sha256": "b5102880bd937d13d92e61f2896ec368177d1828113f75565d6471b8fcccfa50" + "bytes": 84884, + "git_blob": "0fd3c887cdec71cd7b232933cdd08b4f34918fee", + "sha256": "ab95294403739a4f20df7fafc6bca7bf0e25748595581cdaaba02fc975a38d2f" } }, "modules": [ diff --git a/companions/torus_filtration_20261011/check.py b/companions/torus_filtration_20261011/check.py index 8443ae319..afc6492bb 100644 --- a/companions/torus_filtration_20261011/check.py +++ b/companions/torus_filtration_20261011/check.py @@ -45,7 +45,8 @@ IDENT = r'[A-Za-z][A-Za-z0-9_]*' HEX40 = re.compile(r'[0-9a-f]{40}') HEX64 = re.compile(r'[0-9a-f]{64}') -BUILDS = ('build-TorusTopology', 'build-ClosedSuperlevel', 'build-TorusFiltration', 'positive', 'axioms', 'types', 'leanchecker') +BUILDS = ('build-TorusTopology', 'build-ClosedSuperlevel', 'build-TorusFiltration', 'positive', 'axioms', 'types', 'census', + 'leanchecker') # The leanchecker invocations replay.sh may record in leanchecker.cmd. Both modules `import Mathlib`, so # `--fresh` (kernel re-check of the whole import closure) exceeds a hosted job: measured locally at 4 threads # it was still running at 1500 s with 6.6 GB resident. The hosted default replays the companion's own @@ -55,15 +56,63 @@ ADMISSION = ('sorry', 'sorryAx', 'admit', 'axiom', 'native_decide', 'ofReduceBool', 'trustCompiler', 'unsafe', 'opaque', 'partial', 'implemented_by', 'extern', 'skipKernelTC', 'autoImplicit') # Module scanner (scan_module): a whitelist of what may start a column-0 code line. Lean itself accepts a -# command anywhere (indented, after another command on the same line, behind `open … in`), so every other -# command keyword is refused wherever it appears outside comments; the scanner refuses what it cannot place. +# command anywhere (indented, after another command on the same line, behind `open … in`), so every command +# keyword in COMMANDS is refused wherever it appears outside comments; the scanner refuses what it cannot place. +# COMMANDS is an explicit list of refused keywords, not a Lean grammar and not a complete census: a +# declaration-producing command or form absent from it passes an indented or same-line position uncounted (C262 +# gate review G2, Math- #428 comment 6112740935, found `alias` absent at head a898bb44; the pre-push adversarial +# verification of the repair then enumerated further commands at the pin, listed below, and the `where` clause of +# a declaration, which no keyword list can refuse). The scanner is therefore only a first filter. The declaration +# census that the receipt stands on is Census.lean (CENSUS below): Lean itself lists every non-internal constant +# the companion modules add to the environment, and `finish` requires that list to equal the inventory plus the +# explicitly named compiler-generated auxiliaries (`census_auxiliary` in SOURCE_FILES.json), nothing else. COMMANDS = ('theorem', 'lemma', 'def', 'abbrev', 'instance', 'axiom', 'axioms', 'example', 'structure', 'inductive', 'class', 'opaque', 'macro', 'macro_rules', 'syntax', 'elab', 'elab_rules', 'notation', 'infix', 'infixl', 'infixr', 'prefix', 'postfix', 'set_option', 'attribute', 'namespace', 'section', 'end', 'universe', 'variable', 'import', 'private', 'protected', 'noncomputable', 'unsafe', 'partial', 'scoped', 'local', 'mutual', 'deriving', 'initialize', 'builtin_initialize', 'declare_syntax_cat', 'register_option', - 'open', 'export', 'include', 'omit', 'run_cmd', 'run_tac', 'run_elab', 'in') -COMMAND_TOKEN = re.compile(r'(? + match env.getModuleIdxFor? n with + | some i => if idxs.contains i then acc.push n else acc + | none => acc + for n in names.qsort (fun a b => a.toString < b.toString) do + let ranged ← Lean.findDeclarationRanges? n + IO.println s!"{n} {if n.isInternalDetail then "internal" else "user"} {if ranged.isSome then "range" else "generated"}" + IO.println s!"CENSUS_END {names.size}" +''' +EVIDENCE_FILES = frozenset(EMITTED_FILES) | {label + ext for label in BUILDS for ext in ('.log', '.status')} \ + | {control + ext for control in CONTROLS for ext in ('.log', '.status')} \ + | {'leanchecker.cmd', 'packages.log', 'toolchain.log', 'source.json', 'tests.log', 'tests-optimized.log'} +if len(EVIDENCE_FILES) != 44: # an explicit check, not an `assert`: the gate must hold under -O too + raise RuntimeError('EVIDENCE_FILES must enumerate exactly 44 members') POSITIVE = '''import TorusFiltration open TorusFiltration @@ -157,7 +240,13 @@ def git(*args): def metadata(): meta = strict((SIDE / 'SOURCE_FILES.json').read_bytes()) require(set(meta) == {'schema', 'scientific_effect', 'alignment_status', 'namespace', 'root_module', 'modules', - 'definitions', 'theorems', 'files', 'provenance'}, 'SOURCE_FILES schema keys') + 'definitions', 'theorems', 'files', 'provenance', 'census_auxiliary'}, 'SOURCE_FILES schema keys') + aux = meta['census_auxiliary'] + # Dotted names under the namespace; that each is compiler-generated is checked by the census (`finish` requires + # every entry to appear without a declaration range), not by this schema rule. + require(isinstance(aux, list) and all(isinstance(n, str) and re.fullmatch(NAME, n) and n.startswith(NAMESPACE + '.') + and n.count('.') >= 2 for n in aux) and len(aux) == len(set(aux)), + 'census_auxiliary must list dotted auxiliary names under the companion namespace') require(type(meta['schema']) is int and meta['schema'] == 1, 'SOURCE_FILES schema version') require(meta['scientific_effect'] == 'NONE', 'scientific effect must be NONE') require(meta['alignment_status'] == 'PENDING_INDEPENDENT_REVIEW', 'alignment status cannot self-award review') @@ -211,9 +300,11 @@ def targets(meta): def code_lines(text): """The comment-free text of a Lean source, line by line (a comment lexer, not a Lean parser). - Handles `--` to end of line and nested `/- … -/` blocks (`/--` and `/-!` included). String - literals are not modelled, so scan_module refuses any `"` left in code; a `-/` outside a comment - or an unterminated block is refused rather than guessed at. + Handles `--` to end of line and nested `/- … -/` blocks (`/--` and `/-!` included); a closed + block comment leaves one space in the code, as Lean treats it as whitespace between tokens, so + `theorem/- -/hidden` is scanned as `theorem hidden`, not `theoremhidden`. String literals are + not modelled, so scan_module refuses any `"` left in code; a `-/` outside a comment or an + unterminated block is refused rather than guessed at. """ lines = [] depth = 0 @@ -229,6 +320,8 @@ def code_lines(text): elif two == '-/': depth -= 1 i += 2 + if depth == 0: + code.append(' ') else: i += 1 elif two == '/-': @@ -264,9 +357,8 @@ def scan_module(text, module): for number, code in enumerate(lines, 1): require('"' not in code, 'string literal in code: ' + module + ':' + str(number)) code_text = '\n'.join(lines) - for token in ADMISSION: - require(re.search(r'(? internal|user range|generated` per constant, then `CENSUS_END `). + + user+range must equal `names` exactly; internal+range is refused; user+generated must equal `auxiliary` exactly.""" + lines = text.strip('\n').split('\n') if text.strip() else [] + require(lines and re.fullmatch(r'CENSUS_END [0-9]+', lines[-1]), 'census terminator absent') + rows = [CENSUS_LINE.fullmatch(line) for line in lines[:-1]] + require(all(rows), 'unrecognized census output') + listed = [m.group(1) for m in rows] + require(int(lines[-1].split()[1]) == len(listed) and len(set(listed)) == len(listed), 'census count mismatch') + kinds = {m.group(1): (m.group(2), m.group(3)) for m in rows} + ranged_user = sorted(n for n, k in kinds.items() if k == ('user', 'range')) + ranged_internal = sorted(n for n, k in kinds.items() if k == ('internal', 'range')) + generated_user = sorted(n for n, k in kinds.items() if k == ('user', 'generated')) + require(not ranged_internal, 'user-written declarations with internal-style names: %s' % ranged_internal) + extra, missing = sorted(set(ranged_user) - set(names)), sorted(set(names) - set(ranged_user)) + require(not extra, 'user-written declarations outside the inventory: %s' % extra) + require(not missing, 'inventory targets absent from the census: %s' % missing) + unlisted, absent = sorted(set(generated_user) - set(auxiliary)), sorted(set(auxiliary) - set(generated_user)) + require(not unlisted, 'compiler-generated constants not listed in census_auxiliary: %s' % unlisted) + require(not absent, 'census_auxiliary entries absent or not compiler-generated: %s' % absent) + return {'constants': len(listed), 'user_declarations': len(ranged_user), 'generated_user': generated_user, + 'internal_generated': sum(1 for k in kinds.values() if k == ('internal', 'generated'))} + + +def write_new_file(path, text): + """Create `path` exclusively (O_EXCL, O_NOFOLLOW): an existing file or a planted symlink fails the open instead of + being replaced or followed; nothing is truncated.""" + descriptor = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, 'O_NOFOLLOW', 0), 0o644) + with os.fdopen(descriptor, 'w', encoding='utf-8') as handle: + handle.write(text) + + def leanchecker_mode(text): command = text.strip() require(command in LEANCHECKER, 'unrecognized leanchecker invocation: ' + repr(command)) @@ -439,6 +567,7 @@ def emit(out): (out / 'Types.lean').write_text(header + 'set_option pp.explicit true\n' + '\n'.join('#check ' + n for n in theorem_targets(meta)) + '\n') (out / 'Positive.lean').write_text(POSITIVE) + (out / 'Census.lean').write_text(CENSUS) for name, (statement, tactic) in FALSE_CONTROLS.items(): (out / (name + '.lean')).write_text(header + 'open ' + NAMESPACE + '\nexample : ' + statement + ' := by\n ' + tactic + '\n') for name, (body, _, _) in INJECTIONS.items(): @@ -446,6 +575,16 @@ def emit(out): def finish(out): + require(out.is_dir() and not out.is_symlink(), 'evidence directory absent, not a directory, or a symlink: ' + str(out)) + receipt_path = out / 'receipt.json' + require(not receipt_path.exists() and not receipt_path.is_symlink(), + 'receipt.json already present: finish never replaces a receipt; a new attempt needs a fresh evidence directory') + present = {p.name for p in out.iterdir()} + missing, unexpected = sorted(EVIDENCE_FILES - present), sorted(present - EVIDENCE_FILES) + require(not missing and not unexpected, 'evidence membership differs: missing %s, unexpected %s' % (missing, unexpected)) + for name in sorted(EVIDENCE_FILES): + member = out / name + require(member.is_file() and not member.is_symlink(), 'evidence member is not a regular file: ' + name) initial = strict((out / 'source.json').read_bytes()) current = source() require(initial == current, 'source changed across execution') @@ -467,6 +606,7 @@ def finish(out): require(mode == 'fresh' or not (out / 'leanchecker.log').read_text().strip(), 'leanchecker reported diagnostics') axioms = audit_axioms((out / 'axioms.log').read_text(), targets(meta)) types((out / 'types.log').read_text(), theorem_targets(meta)) + counted = census((out / 'census.log').read_text(), targets(meta), meta['census_auxiliary']) outcomes = {} for control in CONTROLS: status = int((out / (control + '.status')).read_text().strip()) @@ -483,11 +623,12 @@ def finish(out): 'theorem_count': len(current['theorems']), 'definition_count': definitions, 'axioms': axioms, 'negative_controls': outcomes, 'provenance': current['provenance'], 'leanchecker': {'command': (out / 'leanchecker.cmd').read_text().strip(), 'mode': mode}, + 'census': counted, 'scope_note': 'kernel-checked records that Lean elaborated these declarations at the pinned toolchain and ' 'that leanchecker replayed ' + replayed + '; it is not alignment with the handoff scope, ' 'not review, and not acceptance.', - 'log_sha256': {p.name: sha(p.read_bytes()) for p in sorted(out.iterdir()) if p.is_file()}} - (out / 'receipt.json').write_text(json.dumps(receipt, indent=2, sort_keys=True) + '\n') + 'log_sha256': {name: sha((out / name).read_bytes()) for name in sorted(EVIDENCE_FILES)}} + write_new_file(receipt_path, json.dumps(receipt, indent=2, sort_keys=True) + '\n') return receipt @@ -498,6 +639,9 @@ def main(): parser.add_argument('--control', choices=CONTROLS) parser.add_argument('--status', type=int) args = parser.parse_args() + # The interpreter mode this invocation actually runs in, for the test fixture (which requires it to equal the + # outer mode for every child) and for the hosted job log (C262 G1). + print('TORUS_FILTRATION_PYTHON: optimize=%d' % sys.flags.optimize, file=sys.stderr) try: if args.command == 'source': result = source() diff --git a/companions/torus_filtration_20261011/replay.sh b/companions/torus_filtration_20261011/replay.sh index c21764322..05602a3f7 100644 --- a/companions/torus_filtration_20261011/replay.sh +++ b/companions/torus_filtration_20261011/replay.sh @@ -3,6 +3,8 @@ # tests: the companion consumes only the pinned toolchain, lakefile and dependency lock from # formal/, and its evidence is kernel-checked declarations, not alignment or acceptance. set -euo pipefail +# The outer Python mode is the one named on each command line below, never an ambient PYTHONOPTIMIZE (C262 G1). +unset PYTHONOPTIMIZE ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" SIDE="$ROOT/companions/torus_filtration_20261011" OUT="$ROOT/.lake/torus-filtration-evidence" @@ -40,6 +42,7 @@ run_lean build-TorusFiltration lean -DwarningAsError=true --root="$TORUS_SIDE" - run_lean positive lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Positive.lean" run_lean axioms lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Audit.lean" run_lean types lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Types.lean" +run_lean census lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Census.lean" # Kernel replay of the companion modules' own declarations against the cached, prebuilt dependency # .oleans (30 s at 2 threads locally). Both modules `import Mathlib`, so `--fresh` (re-check of the whole # import closure) does not fit a hosted job: still running at 1500 s with 6.6 GB resident at 4 threads. diff --git a/companions/torus_filtration_20261011/test_torus_filtration.py b/companions/torus_filtration_20261011/test_torus_filtration.py index 6eb9a3eb3..0fd3c887c 100644 --- a/companions/torus_filtration_20261011/test_torus_filtration.py +++ b/companions/torus_filtration_20261011/test_torus_filtration.py @@ -50,8 +50,17 @@ INJECTED = "'injected' depends on axioms: [{0}]\n" LEANCHECKER_MODULES = 'leanchecker TorusTopology ClosedSuperlevel TorusFiltration' LEANCHECKER_FRESH = 'leanchecker --fresh TorusFiltration' -EMITTED = ('Audit.lean', 'Types.lean', 'Positive.lean', 'RejectSuperlevelSignFlip.lean', 'RejectSuperlevelBelowThreshold.lean', - 'RejectConstantNotPeriodic.lean', 'RejectSorry.lean', 'RejectCustomAxiom.lean', 'RejectNativeDecide.lean') +EMITTED = ('Audit.lean', 'Types.lean', 'Positive.lean', 'Census.lean', 'RejectSuperlevelSignFlip.lean', + 'RejectSuperlevelBelowThreshold.lean', 'RejectConstantNotPeriodic.lean', 'RejectSorry.lean', 'RejectCustomAxiom.lean', + 'RejectNativeDecide.lean') +PYTHON_LINE = 'TORUS_FILTRATION_PYTHON: optimize=%d' % sys.flags.optimize +# Compiler-generated internal constants as the real census lists them (abstracted proofs, equation lemmas); the fixture +# census carries a few so the parser's `internal generated` branch is exercised. +INTERNAL_GENERATED = ('TorusFiltration.superlevel_set.eq_1', 'TorusFiltration.torus_periodBasis._proof_1', + 'TorusFiltration.torus_proj_eq_iff._abel_1_1') +# The outer interpreter mode goes into the test transcript (tests.log / tests-optimized.log), so the hosted +# evidence records which mode each suite ran in (C262 G1). +print('TORUS_FILTRATION_TESTS: outer optimize=%d' % sys.flags.optimize, file=sys.stderr) def checker(): @@ -61,6 +70,29 @@ def checker(): return module +def child_python(): + """Interpreter prefix for every check.py child: `-B -S` plus the OUTER interpreter's optimization level. + + A child spawned through sys.executable does not inherit the parent's -O; until C262 (Math- #428 comment + 6112740935, finding G1) the -O test run therefore exercised check.py's CLI paths unoptimized.""" + flags = ['-B', '-S'] + if sys.flags.optimize: + flags.append('-' + 'O' * sys.flags.optimize) + return [sys.executable, *flags] + + +def child_env(extra=None): + """Child environment: no GITHUB_* (host identity is set explicitly where a test needs it) and no PYTHONOPTIMIZE, + ambient or injected, so the child's mode is exactly the one child_python() selects.""" + environment = {k: v for k, v in os.environ.items() if not k.startswith('GITHUB_')} + environment.update(extra or {}) + environment.pop('PYTHONOPTIMIZE', None) + return environment + + +OPTIMIZE_PROBE = 'import sys; print(sys.flags.optimize)' + + def placeholder_module(module): """Inventory-exact Lean text that is never compiled; only the whitelist scan reads it.""" lines = ['import Mathlib', '', '/-! fixture module; not the companion source -/', '', 'namespace TorusFiltration', ''] @@ -133,10 +165,13 @@ def restore(self): self.commit() def run(self, *args, env=None): - environment = {k: v for k, v in os.environ.items() if not k.startswith('GITHUB_')} - environment.update(env or {}) - return subprocess.run([sys.executable, '-B', '-S', str(self.side / 'check.py'), *args], cwd=self.root, - capture_output=True, text=True, env=environment) + result = subprocess.run([*child_python(), str(self.side / 'check.py'), *args], cwd=self.root, + capture_output=True, text=True, env=child_env(env)) + # Every child reports the mode it actually runs in (check.py main); it must be the outer mode, on every + # call, accept or refuse. A fixture that stopped propagating -O would fail here, not pass silently (C262 G1). + if result.stderr.count(PYTHON_LINE + '\n') != 1 or 'TORUS_FILTRATION_PYTHON: optimize=' in result.stderr.replace(PYTHON_LINE, ''): + raise AssertionError('check.py child did not report the outer interpreter mode %d: %r' % (sys.flags.optimize, result.stderr[:300])) + return result def evidence(self): out = self.root / 'evidence' @@ -150,6 +185,8 @@ def evidence(self): raise AssertionError(emitted.stderr) (out / 'toolchain.log').write_text(LEAN_VERSION_LINE) (out / 'packages.log').write_text(''.join('%s %s\n' % kv for kv in self.revisions.items())) + (out / 'tests.log').write_text('TORUS_FILTRATION_TESTS: outer optimize=0\nRan 1 test\n\nOK\n') + (out / 'tests-optimized.log').write_text('TORUS_FILTRATION_TESTS: outer optimize=1\nRan 1 test\n\nOK\n') for label in self.c.BUILDS: (out / (label + '.status')).write_text('0\n') (out / (label + '.log')).write_text('') @@ -166,6 +203,9 @@ def evidence(self): for control in self.c.INJECTIONS: (out / (control + '.log')).write_text(good_injection_log(self.c, control)) (out / (control + '.status')).write_text('0\n') + rows = sorted([(n, 'user range') for n in targets] + [(n, 'user generated') for n in meta['census_auxiliary']] + + [(n, 'internal generated') for n in INTERNAL_GENERATED]) + (out / 'census.log').write_text(''.join('%s %s\n' % r for r in rows) + 'CENSUS_END %d\n' % len(rows)) return out @@ -179,6 +219,69 @@ def assertFails(self, run, message): self.assertIn('TORUS_FILTRATION_FAIL: ' + message, run.stderr) +class ChildInterpreterMode(unittest.TestCase): + """C262 G1: the mode a check.py child actually runs in is observed, not inferred from an argument string.""" + + def test_children_run_in_the_outer_optimization_mode(self): + outer = sys.flags.optimize + probe = subprocess.run([*child_python(), '-c', OPTIMIZE_PROBE], capture_output=True, text=True, env=child_env()) + self.assertEqual((probe.returncode, probe.stdout.strip()), (0, str(outer)), probe.stderr) + # Ambient or injected PYTHONOPTIMIZE never reaches the child: the mode is the outer one in both cases. + saved = os.environ.get('PYTHONOPTIMIZE') + os.environ['PYTHONOPTIMIZE'] = '2' + try: + ambient = subprocess.run([*child_python(), '-c', OPTIMIZE_PROBE], capture_output=True, text=True, env=child_env()) + injected = subprocess.run([*child_python(), '-c', OPTIMIZE_PROBE], capture_output=True, text=True, + env=child_env({'PYTHONOPTIMIZE': '1'})) + finally: + if saved is None: + del os.environ['PYTHONOPTIMIZE'] + else: + os.environ['PYTHONOPTIMIZE'] = saved + self.assertEqual(ambient.stdout.strip(), str(outer)) + self.assertEqual(injected.stdout.strip(), str(outer)) + self.assertFalse('PYTHONOPTIMIZE' in child_env({'PYTHONOPTIMIZE': '1'})) # assertFalse: never print an environment + # The invocation the fixture used before C262 (no propagation) runs the child unoptimized whatever the outer + # mode is; under `-O` that is exactly the G1 observation, under the normal mode the two agree at 0. + plain = subprocess.run([sys.executable, '-B', '-S', '-c', OPTIMIZE_PROBE], capture_output=True, text=True, env=child_env()) + self.assertEqual(plain.stdout.strip(), '0') + if outer: + self.assertNotEqual(plain.stdout.strip(), str(outer)) + self.assertEqual(child_python()[1:], ['-B', '-S'] + (['-' + 'O' * outer] if outer else [])) + + def test_every_check_py_child_reports_the_outer_mode(self): + with tempfile.TemporaryDirectory() as tmp: + f = Fixture(checker(), tmp) + accepted = f.run('source') # Fixture.run itself requires the diagnostic on every call + self.assertEqual(accepted.returncode, 0, accepted.stderr) + self.assertEqual(accepted.stderr.strip(), PYTHON_LINE) + (f.side / 'README.md').write_text('# edited without a commit\n') + refused = f.run('source') + self.assertEqual(refused.returncode, 1) + self.assertEqual(refused.stderr.splitlines()[0], PYTHON_LINE) + self.assertIn('TORUS_FILTRATION_FAIL: dirty execution/source bytes', refused.stderr) + f.git('checkout', '--', '.') + # The invocation the fixture used before C262 runs the real check.py unoptimized under an outer -O, and + # check.py now says so itself; under the normal outer mode both report 0. + plain = subprocess.run([sys.executable, '-B', '-S', str(f.side / 'check.py'), 'source'], cwd=f.root, + capture_output=True, text=True, env=child_env()) + self.assertEqual(plain.returncode, 0, plain.stderr) + self.assertEqual(plain.stderr.strip(), 'TORUS_FILTRATION_PYTHON: optimize=0') + if sys.flags.optimize: + self.assertNotEqual(plain.stderr.strip(), PYTHON_LINE) + # Negative control of the fixture's own guard: with the child prefix rebound to the OTHER mode, Fixture.run + # itself must refuse (so a fixture that stopped propagating -O, or dropped the guard, is caught here). + other = [sys.executable, '-B', '-S'] + ([] if sys.flags.optimize else ['-O']) + saved = globals()['child_python'] + globals()['child_python'] = lambda: other + try: + with self.assertRaises(AssertionError): + f.run('source') + finally: + globals()['child_python'] = saved + self.assertEqual(f.run('source').returncode, 0) + + class InventoryTests(unittest.TestCase): @classmethod def setUpClass(cls): @@ -291,6 +394,51 @@ def inject(line): (inject('set_option maxHeartbeats 0 in'), unexpected), (inject('section\n theorem indented_hidden : True := trivial\nend'), unexpected), (inject(' theorem indented_hidden : True := trivial'), command), + (good.replace('namespace TorusFiltration\n', 'namespace TorusFiltration\n alias hidden := Nat.add_comm\n'), command), + (inject('theorem a_hidden : True := trivial alias hidden := Nat.add_comm'), command), + (inject('alias hidden := Nat.add_comm'), unexpected), + (inject(' irreducible_def hidden : Nat := 0'), command), + (inject(' simproc hidden (Nat.succ _) := fun _ => return .continue'), command), + (inject(' notation3 hidden => Nat.zero'), command), + (inject(' run_meta pure ()'), command), + (inject(' mk_iff_of_inductive_prop Nat.le hidden'), command), + (inject(' cbv_simproc hidden (Nat.succ _) := fun _ => return .continue'), command), + (inject(' builtin_simproc_decl hidden (Nat.succ _) := fun _ => return .continue'), command), + (inject(' add_aesop_rules safe hidden'), command), + (inject(' register_label_attr hidden'), command), + (inject(' grind_propagator hidden ↓Nat.le := fun _ => pure ()'), command), + (inject(' declare_uint_theorems Nat'), command), + (inject(' name_poly_vars X over Nat'), command), + (inject(' with_weak_namespace Hidden theorem hidden : True := trivial'), command), + (inject(' meta def hidden : Nat := 0'), command), + (inject(' public theorem hidden : True := trivial'), command), + (inject(' aux_def hidden : Nat := 0'), command), + (inject(' lrat_proof hidden "p cnf 1 1 1 0" "1 0"'), 'string literal in code: ClosedSuperlevel:'), + (inject(' lrat_proof hidden'), command), + # lexical splices found by the verification of the G2 repair: a closed block comment is a token separator + # (as in Lean), and a numeral ends at the first non-digit, so `0alias` is `0` then the keyword + (inject(' theorem/- -/hidden : True := trivial'), command), + (inject(' alias/- -/hidden := Nat.add_comm'), command), + (inject('theorem a_hidden : True := trivial theorem/- -/b_hidden : True := trivial'), command), + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0alias hidden := Nat.add_comm'), command), + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0theorem hidden : True := trivial'), command), + (good.replace(':= trivial', ':= by\n exact/- -/sorry', 1), 'admission token in ClosedSuperlevel: sorry'), + # Lean's non-decimal numerals end where Lean ends them (hex, binary, octal, exponent, `_` separators) + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0x1Ftheorem hidden : True := trivial'), command), + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 1e5theorem hidden : True := trivial'), command), + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 1_0theorem hidden : True := trivial'), command), + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0o7instance hidden : Inhabited Nat := ⟨0⟩'), command), + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0b1axiom hidden : False'), 'admission token in ClosedSuperlevel: axiom'), + (good.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0x1Fset_option maxHeartbeats 0'), command), + (inject(' reprove superlevel_mono by trivial'), command), + (inject(' declare_aesop_exception hidden'), command), + (inject(' seal superlevel_set'), command), + (inject(' unset_option maxHeartbeats'), command), + (good.replace(':= trivial', ':= by/- -/native_decide', 1), 'admission token in ClosedSuperlevel: native_decide'), + (inject(' unif_hint (x : Nat) where ⊢ x =?= x'), command), + (inject(' recall superlevel_set : Nat := 0'), command), + (inject(' add_decl_doc superlevel_set'), command), + (inject(' nonrec def hidden : Nat := 0'), command), (inject('theorem a_hidden : True := trivial theorem b_hidden : True := trivial'), command), (inject('theorem a_hidden : True := by\n open Classical in exact trivial'), command), (inject('variable (h : False) in theorem hidden : True := trivial'), command), @@ -340,10 +488,23 @@ def inject(line): for text, message in cases: with self.subTest(message=message, text=text[-70:]), self.assertRaisesRegex(ValueError, re.escape(message)): self.c.scan_module(text, 'ClosedSuperlevel') - # Every command keyword the scanner knows is refused somewhere other than the start of a whitelisted line. + # Every command keyword the scanner knows is refused somewhere other than the start of a whitelisted line, + # indented after the namespace opening included (the C262 G2 position). for keyword in self.c.COMMANDS: with self.subTest(keyword=keyword), self.assertRaises(ValueError): self.c.scan_module(inject('theorem k_hidden : True := trivial ' + keyword), 'ClosedSuperlevel') + with self.subTest(keyword=keyword, position='indented after namespace'), self.assertRaises(ValueError): + self.c.scan_module(good.replace('namespace TorusFiltration\n', 'namespace TorusFiltration\n ' + keyword + ' hidden\n'), 'ClosedSuperlevel') + # Identifiers that merely contain a keyword, or dotted components, are not keywords (no false refusal). + for text in (good.replace(':= trivial', ':= (fun (_ : Foo.alias = 0) => trivial) rfl', 1), + good.replace(':= trivial', ':= (fun (foo2alias : True) => foo2alias) trivial', 1), + good.replace(':= trivial', ':= (fun (alias_like theorem_like : True) => theorem_like) trivial trivial', 1), + good.replace(':= trivial', ':= (Classical.byContradiction fun h => h trivial)', 1)): + self.assertEqual(self.c.scan_module(text, 'ClosedSuperlevel'), INVENTORY['ClosedSuperlevel']) + # A `where` clause adds a dotted auxiliary declaration that no keyword list refuses: the scanner accepts it + # and the elaborated census (Census.lean, `finish`) is what refuses it. Recorded here so the boundary is explicit. + where_clause = good.replace('theorem superlevel_mono : True := trivial', 'theorem superlevel_mono : True := trivial\n where hidden : True := trivial') + self.assertEqual(self.c.scan_module(where_clause, 'ClosedSuperlevel'), INVENTORY['ClosedSuperlevel']) class ParserControls(unittest.TestCase): @@ -471,7 +632,12 @@ def test_emit_writes_exactly_the_audit_types_positive_and_controls(self): self.c.emit(out) self.assertEqual({p.name for p in out.iterdir()}, set(EMITTED)) self.assertEqual({p.name for p in out.iterdir()}, - {'Audit.lean', 'Types.lean', 'Positive.lean'} | {n + '.lean' for n in self.c.CONTROLS}) + {'Audit.lean', 'Types.lean', 'Positive.lean', 'Census.lean'} | {n + '.lean' for n in self.c.CONTROLS}) + census = (out / 'Census.lean').read_text() + self.assertTrue(census.startswith('import TorusFiltration\n')) + for needed in ('isInternalDetail', 'findDeclarationRanges?', 'getModuleIdxFor?', '`TorusTopology', '`ClosedSuperlevel', + '`TorusFiltration', 'CENSUS_END', '"internal" else "user"', '"range" else "generated"'): + self.assertIn(needed, census) audit = (out / 'Audit.lean').read_text().splitlines() self.assertEqual(audit[0], 'import TorusFiltration') self.assertEqual(audit[1:], ['#print axioms ' + n for n in self.c.targets(meta)]) @@ -556,7 +722,9 @@ def test_replay_contract(self): 'printf \'%s\\n\' "$LEANCHECKER_COMMAND" > "$TORUS_OUT/leanchecker.cmd"', 'run_lean leanchecker $LEANCHECKER_COMMAND', 'run_lean positive lean -DwarningAsError=true', 'run_lean axioms lean -DwarningAsError=true', - 'run_lean types lean -DwarningAsError=true'): + 'run_lean types lean -DwarningAsError=true', + 'run_lean census lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Census.lean"', + 'set -euo pipefail\n# The outer Python mode is the one named on each command line below, never an ambient PYTHONOPTIMIZE (C262 G1).\nunset PYTHONOPTIMIZE\n'): self.assertIn(required, self.replay, required) for module in ('TorusTopology', 'ClosedSuperlevel', 'TorusFiltration'): self.assertIn('run_lean build-%s lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/%s.olean" "$TORUS_SIDE/%s.lean"' @@ -690,6 +858,22 @@ def test_module_mutations_are_detected(self): 'unexpected column-0 line in ClosedSuperlevel:'), (original.replace('\nend TorusFiltration', '\n theorem hidden : True := trivial\nend TorusFiltration'), 'command token outside a column-0 declaration in ClosedSuperlevel:'), + # C262 G2: an indented imported `alias` immediately after the namespace opening, refused by the source CLI + (original.replace('namespace TorusFiltration\n', 'namespace TorusFiltration\n alias hidden := Nat.add_comm\n'), + 'command token outside a column-0 declaration in ClosedSuperlevel:'), + (original.replace('theorem superlevel_mono : True := trivial', + 'theorem superlevel_mono : True := trivial alias hidden := Nat.add_comm'), + 'command token outside a column-0 declaration in ClosedSuperlevel:'), + (original.replace('\nend TorusFiltration', '\nalias hidden := Nat.add_comm\nend TorusFiltration'), + 'unexpected column-0 line in ClosedSuperlevel:'), + (original.replace('\nend TorusFiltration', '\n theorem/- -/hidden : True := trivial\nend TorusFiltration'), + 'command token outside a column-0 declaration in ClosedSuperlevel:'), + (original.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0alias hidden := Nat.add_comm'), + 'command token outside a column-0 declaration in ClosedSuperlevel:'), + (original.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0x1Ftheorem hidden : True := trivial'), + 'command token outside a column-0 declaration in ClosedSuperlevel:'), + (original.replace('noncomputable def superlevel_set : Nat := 0', 'noncomputable def superlevel_set : Nat := 0b1axiom hidden : False'), + 'admission token in ClosedSuperlevel: axiom'), (original.replace('namespace TorusFiltration', 'namespace ResearchFormalCoreR1'), 'handoff namespace left in place: ClosedSuperlevel')] for text, message in cases: @@ -768,6 +952,11 @@ def mutate(m): (setter(('provenance',), 'none'), 'provenance object'), (setter(('extra',), 1), 'SOURCE_FILES schema keys'), (deleter(('provenance',)), 'SOURCE_FILES schema keys'), + (deleter(('census_auxiliary',)), 'SOURCE_FILES schema keys'), + (setter(('census_auxiliary',), 'TorusFiltration.torus_periodBasis.congr_simp'), 'census_auxiliary must list dotted auxiliary names'), + (setter(('census_auxiliary',), ['TorusFiltration.hidden']), 'census_auxiliary must list dotted auxiliary names'), + (setter(('census_auxiliary',), ['Other.torus_periodBasis.congr_simp']), 'census_auxiliary must list dotted auxiliary names'), + (setter(('census_auxiliary',), ['TorusFiltration.torus_periodBasis.congr_simp'] * 2), 'census_auxiliary must list dotted auxiliary names'), (setter(('schema',), 2), 'SOURCE_FILES schema version'), (setter(('schema',), '1'), 'SOURCE_FILES schema version'), (setter(('schema',), True), 'SOURCE_FILES schema version'), @@ -838,9 +1027,27 @@ def test_complete_evidence_yields_a_bounded_receipt(self): for name, digest in receipt['log_sha256'].items(): self.assertEqual(hashlib.sha256((out / name).read_bytes()).hexdigest(), digest, name) self.assertEqual(set(receipt['log_sha256']), {p.name for p in out.iterdir() if p.is_file()} - {'receipt.json'}) + self.assertEqual(set(receipt['log_sha256']), set(self.c.EVIDENCE_FILES)) + self.assertEqual(len(receipt['log_sha256']), 44) + self.assertEqual(receipt['census'], {'constants': 58 + len(self.c.metadata()['census_auxiliary']) + len(INTERNAL_GENERATED), + 'user_declarations': 58, + 'generated_user': sorted(self.c.metadata()['census_auxiliary']), + 'internal_generated': len(INTERNAL_GENERATED)}) + self.assertIn('census.log', receipt['log_sha256']) self.assertIn('axioms.log', receipt['log_sha256']) self.assertIn('leanchecker.cmd', receipt['log_sha256']) self.assertIn('Positive.lean', receipt['log_sha256']) + self.assertIn('tests-optimized.log', receipt['log_sha256']) + # C262 G3: a receipt is never replaced. A second finish on the same directory is refused and leaves the + # old bytes intact, with or without a newly failing input; no digest of the receipt itself appears. + frozen = (out / 'receipt.json').read_bytes() + self.assertFails(f.run('finish', str(out)), 'receipt.json already present') + self.assertEqual((out / 'receipt.json').read_bytes(), frozen) + (out / 'leanchecker.status').write_text('1\n') + self.assertFails(f.run('finish', str(out)), 'receipt.json already present') + self.assertEqual((out / 'receipt.json').read_bytes(), frozen) + (out / 'leanchecker.status').write_text('0\n') + self.assertNotIn('receipt.json', receipt['log_sha256']) # An operator's --fresh run is recorded as such, with leanchecker's own progress line tolerated. (out / 'receipt.json').unlink() (out / 'leanchecker.cmd').write_text(LEANCHECKER_FRESH + '\n') @@ -860,6 +1067,15 @@ def test_every_weakening_withholds_the_receipt(self): axioms = (out / 'axioms.log').read_text() types_log = (out / 'types.log').read_text() audit = (out / 'Audit.lean').read_text() + def census_with(row): + lines = (out / 'census.log').read_text().splitlines(True) + body = sorted(lines[:-1] + ['%s %s\n' % row]) + return ''.join(body) + 'CENSUS_END %d\n' % len(body) + + def census_without(name): + lines = (out / 'census.log').read_text().splitlines(True) + body = [l for l in lines[:-1] if not l.startswith(name + ' ')] + return ''.join(body) + 'CENSUS_END %d\n' % len(body) cases = [ ('build-TorusTopology.status', '1\n', 'missing successful process: build-TorusTopology'), ('leanchecker.status', '', 'missing successful process: leanchecker'), @@ -875,6 +1091,20 @@ def test_every_weakening_withholds_the_receipt(self): ('axioms.log', 'warning: noise\n' + axioms, 'unrecognized audit output'), ('types.log', ''.join(types_log.splitlines(True)[1:]), 'type inventory mismatch'), ('types.log', types_log + 'error: crash\n', 'type diagnostic'), + # C262 G2 closure: the elaborated census. N = the fixture's row count. + ('census.log', census_with(('TorusFiltration.superlevel_mono.hidden', 'user range')), "user-written declarations outside the inventory: ['TorusFiltration.superlevel_mono.hidden']"), + ('census.log', census_with(('TorusFiltration.superlevel_mono.proof_1', 'internal range')), "user-written declarations with internal-style names: ['TorusFiltration.superlevel_mono.proof_1']"), + ('census.log', census_with(('TorusFiltration.superlevel_mono._hidden', 'internal range')), "user-written declarations with internal-style names: ['TorusFiltration.superlevel_mono._hidden']"), + ('census.log', census_with(('TorusFiltration.superlevel_mono.other_simp', 'user generated')), "compiler-generated constants not listed in census_auxiliary: ['TorusFiltration.superlevel_mono.other_simp']"), + ('census.log', census_without('TorusFiltration.superlevel_mono'), "inventory targets absent from the census: ['TorusFiltration.superlevel_mono']"), + ('census.log', census_without('TorusFiltration.torus_periodBasis.congr_simp'), "census_auxiliary entries absent or not compiler-generated: ['TorusFiltration.torus_periodBasis.congr_simp']"), + ('census.log', (out / 'census.log').read_text().replace('TorusFiltration.torus_periodBasis.congr_simp user generated', 'TorusFiltration.torus_periodBasis.congr_simp user range'), + "user-written declarations outside the inventory: ['TorusFiltration.torus_periodBasis.congr_simp']"), + ('census.log', (out / 'census.log').read_text().replace('CENSUS_END', 'TorusFiltration.superlevel_mono.hidden user range\nCENSUS_END'), 'census count mismatch'), + ('census.log', ''.join((out / 'census.log').read_text().splitlines(True)[:-1]), 'census terminator absent'), + ('census.log', 'warning: noise\n' + (out / 'census.log').read_text(), 'unrecognized census output'), + ('census.log', (out / 'census.log').read_text().replace(' user range\n', '\n', 1), 'unrecognized census output'), + ('census.status', '1\n', 'missing successful process: census'), ('RejectSuperlevelSignFlip.log', FALSE_LOG.format('RejectSuperlevelSignFlip').replace('False', 'True'), 'not the intended False-goal diagnostic'), ('RejectSuperlevelSignFlip.status', '0\n', 'false-statement control must exit exactly one'), @@ -900,17 +1130,59 @@ def test_every_weakening_withholds_the_receipt(self): self.assertFalse((out / 'receipt.json').exists(), 'receipt written despite refusal') finally: (out / name).write_text(saved) - for name, message in (('leanchecker.cmd', 'leanchecker invocation record absent'), - ('Positive.lean', 'emitted Lean file changed across execution: Positive.lean'), - ('RejectSuperlevelBelowThreshold.status', '[Errno 2] No such file or directory')): - with self.subTest(name=name, message=message): - saved = (out / name).read_text() + # C262 G3: every one of the 44 required evidence members is required; removing any one withholds the receipt. + self.assertEqual({p.name for p in out.iterdir()}, set(self.c.EVIDENCE_FILES)) + for name in sorted(self.c.EVIDENCE_FILES): + with self.subTest(removed=name): + saved = (out / name).read_bytes() (out / name).unlink() try: - self.assertFails(f.run('finish', str(out)), message) + self.assertFails(f.run('finish', str(out)), "evidence membership differs: missing ['%s'], unexpected []" % name) self.assertFalse((out / 'receipt.json').exists(), 'receipt written despite refusal') finally: - (out / name).write_text(saved) + (out / name).write_bytes(saved) + # An unexpected member, a symlinked member and a stray subdirectory are refused too. + (out / 'extra.log').write_text('') + self.assertFails(f.run('finish', str(out)), "evidence membership differs: missing [], unexpected ['extra.log']") + (out / 'extra.log').unlink() + (out / 'stray').mkdir() + self.assertFails(f.run('finish', str(out)), "evidence membership differs: missing [], unexpected ['stray']") + (out / 'stray').rmdir() + # A required member that is a directory is not a regular file. + saved = (out / 'tests.log').read_bytes() + (out / 'tests.log').unlink() + (out / 'tests.log').mkdir() + self.assertFails(f.run('finish', str(out)), 'evidence member is not a regular file: tests.log') + self.assertFalse((out / 'receipt.json').exists()) + (out / 'tests.log').rmdir() + (out / 'tests.log').write_bytes(saved) + saved = (out / 'tests.log').read_bytes() + (out / 'tests.log').unlink() + os.symlink('tests-optimized.log', out / 'tests.log') + self.assertFails(f.run('finish', str(out)), 'evidence member is not a regular file: tests.log') + self.assertFalse((out / 'receipt.json').exists()) + (out / 'tests.log').unlink() + (out / 'tests.log').write_bytes(saved) + # A symlinked evidence directory is refused before anything is read. + os.symlink(out, Path(tmp) / 'evidence-link') + self.assertFails(f.run('finish', str(Path(tmp) / 'evidence-link')), 'evidence directory absent, not a directory, or a symlink') + (Path(tmp) / 'evidence-link').unlink() + # The exclusive write itself (not only the pre-check) refuses an existing file and a planted symlink, intact. + frozen = b'frozen receipt bytes\n' + (out / 'planted.json').write_bytes(frozen) + with self.assertRaises(FileExistsError): + self.c.write_new_file(out / 'planted.json', 'new\n') + self.assertEqual((out / 'planted.json').read_bytes(), frozen) + (out / 'planted.json').unlink() + os.symlink('absent-target', out / 'planted.json') + with self.assertRaises(OSError): + self.c.write_new_file(out / 'planted.json', 'new\n') + self.assertFalse((out / 'absent-target').exists()) + (out / 'planted.json').unlink() + # A pre-existing receipt (even a symlink to nothing) is never replaced. + os.symlink('absent-target', out / 'receipt.json') + self.assertFails(f.run('finish', str(out)), 'receipt.json already present') + (out / 'receipt.json').unlink() self.assertEqual(f.run('finish', str(out)).returncode, 0) From 940dffc9bac927250c03a8194aaa75552cdda060 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 11 Oct 2026 22:44:18 +0000 Subject: [PATCH 4/5] Companion torus_filtration_20261011: register the C263 SuperlevelBar and C264 OrdinaryH0 successors (compiled at the pin; FORMAL HOLD until nonauthor exact-source review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One forward commit on top of the C262 AMEND head 4c33d8cd. It registers two compiled Lean modules in the existing, reviewed gate; it moves no status label. Modules. SuperlevelBar.lean (C263 successor, 15309 B, sha256 346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9; handoff d74dc8b2…, 14904 B, failed at the pin with warnings as errors on the deprecated `if_pos` at line 123; the successor replaces `if_pos hne` by `ite_eq_left hne` in superlevelBar_death_eq_sSup_of_nonempty and records it in the docstring; imports Mathlib only; 20 theorems, 1 abbrev, 3 defs). OrdinaryH0.lean (C264 successor, 19803 B, sha256 3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88; handoff 261dd052…, 18469 B, failed at the pin; owner repair per 428/6113372506, full diff posted in 428/6113438262: variable scope split, explicit rw/erw naturality proof, Functor.isoWhiskerLeft, three ASCII iota names, no statement changed; imports Mathlib and ClosedSuperlevel; 20 theorems, 7 defs). Both copied byte-exactly; neither changed here. Root module TorusFiltration.lean imports the four modules in dependency order. TorusTopology.lean, ClosedSuperlevel.lean and the Actions workflow file are byte-identical. check.py. MODULES, ROOT_SOURCE, REQUIRED_FILES, BUILDS (build-SuperlevelBar, build-OrdinaryH0 before build-TorusFiltration), the modules-mode leanchecker command (five modules; the three-module form is now refused), the census over five modules, EVIDENCE_FILES 44 -> 54 (two builds and two controls, not 48: each control adds a .lean/.log/.status triple). Provenance: ORIGINAL_SHA256 gains the two handoff originals, ORIGINAL_BYTES records all four byte counts, SUCCESSORS records both successors (hashes, bytes, fixes, authors, imports, range-aware census 25 = 24 + 0 + 1 and 38 = 27 + 0 + 11, cited comments, FORMAL HOLD, credit 0) and SOURCE_FILES.json must carry the record whole; NAMESPACE_MAPPING notes that the C26x modules were authored directly in namespace TorusFiltration. Two new false controls, each run through Lean before being relied on and refused with exactly `⊢ False` (exit 1): RejectEssentialDeathBound (C263: the death/start bound asserted on the essential default branch; the proposition of the handoff's FALSE_CONTROL_PROPOSAL, Math- #428 comment 6113033351, with its tactic replaced) and RejectReducedPointClass (C264: the ordinary point class of the one-point space with ℤ-module coefficients asserted NOT to be augmented to the identity). Scanner: the registered OrdinaryH0.lean carries `import ClosedSuperlevel` and `open scoped Simplicial`, which the whitelist refused, so PRELUDE admits an import of a companion module listed before the scanned module in MODULES (self, forward and root imports refused as `companion import out of dependency order`) and `open scoped ` (capitalized names only, nothing else on the line); COMMANDS, TOKEN, the admission list, the lexer and every other rule are unchanged, and both forms carry negative controls. census_auxiliary gains no entry. test_torus_filtration.py: inventories for both modules as scan_module reports them, the 12 internal generated names of the two censuses, the counts (81 theorems, 109 declarations, 22 defs, 3 abbrevs, 3 instances, 54 evidence members), nine single-field changes to the successor record through the CLI (its seven other fields only through the whole-record comparison), the new controls in the fixture, the five-build dependency order in replay.sh, the new leanchecker command, the document checks (identities, fix, diff pointer, census numbers, FORMAL HOLD), scanner controls for the two prelude forms; every existing negative control still fails for its reason. replay.sh: two build lines in dependency order, the leanchecker command, the control loop names, one comment. README.md and SCOPE.md: both modules registered (declarations, identities, provenance, census, what is NOT established from the modules' own docstrings), every count updated, a registration section stating what this commit does not establish. SOURCE_FILES.json regenerated by the out-of-tree generator, which now refuses a registered module whose bytes are not the recorded successor. Checked locally at Lean v4.34.1 / Mathlib d13f23b7 on the registered bytes before this commit: all five modules compile with warnings as errors (exit 0, empty logs); the emitted Audit (109 #print axioms, all within propext, Classical.choice, Quot.sound), Types (81 #check), Census (133 constants = 109 user range + 1 user generated + 23 internal generated) and Positive files exit 0; `leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration` exits 0 with no output (53 s at 2 threads); both new controls exit 1 with exactly `⊢ False` and `check.py negative` records REJECTED_BY_LEAN. Protocol tests: 28 in both Python modes. These are records of computations on a worktree, not a receipt; the receipt is the hosted run. Registration is not review and not acceptance. The C263 and C264 handoffs' FORMAL HOLD stands until a nonauthor exact-source review of the compiled successors; alignment PENDING_INDEPENDENT_REVIEW; organizational-independence credit 0 (same project account compiled, repaired and registered both). Scientific effect NONE. Before the push, this lane's own adversarial verification of the first form of this commit (two verifiers, same account, credit 0) refuted one sentence and found further documentation slips; all are fixed here, so the registration stays one forward commit: the README no longer implies the successors were reviewed (none exists; this lane compiled, repaired and registered them and has not reviewed them); the open C264 obligation of concrete ordinary-H0 controls (owner task item 4, Math- #428 comment 6113277485) is disclosed as not provided; the C264 census list names three eq_1 lemmas, not two; the C264 names are the handoff's except the three iota respellings; the docstring-line counts state the blank separator; the pre-registration measured run had 41 evidence files; the successor-byte check is attributed to the in-tree protocol tests rather than only the out-of-tree generator; the C263 false control is described as the proposition of the handoff's FALSE_CONTROL_PROPOSAL with its tactic changed; the SCOPE no longer says every successor-record field has its own control; the C264 attribution discloses the root and API-support contributions (including the naturality rewrite chain proposed by api_support); the C264 change summary says the three names contain iota rather than end in it; original_status is scoped to the C254 pair; the stale workflow comment ('twelve lean invocations') is disclosed rather than edited. The scanner's two new prelude forms (an import of an earlier companion module, open scoped ) were needed by OrdinaryH0.lean and admit no declaration or command; both verifiers probed them and found no escape, and they carry negative controls. The full replay with LEAN_NUM_THREADS unset on this four-core box was killed in leanchecker at the 13.36 GB memory limit (twice); at two threads, the hosted job's setting, the five-module leanchecker peaks near 8.4 GB and the replay passes. replay.sh therefore defaults LEAN_NUM_THREADS to 2 when unset, and the README records the measured footprint (its earlier '6.6 GB resident' was the three-module figure). A second adversarial pass on the fix delta (same account, credit 0) found the SCOPE line and the fixture docstring still claiming per-field controls for every manifest field; both now state the seven successor-record fields covered only by the whole-record comparison. Memory figures are given in GiB (8.4-8.7 GiB peak, 13.36 GiB limit), the measured-run comparison names the census step and the leanchecker growth, and the replay header names the four modules. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cz7WZybv8znP64SpPj6sWY --- .../torus_filtration_20261011/OrdinaryH0.lean | 339 +++++++++++++++++ .../torus_filtration_20261011/README.md | 355 +++++++++++++++--- companions/torus_filtration_20261011/SCOPE.md | 110 ++++-- .../SOURCE_FILES.json | 182 +++++++-- .../SuperlevelBar.lean | 299 +++++++++++++++ .../TorusFiltration.lean | 2 + companions/torus_filtration_20261011/check.py | 149 ++++++-- .../torus_filtration_20261011/replay.sh | 21 +- .../test_torus_filtration.py | 293 +++++++++++++-- 9 files changed, 1575 insertions(+), 175 deletions(-) create mode 100644 companions/torus_filtration_20261011/OrdinaryH0.lean create mode 100644 companions/torus_filtration_20261011/SuperlevelBar.lean diff --git a/companions/torus_filtration_20261011/OrdinaryH0.lean b/companions/torus_filtration_20261011/OrdinaryH0.lean new file mode 100644 index 000000000..7bc5f8002 --- /dev/null +++ b/companions/torus_filtration_20261011/OrdinaryH0.lean @@ -0,0 +1,339 @@ +import Mathlib +import ClosedSuperlevel + +/-! +# Actual ordinary singular H0 and path components, naturally + +C264 isolated source candidate. Compilation and kernel audit: NOT_RUN. +The homology objects and maps below are Mathlib's singular homology functor. +The comparison is its existing objectwise `TopCat.singularHomology₀Iso`; +its naturality is proved here from actual zero-cycle generators. + +The coefficient object belongs to an arbitrary preadditive category with +the required coproducts and homology. Nonzero/distinction controls explicitly +require `𝟙 R ≠ 0`; no nonzero claim is made for a zero coefficient object. + +This supplies the component/H0 comparison for the existing closed-superlevel +filtration. It supplies no Morse chart, critical-level attainment theorem, +interval decomposition, elder correspondence, Field adapter, count identity, +stochastic law, or scientific-status promotion. + +Owner repairs at the pin (Anthropic/Claude lane, companion owner, recorded as the +actual repair author; handoff bytes SHA-256 +261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e did not elaborate +with `-DwarningAsError=true`, Math- #428 comments 6113300903 and 6113372506): the +homology instances `[Preadditive C] [CategoryWithHomology C]` enter the `variable` +scope only after `ordinaryH0_componentCoproductMap_iota`, `ordinaryH0_componentFiltration` +and `ordinaryH0_componentFiltration_map_iota`, which do not use them (the two filtration +declarations therefore precede the homology ones; no statement changed); +`ordinaryH0_iso_naturality` is proved by explicit `rw`/`erw` reassociation of both sides +(the source author's five-step `calc` elaborated with an unresolved `Trans` instance +at the pin) instead of a `simp only` that left the right side unreassociated; `isoWhiskerLeft` is referred to as `Functor.isoWhiskerLeft`; the +three declaration names ending in `ι` are spelled `…_iota` / `…Iota…` for the +companion's ASCII identifier rule. No statement changed. +-/ + +noncomputable section + +open CategoryTheory Limits AlgebraicTopology +open scoped Simplicial + +universe w v u + +namespace TorusFiltration + +/-- Proves: actual path-component quotients form a functor on topological spaces. +Method: use the existing continuous-map quotient map and its identity/composition laws. +Does not establish: equality of connected and path-connected components. -/ +def ordinaryH0_componentFunctor : TopCat.{w} ⥤ Type w where + obj X := ZerothHomotopy X + map f := TypeCat.ofHom (superlevel_componentMap f.hom) + map_id X := by + apply ConcreteCategory.hom_ext + intro q + exact congrFun superlevel_componentMap_id q + map_comp f g := by + apply ConcreteCategory.hom_ext + intro q + exact congrFun (superlevel_componentMap_comp f.hom g.hom) q + +variable {C : Type u} [Category.{v} C] [HasCoproducts.{w} C] + +/-- Proves: the component-indexed coproduct construction is a functor. +Method: compose the actual component functor with the categorical coproduct functor. +Does not establish: an identification with homology until naturality is proved below. -/ +def ordinaryH0_componentCoproductFunctor (R : C) : TopCat.{w} ⥤ C := + ordinaryH0_componentFunctor ⋙ sigmaConst.obj R + +/-- Proves: a coproduct generator maps to the component of its continuous image. +Method: the universal coproduct map sends each inclusion to its indexed image. +Does not establish: that distinct source components stay distinct. -/ +theorem ordinaryH0_componentCoproductMap_iota (R : C) {X Y : TopCat.{w}} + (f : X ⟶ Y) (q : ZerothHomotopy X) : + Sigma.ι (fun _ : ZerothHomotopy X => R) q ≫ + (ordinaryH0_componentCoproductFunctor R).map f = + Sigma.ι (fun _ : ZerothHomotopy Y => R) (superlevel_componentMap f.hom q) := by + simp [ordinaryH0_componentCoproductFunctor, ordinaryH0_componentFunctor, sigmaConst] + +/-- Proves: the existing closed-superlevel family has a component-indexed coproduct filtration. +Method: compose its actual continuous inclusions with the proved component coproduct functor. +Does not establish: regularity, finite dimensionality, or Morse hypotheses for the height function. -/ +def ordinaryH0_componentFiltration {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (R : C) : ℝ ⥤ C := + superlevel_filtration g ⋙ ordinaryH0_componentCoproductFunctor R + +/-- Proves: a filtration component generator maps by the existing actual component inclusion. +Method: specialize the coproduct generator map formula to a closed-superlevel inclusion. +Does not establish: a reverse inclusion or endpoint deletion. -/ +theorem ordinaryH0_componentFiltration_map_iota {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (R : C) {s t : ℝ} (hst : s ≤ t) + (q : ZerothHomotopy (superlevel_set g s)) : + Sigma.ι (fun _ : ZerothHomotopy (superlevel_set g s) => R) q ≫ + (ordinaryH0_componentFiltration g R).map (homOfLE hst) = + Sigma.ι (fun _ : ZerothHomotopy (superlevel_set g t) => R) + (superlevel_componentInclusion g hst q) := by + exact ordinaryH0_componentCoproductMap_iota R + (TopCat.ofHom (superlevel_inclusion g hst)) q + +variable [Preadditive C] [CategoryWithHomology C] + +/-- Proves: a zero-simplex defines a morphism into actual simplicial homology. +Method: include its chain generator, lift through the zero differential, then take its class. +Does not establish: a replacement definition of homology or any naturality premise. -/ +def ordinaryH0_simplicialPointClass (S : SSet.{w}) (R : C) (x : S _⦋0⦌) : + R ⟶ S.homology R 0 := + (S.chainComplex R).liftCycles (S.ιChainComplex x) 0 (by simp) (by simp) ≫ + (S.chainComplex R).homologyπ 0 + +/-- Proves: the existing simplicial H0 isomorphism sends a point class to its component. +Method: apply Mathlib's zero-cycle generator formula. +Does not establish: naturality merely from the existence of the objectwise isomorphism. -/ +theorem ordinaryH0_simplicialPointClass_iso (S : SSet.{w}) (R : C) + (x : S _⦋0⦌) : + ordinaryH0_simplicialPointClass S R x ≫ (S.homology₀Iso R).hom = + Sigma.ι (fun _ : S.π₀ => R) (SSet.π₀.mk x) := by + simpa only [ordinaryH0_simplicialPointClass, Category.assoc] using + SSet.liftCycles_ιChainComplex_homologyπ_homology₀Iso_hom S R x + +/-- Proves: the actual simplicial homology map carries a point class to its image class. +Method: homology projection naturality, cycle-lift naturality, and the chain generator formula. +Does not establish: a transported or postulated substitute for the actual homology map. -/ +theorem ordinaryH0_simplicialPointClass_map (R : C) {S T : SSet.{w}} + (f : S ⟶ T) (x : S _⦋0⦌) : + ordinaryH0_simplicialPointClass S R x ≫ SSet.homologyMap f R 0 = + ordinaryH0_simplicialPointClass T R (f.app _ x) := by + simp only [ordinaryH0_simplicialPointClass, SSet.homologyMap, Category.assoc, + HomologicalComplex.homologyπ_naturality, + HomologicalComplex.liftCycles_comp_cyclesMap_assoc, SSet.ι_chainComplexMap_f] + +/-- Proves: the singular zero-simplex of a point maps to that of its continuous image. +Method: unfold the point/simplex correspondence and the singular-set map. +Does not establish: a chain or homology identification by itself. -/ +theorem ordinaryH0_toSSet_pointMap {X Y : TopCat.{w}} (f : X ⟶ Y) (x : X) : + (TopCat.toSSet.map f).app _ (TopCat.toSSetObj₀Equiv.symm x) = + TopCat.toSSetObj₀Equiv.symm (f x) := by + rfl + +/-- Proves: each point has its actual ordinary singular zero-homology class morphism. +Method: use the actual singular zero-simplex and the cycle/projection construction above. +Does not establish: a free-module definition standing in for singular H0. -/ +def ordinaryH0_pointClass (X : TopCat.{w}) (R : C) (x : X) : + R ⟶ ((singularHomologyFunctor C 0).obj R).obj X := + ordinaryH0_simplicialPointClass (TopCat.toSSet.obj X) R + (TopCat.toSSetObj₀Equiv.symm x) + +/-- Proves: actual continuous-map-induced singular H0 maps transport point classes. +Method: specialize the proved simplicial generator naturality to the singular-set functor. +Does not establish: injectivity of the induced map. -/ +theorem ordinaryH0_pointClass_map (R : C) {X Y : TopCat.{w}} + (f : X ⟶ Y) (x : X) : + ordinaryH0_pointClass X R x ≫ ((singularHomologyFunctor C 0).obj R).map f = + ordinaryH0_pointClass Y R (f x) := by + change ordinaryH0_simplicialPointClass (TopCat.toSSet.obj X) R + (TopCat.toSSetObj₀Equiv.symm x) ≫ + SSet.homologyMap (TopCat.toSSet.map f) R 0 = + ordinaryH0_simplicialPointClass (TopCat.toSSet.obj Y) R + (TopCat.toSSetObj₀Equiv.symm (f x)) + rw [ordinaryH0_simplicialPointClass_map, ordinaryH0_toSSet_pointMap] + +/-- Proves: Mathlib's existing topological comparison sends actual point classes to components. +Method: combine the simplicial generator formula with the actual path-component equivalence. +Does not establish: any connected-component substitution. -/ +theorem ordinaryH0_pointClass_iso (X : TopCat.{w}) (R : C) (x : X) : + ordinaryH0_pointClass X R x ≫ (TopCat.singularHomology₀Iso X R).hom = + Sigma.ι (fun _ : ZerothHomotopy X => R) (ZerothHomotopy.mk x) := by + change ordinaryH0_simplicialPointClass (TopCat.toSSet.obj X) R + (TopCat.toSSetObj₀Equiv.symm x) ≫ + ((SSet.homology₀Iso (TopCat.toSSet.obj X) R).hom ≫ + (sigmaConst.obj R).map TopCat.zerothHomotopyEquiv.toIso.inv) = _ + rw [← Category.assoc, ordinaryH0_simplicialPointClass_iso] + simp [sigmaConst] + +/-- Proves: inverse comparison takes each component generator to any representing point class. +Method: cancel the comparison isomorphism and use the point-class formula. +Does not establish: a choice of distinguished geometric representative. -/ +theorem ordinaryH0_componentIota_isoInv (X : TopCat.{w}) (R : C) (x : X) : + Sigma.ι (fun _ : ZerothHomotopy X => R) (ZerothHomotopy.mk x) ≫ + (TopCat.singularHomology₀Iso X R).inv = ordinaryH0_pointClass X R x := by + apply (cancel_mono (TopCat.singularHomology₀Iso X R).hom).1 + simp only [Category.assoc, Iso.inv_hom_id, Category.comp_id, ordinaryH0_pointClass_iso] + +/-- Proves: morphisms out of actual singular H0 agree if they agree on all point classes. +Method: cancel the inverse comparison, use coproduct extensionality and quotient surjectivity. +Does not establish: a basis of geometric maxima or finiteness of components. -/ +theorem ordinaryH0_hom_ext (X : TopCat.{w}) (R : C) {A : C} + {f g : ((singularHomologyFunctor C 0).obj R).obj X ⟶ A} + (h : ∀ x : X, ordinaryH0_pointClass X R x ≫ f = ordinaryH0_pointClass X R x ≫ g) : + f = g := by + apply (cancel_epi (TopCat.singularHomology₀Iso X R).inv).1 + apply Sigma.hom_ext + intro q + obtain ⟨x, rfl⟩ := ZerothHomotopy.mk_surjective q + simpa only [← Category.assoc, ordinaryH0_componentIota_isoInv] using h x + +/-- Proves: the existing actual singular H0 comparison commutes with every continuous map. +Method: test both composites on actual point classes, transport them, and compare component images. +Does not establish: naturality by adding an assumption or a compatibility record. -/ +theorem ordinaryH0_iso_naturality (R : C) {X Y : TopCat.{w}} (f : X ⟶ Y) : + ((singularHomologyFunctor C 0).obj R).map f ≫ + (TopCat.singularHomology₀Iso Y R).hom = + (TopCat.singularHomology₀Iso X R).hom ≫ + (ordinaryH0_componentCoproductFunctor R).map f := by + apply ordinaryH0_hom_ext X R + intro x + rw [← Category.assoc, ordinaryH0_pointClass_map, ordinaryH0_pointClass_iso] + -- the right side composes through `(ordinaryH0_componentCoproductFunctor R).obj X`, which is + -- `∐ fun _ => R` only after unfolding, so its reassociation is rewritten at default transparency + erw [← Category.assoc, ordinaryH0_pointClass_iso, ordinaryH0_componentCoproductMap_iota] + rfl + +/-- Proves: actual ordinary singular H0 is naturally isomorphic to component-indexed coproducts. +Method: assemble the existing objectwise isomorphisms using the commuting square proved above. +Does not establish: an interval decomposition or persistence-bar classification. -/ +def ordinaryH0_naturalIso (R : C) : + (singularHomologyFunctor C 0).obj R ≅ ordinaryH0_componentCoproductFunctor R := + NatIso.ofComponents (fun X => TopCat.singularHomology₀Iso X R) + (fun f => ordinaryH0_iso_naturality R f) + +/-- Proves: ordinary augmentation sends every actual point-class morphism to the coefficient identity. +Method: use the comparison's augmentation formula and the coproduct universal property. +Does not establish: reduced-H0 vanishing; this retains the ordinary point class. -/ +theorem ordinaryH0_pointClass_augmentation (X : TopCat.{w}) (R : C) (x : X) : + ordinaryH0_pointClass X R x ≫ TopCat.singularHomology₀ε X R = 𝟙 R := by + rw [← TopCat.singularHomology₀Iso_sigma_desc_id X R, ← Category.assoc, + ordinaryH0_pointClass_iso] + simp + +/-- Proves: an actual point class is nonzero for a coefficient object with nonzero identity. +Method: compose a proposed zero class with ordinary augmentation. +Does not establish: nonzero classes for a zero coefficient object. -/ +theorem ordinaryH0_pointClass_ne_zero (X : TopCat.{w}) (R : C) + (hR : (𝟙 R : R ⟶ R) ≠ 0) (x : X) : ordinaryH0_pointClass X R x ≠ 0 := by + intro h + have hε := ordinaryH0_pointClass_augmentation X R x + rw [h, zero_comp] at hε + exact hR hε.symm + +/-- Proves: points in the same actual path component give equal ordinary H0 class morphisms. +Method: cancel the objectwise comparison and compare their component indices. +Does not establish: a converse for zero coefficients. -/ +theorem ordinaryH0_pointClass_eq_of_component_eq (X : TopCat.{w}) (R : C) + (x y : X) (h : ZerothHomotopy.mk x = ZerothHomotopy.mk y) : + ordinaryH0_pointClass X R x = ordinaryH0_pointClass X R y := by + apply (cancel_mono (TopCat.singularHomology₀Iso X R).hom).1 + rw [ordinaryH0_pointClass_iso, ordinaryH0_pointClass_iso, h] + +/-- Proves: the difference of same-component point classes is zero for arbitrary coefficients. +Method: subtract the equality proved from actual path-component equality. +Does not establish: that either individual point class dies. -/ +theorem ordinaryH0_sameComponent_difference_zero (X : TopCat.{w}) (R : C) + (x y : X) (h : ZerothHomotopy.mk x = ZerothHomotopy.mk y) : + ordinaryH0_pointClass X R x - ordinaryH0_pointClass X R y = 0 := by + rw [ordinaryH0_pointClass_eq_of_component_eq X R x y h, sub_self] + +/-- Proves: distinct actual path components have distinct ordinary H0 class morphisms if coefficients are nonzero. +Method: separate the two coproduct injections by an identity/zero component projection. +Does not establish: distinction with zero coefficients or distinction of points within one component. -/ +theorem ordinaryH0_pointClass_ne_of_component_ne (X : TopCat.{w}) (R : C) + (hR : (𝟙 R : R ⟶ R) ≠ 0) (x y : X) + (hxy : ZerothHomotopy.mk x ≠ ZerothHomotopy.mk y) : + ordinaryH0_pointClass X R x ≠ ordinaryH0_pointClass X R y := by + classical + intro h + have hc : Sigma.ι (fun _ : ZerothHomotopy X => R) (ZerothHomotopy.mk x) = + Sigma.ι (fun _ : ZerothHomotopy X => R) (ZerothHomotopy.mk y) := by + simpa only [ordinaryH0_pointClass_iso] using + congrArg (fun k => k ≫ (TopCat.singularHomology₀Iso X R).hom) h + let p : (∐ fun _ : ZerothHomotopy X => R) ⟶ R := + Sigma.desc (fun q => if q = ZerothHomotopy.mk x then 𝟙 R else 0) + apply hR + simpa [p, Ne.symm hxy] using congrArg (fun k => k ≫ p) hc + +/-- Proves: with nonzero coefficients, actual point-class equality is exactly path-component equality. +Method: combine the same-component formula with the separating projection control. +Does not establish: equality of geometric points or connected components. -/ +theorem ordinaryH0_pointClass_eq_iff (X : TopCat.{w}) (R : C) + (hR : (𝟙 R : R ⟶ R) ≠ 0) (x y : X) : + ordinaryH0_pointClass X R x = ordinaryH0_pointClass X R y ↔ + ZerothHomotopy.mk x = ZerothHomotopy.mk y := by + constructor + · intro h + by_contra hn + exact ordinaryH0_pointClass_ne_of_component_ne X R hR x y hn h + · exact ordinaryH0_pointClass_eq_of_component_eq X R x y + +/-- Proves: the actual H0 map sends a difference of point classes to the difference of image classes. +Method: distribute composition over subtraction and use proved actual point-class transport. +Does not establish: death of the individual ordinary point classes. -/ +theorem ordinaryH0_difference_map (R : C) {X Y : TopCat.{w}} (f : X ⟶ Y) (x y : X) : + (ordinaryH0_pointClass X R x - ordinaryH0_pointClass X R y) ≫ + ((singularHomologyFunctor C 0).obj R).map f = + ordinaryH0_pointClass Y R (f x) - ordinaryH0_pointClass Y R (f y) := by + rw [Preadditive.sub_comp, ordinaryH0_pointClass_map, ordinaryH0_pointClass_map] + +/-- Proves: with nonzero coefficients, a mapped difference vanishes exactly when the image points merge in path components. +Method: actual homology-map transport, subtraction cancellation, and the component equality criterion. +Does not establish: a Morse merger event, elder selection, death height, or barcode. -/ +theorem ordinaryH0_difference_map_eq_zero_iff (R : C) (hR : (𝟙 R : R ⟶ R) ≠ 0) + {X Y : TopCat.{w}} (f : X ⟶ Y) (x y : X) : + (ordinaryH0_pointClass X R x - ordinaryH0_pointClass X R y) ≫ + ((singularHomologyFunctor C 0).obj R).map f = 0 ↔ + ZerothHomotopy.mk (f x) = ZerothHomotopy.mk (f y) := by + rw [ordinaryH0_difference_map, sub_eq_zero, ordinaryH0_pointClass_eq_iff Y R hR] + +/-- Proves: the existing actual singular H0 filtration is naturally isomorphic to its component coproduct filtration. +Method: restrict the proved natural comparison along the existing topological filtration. +Does not establish: the later interval, elder, maximum/saddle, count, Field, or stochastic bridges. -/ +def ordinaryH0_filtrationIso {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (R : C) : + superlevel_h0Filtration g R ≅ ordinaryH0_componentFiltration g R := + Functor.isoWhiskerLeft (superlevel_filtration g) (ordinaryH0_naturalIso R) + +/-- Proves: all ordered closed-superlevel inclusion maps satisfy the actual H0/component square. +Method: read the naturality of the proved filtration isomorphism at the preorder morphism. +Does not establish: strict-level conventions or any unproved geometric persistence hypothesis. -/ +theorem ordinaryH0_filtration_naturality {X : Type w} [TopologicalSpace X] + (g : X → ℝ) (R : C) {s t : ℝ} (hst : s ≤ t) : + (superlevel_h0Filtration g R).map (homOfLE hst) ≫ + (ordinaryH0_filtrationIso g R).hom.app t = + (ordinaryH0_filtrationIso g R).hom.app s ≫ + (ordinaryH0_componentFiltration g R).map (homOfLE hst) := + (ordinaryH0_filtrationIso g R).hom.naturality (homOfLE hst) + +/-- Proves: under a closed-superlevel inclusion, a difference vanishes exactly when the two included points are joined in the target closed superlevel. +Method: apply the actual H0 difference control and the existing component/JoinedIn equivalence. +Does not establish: attainment of a critical death threshold or an elder/barcode theorem. -/ +theorem ordinaryH0_filtration_difference_zero_iff_joinedIn + {X : Type w} [TopologicalSpace X] (g : X → ℝ) (R : C) + (hR : (𝟙 R : R ⟶ R) ≠ 0) {s t : ℝ} (hst : s ≤ t) + (x y : superlevel_set g s) : + (ordinaryH0_pointClass (TopCat.of (superlevel_set g s)) R x - + ordinaryH0_pointClass (TopCat.of (superlevel_set g s)) R y) ≫ + (superlevel_h0Filtration g R).map (homOfLE hst) = 0 ↔ + JoinedIn (superlevel_set g t) x.val y.val := by + exact (ordinaryH0_difference_map_eq_zero_iff R hR + (TopCat.ofHom (superlevel_inclusion g hst)) x y).trans + (superlevel_component_eq_iff_joinedIn g t + (superlevel_inclusion g hst x) (superlevel_inclusion g hst y)) + +end TorusFiltration diff --git a/companions/torus_filtration_20261011/README.md b/companions/torus_filtration_20261011/README.md index 2f99b8976..671b4cb7c 100644 --- a/companions/torus_filtration_20261011/README.md +++ b/companions/torus_filtration_20261011/README.md @@ -1,8 +1,12 @@ -# C254 torus quotient and closed-superlevel filtration (isolated Lean companion) - -Dylan Roy — delegated AI work. Source author: OpenAI/Codex lane (C254). Compile fixes and -companion: Anthropic/Claude lane. Scientific effect **NONE**. Organizational-independence -credit **0** for both lanes; no human review. Alignment status `PENDING_INDEPENDENT_REVIEW`. +# C254 torus quotient and closed-superlevel filtration, with the C263 strict-cut and C264 ordinary-H0 modules (isolated Lean companion) + +Dylan Roy — delegated AI work. Source authors: OpenAI/Codex lanes (C254 for `TorusTopology` and +`ClosedSuperlevel`; C263 for `SuperlevelBar`; C264 for `OrdinaryH0`). Compile fixes, the C264 +owner repair and the companion: Anthropic/Claude lane. Scientific effect **NONE**. +Organizational-independence credit **0** for every lane; no human review. Alignment status +`PENDING_INDEPENDENT_REVIEW`. The two C26x modules are registered here as compiled successors +under the handoffs' own **FORMAL HOLD**, which stands until a nonauthor exact-source review of the +compiled bytes (see [C263 and C264 registration](#c263-and-c264-registration-2026-10-11)). Nothing here promotes, discharges or reclassifies any claim. ## Purpose and route rationale @@ -20,7 +24,9 @@ primary manifest at SHA-256 `40cb6ffc…` and the gate at `278989bb…`; any cha review scope for all three. The C255 route finding (6111255007) therefore recommended an isolated companion. This directory is that companion: -- it holds the compile-fixed modules under namespace `TorusFiltration` and a two-line root module; +- it holds the compile-fixed modules under namespace `TorusFiltration` and a four-line root module + (`import TorusTopology`, `import ClosedSuperlevel`, `import SuperlevelBar`, `import OrdinaryH0`, in + dependency order; the two C26x modules joined on 2026-10-11); - it compiles them against the **same** pinned toolchain and dependency lock as `formal/` (`formal/lean-toolchain`, `formal/lakefile.toml`, `formal/lake-manifest.json`), which it reads but never edits; @@ -36,19 +42,27 @@ isolated companion. This directory is that companion: | This lane | local elaboration report 6111093545; pickup 6111139060 | | Original `TorusTopology.lean` (NOT_COMPILED) | SHA-256 `efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4`, 11542 bytes | | Original `ClosedSuperlevel.lean` (NOT_COMPILED) | SHA-256 `1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e`, 7827 bytes | -| Namespace mapping | `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion); no other name changes | +| Namespace mapping | `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion); no other name changes. `SuperlevelBar` and `OrdinaryH0` were authored directly in namespace `TorusFiltration` | +| C263 handoff `SuperlevelBar.lean` (failed at the pin with warnings as errors) | SHA-256 `d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8`, 14904 bytes; Math- PR #428 comments 6113033147 (source), 6113033351 (nonauthor source review), 6113033545 (final handoff audit and owner task: 28/28 static checks, formal acceptance HOLD); allocation PR #419 comment 6112439759; this lane's compile report 428/6113229784 | +| Registered `SuperlevelBar.lean` (successor) | SHA-256 `346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9`, 15309 bytes; imports `Mathlib` only | +| C264 handoff `OrdinaryH0.lean` (failed at the pin with warnings as errors) | SHA-256 `261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e`, 18469 bytes; Math- PR #428 comments 6113276830 (source, delivery 1/3), 6113277173 (nonauthor source review, 2/3), 6113277485 (verification and owner task, 3/3); this lane's failed-compile record 428/6113300903; owner repair handoff 428/6113372506; this lane's repair report with the full diff 428/6113438262 | +| Registered `OrdinaryH0.lean` (successor) | SHA-256 `3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88`, 19803 bytes; imports `Mathlib` and `ClosedSuperlevel` | | Toolchain | `leanprover/lean4:v4.34.1`, release commit `5045d0056413266e57c625dcd7c365b10e377c52`; Mathlib `d13f23b723b8a846827a245b89c10fc7d3f11612` via `formal/lake-manifest.json` | `SOURCE_FILES.json` records bytes, SHA-256 and Git blob of every tracked companion file and the workflow, the per-module declaration inventory and this provenance. `check.py source` refuses to run unless the tracked tree, the working bytes and that manifest agree. -## What the 41 theorems and 17 definitions establish +## What the 81 theorems and 28 definitions establish Topology and scaffolding only: the period-lattice quotient, descent of periodic functions, path lifting with an **existential** endpoint, closed superlevel inclusions and their path-component -and singular-H0 maps. The source labels these `proved`; the hosted receipt may call them -`kernel-checked`; neither label is alignment or acceptance. +and singular-H0 maps (C254); the total strict-clearance set, its real death value with an explicit +empty-set default of `0`, and the exact strict supremum cut for continuous Euclidean heights (C263); +and the natural comparison of Mathlib's actual ordinary singular H0 with component-indexed +coproducts, restricted along the closed-superlevel filtration (C264). The sources label these +`proved`; the hosted receipt may call them `kernel-checked`; neither label is alignment or +acceptance. 109 declarations in all: 21 + 20 + 20 + 20 theorems, 3 abbrevs, 22 defs, 3 instances. ### `TorusTopology` (21 theorems; 2 abbrevs, 6 defs, 3 instances) @@ -94,12 +108,77 @@ and singular-H0 maps. The source labels these `proved`; the hosted receipt may c | `superlevel_component_eq_iff_joinedIn` | equal path components iff `JoinedIn` the closed superlevel | | `superlevel_h0Filtration_map_id`, `superlevel_h0Filtration_map_comp` | functor laws of the singular-H0 filtration; they put the H0 definition into the axiom audit | +### `SuperlevelBar` (20 theorems; 1 abbrev, 3 defs) — C263 total strict-clearance cut + +`superlevelBar_E d = EuclideanSpace ℝ (Fin d)`; `superlevelBar_isEssential g M := ∀ y, g y ≤ g M`; +`superlevelBar_clearanceSet g M = {h | ∃ y, g M < g y ∧ ∃ γ : Path M y, ∀ t, h < g (γ t)}` (strict +at every parameter, endpoints included); `superlevelBar_deathHeight g M` is `sSup` of that set when +it is nonempty and the declared default `0` otherwise. The source's own docstring: the scalar zero +on an empty set is a default, not an essential-bar death. + +| Theorem | What it states | +|---|---| +| `superlevelBar_essential_iff` | essentiality is exactly `∀ y, g y ≤ g M` (`Iff.rfl`) | +| `superlevelBar_mem_lt_start` | every clearance member is strictly below the start height `g M` (the path at `0`) | +| `superlevelBar_clearance_bddAbove` | the clearance set is bounded above by `g M`, including when empty | +| `superlevelBar_clearance_empty_of_essential` | an essential `M` has empty clearance set | +| `superlevelBar_death_eq_zero_of_empty`, `superlevelBar_death_eq_zero_of_essential` | an empty clearance set, hence an essential input, selects the declared default `0` | +| `superlevelBar_death_eq_sSup_of_nonempty` | a nonempty clearance set selects its real supremum (the compile-fixed proof: `ite_eq_left`) | +| `superlevelBar_path_minimum` | a continuous height attains a minimum along each path (compact unit interval) | +| `superlevelBar_clearance_nonempty`, `superlevelBar_clearance_nonempty_iff` | for continuous `g`, the clearance set is nonempty exactly off the essential locus (`Path.segment`, minimum minus one) | +| `superlevelBar_clearance_downward` | any threshold below a clearance is a clearance (same endpoint and path) | +| `superlevelBar_clearance_improve` | each strict witness has a strictly larger witness on its own path (midpoint below the attained minimum) | +| `superlevelBar_strict_cut` | for continuous nonessential inputs, `h < death ↔ h ∈ clearance` | +| `superlevelBar_death_le_start_of_nonempty`, `superlevelBar_death_le_start` | death `≤ g M` when the clearance set is nonempty, hence for continuous nonessential inputs | +| `superlevelBar_clearance_eq_Iio` | on that locus the clearance set is `Set.Iio death` | +| `superlevelBar_death_not_mem_clearance` | death is not itself a strict clearance | +| `superlevelBar_cut_unique` | a real with the same strict cut equals the death height | +| `superlevelBar_death_const` | a constant height has death `0` at every point | +| `superlevelBar_control_negative_essential` | control: the constant `-1` has death `0` and `¬ 0 ≤ -1`, so the death/start bound does not hold on the essential default branch | + +### `OrdinaryH0` (20 theorems; 7 defs) — C264 actual ordinary singular H0 and path components + +The homology objects and maps are Mathlib's `singularHomologyFunctor C 0`; the comparison is +Mathlib's objectwise `TopCat.singularHomology₀Iso`, whose naturality is proved here from actual +zero-cycle generators. Definitions: `ordinaryH0_componentFunctor : TopCat ⥤ Type` (objects +`ZerothHomotopy X`, maps `superlevel_componentMap`); `ordinaryH0_componentCoproductFunctor R` +(that functor followed by `sigmaConst.obj R`); `ordinaryH0_componentFiltration g R` +(`superlevel_filtration g` followed by it); `ordinaryH0_simplicialPointClass S R x : R ⟶ S.homology R 0` +(the chain generator of a zero-simplex, lifted through the zero differential, then its class); +`ordinaryH0_pointClass X R x` (the same for the singular zero-simplex of a point); +`ordinaryH0_naturalIso R : (singularHomologyFunctor C 0).obj R ≅ ordinaryH0_componentCoproductFunctor R`; +`ordinaryH0_filtrationIso g R : superlevel_h0Filtration g R ≅ ordinaryH0_componentFiltration g R` +(`Functor.isoWhiskerLeft`). The coefficient object lives in an arbitrary preadditive category with +the required coproducts and homology; the nonzero/distinction statements require `𝟙 R ≠ 0`. + +| Theorem | What it states | +|---|---| +| `ordinaryH0_componentCoproductMap_iota` | `Sigma.ι q ≫ (coproduct functor).map f = Sigma.ι (superlevel_componentMap f.hom q)` | +| `ordinaryH0_componentFiltration_map_iota` | the same for a closed-superlevel inclusion `homOfLE hst`, through `superlevel_componentInclusion` | +| `ordinaryH0_simplicialPointClass_iso` | the simplicial point class composed with `S.homology₀Iso R` is the generator at `SSet.π₀.mk x` | +| `ordinaryH0_simplicialPointClass_map` | the actual simplicial homology map carries a point class to the point class of the image simplex | +| `ordinaryH0_toSSet_pointMap` | the singular zero-simplex of `x` maps to that of `f x` (`rfl`) | +| `ordinaryH0_pointClass_map` | the induced singular-H0 map carries `pointClass x` to `pointClass (f x)` | +| `ordinaryH0_pointClass_iso`, `ordinaryH0_componentIota_isoInv` | `pointClass x ≫ (singularHomology₀Iso X R).hom = Sigma.ι (ZerothHomotopy.mk x)`, and the inverse form | +| `ordinaryH0_hom_ext` | two morphisms out of singular H0 agree if they agree on every point class | +| `ordinaryH0_iso_naturality` | the objectwise comparison isomorphism commutes with every continuous map (the repaired proof: explicit `rw`/`erw` reassociation of both sides) | +| `ordinaryH0_pointClass_augmentation` | `pointClass x ≫ singularHomology₀ε X R = 𝟙 R`: the ordinary point class is retained, not killed | +| `ordinaryH0_pointClass_ne_zero` | `pointClass x ≠ 0` when `𝟙 R ≠ 0` | +| `ordinaryH0_pointClass_eq_of_component_eq`, `ordinaryH0_sameComponent_difference_zero` | points of one path component have equal point classes; their difference is `0` (any coefficients) | +| `ordinaryH0_pointClass_ne_of_component_ne`, `ordinaryH0_pointClass_eq_iff` | with `𝟙 R ≠ 0`, point classes are equal exactly when the path components are | +| `ordinaryH0_difference_map`, `ordinaryH0_difference_map_eq_zero_iff` | the induced map of a difference is the difference of image classes; with `𝟙 R ≠ 0` it vanishes exactly when the image points share a component | +| `ordinaryH0_filtration_naturality` | the H0/component square at every ordered closed-superlevel inclusion `s ≤ t` | +| `ordinaryH0_filtration_difference_zero_iff_joinedIn` | under a closed-superlevel inclusion the difference of two point classes vanishes exactly when the points are `JoinedIn` the target closed superlevel (`𝟙 R ≠ 0`) | + Audited definitions: `torus_E`, `torus_quotient` (abbrev); `torus_latticeVec`, `torus_periodBasis`, `torus_periodLattice`, `torus_proj`, `torus_isPeriodic`, `torus_descend`; instances `torus_lattice_discrete`, `torus_lattice_addSubgroup_discrete`, `torus_lattice_isZLattice`; `superlevel_set`, `superlevel_inclusion`, `superlevel_componentMap`, `superlevel_componentInclusion`, -`superlevel_filtration`, `superlevel_h0Filtration`. Every one of the 58 declarations is a -`#print axioms` target. +`superlevel_filtration`, `superlevel_h0Filtration`; `superlevelBar_E` (abbrev), `superlevelBar_isEssential`, +`superlevelBar_clearanceSet`, `superlevelBar_deathHeight`; `ordinaryH0_componentFunctor`, +`ordinaryH0_componentCoproductFunctor`, `ordinaryH0_componentFiltration`, `ordinaryH0_simplicialPointClass`, +`ordinaryH0_pointClass`, `ordinaryH0_naturalIso`, `ordinaryH0_filtrationIso`. Every one of the 109 +declarations is a `#print axioms` target. ## What is NOT established @@ -120,9 +199,38 @@ Copied from the handoff's own exclusions (TORUS_FILTRATION.md, source review F3 carries the literal formulas (`torus_field_latticeVec_formula`, `torus_field_periodic_formula`) and does not import that file. +Copied from the C263 module's own docstrings (`SuperlevelBar.lean`): + +- an inhabitant of the separately owned Field or Lifetime record, an elder relation, Morse + endpoint attainment, ordinary H0 bar pairing, finite-bar counts, a Gaussian field or weighted + law, or scientific acceptance; the scalar zero on an empty set is a default, not an + essential-bar death; +- closed-threshold attainment at the death height (the cut is strict; `superlevelBar_death_not_mem_clearance` + says death is not a clearance); a finite death for an essential class; the death/start bound on + the empty default branch (refuted by `superlevelBar_control_negative_essential`); compactness of + the whole Euclidean domain; a positive-dimensional or periodic quotient-space hypothesis (the + ambient type is `EuclideanSpace ℝ (Fin d)`, not the torus of `TorusTopology`); an optimal path + or a path attaining the supremum; a converse of `superlevelBar_clearance_empty_of_essential` + for discontinuous heights. + +Copied from the C264 module's own docstrings (`OrdinaryH0.lean`): + +- any Morse chart, critical-level attainment theorem, interval decomposition, elder correspondence, + Field adapter, count identity, stochastic law, or scientific-status promotion; +- any nonzero or distinction claim for a zero coefficient object (every such statement carries + `𝟙 R ≠ 0`); reduced-H0 vanishing (the ordinary point class is retained); equality of connected + and path-connected components; injectivity of the induced map; a distinguished geometric + representative; a basis of geometric maxima or finiteness of components; a Morse merger event, + elder selection, death height or barcode; strict-level conventions; the later interval, elder, + maximum/saddle, count, Field or stochastic bridges. + Compile success, the axiom audit, `leanchecker` and the negative controls say that Lean elaborated these statements with these proofs at this pin. They do not say that the statements are the ones the research programme needs; that is the pending independent alignment review. +For the two C26x modules there is, in addition, no nonauthor review of the compiled successor +bytes yet: the C263 nonauthor source review (6113033351) and the C264 nonauthor source review +(6113277173) read the handoff bytes, not the successors, and both lanes' handoffs keep formal +acceptance on HOLD until such a review exists. ## Compile fixes at the pin @@ -130,7 +238,8 @@ The C254 handoff delivered both modules as NOT_COMPILED. At the pin they did not this companion differ from the handoff bytes only as listed here. No theorem or lemma statement changed (all 41 statement lines are byte-identical before `:=`); the 21 + 20 theorem names and the 11 + 6 definition names keep their order; no `sorry`, `axiom`, `native_decide` or `set_option` was added; every declaration's axioms are within -`propext`, `Classical.choice`, `Quot.sound`. +`propext`, `Classical.choice`, `Quot.sound`. The C263 and C264 handoffs were compiled at the pin by this lane with +warnings as errors and failed; their successors are described after the C254 fixes. `TorusTopology.lean` (handoff sha256 `efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4`): - `def torus_periodBasis`: declared type `Basis (Fin d) ℝ (torus_E d)` → `Module.Basis (Fin d) ℝ (torus_E d)`. At the @@ -161,25 +270,71 @@ Evidence of the fixes themselves is local (`lean -DwarningAsError=true --root=` (handoff) -> -`TorusFiltration.` (companion). The inventory lists in `SOURCE_FILES.json` are derived from +Every C254 declaration keeps its handoff name: `ResearchFormalCoreR1.` (handoff) -> +`TorusFiltration.` (companion). The C263 and C264 modules were authored directly in namespace +`TorusFiltration` (there is no handoff namespace to map); the only C264 renames are the three +ASCII `iota` spellings listed above. The inventory lists in `SOURCE_FILES.json` are derived from the originals by column-0 scans (`^theorem`, `^(noncomputable )?def`, `^abbrev`, `^instance`). `check.py source` re-derives them from the companion modules with a whitelist scanner (`scan_module`, not a Lean parser) and refuses any module whose scan differs. The scanner strips comments (`--`, nested `/- -/`, `/-- -/`, `/-! -/`) and then permits, at column 0, only: -`import Mathlib` or `import Mathlib.…` (before the namespace), `noncomputable section`, -`open `, `universe …`, `variable …`, exactly one `namespace TorusFiltration` / +`import Mathlib` or `import Mathlib.…`, or `import ` for a companion module `M` that precedes +the scanned module in `MODULES` (`OrdinaryH0.lean` imports `ClosedSuperlevel`; a self, forward or +root import is refused as `companion import out of dependency order`; both only before the +namespace), `noncomputable section`, `open `, `open scoped ` +(`OrdinaryH0.lean` opens the scoped simplicial notation; capitalized names only, nothing else on +the line), `universe …`, `variable …`, exactly one `namespace TorusFiltration` / `end TorusFiltration` pair, and inside it a named `theorem`, `def`, `noncomputable def`, `abbrev` -or `instance` whose name matches `[A-Za-z][A-Za-z0-9_]*`. Everything else is refused: any other +or `instance` whose name matches `[A-Za-z][A-Za-z0-9_]*`. The two prelude forms (companion import, +`open scoped`) were added by the C263/C264 registration because the registered `OrdinaryH0.lean` +carries both lines; neither admits a declaration, a command or a foreign import, and each has +its own negative controls. Everything else is refused: any other command keyword anywhere outside comments (`lemma`, `example`, `axiom`, `opaque`, `structure`, `inductive`, `class`, `private`, `protected`, `noncomputable instance`, an anonymous `instance`, `attribute`, `set_option`, `section`, `end`, `mutual`, `deriving`, `macro`, `macro_rules`, @@ -219,17 +374,21 @@ refuse. The lexer also treats a closed block comment as a token separator (`theo is `theorem hidden`) and lexes numerals as Lean does (`0alias` is `0` then `alias`; `0x1Ftheorem` is `0x1F` then `theorem`), both found by that verification. **The declaration census the receipt stands on is therefore not the scanner but `Census.lean`**, emitted by `check.py emit` and run -by the replay: Lean itself lists every constant the three companion modules add to the -environment, tagged `internal` or `user` (`Name.isInternalDetail`: `_`-prefixed, `eq_n`, -`match_n`, `proof_n`, `omega_n` or numeric components) and `range` or `generated` (whether Lean -recorded a declaration range, which every declaration elaborated from source syntax carries and -compiler-generated constants lack). `check.py finish` requires the user-named ranged constants -to equal the 58 inventoried names exactly, refuses any ranged constant with an internal-style -name (a `where`-clause `proof_1` written by hand), and requires the user-named generated -constants to equal `census_auxiliary` in `SOURCE_FILES.json` exactly (today -`TorusFiltration.torus_periodBasis.congr_simp`, the simp-congruence lemma Lean generates for -`torus_periodBasis`), so that list can name only constants Lean generated; internal generated -constants (abstracted proofs, equation lemmas) are counted and otherwise ignored. A declaration +by the replay: Lean itself lists every constant the five companion modules (the four modules and +the root) add to the environment, tagged `internal` or `user` (`Name.isInternalDetail`: +`_`-prefixed, `eq_n`, `match_n`, `proof_n`, `omega_n` or numeric components) and `range` or +`generated` (whether Lean recorded a declaration range, which every declaration elaborated from +source syntax carries and compiler-generated constants lack). `check.py finish` requires the +user-named ranged constants to equal the 109 inventoried names exactly, refuses any ranged +constant with an internal-style name (a `where`-clause `proof_1` written by hand), and requires +the user-named generated constants to equal `census_auxiliary` in `SOURCE_FILES.json` exactly +(today `TorusFiltration.torus_periodBasis.congr_simp`, the simp-congruence lemma Lean generates +for `torus_periodBasis`; the C263 and C264 modules add no user-named generated constant), so that +list can name only constants Lean generated; internal generated constants (abstracted proofs, +equation lemmas, `_simp` auxiliaries, and `CategoryTheory.Limits.sigmaConst.eq_1`, the equation +lemma Lean generated for a Mathlib definition that `OrdinaryH0.lean` unfolds and attributed to +that module) are counted and otherwise ignored: 23 at the pin for the five modules, of which 12 +belong to the C26x pair. A declaration the scanner missed is refused by the receipt whatever its spelling, because it was elaborated from source and therefore carries a range. A compile fix that needs a refused form must extend the scanner, the inventory and, for a new compiler-generated constant, `census_auxiliary`. @@ -256,12 +415,13 @@ cache for `formal/` retrieved: The replay: binds HEAD to the manifest (`check.py source`), runs the Python tests in normal and `-O` modes, emits the Lean audit files, then inside `lake env bash` from `formal/` records -`lean --version` and every installed package HEAD, compiles `TorusTopology`, `ClosedSuperlevel` -and the root `TorusFiltration` with `-DwarningAsError=true`, compiles `Positive.lean` (six -concrete applications of the companion's theorems), `Audit.lean` (58 `#print axioms`), -`Types.lean` (41 `#check` with `pp.explicit`), `Census.lean` (the elaborated declaration census -above), runs `leanchecker TorusTopology ClosedSuperlevel TorusFiltration`, and runs six negative -controls. The replay unsets `PYTHONOPTIMIZE` first, so each Python invocation runs in exactly the +`lean --version` and every installed package HEAD, compiles `TorusTopology`, `ClosedSuperlevel`, +`SuperlevelBar`, `OrdinaryH0` (in that dependency order) and the root `TorusFiltration` with +`-DwarningAsError=true`, compiles `Positive.lean` (six concrete applications of the C254 +theorems; unchanged by the registration), `Audit.lean` (109 `#print axioms`), `Types.lean` (81 +`#check` with `pp.explicit`), `Census.lean` (the elaborated declaration census above), runs +`leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration`, and runs +eight negative controls. The replay unsets `PYTHONOPTIMIZE` first, so each Python invocation runs in exactly the mode its command line names, and every `check.py` invocation prints the mode it runs in (`TORUS_FILTRATION_PYTHON: optimize=N`) to the job log (an invocation that argparse rejects exits 2 before that line; the replay never issues one). @@ -273,6 +433,8 @@ elaborated as `example : := by ` and must fail with exactly | `RejectSuperlevelSignFlip` | false statement `() ∈ superlevel_set (fun _ : Unit => (0 : ℝ)) (-1)` (true only if the parameter were `+t`), tactic `norm_num [superlevel_set]` | exit 1, `error: unsolved goals` / `⊢ False` | | `RejectSuperlevelBelowThreshold` | false statement `(3 : ℝ) ∈ superlevel_set (fun x : ℝ => x) (-4)` (`3 ∈ {x | 4 ≤ x}`), tactic `norm_num [superlevel_set]` | exit 1, `⊢ False` | | `RejectConstantNotPeriodic` | false statement `¬ torus_isPeriodic 1 (1 : ℝ) (fun _ => (0 : ℝ))`, tactic `simp [torus_isPeriodic]` | exit 1, `⊢ False` | +| `RejectEssentialDeathBound` (C263) | false statement `superlevelBar_deathHeight (fun _ : superlevelBar_E 1 => (-1 : ℝ)) 0 ≤ (-1 : ℝ)` (the death/start bound on the essential default branch: the constant `-1` has death `0` by `superlevelBar_death_const`, and `0 ≤ -1` is false; the proposition of the C263 handoff's `FALSE_CONTROL_PROPOSAL` (Math- #428 comment 6113033351), whose tactic `rw [superlevelBar_death_const 1 (-1) (0 : superlevelBar_E 1)]; norm_num` is replaced here by `norm_num [superlevelBar_death_const]`), tactic `norm_num [superlevelBar_death_const]` | exit 1, `⊢ False` | +| `RejectReducedPointClass` (C264) | false statement `CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of Unit) (ModuleCat.of ℤ ℤ) ()) (TopCat.singularHomology₀ε (TopCat.of Unit) (ModuleCat.of ℤ ℤ)) ≠ CategoryTheory.CategoryStruct.id (ModuleCat.of ℤ ℤ)` (the ordinary point class of the one-point space with `ℤ`-module coefficients is **not** augmented to the identity, which is what a reduced-H0 substitution would give; `ordinaryH0_pointClass_augmentation` says it is the identity; the notation `≫`/`𝟙` is spelled out because the emitted file opens only `TorusFiltration`), tactic `simp [ordinaryH0_pointClass_augmentation]` | exit 1, `⊢ False` | | `RejectSorry` | `theorem injected : False := by sorry` | exit 0 with the `sorry` warning; audit refuses `sorryAx` | | `RejectCustomAxiom` | `axiom hiddenPremise : False` behind one intermediate theorem | exit 0; audit refuses `hiddenPremise` | | `RejectNativeDecide` | `native_decide` proof | exit 0; audit refuses `injected._native.native_decide.ax_1_1` | @@ -282,32 +444,39 @@ and only the axiom audit refuses them, which is what the audit is for. `check.py `re.fullmatch` on each log, so a crash, an extra error or a different exit code is a failed control, not a passed one. `check.py finish` refuses an evidence directory that already holds `receipt.json` (a receipt is written once and never replaced; a new attempt needs a fresh -directory) and requires exactly the 44 evidence files, each a regular file and nothing else: the -ten emitted Lean files (`Audit.lean`, `Types.lean`, `Positive.lean`, `Census.lean` and the six -controls' `.lean`), a `.log` and `.status` pair for each of the eight Lean processes (three -module builds, `positive`, `axioms`, `types`, `census`, `leanchecker`), the six controls' +directory) and requires exactly the 54 evidence files, each a regular file and nothing else: the +twelve emitted Lean files (`Audit.lean`, `Types.lean`, `Positive.lean`, `Census.lean` and the +eight controls' `.lean`), a `.log` and `.status` pair for each of the ten Lean processes (five +module builds, `positive`, `axioms`, `types`, `census`, `leanchecker`), the eight controls' `.log`/`.status`, `leanchecker.cmd`, `packages.log`, `toolchain.log`, `source.json`, -`tests.log` and `tests-optimized.log` (`EVIDENCE_FILES` in `check.py`; C262 finding G3). It then -re-runs the source binding, re-derives the ten emitted Lean files and requires byte equality +`tests.log` and `tests-optimized.log` (`EVIDENCE_FILES` in `check.py`; C262 finding G3; 44 +members before the C263/C264 registration added two builds and two controls). It then +re-runs the source binding, re-derives the twelve emitted Lean files and requires byte equality with the ones Lean consumed, checks every status, the toolchain line, the installed package HEADs against `formal/lake-manifest.json`, the recorded `leanchecker` invocation, the axiom and -type inventories, the declaration census and the six controls, and writes `receipt.json` with -`log_sha256` over exactly those 44 files, created exclusively (`O_EXCL`, `O_NOFOLLOW`). The +type inventories, the declaration census and the eight controls, and writes `receipt.json` with +`log_sha256` over exactly those 54 files, created exclusively (`O_EXCL`, `O_NOFOLLOW`). The evidence directory `.lake/torus-filtration-evidence` must not pre-exist. ### What `leanchecker` checks here, and why not `--fresh` -Both modules `import Mathlib`, so their import closure is all of Mathlib (6.1 GB of `.olean` +All four modules `import Mathlib` (`OrdinaryH0` also imports `ClosedSuperlevel`), so their import closure is all of Mathlib (6.1 GB of `.olean` files at the pin). `leanchecker --fresh TorusFiltration`, the shape of the D2 companions' step (`leanchecker --fresh D2MomentBridge`, affordable there only because that module imports `Mathlib.Tactic` and one Bochner file), re-checks that entire closure from scratch: measured locally against the pinned cache at 4 threads it was still running at 1500 s with 6.6 GB resident, so it cannot complete inside a hosted job. The hosted -default is therefore `leanchecker TorusTopology ClosedSuperlevel TorusFiltration`: leanchecker +default is therefore `leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration` +(before the C263/C264 registration it named the three C254 modules; `check.py finish` now refuses that +shorter form): leanchecker builds the environment from the cached, prebuilt dependency `.olean` files (trusted, exactly as -`lean` itself trusts them when compiling the modules) and replays every declaration of the three -named modules through the kernel. Measured locally at `LEAN_NUM_THREADS=2`: 30 s wall, -6.6 GB resident, no output on success (the same footprint as one `lean` compile of -`ClosedSuperlevel.lean`, 9 s and 6.8 GB). `replay.sh` writes the exact invocation to +`lean` itself trusts them when compiling the modules) and replays every declaration of the five +named modules through the kernel. Measured locally at `LEAN_NUM_THREADS=2`: 30 s wall and 6.6 GB +resident for the three C254 modules; 53 s for the five (2026-10-11, this lane's pre-commit run on the +registered bytes) with a peak of about 8.4 to 8.7 GiB resident (two runs, sampled every 2 s), no output on success (one +`lean` compile of `ClosedSuperlevel.lean` takes 9 s and 6.8 GB; `OrdinaryH0.lean` compiles in 12 s). +With `LEAN_NUM_THREADS` unset on a four-core machine the five-module `leanchecker` exceeded a +13.36 GiB memory limit and was killed (twice, 2026-10-11), so `replay.sh` defaults `LEAN_NUM_THREADS` +to 2, the hosted job's setting, when the operator has not set it. `replay.sh` writes the exact invocation to `leanchecker.cmd`; `check.py finish` accepts only the two pinned forms, requires the modules-mode log to be empty, and copies command and mode into `receipt.json` under `leanchecker`. An operator who wants the whole-closure re-check runs @@ -324,9 +493,15 @@ replay step itself 1 min 27 s at `LEAN_NUM_THREADS=2`; artifact `torus-filtratio 42 files, 22,572 bytes, SHA-256 `c9bf02d33ddd9addb5d2883af982827b44ef3fd5e84d877ed78504efe8f19c0d`. The workflow's `timeout-minutes: 45` is kept: a cache miss or a slow runner needs the margin and lowering it buys nothing. One hosted completion is recorded here; every later run's receipt stands -on its own, and a receipt is a record of a computation, not evidence of alignment. - -The replay writes `TorusTopology.olean`, `ClosedSuperlevel.olean` and `TorusFiltration.olean` +on its own, and a receipt is a record of a computation, not evidence of alignment. That measured +run predates the C263/C264 registration (three module builds, six controls, 41 evidence files, 42 with the receipt); +the registered set (five builds, the census, eight controls, 54 files) adds, relative to that run, the +census `lean` run (from the C262 AMEND), two `lean` compiles of about 10 and 12 s, two control runs of +about 10 s each and about 23 s more of `leanchecker` (30 s to 53 s), at `LEAN_NUM_THREADS=2`, measured +locally; the registered set has no hosted completion yet. + +The replay writes `TorusTopology.olean`, `ClosedSuperlevel.olean`, `SuperlevelBar.olean`, +`OrdinaryH0.olean` and `TorusFiltration.olean` into the companion directory (Lean needs them on `LEAN_PATH` for the root module and the audit files). They are build artefacts and must never be committed: the repository has no root `.gitignore`, `git add -A` would stage them, and `check.py source` then refuses the companion @@ -373,10 +548,70 @@ narrower attribution stands for those runs and is not revised. [6112740740](https://github.com/d6g8k5htny-coder/Math-/pull/428#issuecomment-6112740740)) and hosted-evidence verdict (APPROVE_OBSERVED_EXECUTION_SCOPE, [6112741132](https://github.com/d6g8k5htny-coder/Math-/pull/428#issuecomment-6112741132)) were of head `a898bb44`; organizational-independence credit 0 throughout. +- C263/C264 registration (2026-10-11, one forward commit on top of the C262 AMEND head `4c33d8cd`): the + two compiled successors `SuperlevelBar.lean` (346eea94…) and `OrdinaryH0.lean` (3d6b0d6b…) are + added as modules three and four; the root module imports four modules; `check.py` gains the two + module builds, the five-module `leanchecker` command, a census over five modules, the two + false controls above, the handoff and successor identities under `provenance.original_sha256`, + `provenance.original_bytes` and `provenance.successors` (compared whole; a changed hash, byte + count, census or status label is refused), and two prelude forms in the scanner (companion import + in dependency order, `open scoped`), each with negative controls; `EVIDENCE_FILES` goes from 44 + to 54 members. The protocol tests (`InventoryTests`, run by the replay) refuse a registered module whose bytes are not the + recorded successor; the out-of-tree generator that writes `SOURCE_FILES.json` checks the same but is not part of this + tree, so no reader can audit it here. `TorusTopology.lean`, `ClosedSuperlevel.lean`, the Actions workflow file, + `Positive.lean`, the three C254 controls and the three injection controls are byte-for-byte + unchanged. The workflow's comment counting "twelve `lean` invocations" is therefore stale (17 now: five module + builds, the positive, audit, types and census files, and eight controls); the file is kept byte-identical rather than + edited for a comment. Details in [C263 and C264 registration](#c263-and-c264-registration-2026-10-11). + +## C263 and C264 registration (2026-10-11) + +This commit registers two compiled Lean modules in the gate. **Registration is not review and +not acceptance.** It records that the successor bytes elaborate at the pin and binds them to the +gate; it moves no status label. Both handoffs keep their own label, **FORMAL HOLD**, which stands +until a nonauthor exact-source review of the compiled successors exists; the C263 (6113033351) +and C264 (6113277173) nonauthor source reviews read the handoff bytes, not the successors, and +this lane (compile fix, repair, registration) is the same project account as the companion, +organizational-independence credit 0. + +| Item | `SuperlevelBar.lean` (C263) | `OrdinaryH0.lean` (C264) | +|---|---|---| +| Source author | OpenAI/Codex lane (`c262_lean_source_review` acting as C263 implementer), delegated AI work for Dylan Roy | OpenAI/Codex lane (`c264_h0_author`; root `01a0bbb5` supplied the target, custody and the nonzero-coefficient/projection control design, `c264_h0_author/api_support` did read-only pinned-API research and proposed the cycle/projection naturality rewrite chain (the step that failed at the pin and was repaired), as disclosed in Math- #428 comment 6113276830), delegated AI work for Dylan Roy | +| Handoff bytes | `d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8`, 14904 bytes (428/6113033147; owner task 428/6113033545: 28/28 static checks, formal acceptance HOLD; allocation 419/6112439759) | `261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e`, 18469 bytes (428/6113276830, 6113277173, 6113277485) | +| At the pin, warnings as errors | failed: deprecated `if_pos` at line 123 (428/6113229784) | failed: unused section instances, unsolved naturality goal, unknown `isoWhiskerLeft` (428/6113300903) | +| Successor bytes | `346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9`, 15309 bytes | `3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88`, 19803 bytes | +| Change | `if_pos hne` → `ite_eq_left hne`, one simp lemma in `superlevelBar_death_eq_sSup_of_nonempty`; docstring lines | the owner repair handed over in 428/6113372506, posted with its full diff in 428/6113438262: `variable` scope split, explicit `rw`/`erw` naturality proof, `Functor.isoWhiskerLeft`, three ASCII `iota` names, docstring lines; no statement changed | +| Imports | `Mathlib` | `Mathlib`, `ClosedSuperlevel` | +| Declarations | 20 theorems, 1 abbrev, 3 defs (`superlevelBar_` prefix) | 20 theorems, 7 defs (`ordinaryH0_` prefix) | +| Range-aware census at the pin | 25 = 24 + 0 + 1 (user range + user generated + internal generated: `superlevelBar_deathHeight.eq_1`) | 38 = 27 + 0 + 11 (internal generated: `sigmaConst.eq_1`, three `eq_1`, `_proof_1`–`_proof_2` of the functor, `_proof_1`–`_proof_4` of the simplicial point class, `_simp_1_1` of `hom_ext`) | +| `census_auxiliary` | no new entry | no new entry | +| `#print axioms` | all 24 within `{propext, Classical.choice, Quot.sound}` | all 27 within the same set | +| New false control | `RejectEssentialDeathBound` | `RejectReducedPointClass` | +| Status | FORMAL HOLD (handoff's own label) until a nonauthor exact-source review of the compiled successor | FORMAL HOLD, same | + +What this commit does not establish: that either module's statements are the ones the +research programme needs (alignment stays `PENDING_INDEPENDENT_REVIEW`); any of the exclusions the +modules' own docstrings list (above, [What is NOT established](#what-is-not-established)); a Field +or Lifetime inhabitant, a Field adapter or any coupling to the `Specifications` package of PR #419; +an elder relation, bar pairing, finite-bar count, interval decomposition or stochastic law; any +review of the compiled successors (none exists: this lane compiled, repaired and registered them and has not reviewed them); any +organizational-independence credit; any hosted receipt for the registered set (a green hosted +run of this commit would produce one, and a receipt is a record of a computation). The compile fix +and the repair changed proof text and declaration spellings; whether every statement still says +what the handoffs intended is part of the pending review, not something this registration +decides. The concrete ordinary-H0 controls the C264 handoff asks for (item 4 of its owner task, Math- #428 comment +6113277485: empty, point, two-component, merge/non-merge and zero-coefficient cases with premises proved in concrete +fixtures) are not provided here: this commit adds one false control (`RejectReducedPointClass`) and no positive +fixture, and that obligation stays open. `provenance.original_status` (`NOT_COMPILED`) records the two C254 handoff +modules at delivery; the C263 and C264 handoffs' statuses are `provenance.successors.*.handoff_status`. Local evidence for this commit (one run of each build, the emitted audit, types, census +and positive files, the five-module `leanchecker` and the two new controls, all exit 0 or the +pinned `⊢ False`, this lane, 2026-10-11) is a record of a computation on an unverified worktree, +not a receipt. ## What this companion does not do It does not modify `formal/`, the D2 companions or their workflows. It does not enter the q0 dependency graph, raise any claim's grade, or substitute for the nonauthor source review, the -independent alignment review or the operator's decisions. The hosted receipt is a record of a -computation, not evidence of alignment with the research programme. +independent alignment review or the operator's decisions. It does not lift the C263 or C264 +FORMAL HOLD, and it does not review the successor bytes it registers. The hosted receipt is a +record of a computation, not evidence of alignment with the research programme. diff --git a/companions/torus_filtration_20261011/SCOPE.md b/companions/torus_filtration_20261011/SCOPE.md index 6f78f7300..5d0b673aa 100644 --- a/companions/torus_filtration_20261011/SCOPE.md +++ b/companions/torus_filtration_20261011/SCOPE.md @@ -1,15 +1,21 @@ -# Scope note: C254 torus quotient and closed-superlevel filtration companion +# Scope note: C254 torus quotient and closed-superlevel filtration companion, with the C263 strict-cut and C264 ordinary-H0 modules -Dylan Roy — delegated AI work. Source author: OpenAI/Codex lane (C254). Compile fixes and -companion: Anthropic/Claude lane. Scientific effect NONE; organizational-independence credit 0; -no human review; alignment `PENDING_INDEPENDENT_REVIEW`. +Dylan Roy — delegated AI work. Source authors: OpenAI/Codex lanes (C254: `TorusTopology`, +`ClosedSuperlevel`; C263: `SuperlevelBar`; C264: `OrdinaryH0`). Compile fixes, the C264 owner +repair and the companion: Anthropic/Claude lane. Scientific effect NONE; +organizational-independence credit 0; no human review; alignment `PENDING_INDEPENDENT_REVIEW`. -This note fixes what the 41 theorem statements and 17 audited definitions of -`TorusTopology.lean` and `ClosedSuperlevel.lean` cover and what they do not. An independent -reviewer must compare each Lean statement with this note and with the handoff's own scope -(TORUS_FILTRATION.md in comment 6111059166) before any alignment record is written. The -compile fixes changed proof terms and resolved names at the pin; whether every statement still -says what the handoff intended is part of that review, not something this note decides. +This note fixes what the 81 theorem statements and 28 audited definitions of the four modules +(`TorusTopology.lean`, `ClosedSuperlevel.lean`, `SuperlevelBar.lean`, `OrdinaryH0.lean`; 109 +declarations) cover and what they do not. An independent reviewer must compare each Lean +statement with this note and with the handoffs' own scope (TORUS_FILTRATION.md in comment +6111059166 for C254; the module docstrings and Math- #428 comments 6113033545 and 6113372506 for +C263 and C264) before any alignment record is written. The compile fixes and the C264 repair +changed proof terms, resolved names and three declaration spellings at the pin; whether every +statement still says what the handoffs intended is part of that review, not something this note +decides. The C263 and C264 modules are registered under the handoffs' own FORMAL HOLD, which +stands until a nonauthor exact-source review of the compiled successor bytes; registration is +not review. ## Bound sources @@ -19,7 +25,24 @@ says what the handoff intended is part of that review, not something this note d - Claim `8a5c7a24-784b-4aaa-b951-cd9f37b0dc64`; Math- PR #419 comments 6111056103, 6111059166, 6111059498 (nonauthor source review: COMPILATION HOLD), 6111059848, 6111255007 (route finding); this lane: 6111093545 (local elaboration report), 6111139060 (pickup). -- Namespace mapping `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion). +- Namespace mapping `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion); + `SuperlevelBar` and `OrdinaryH0` were authored directly in namespace `TorusFiltration`. +- C263 handoff `SuperlevelBar.lean` SHA-256 + `d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8` (14904 bytes; Math- #428 + comments 6113033147, 6113033351, 6113033545; allocation #419 comment 6112439759), failed at the + pin with warnings as errors (deprecated `if_pos`, line 123; this lane's report 428/6113229784). + Registered successor SHA-256 `346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9` + (15309 bytes): `if_pos hne` -> `ite_eq_left hne` in `superlevelBar_death_eq_sSup_of_nonempty` + plus docstring lines; imports `Mathlib` only. Census at the pin 25 = 24 + 0 + 1. +- C264 handoff `OrdinaryH0.lean` SHA-256 + `261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e` (18469 bytes; Math- #428 + comments 6113276830, 6113277173, 6113277485), failed at the pin (this lane's record + 428/6113300903); owner repair handed to this lane in 428/6113372506 and posted with its full + diff in 428/6113438262. Registered successor SHA-256 + `3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88` (19803 bytes): `variable` + scope split, explicit `rw`/`erw` naturality proof, `Functor.isoWhiskerLeft`, three ASCII `iota` + names, docstring lines, no statement changed; imports `Mathlib` and `ClosedSuperlevel`. Census + at the pin 38 = 27 + 0 + 11. - Pinned environment read from `formal/`: `leanprover/lean4:v4.34.1`, Mathlib `d13f23b723b8a846827a245b89c10fc7d3f11612`; nothing from the core is imported or pinned. @@ -36,13 +59,27 @@ says what the handoff intended is part of that review, not something this note d | `superlevel_control_closed_endpoint`, `superlevel_control_strict_endpoint`, `superlevel_control_parameter_sign`, `superlevel_control_inclusion_direction`, `superlevel_control_essential`, `superlevel_control_strict_thresholds` | the handoff's own controls: closed endpoint membership vs strict failure; parameter sign `t = -h`; inclusion direction; no strictly higher endpoint at a global maximum; density of strict witnesses below `0` with no witness at `0` | a compact Morse counterexample; a supremum theorem; endpoint nonattainment for the research problem; a finite death from an essential maximum | | `superlevel_mono`, `superlevel_isClosed`, `superlevel_inclusion_id`, `superlevel_inclusion_comp`, `superlevel_mem_at_own_height`, `superlevel_neg_height` | `s ≤ t → F(s) ⊆ F(t)`; `F(t)` closed for continuous `g`; the continuous inclusions are a functor; `x ∈ F(-g x)`; `F(-h) = {x | h ≤ g x}` | component birth at the own height; finiteness of components | | `superlevel_componentMap_mk`, `superlevel_componentMap_id`, `superlevel_componentMap_comp`, `superlevel_componentInclusion_id`, `superlevel_componentInclusion_comp`, `superlevel_component_eq_iff_joinedIn` | the induced maps on actual `ZerothHomotopy` quotients are functorial; equal classes iff `JoinedIn` the closed superlevel | label tracking, elder events, once-counting, interval decomposition, bar bijection | -| `superlevel_h0Filtration_map_id`, `superlevel_h0Filtration_map_comp` | functor laws of `superlevel_filtration g ⋙ (singularHomologyFunctor C 0).obj R` with the coefficient category's coproduct, preadditive and homology structure stated explicitly | naturality comparing component maps with singular-H0 generators; any identification of `PairLawInterface.p` | +| `superlevel_h0Filtration_map_id`, `superlevel_h0Filtration_map_comp` | functor laws of `superlevel_filtration g ⋙ (singularHomologyFunctor C 0).obj R` with the coefficient category's coproduct, preadditive and homology structure stated explicitly | naturality comparing component maps with singular-H0 generators (supplied, for Mathlib's actual H0, by `OrdinaryH0` below); any identification of `PairLawInterface.p` | +| `superlevelBar_essential_iff`, `superlevelBar_mem_lt_start`, `superlevelBar_clearance_bddAbove`, `superlevelBar_clearance_empty_of_essential` (C263) | on `EuclideanSpace ℝ (Fin d)`: essentiality is `∀ y, g y ≤ g M`; every member of the total strict-clearance set `{h | ∃ y, g M < g y ∧ ∃ γ : Path M y, ∀ t, h < g (γ t)}` is `< g M`; the set is bounded above by `g M` even when empty; an essential `M` has empty clearance | a positive-dimensional or periodic quotient-space hypothesis (the C263 ambient type is Euclidean space, not the torus of `TorusTopology`); a converse for discontinuous heights | +| `superlevelBar_death_eq_zero_of_empty`, `superlevelBar_death_eq_zero_of_essential`, `superlevelBar_death_eq_sSup_of_nonempty` | `superlevelBar_deathHeight` is `sSup` of the clearance set when nonempty and the declared default `0` when empty, hence `0` for essential inputs | a geometric death event or finite persistence interval at that `0`; a finite death for an essential class; the handoff's own words: the scalar zero on an empty set is a default, not an essential-bar death | +| `superlevelBar_path_minimum`, `superlevelBar_clearance_nonempty`, `superlevelBar_clearance_nonempty_iff`, `superlevelBar_clearance_downward`, `superlevelBar_clearance_improve` | a continuous height attains a minimum on each path; for continuous `g` the clearance set is nonempty exactly off the essential locus (`Path.segment`, minimum minus one); clearance is downward closed; each strict witness has a strictly larger witness on its own path | a minimum over all paths or an optimal path; compactness of the whole Euclidean domain; a witness strictly above the supremum | +| `superlevelBar_strict_cut`, `superlevelBar_death_le_start_of_nonempty`, `superlevelBar_death_le_start`, `superlevelBar_clearance_eq_Iio`, `superlevelBar_death_not_mem_clearance`, `superlevelBar_cut_unique` | for continuous nonessential inputs: `h < death ↔ h ∈ clearance`; death `≤ g M`; the clearance set is `Set.Iio death`; death is not a clearance; a real with the same strict cut is the death height | closed-threshold attainment at the death height; the death/start bound on the empty default branch; equality of arbitrary total interface records off the valid locus | +| `superlevelBar_death_const`, `superlevelBar_control_negative_essential` | a constant height has death `0` everywhere; the handoff's own control: the constant `-1` has death `0` and `¬ 0 ≤ -1`, so no unconditional death/start bound holds on the essential default | any finite ordinary bar for a constant height; an inhabitant of the separately owned Field or Lifetime record; an elder relation; Morse endpoint attainment; ordinary H0 bar pairing; finite-bar counts; a Gaussian field or weighted law | +| `ordinaryH0_componentCoproductMap_iota`, `ordinaryH0_componentFiltration_map_iota` (C264) | the component functor `TopCat ⥤ Type` (objects `ZerothHomotopy X`, maps `superlevel_componentMap`) followed by `sigmaConst.obj R` sends the generator at `q` to the generator at `superlevel_componentMap f.hom q`; the same along a closed-superlevel inclusion `homOfLE hst` through `superlevel_componentInclusion` | that distinct source components stay distinct; a reverse inclusion or endpoint deletion; regularity, finite dimensionality or Morse hypotheses on the height | +| `ordinaryH0_simplicialPointClass_iso`, `ordinaryH0_simplicialPointClass_map`, `ordinaryH0_toSSet_pointMap`, `ordinaryH0_pointClass_map`, `ordinaryH0_pointClass_iso`, `ordinaryH0_componentIota_isoInv`, `ordinaryH0_hom_ext` | in Mathlib's actual singular homology: the point class of a zero-simplex composed with `S.homology₀Iso R` is the generator at `SSet.π₀.mk x`; the actual homology map transports point classes; `TopCat.singularHomology₀Iso` sends `ordinaryH0_pointClass X R x` to the generator at `ZerothHomotopy.mk x` (and inversely); morphisms out of singular H0 agree if they agree on all point classes | a replacement or free-module definition standing in for singular H0; a transported or postulated substitute for the actual homology map; injectivity of the induced map; a distinguished geometric representative; a basis of geometric maxima or finiteness of components | +| `ordinaryH0_iso_naturality` (with `ordinaryH0_naturalIso`) | Mathlib's objectwise comparison `TopCat.singularHomology₀Iso` commutes with every continuous map, proved from actual zero-cycle generators (the repaired proof: explicit reassociation of both sides), so it assembles into a natural isomorphism `(singularHomologyFunctor C 0).obj R ≅ ordinaryH0_componentCoproductFunctor R` | naturality by an added assumption or compatibility record (none is used); an interval decomposition or persistence-bar classification | +| `ordinaryH0_pointClass_augmentation`, `ordinaryH0_pointClass_ne_zero`, `ordinaryH0_pointClass_eq_of_component_eq`, `ordinaryH0_sameComponent_difference_zero`, `ordinaryH0_pointClass_ne_of_component_ne`, `ordinaryH0_pointClass_eq_iff`, `ordinaryH0_difference_map`, `ordinaryH0_difference_map_eq_zero_iff` | the ordinary point class composed with `singularHomology₀ε` is `𝟙 R`; with `𝟙 R ≠ 0` it is nonzero and two point classes are equal exactly when the path components are; same-component differences are `0` for any coefficients; the induced map of a difference is the difference of image classes and, with `𝟙 R ≠ 0`, vanishes exactly when the image points share a component | any nonzero or distinction claim for a zero coefficient object; reduced-H0 vanishing (the ordinary point class is retained); equality of connected and path-connected components; death of the individual point classes; a Morse merger event, elder selection, death height or barcode | +| `ordinaryH0_filtration_naturality`, `ordinaryH0_filtration_difference_zero_iff_joinedIn` (with `ordinaryH0_componentFiltration`, `ordinaryH0_filtrationIso`) | `superlevel_h0Filtration g R ≅ superlevel_filtration g ⋙ ordinaryH0_componentCoproductFunctor R` (`Functor.isoWhiskerLeft`); the H0/component square at every `s ≤ t`; with `𝟙 R ≠ 0`, the difference of two point classes of `superlevel_set g s` dies under the inclusion into `superlevel_set g t` exactly when the points are `JoinedIn` the target closed superlevel | strict-level conventions; attainment of a critical death threshold; an elder or barcode theorem; the later interval, elder, maximum/saddle, count, Field or stochastic bridges; any Morse chart, critical-level attainment theorem, elder correspondence, Field adapter, count identity or stochastic law | The audited definitions (`torus_E`, `torus_quotient`, `torus_latticeVec`, `torus_periodBasis`, `torus_periodLattice`, `torus_proj`, `torus_isPeriodic`, `torus_descend`, the three lattice instances, `superlevel_set`, `superlevel_inclusion`, `superlevel_componentMap`, -`superlevel_componentInclusion`, `superlevel_filtration`, `superlevel_h0Filtration`) are -constructions, not claims; they are audited so that no hidden axiom enters through a definition. +`superlevel_componentInclusion`, `superlevel_filtration`, `superlevel_h0Filtration`, +`superlevelBar_E`, `superlevelBar_isEssential`, `superlevelBar_clearanceSet`, +`superlevelBar_deathHeight`, `ordinaryH0_componentFunctor`, `ordinaryH0_componentCoproductFunctor`, +`ordinaryH0_componentFiltration`, `ordinaryH0_simplicialPointClass`, `ordinaryH0_pointClass`, +`ordinaryH0_naturalIso`, `ordinaryH0_filtrationIso`) are constructions, not claims; they are +audited so that no hidden axiom enters through a definition. ## Controls in the replay @@ -51,6 +88,8 @@ constructions, not claims; they are audited so that no hidden axiom enters throu | `RejectSuperlevelSignFlip` | the parameter convention: `() ∈ F(-1)` for the constant `0` would hold if the definition read `t ≤ g x` instead of `-t ≤ g x`; Lean leaves `⊢ False` | | `RejectSuperlevelBelowThreshold` | a point below the threshold admitted to the closed level (`3 ∈ {x | 4 ≤ x}`); `⊢ False` | | `RejectConstantNotPeriodic` | the negation of a periodicity instance that `Positive.lean` uses (`fun _ _ => rfl`); `⊢ False` | +| `RejectEssentialDeathBound` (C263) | the death/start bound asserted on the essential default branch: `superlevelBar_deathHeight (fun _ : superlevelBar_E 1 => (-1 : ℝ)) 0 ≤ (-1 : ℝ)`; `superlevelBar_death_const` reduces the death to `0` and `0 ≤ -1` is false (the proposition of the C263 handoff's `FALSE_CONTROL_PROPOSAL` (Math- #428 comment 6113033351), whose tactic `rw [superlevelBar_death_const 1 (-1) (0 : superlevelBar_E 1)]; norm_num` is replaced here by `norm_num [superlevelBar_death_const]`); `⊢ False` | +| `RejectReducedPointClass` (C264) | a reduced-H0 substitution: the ordinary point class of the one-point space with `ℤ`-module coefficients asserted NOT to be augmented to the identity; `ordinaryH0_pointClass_augmentation` rewrites it to `𝟙 R ≠ 𝟙 R`; `⊢ False` | | `RejectSorry`, `RejectCustomAxiom`, `RejectNativeDecide` | an admitted proof, a hidden premise behind an intermediate theorem, and a native-code decision each pass Lean (exit 0) and must be refused by the transitive axiom audit (`sorryAx`, `hiddenPremise`, `injected._native.native_decide.ax_1_1`) | Each control is matched by `re.fullmatch` against its pinned diagnostic; the false-statement @@ -61,7 +100,8 @@ diagnostic, wrong exit code, unknown control, `sorryAx`, unknown or missing audi unrecognized audit text, missing or extra type, a diagnostic after the type listing, membership or byte drift, a committed `.olean`, a symlinked source, stale manifest, duplicate JSON key, renamed theorem, hidden or indented declaration, injected admission, every honesty label and -schema field of `SOURCE_FILES.json` one at a time, wrong or unpinned toolchain and dependency +schema field of `SOURCE_FILES.json` outside the successor record one at a time (the successor record's +coverage is stated at the end of this list), wrong or unpinned toolchain and dependency lock, host identity mismatch, an emitted Lean file altered between `emit` and `finish`, an unrecognized `leanchecker` invocation, leanchecker output in modules mode, wrong installed dependency, a second `finish` on a directory already holding a receipt, an existing receipt @@ -71,29 +111,47 @@ spliced to a closed block comment or to a numeral, every refused command keyword the namespace opening, a declaration census (`Census.lean`) with an extra, missing or unlisted constant, a user-written declaration with an internal-style name, a `census_auxiliary` entry that Lean did not generate, a keyword spliced to a hex/binary/octal/exponent numeral, a wrong -census count or terminator, and a `check.py` child running in a different -optimization mode from the outer test interpreter, which the fixture checks on every child). +census count or terminator, a `check.py` child running in a different +optimization mode from the outer test interpreter, which the fixture checks on every child, and, +since the C263/C264 registration, a companion import of the module itself, of a later module or +of the root, an `open scoped` line with a lowercase or missing namespace or anything else on the +line, the pre-registration two-import root module and three-module `leanchecker` command, a +module name outside `MODULES`, and single-field changes to the successor record (a changed +handoff or successor hash, a successor byte count or a C26x entry of `provenance.original_bytes`, a changed census line, a nonzero credit, a lifted or +self-awarded `formal_status`, a dropped comment pointer, a dropped or added module entry); its remaining fields (handoff +byte count and status, lane, authors, namespace, imports, change summary) are refused through the whole-record +comparison in `metadata`, not by a control of their own). ## Evidence boundary -A green hosted run establishes, for these 58 declarations at this toolchain and dependency +A green hosted run establishes, for these 109 declarations at this toolchain and dependency lock, that Lean elaborated them with warnings as errors, that Lean's own census of the -constants the three modules add to the environment (`Census.lean`, with declaration-range and -internal-name tags) has exactly these 58 as its user-written declarations and exactly the one -named compiler-generated auxiliary, that -`leanchecker TorusTopology ClosedSuperlevel TorusFiltration` replayed the companion modules' own +constants the five modules (the four modules and the root) add to the environment +(`Census.lean`, with declaration-range and internal-name tags) has exactly these 109 as its +user-written declarations and exactly the one named compiler-generated auxiliary (internal +generated constants, 23 at the pin, are counted and otherwise ignored), that +`leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration` replayed the +companion modules' own declarations through the kernel against the cached, prebuilt dependency `.olean` files (the import closure, all of Mathlib, is trusted from that cache and not re-checked; a `--fresh` re-check of the closure does not fit a hosted job and is available only as an operator's local run, which the receipt records as mode `fresh`), and that every transitive axiom lies in `{propext, Classical.choice, Quot.sound}`. It establishes nothing about alignment with the -research programme, nothing about C253 or any q0 claim, and nothing the handoff's own list of exclusions names: critical-level +research programme, nothing about C253 or any q0 claim, and nothing the handoffs' own lists of exclusions name: critical-level attainment, finite critical events, label tracking, naturality to singular-H0 generators beyond -the functor laws, interval decomposition, bar bijection, elder events, once-counting, or any -identification of `PairLawInterface.p`. The receipt's `formalization_status: kernel-checked` is a +the functor laws (C254; the C264 module proves that naturality for Mathlib's actual H0 and +nothing beyond it), interval decomposition, bar bijection, elder events, once-counting, any +identification of `PairLawInterface.p`, an inhabitant of the Field or Lifetime record, a Field +adapter, a Morse chart, a count identity, a Gaussian or stochastic law, closed-threshold +attainment at the C263 death height, reduced-H0 vanishing, or any claim for a zero coefficient +object. The receipt's `formalization_status: kernel-checked` is a record of that computation; `alignment_status` remains `PENDING_INDEPENDENT_REVIEW` and `scientific_acceptance` remains `false` until an independent reviewer with nonzero -organizational-independence credit records otherwise. Aging approves nothing. +organizational-independence credit records otherwise. For `SuperlevelBar` and `OrdinaryH0` the +handoffs' own FORMAL HOLD stands in addition until a nonauthor exact-source review of the compiled +successor bytes (346eea94…, 3d6b0d6b…) exists; the registration of 2026-10-11 is not that review, +and the compiler, repairer and registrar of both successors is the companion's own lane at +organizational-independence credit 0. Aging approves nothing. ## Reproduction diff --git a/companions/torus_filtration_20261011/SOURCE_FILES.json b/companions/torus_filtration_20261011/SOURCE_FILES.json index 09cb314ab..839dafcca 100644 --- a/companions/torus_filtration_20261011/SOURCE_FILES.json +++ b/companions/torus_filtration_20261011/SOURCE_FILES.json @@ -16,6 +16,30 @@ ], "instance": [] }, + "OrdinaryH0": { + "abbrev": [], + "def": [ + "ordinaryH0_componentFunctor", + "ordinaryH0_componentCoproductFunctor", + "ordinaryH0_componentFiltration", + "ordinaryH0_simplicialPointClass", + "ordinaryH0_pointClass", + "ordinaryH0_naturalIso", + "ordinaryH0_filtrationIso" + ], + "instance": [] + }, + "SuperlevelBar": { + "abbrev": [ + "superlevelBar_E" + ], + "def": [ + "superlevelBar_isEssential", + "superlevelBar_clearanceSet", + "superlevelBar_deathHeight" + ], + "instance": [] + }, "TorusTopology": { "abbrev": [ "torus_E", @@ -47,20 +71,30 @@ "git_blob": "a4323cb50fb2d5861c4e6240a18684bfb566fb80", "sha256": "90d1481b75d9c6d14e462c3fbf0bf7c7cdd0efb9eaad68d6732400658753b1c2" }, + "companions/torus_filtration_20261011/OrdinaryH0.lean": { + "bytes": 19803, + "git_blob": "7bc5f80028271e0e33d857e60496ca4cadaa9364", + "sha256": "3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88" + }, "companions/torus_filtration_20261011/README.md": { - "bytes": 30582, - "git_blob": "2f99b89767fb37648bc0742ed4e8328c245b74b1", - "sha256": "8084b313486bbf72fa32ab57fc604fb88bccb658b21569c225f5b6b68a783f49" + "bytes": 56162, + "git_blob": "671b4cb7c295461efb3e4922537f476139177dfb", + "sha256": "f1e0a8c57012a024f744da74229885bb3062e0db842ad36ba489dbb7e06f74fe" }, "companions/torus_filtration_20261011/SCOPE.md": { - "bytes": 11141, - "git_blob": "6f78f7300475eec8b97455133714310fbdf35a29", - "sha256": "cb7d9cb9929a05fd3b0d07f91dfbc9b2b0f796cbd59da5f1e34bc2ab08a55d7b" + "bytes": 22627, + "git_blob": "5d0b673aa604173c2161d839f700d4c397ea7bfb", + "sha256": "b2239cf0548f87b588925eb9d86aa17b74dff7774d2653925d4d888389977072" + }, + "companions/torus_filtration_20261011/SuperlevelBar.lean": { + "bytes": 15309, + "git_blob": "b047384e20306ee030154885536c531633b88bd8", + "sha256": "346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9" }, "companions/torus_filtration_20261011/TorusFiltration.lean": { - "bytes": 45, - "git_blob": "d8e52f866943d54959cd38d5ec496739f739bc17", - "sha256": "5498eb85d94965073f8cee18fda4bd8a6f4ceef36ed85efd7fb78784ab4f0e58" + "bytes": 84, + "git_blob": "29e41ef12ae1a24eb36de48b9ee0738fc939d77b", + "sha256": "33b88648df5c0144a492544f3da83e6ebbe72aadc6fccc1ece930335ad2a3af5" }, "companions/torus_filtration_20261011/TorusTopology.lean": { "bytes": 12257, @@ -68,24 +102,26 @@ "sha256": "ddb145b3f791c181d4f2a51e54e711937297bd6476ba55bcd5252b7ddb57cfe1" }, "companions/torus_filtration_20261011/check.py": { - "bytes": 40225, - "git_blob": "afc6492bb39f9830f99b1a28ee16ab04537fd45d", - "sha256": "d8fb2add2ca430b0f935f1578adecc90da798a7fb33f693ada156a09af99077d" + "bytes": 49482, + "git_blob": "999eb4bf06273e572f19e9e34125898657832a8c", + "sha256": "c4416dc9e890895156bec553971d4dbcb0f4a6feeddaa9fcdbe055e405f4cf0a" }, "companions/torus_filtration_20261011/replay.sh": { - "bytes": 4382, - "git_blob": "05602a3f7f5fd2cada98625b27c5268a407cc8f1", - "sha256": "cb6b54e1aabda382c48eca7316d5e892845f68e2a708082a30b5e2acf81fe95c" + "bytes": 5236, + "git_blob": "ff47d2393e341232273186d5e9ff44559eac1e3d", + "sha256": "34b739182179806a802633eff78b2006c8e5baa49cd04652f951a121a3bc8f2d" }, "companions/torus_filtration_20261011/test_torus_filtration.py": { - "bytes": 84884, - "git_blob": "0fd3c887cdec71cd7b232933cdd08b4f34918fee", - "sha256": "ab95294403739a4f20df7fafc6bca7bf0e25748595581cdaaba02fc975a38d2f" + "bytes": 108149, + "git_blob": "ef12443fb8b2d6e0cbb61706d45d023815bad261", + "sha256": "007365ea76c68f59ff85f3190dff6fe0a3676ade44915fa2f260542f02be8a84" } }, "modules": [ "TorusTopology", - "ClosedSuperlevel" + "ClosedSuperlevel", + "SuperlevelBar", + "OrdinaryH0" ], "namespace": "TorusFiltration", "provenance": { @@ -102,14 +138,74 @@ }, "handoff_pr": "d6g8k5htny-coder/Math-#419", "human_review": "none", - "namespace_mapping": "ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion)", + "namespace_mapping": "ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion) for TorusTopology and ClosedSuperlevel; SuperlevelBar and OrdinaryH0 were authored directly in namespace TorusFiltration", "organizational_independence_credit": 0, + "original_bytes": { + "C263-handoff/SuperlevelBar.lean": 14904, + "C264-handoff/OrdinaryH0.lean": 18469, + "ResearchFormalCoreR1/ClosedSuperlevel.lean": 7827, + "ResearchFormalCoreR1/TorusTopology.lean": 11542 + }, "original_sha256": { + "C263-handoff/SuperlevelBar.lean": "d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8", + "C264-handoff/OrdinaryH0.lean": "261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e", "ResearchFormalCoreR1/ClosedSuperlevel.lean": "1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e", "ResearchFormalCoreR1/TorusTopology.lean": "efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4" }, "original_status": "NOT_COMPILED", - "source_author": "OpenAI/Codex lane (C254), delegated AI work for Dylan Roy" + "source_author": "OpenAI/Codex lane (C254), delegated AI work for Dylan Roy", + "successors": { + "OrdinaryH0.lean": { + "census_at_pin": "38 constants = 27 user range + 0 user generated + 11 internal generated", + "comments": { + "delivery_1_of_3_source_428": "6113276830", + "delivery_2_of_3_nonauthor_source_review_428": "6113277173", + "delivery_3_of_3_verification_and_owner_task_428": "6113277485", + "failed_compile_record_this_lane_428": "6113300903", + "owner_repair_handoff_428": "6113372506", + "repair_report_this_lane_428": "6113438262" + }, + "formal_status": "FORMAL_HOLD until a nonauthor exact-source review of the compiled successor; registration is not review", + "handoff_bytes": 18469, + "handoff_sha256": "261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e", + "handoff_status": "FAILED_AT_PIN_WITH_WARNINGS_AS_ERRORS: unused section instances, an unsolved naturality goal and two unused simp arguments, unknown identifier isoWhiskerLeft (Math- #428 comment 6113300903)", + "imports": [ + "Mathlib", + "ClosedSuperlevel" + ], + "lane": "C264", + "namespace": "authored directly in namespace TorusFiltration (no handoff namespace to map)", + "organizational_independence_credit": 0, + "source_author": "OpenAI/Codex lane (C264, c264_h0_author; root 01a0bbb5 supplied the target, custody and the nonzero-coefficient/projection control design; c264_h0_author/api_support did read-only pinned-API research and proposed the cycle/projection naturality rewrite chain; as disclosed in Math- #428 comment 6113276830), delegated AI work for Dylan Roy", + "successor_author": "Anthropic/Claude lane (companion owner, actual repair author), delegated AI work for Dylan Roy", + "successor_bytes": 19803, + "successor_changes": "owner repair per the C264 handoff: the homology instances enter the variable scope after the two filtration declarations (moved up; no statement changed); ordinaryH0_iso_naturality proved by explicit rw/erw reassociation; Functor.isoWhiskerLeft qualified; the three names containing iota spelled in ASCII; module-docstring lines recording the repair (full diff: Math- #428 comment 6113438262)", + "successor_sha256": "3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88" + }, + "SuperlevelBar.lean": { + "census_at_pin": "25 constants = 24 user range + 0 user generated + 1 internal generated (superlevelBar_deathHeight.eq_1)", + "comments": { + "allocation_419": "6112439759", + "compile_report_this_lane_428": "6113229784", + "delivery_and_owner_task_428": "6113033545" + }, + "formal_status": "FORMAL_HOLD until a nonauthor exact-source review of the compiled successor; registration is not review", + "handoff_bytes": 14904, + "handoff_sha256": "d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8", + "handoff_status": "FAILED_AT_PIN_WITH_WARNINGS_AS_ERRORS: deprecated if_pos at line 123 (Lean core, deprecated since 2026-07-21)", + "imports": [ + "Mathlib" + ], + "lane": "C263", + "namespace": "authored directly in namespace TorusFiltration (no handoff namespace to map)", + "organizational_independence_credit": 0, + "source_author": "OpenAI/Codex lane (C263, c262_lean_source_review acting as implementer), delegated AI work for Dylan Roy", + "successor_author": "Anthropic/Claude lane (companion owner), delegated AI work for Dylan Roy", + "successor_bytes": 15309, + "successor_changes": "superlevelBar_death_eq_sSup_of_nonempty: simp lemma if_pos hne -> ite_eq_left hne (same statement, Lean's own replacement); six module-docstring lines (a blank separator and five text lines) recording the handoff hash and the fix; no other byte", + "successor_sha256": "346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9" + } + } }, "root_module": "TorusFiltration", "schema": 1, @@ -137,6 +233,50 @@ "superlevel_h0Filtration_map_id", "superlevel_h0Filtration_map_comp" ], + "OrdinaryH0": [ + "ordinaryH0_componentCoproductMap_iota", + "ordinaryH0_componentFiltration_map_iota", + "ordinaryH0_simplicialPointClass_iso", + "ordinaryH0_simplicialPointClass_map", + "ordinaryH0_toSSet_pointMap", + "ordinaryH0_pointClass_map", + "ordinaryH0_pointClass_iso", + "ordinaryH0_componentIota_isoInv", + "ordinaryH0_hom_ext", + "ordinaryH0_iso_naturality", + "ordinaryH0_pointClass_augmentation", + "ordinaryH0_pointClass_ne_zero", + "ordinaryH0_pointClass_eq_of_component_eq", + "ordinaryH0_sameComponent_difference_zero", + "ordinaryH0_pointClass_ne_of_component_ne", + "ordinaryH0_pointClass_eq_iff", + "ordinaryH0_difference_map", + "ordinaryH0_difference_map_eq_zero_iff", + "ordinaryH0_filtration_naturality", + "ordinaryH0_filtration_difference_zero_iff_joinedIn" + ], + "SuperlevelBar": [ + "superlevelBar_essential_iff", + "superlevelBar_mem_lt_start", + "superlevelBar_clearance_bddAbove", + "superlevelBar_clearance_empty_of_essential", + "superlevelBar_death_eq_zero_of_empty", + "superlevelBar_death_eq_zero_of_essential", + "superlevelBar_death_eq_sSup_of_nonempty", + "superlevelBar_path_minimum", + "superlevelBar_clearance_nonempty", + "superlevelBar_clearance_nonempty_iff", + "superlevelBar_clearance_downward", + "superlevelBar_clearance_improve", + "superlevelBar_strict_cut", + "superlevelBar_death_le_start_of_nonempty", + "superlevelBar_death_le_start", + "superlevelBar_clearance_eq_Iio", + "superlevelBar_death_not_mem_clearance", + "superlevelBar_cut_unique", + "superlevelBar_death_const", + "superlevelBar_control_negative_essential" + ], "TorusTopology": [ "torus_field_latticeVec_formula", "torus_basis_sum_eq_latticeVec", diff --git a/companions/torus_filtration_20261011/SuperlevelBar.lean b/companions/torus_filtration_20261011/SuperlevelBar.lean new file mode 100644 index 000000000..b047384e2 --- /dev/null +++ b/companions/torus_filtration_20261011/SuperlevelBar.lean @@ -0,0 +1,299 @@ +import Mathlib + +/-! +# C263 total strict-clearance cut for continuous Euclidean heights + +Proves: total essentiality, strict-clearance set and real death value with an +explicit empty-set value zero; an unconditional bound for clearance members; +nonemptiness for continuous nonessential inputs; strict witness improvement; +the exact strict supremum cut, guarded death bound and cut uniqueness. + +Method: the starting endpoint bounds every clearance; a straight path and the +attained minimum on its compact unit-interval parameter supply a lower witness +and a uniform strict margin; conditional real supremum laws identify the cut. + +Does not establish: an inhabitant of the separately owned Field or Lifetime +record, an elder relation, Morse endpoint attainment, ordinary H0 bar pairing, +finite-bar counts, a Gaussian field or weighted law, or scientific acceptance. +The scalar zero on an empty set is a default, not an essential-bar death. + +Authored by OpenAI/Codex c262_lean_source_review, now acting as C263 implementer, +delegated for Dylan Roy. Source/design-exposed; organizational independence 0; +no human review. Consumes C260 prose SHA-256 +d2462639df32364e6fc8b0fea0703106c668cedb0aa7bb00e139aa81561bd845. +Target pin: Lean 4.34.1 / Mathlib d13f23b723b8a846827a245b89c10fc7d3f11612. +Elaboration, kernel audit and executed controls are recorded in separate +source-bound receipts; this text makes no execution claim. + +Compile fix at the pin (Anthropic/Claude lane, companion owner; handoff bytes +SHA-256 d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8 did not +elaborate with `-DwarningAsError=true`): in `superlevelBar_death_eq_sSup_of_nonempty` +the simp lemma `if_pos` (deprecated in Lean core since 2026-07-21) is replaced by +its successor `ite_eq_left`, the same statement; no other byte changes. +-/ + +noncomputable section + +namespace TorusFiltration + +/-- Proves: the ambient type is real Euclidean space in the stated dimension. +Method: a type abbreviation. Does not establish: a positive-dimensional or +periodic quotient-space hypothesis. -/ +abbrev superlevelBar_E (d : ℕ) := EuclideanSpace ℝ (Fin d) + +/-- Proves: the essentiality datum is total. Method: global order comparison. +Does not establish: an actual persistence interpretation off the guarded locus. -/ +def superlevelBar_isEssential {d : ℕ} (g : superlevelBar_E d → ℝ) + (M : superlevelBar_E d) : Prop := + ∀ y, g y ≤ g M + +/-- Proves: a total strict-clearance set with the source's existential endpoint. +Method: quantify over actual paths and every parameter, including endpoints. +Does not establish: a path attaining the supremum with closed inequalities. -/ +def superlevelBar_clearanceSet {d : ℕ} (g : superlevelBar_E d → ℝ) + (M : superlevelBar_E d) : Set ℝ := + {h | ∃ y, g M < g y ∧ ∃ γ : Path M y, ∀ t : unitInterval, h < g (γ t)} + +/-- Proves: the death datum is a total real number with explicit empty default. +Method: nonempty conditional supremum; boundedness is proved below. +Does not establish: a finite death for an essential class. -/ +def superlevelBar_deathHeight {d : ℕ} (g : superlevelBar_E d → ℝ) + (M : superlevelBar_E d) : ℝ := by + classical + exact if (superlevelBar_clearanceSet g M).Nonempty then + sSup (superlevelBar_clearanceSet g M) else 0 + +/-- Proves: essentiality is exactly global maximality for these total data. +Method: unfold the defining proposition. Does not establish: agreement with +an independently defined essential persistence class. -/ +theorem superlevelBar_essential_iff {d : ℕ} (g : superlevelBar_E d → ℝ) + (M : superlevelBar_E d) : + superlevelBar_isEssential g M ↔ ∀ y, g y ≤ g M := Iff.rfl + +/-- Proves: an unconditional strict bound on each clearance member. +Method: evaluate its path at zero. Does not establish: an unconditional bound +on the default death value when the clearance set is empty. -/ +theorem superlevelBar_mem_lt_start {d : ℕ} (g : superlevelBar_E d → ℝ) + (M : superlevelBar_E d) {h : ℝ} (hh : h ∈ superlevelBar_clearanceSet g M) : + h < g M := by + obtain ⟨y, hy, γ, hγ⟩ := hh + have hzero := hγ (0 : unitInterval) + simpa only [γ.source] using hzero + +/-- Proves: the clearance set is bounded above, including when empty. +Method: the initial height bounds each member. Does not establish: that the +empty-set default death value obeys the same bound. -/ +theorem superlevelBar_clearance_bddAbove {d : ℕ} (g : superlevelBar_E d → ℝ) + (M : superlevelBar_E d) : BddAbove (superlevelBar_clearanceSet g M) := by + exact ⟨g M, fun h hh => (superlevelBar_mem_lt_start g M hh).le⟩ + +/-- Proves: essentiality forces the clearance set to be empty. +Method: contradict the required strictly higher endpoint. +Does not establish: a converse for arbitrary discontinuous heights. -/ +theorem superlevelBar_clearance_empty_of_essential {d : ℕ} + (g : superlevelBar_E d → ℝ) (M : superlevelBar_E d) + (hM : superlevelBar_isEssential g M) : superlevelBar_clearanceSet g M = ∅ := by + ext h + constructor + · rintro ⟨y, hy, γ, hγ⟩ + exact False.elim ((not_lt_of_ge (hM y)) hy) + · intro hh + exact False.elim hh + +/-- Proves: an empty clearance set selects the declared real value zero. +Method: simplify the conditional definition. Does not establish: a geometric +death event or finite persistence interval at that zero. -/ +theorem superlevelBar_death_eq_zero_of_empty {d : ℕ} + (g : superlevelBar_E d → ℝ) (M : superlevelBar_E d) + (he : superlevelBar_clearanceSet g M = ∅) : superlevelBar_deathHeight g M = 0 := by + classical + simp [superlevelBar_deathHeight, he] + +/-- Proves: essential inputs have the declared zero default. +Method: essentiality implies empty clearance, then use the empty branch. +Does not establish: an essential-bar death height. -/ +theorem superlevelBar_death_eq_zero_of_essential {d : ℕ} + (g : superlevelBar_E d → ℝ) (M : superlevelBar_E d) + (hM : superlevelBar_isEssential g M) : superlevelBar_deathHeight g M = 0 := by + exact superlevelBar_death_eq_zero_of_empty g M + (superlevelBar_clearance_empty_of_essential g M hM) + +/-- Proves: nonempty clearance selects its real supremum in the total data. +Method: simplify the nonempty conditional branch. Does not establish: +nonemptiness without a witness or a regularity hypothesis. -/ +theorem superlevelBar_death_eq_sSup_of_nonempty {d : ℕ} + (g : superlevelBar_E d → ℝ) (M : superlevelBar_E d) + (hne : (superlevelBar_clearanceSet g M).Nonempty) : + superlevelBar_deathHeight g M = sSup (superlevelBar_clearanceSet g M) := by + classical + simp only [superlevelBar_deathHeight, ite_eq_left hne] + +/-- Proves: a continuous height attains a minimum along each actual path. +Method: compact unit interval and the extreme-value theorem. +Does not establish: a minimum over all paths or an optimal path. -/ +theorem superlevelBar_path_minimum {d : ℕ} (g : superlevelBar_E d → ℝ) + (hg : Continuous g) {M y : superlevelBar_E d} (γ : Path M y) : + ∃ t₀ : unitInterval, ∀ t : unitInterval, g (γ t₀) ≤ g (γ t) := by + obtain ⟨t₀, ht₀, hmin⟩ := + (isCompact_univ : IsCompact (Set.univ : Set unitInterval)).exists_isMinOn + (show (Set.univ : Set unitInterval).Nonempty from ⟨0, Set.mem_univ _⟩) + (hg.comp γ.continuous).continuousOn + exact ⟨t₀, fun t => hmin (Set.mem_univ t)⟩ + +/-- Proves: nonessential continuous inputs have a nonempty clearance set. +Method: a higher endpoint, Path.segment, and minimum minus one. +Does not establish: compactness of the whole Euclidean domain. -/ +theorem superlevelBar_clearance_nonempty {d : ℕ} (g : superlevelBar_E d → ℝ) + (hg : Continuous g) (M : superlevelBar_E d) + (hM : ¬ superlevelBar_isEssential g M) : + (superlevelBar_clearanceSet g M).Nonempty := by + classical + have hhigh : ∃ y, g M < g y := by + by_contra hn + apply hM + intro y + exact le_of_not_gt (fun hy => hn ⟨y, hy⟩) + obtain ⟨y, hy⟩ := hhigh + let γ : Path M y := Path.segment M y + obtain ⟨t₀, hmin⟩ := superlevelBar_path_minimum g hg γ + refine ⟨g (γ t₀) - 1, y, hy, γ, ?_⟩ + intro t + have ht := hmin t + linarith + +/-- Proves: for continuous heights, clearance is nonempty exactly off the +essential locus. Method: the higher witness endpoint and the straight-path +construction. Does not establish: this equivalence without continuity. -/ +theorem superlevelBar_clearance_nonempty_iff {d : ℕ} + (g : superlevelBar_E d → ℝ) (hg : Continuous g) (M : superlevelBar_E d) : + (superlevelBar_clearanceSet g M).Nonempty ↔ ¬ superlevelBar_isEssential g M := by + constructor + · rintro ⟨h, y, hy, γ, hγ⟩ hM + exact (not_lt_of_ge (hM y)) hy + · exact superlevelBar_clearance_nonempty g hg M + +/-- Proves: any smaller threshold than an existing clearance is a clearance. +Method: reuse the same endpoint and path and compose strict inequalities. +Does not establish: strict improvement to a larger threshold. -/ +theorem superlevelBar_clearance_downward {d : ℕ} (g : superlevelBar_E d → ℝ) + (M : superlevelBar_E d) {h c : ℝ} (hhc : h < c) + (hc : c ∈ superlevelBar_clearanceSet g M) : h ∈ superlevelBar_clearanceSet g M := by + obtain ⟨y, hy, γ, hγ⟩ := hc + exact ⟨y, hy, γ, fun t => hhc.trans (hγ t)⟩ + +/-- Proves: each strict witness has a larger strict witness on its same path. +Method: attained minimum and a midpoint below it. +Does not establish: a witness with clearance strictly above the supremum. -/ +theorem superlevelBar_clearance_improve {d : ℕ} (g : superlevelBar_E d → ℝ) + (hg : Continuous g) (M : superlevelBar_E d) {h : ℝ} + (hh : h ∈ superlevelBar_clearanceSet g M) : + ∃ c : ℝ, h < c ∧ c ∈ superlevelBar_clearanceSet g M := by + obtain ⟨y, hy, γ, hγ⟩ := hh + obtain ⟨t₀, hmin⟩ := superlevelBar_path_minimum g hg γ + have hmargin := hγ t₀ + refine ⟨(h + g (γ t₀)) / 2, ?_, y, hy, γ, ?_⟩ + · linarith + · intro t + have ht := hmin t + linarith + +/-- Proves: the exact strict cut for continuous nonessential inputs. +Method: least-upper-bound property, downward closure and strict improvement. +Does not establish: closed-threshold attainment at the death height. -/ +theorem superlevelBar_strict_cut {d : ℕ} (g : superlevelBar_E d → ℝ) + (hg : Continuous g) (M : superlevelBar_E d) + (hM : ¬ superlevelBar_isEssential g M) (h : ℝ) : + h < superlevelBar_deathHeight g M ↔ h ∈ superlevelBar_clearanceSet g M := by + classical + have hne := superlevelBar_clearance_nonempty g hg M hM + rw [superlevelBar_death_eq_sSup_of_nonempty g M hne] + constructor + · intro hlt + have hex : ∃ c ∈ superlevelBar_clearanceSet g M, h < c := by + by_contra hn + have hub : ∀ c ∈ superlevelBar_clearanceSet g M, c ≤ h := by + intro c hc + exact le_of_not_gt (fun hhc => hn ⟨c, hc, hhc⟩) + exact (not_le_of_gt hlt) (csSup_le hne hub) + obtain ⟨c, hc, hhc⟩ := hex + exact superlevelBar_clearance_downward g M hhc hc + · intro hh + obtain ⟨c, hhc, hc⟩ := superlevelBar_clearance_improve g hg M hh + exact hhc.trans_le (le_csSup (superlevelBar_clearance_bddAbove g M) hc) + +/-- Proves: the death value is at most the initial height when clearance is +nonempty. Method: the supremum is at most this upper bound. +Does not establish: the bound on the empty default branch. -/ +theorem superlevelBar_death_le_start_of_nonempty {d : ℕ} + (g : superlevelBar_E d → ℝ) (M : superlevelBar_E d) + (hne : (superlevelBar_clearanceSet g M).Nonempty) : + superlevelBar_deathHeight g M ≤ g M := by + rw [superlevelBar_death_eq_sSup_of_nonempty g M hne] + exact csSup_le hne (fun h hh => (superlevelBar_mem_lt_start g M hh).le) + +/-- Proves: the death upper bound for continuous nonessential inputs. +Method: establish nonempty clearance and apply its guarded supremum bound. +Does not establish: a strict inequality or an attained optimal path. -/ +theorem superlevelBar_death_le_start {d : ℕ} (g : superlevelBar_E d → ℝ) + (hg : Continuous g) (M : superlevelBar_E d) + (hM : ¬ superlevelBar_isEssential g M) : superlevelBar_deathHeight g M ≤ g M := by + exact superlevelBar_death_le_start_of_nonempty g M + (superlevelBar_clearance_nonempty g hg M hM) + +/-- Proves: the clearance set is the open lower interval below death on the +continuous nonessential locus. Method: extensionality and the strict cut. +Does not establish: a closed-threshold path at the excluded endpoint. -/ +theorem superlevelBar_clearance_eq_Iio {d : ℕ} (g : superlevelBar_E d → ℝ) + (hg : Continuous g) (M : superlevelBar_E d) + (hM : ¬ superlevelBar_isEssential g M) : + superlevelBar_clearanceSet g M = Set.Iio (superlevelBar_deathHeight g M) := by + ext h + exact (superlevelBar_strict_cut g hg M hM h).symm + +/-- Proves: death is not a strict clearance for continuous nonessential inputs. +Method: the cut would otherwise imply that death is strictly below itself. +Does not establish: failure or success of closed-threshold attainment. -/ +theorem superlevelBar_death_not_mem_clearance {d : ℕ} + (g : superlevelBar_E d → ℝ) (hg : Continuous g) (M : superlevelBar_E d) + (hM : ¬ superlevelBar_isEssential g M) : + superlevelBar_deathHeight g M ∉ superlevelBar_clearanceSet g M := by + intro hh + have hlt := (superlevelBar_strict_cut g hg M hM (superlevelBar_deathHeight g M)).2 hh + exact (lt_irrefl _) hlt + +/-- Proves: uniqueness of a real number with this strict cut on the valid locus. +Method: evaluate either cut at the competing endpoint. +Does not establish: equality of arbitrary total interface records off that locus. -/ +theorem superlevelBar_cut_unique {d : ℕ} (g : superlevelBar_E d → ℝ) + (hg : Continuous g) (M : superlevelBar_E d) + (hM : ¬ superlevelBar_isEssential g M) (a : ℝ) + (ha : ∀ h : ℝ, h < a ↔ h ∈ superlevelBar_clearanceSet g M) : + a = superlevelBar_deathHeight g M := by + apply le_antisymm + · by_contra hn + have hlt : superlevelBar_deathHeight g M < a := lt_of_not_ge hn + exact superlevelBar_death_not_mem_clearance g hg M hM ((ha _).1 hlt) + · by_contra hn + have hlt : a < superlevelBar_deathHeight g M := lt_of_not_ge hn + have hc := (superlevelBar_strict_cut g hg M hM a).1 hlt + exact (lt_irrefl a) ((ha a).2 hc) + +/-- Proves: any constant height selects the zero default at every point. +Method: every point is globally maximal, hence essential in these data. +Does not establish: any finite ordinary bar for that constant height. -/ +theorem superlevelBar_death_const (d : ℕ) (b : ℝ) (M : superlevelBar_E d) : + superlevelBar_deathHeight (fun _ : superlevelBar_E d => b) M = 0 := by + apply superlevelBar_death_eq_zero_of_essential + intro y + exact le_rfl + +/-- Proves: the essential default forbids an unconditional death/start bound. +Method: constant height minus one has empty clearance and death zero. +Does not establish: any finite ordinary bar on a constant field. -/ +theorem superlevelBar_control_negative_essential (d : ℕ) (M : superlevelBar_E d) : + superlevelBar_deathHeight (fun _ : superlevelBar_E d => (-1 : ℝ)) M = 0 ∧ + ¬ superlevelBar_deathHeight (fun _ : superlevelBar_E d => (-1 : ℝ)) M ≤ (-1 : ℝ) := by + rw [superlevelBar_death_const d (-1) M] + norm_num + +end TorusFiltration diff --git a/companions/torus_filtration_20261011/TorusFiltration.lean b/companions/torus_filtration_20261011/TorusFiltration.lean index d8e52f866..29e41ef12 100644 --- a/companions/torus_filtration_20261011/TorusFiltration.lean +++ b/companions/torus_filtration_20261011/TorusFiltration.lean @@ -1,2 +1,4 @@ import TorusTopology import ClosedSuperlevel +import SuperlevelBar +import OrdinaryH0 diff --git a/companions/torus_filtration_20261011/check.py b/companions/torus_filtration_20261011/check.py index afc6492bb..999eb4bf0 100644 --- a/companions/torus_filtration_20261011/check.py +++ b/companions/torus_filtration_20261011/check.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 -"""Source-bound evidence driver for the C254 torus/closed-superlevel companion (stdlib only). +"""Source-bound evidence driver for the torus-filtration companion (stdlib only). +The companion holds the C254 torus/closed-superlevel modules and, since the C263/C264 +registration, the strict-cut module SuperlevelBar and the ordinary-H0 module OrdinaryH0. Not an acceptance engine, not a general Lean parser, not a review. It binds the companion's bytes to Git HEAD, emits the audit/type/positive/negative Lean files, refuses negative-control logs that are not the intended diagnostic, and writes a @@ -24,20 +26,76 @@ WORKFLOW = '.github/workflows/torus-filtration.yml' REPO = 'd6g8k5htny-coder/Math-' NAMESPACE = 'TorusFiltration' -MODULES = ('TorusTopology', 'ClosedSuperlevel') +# Dependency order: a module may `import` only Mathlib and companion modules listed before it (scan_module). +MODULES = ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0') ROOT_MODULE = 'TorusFiltration' -ROOT_SOURCE = 'import TorusTopology\nimport ClosedSuperlevel\n' +ROOT_SOURCE = ''.join('import ' + m + '\n' for m in MODULES) REQUIRED_FILES = tuple(PACKAGE + '/' + n for n in ( - 'TorusFiltration.lean', 'TorusTopology.lean', 'ClosedSuperlevel.lean', 'check.py', 'replay.sh', - 'test_torus_filtration.py', 'README.md', 'SCOPE.md')) + (WORKFLOW,) + 'TorusFiltration.lean', 'TorusTopology.lean', 'ClosedSuperlevel.lean', 'SuperlevelBar.lean', 'OrdinaryH0.lean', + 'check.py', 'replay.sh', 'test_torus_filtration.py', 'README.md', 'SCOPE.md')) + (WORKFLOW,) PINNED_CORE = ('formal/lakefile.toml', 'formal/lake-manifest.json', 'formal/lean-toolchain') TOOLCHAIN = 'leanprover/lean4:v4.34.1' LEAN_VERSION = re.compile(r'Lean \(version 4\.34\.1, [^()\r\n]+, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release\)') CLAIM = '8a5c7a24-784b-4aaa-b951-cd9f37b0dc64' +# Handoff bytes as posted, before any compile fix: the two C254 originals (Math- #419, NOT_COMPILED) and the C263 and +# C264 originals (Math- #428), which were compiled at the pin with warnings as errors and failed (SUCCESSORS below). ORIGINAL_SHA256 = { 'ResearchFormalCoreR1/TorusTopology.lean': 'efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4', - 'ResearchFormalCoreR1/ClosedSuperlevel.lean': '1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e'} -NAMESPACE_MAPPING = 'ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion)' + 'ResearchFormalCoreR1/ClosedSuperlevel.lean': '1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e', + 'C263-handoff/SuperlevelBar.lean': 'd74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8', + 'C264-handoff/OrdinaryH0.lean': '261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e'} +ORIGINAL_BYTES = { + 'ResearchFormalCoreR1/TorusTopology.lean': 11542, 'ResearchFormalCoreR1/ClosedSuperlevel.lean': 7827, + 'C263-handoff/SuperlevelBar.lean': 14904, 'C264-handoff/OrdinaryH0.lean': 18469} +# The two C26x successors as registered. `metadata` requires SOURCE_FILES.json to carry exactly this record; the +# protocol tests (InventoryTests, run by the replay) and the out-of-tree generator require the tracked module bytes to carry exactly these identities, so +# neither successor changes by a byte without this record changing with it. Every label here is transcribed from the +# handoffs (Math- #428 comments 6113033545 and 6113372506) or records a computation of this lane; FORMAL HOLD is the +# handoffs' own acceptance status and stands until a nonauthor exact-source review of the compiled successor bytes. +# Registration is not review, not acceptance; organizational-independence credit 0 (same project account). +SUCCESSORS = { + 'SuperlevelBar.lean': { + 'lane': 'C263', + 'source_author': 'OpenAI/Codex lane (C263, c262_lean_source_review acting as implementer), delegated AI work for Dylan Roy', + 'handoff_sha256': 'd74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8', 'handoff_bytes': 14904, + 'handoff_status': 'FAILED_AT_PIN_WITH_WARNINGS_AS_ERRORS: deprecated if_pos at line 123 (Lean core, deprecated since 2026-07-21)', + 'successor_sha256': '346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9', 'successor_bytes': 15309, + 'successor_changes': 'superlevelBar_death_eq_sSup_of_nonempty: simp lemma if_pos hne -> ite_eq_left hne (same statement, ' + 'Lean\'s own replacement); six module-docstring lines (a blank separator and five text lines) recording the handoff hash and the fix; no other byte', + 'successor_author': 'Anthropic/Claude lane (companion owner), delegated AI work for Dylan Roy', + 'namespace': 'authored directly in namespace TorusFiltration (no handoff namespace to map)', + 'imports': ['Mathlib'], + 'census_at_pin': '25 constants = 24 user range + 0 user generated + 1 internal generated (superlevelBar_deathHeight.eq_1)', + 'comments': {'allocation_419': '6112439759', 'delivery_and_owner_task_428': '6113033545', + 'compile_report_this_lane_428': '6113229784'}, + 'formal_status': 'FORMAL_HOLD until a nonauthor exact-source review of the compiled successor; registration is not review', + 'organizational_independence_credit': 0}, + 'OrdinaryH0.lean': { + 'lane': 'C264', + 'source_author': 'OpenAI/Codex lane (C264, c264_h0_author; root 01a0bbb5 supplied the target, custody and the ' + 'nonzero-coefficient/projection control design; c264_h0_author/api_support did read-only pinned-API ' + 'research and proposed the cycle/projection naturality rewrite chain; as disclosed in Math- #428 ' + 'comment 6113276830), ' + 'delegated AI work for Dylan Roy', + 'handoff_sha256': '261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e', 'handoff_bytes': 18469, + 'handoff_status': 'FAILED_AT_PIN_WITH_WARNINGS_AS_ERRORS: unused section instances, an unsolved naturality goal and two ' + 'unused simp arguments, unknown identifier isoWhiskerLeft (Math- #428 comment 6113300903)', + 'successor_sha256': '3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88', 'successor_bytes': 19803, + 'successor_changes': 'owner repair per the C264 handoff: the homology instances enter the variable scope after the two ' + 'filtration declarations (moved up; no statement changed); ordinaryH0_iso_naturality proved by explicit ' + 'rw/erw reassociation; Functor.isoWhiskerLeft qualified; the three names containing iota spelled in ' + 'ASCII; module-docstring lines recording the repair (full diff: Math- #428 comment 6113438262)', + 'successor_author': 'Anthropic/Claude lane (companion owner, actual repair author), delegated AI work for Dylan Roy', + 'namespace': 'authored directly in namespace TorusFiltration (no handoff namespace to map)', + 'imports': ['Mathlib', 'ClosedSuperlevel'], + 'census_at_pin': '38 constants = 27 user range + 0 user generated + 11 internal generated', + 'comments': {'delivery_1_of_3_source_428': '6113276830', 'delivery_2_of_3_nonauthor_source_review_428': '6113277173', + 'delivery_3_of_3_verification_and_owner_task_428': '6113277485', 'failed_compile_record_this_lane_428': '6113300903', + 'owner_repair_handoff_428': '6113372506', 'repair_report_this_lane_428': '6113438262'}, + 'formal_status': 'FORMAL_HOLD until a nonauthor exact-source review of the compiled successor; registration is not review', + 'organizational_independence_credit': 0}} +NAMESPACE_MAPPING = ('ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion) for TorusTopology and ClosedSuperlevel; ' + 'SuperlevelBar and OrdinaryH0 were authored directly in namespace TorusFiltration') # Own copy of formal/gate.py's audit rules; the companion imports nothing from the core. ALLOWED = frozenset({'propext', 'Classical.choice', 'Quot.sound'}) NAME = r'[A-Za-z_][A-Za-z0-9_.]*' @@ -45,13 +103,12 @@ IDENT = r'[A-Za-z][A-Za-z0-9_]*' HEX40 = re.compile(r'[0-9a-f]{40}') HEX64 = re.compile(r'[0-9a-f]{64}') -BUILDS = ('build-TorusTopology', 'build-ClosedSuperlevel', 'build-TorusFiltration', 'positive', 'axioms', 'types', 'census', - 'leanchecker') -# The leanchecker invocations replay.sh may record in leanchecker.cmd. Both modules `import Mathlib`, so +BUILDS = tuple('build-' + m for m in MODULES + (ROOT_MODULE,)) + ('positive', 'axioms', 'types', 'census', 'leanchecker') +# The leanchecker invocations replay.sh may record in leanchecker.cmd. All four modules `import Mathlib`, so # `--fresh` (kernel re-check of the whole import closure) exceeds a hosted job: measured locally at 4 threads # it was still running at 1500 s with 6.6 GB resident. The hosted default replays the companion's own -# declarations against the cached, prebuilt dependency .oleans (33 s at 2 threads locally). -LEANCHECKER = {'leanchecker TorusTopology ClosedSuperlevel TorusFiltration': 'modules', +# declarations against the cached, prebuilt dependency .oleans (33 s at 2 threads locally for the C254 pair). +LEANCHECKER = {'leanchecker ' + ' '.join(MODULES + (ROOT_MODULE,)): 'modules', 'leanchecker --fresh TorusFiltration': 'fresh'} ADMISSION = ('sorry', 'sorryAx', 'admit', 'axiom', 'native_decide', 'ofReduceBool', 'trustCompiler', 'unsafe', 'opaque', 'partial', 'implemented_by', 'extern', 'skipKernelTC', 'autoImplicit') @@ -114,16 +171,33 @@ def admission_tokens(text): present.update(found.group().split('.')) return [token for token in ADMISSION if token in present] DECLARATION = re.compile(r'(theorem|abbrev|instance|def|noncomputable def) (' + IDENT + r')(?=$|[\s:(\[{⦃])') -PRELUDE = {'import': re.compile(r'import Mathlib(?:\.[A-Za-z0-9_]+)*'), +# Column-0 prelude lines. `import` admits Mathlib and, since the C263/C264 registration, a companion module named in +# MODULES (scan_module further requires it to precede the importing module in MODULES: no self, forward or root import). +# `open scoped ` activates scoped notation and instances only, a strictly smaller effect than the `open` +# already admitted; both lines appear in OrdinaryH0.lean. Keys are tried in order, so `open scoped` precedes `open`. +PRELUDE = {'import': re.compile(r'import (?:Mathlib(?:\.[A-Za-z0-9_]+)*|' + '|'.join(MODULES) + ')'), 'noncomputable section': re.compile(r'noncomputable section'), + 'open scoped': re.compile(r'open scoped(?: [A-Z][A-Za-z0-9_.]*)+'), 'open': re.compile(r'open(?: [A-Z][A-Za-z0-9_.]*)+'), 'universe': re.compile(r'universe(?: [A-Za-z_][A-Za-z0-9_]*)+'), 'variable': re.compile(r'variable .*')} -# False statements about the companion's own definitions; Lean must leave exactly `⊢ False`. +# False statements about the companion's own definitions; Lean must leave exactly `⊢ False`. The two C26x controls: +# RejectEssentialDeathBound asserts the death/start bound on the essential default branch (the constant height -1 has +# death 0 by superlevelBar_death_const, and 0 ≤ -1 is false; the proposition of the C263 handoff's FALSE_CONTROL_PROPOSAL, +# Math- #428 comment 6113033351, with its rw-then-norm_num tactic replaced by norm_num [superlevelBar_death_const]); +# RejectReducedPointClass asserts that the ordinary point class of the one-point space with ℤ-module coefficients is NOT +# augmented to the identity, which is what reduced H0 would give and what ordinaryH0_pointClass_augmentation refutes. +# Both diagnostics were pinned from actual Lean 4.34.1 output at the Mathlib d13f23b7 pin against the registered bytes. FALSE_CONTROLS = { 'RejectSuperlevelSignFlip': ('() ∈ superlevel_set (fun _ : Unit => (0 : ℝ)) (-1)', 'norm_num [superlevel_set]'), 'RejectSuperlevelBelowThreshold': ('(3 : ℝ) ∈ superlevel_set (fun x : ℝ => x) (-4)', 'norm_num [superlevel_set]'), - 'RejectConstantNotPeriodic': ('¬ torus_isPeriodic 1 (1 : ℝ) (fun _ => (0 : ℝ))', 'simp [torus_isPeriodic]')} + 'RejectConstantNotPeriodic': ('¬ torus_isPeriodic 1 (1 : ℝ) (fun _ => (0 : ℝ))', 'simp [torus_isPeriodic]'), + 'RejectEssentialDeathBound': ('superlevelBar_deathHeight (fun _ : superlevelBar_E 1 => (-1 : ℝ)) 0 ≤ (-1 : ℝ)', + 'norm_num [superlevelBar_death_const]'), + 'RejectReducedPointClass': ('CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of Unit) (ModuleCat.of ℤ ℤ) ()) ' + '(TopCat.singularHomology₀ε (TopCat.of Unit) (ModuleCat.of ℤ ℤ)) ' + '≠ CategoryTheory.CategoryStruct.id (ModuleCat.of ℤ ℤ)', + 'simp [ordinaryH0_pointClass_augmentation]')} # Admission injections; Lean accepts each file (exit 0), the transitive axiom audit must refuse it. # Diagnostics pinned from Lean 4.34.1 at the Mathlib d13f23b7 pin: the sorry warning uses backticks, and # native_decide introduces the auxiliary axiom `injected._native.native_decide.ax_1_1` (not Lean.ofReduceBool). @@ -135,8 +209,9 @@ def admission_tokens(text): 'RejectNativeDecide': ("theorem injected : (2 : Nat) + 2 = 4 := by native_decide\n", 'injected._native.native_decide.ax_1_1', '')} CONTROLS = tuple(FALSE_CONTROLS) + tuple(INJECTIONS) -# The exact membership of the evidence directory when `finish` runs (C262 gate review G3): the ten files emit() -# writes, a .log/.status pair per Lean process, the two protocol-test transcripts and the four environment records. +# The exact membership of the evidence directory when `finish` runs (C262 gate review G3): the twelve files emit() +# writes, a .log/.status pair per Lean process (five module builds, positive, axioms, types, census, leanchecker, eight +# controls), the two protocol-test transcripts and the four environment records. # finish() refuses a directory with any member missing or unexpected, any member that is not a regular file, and # any directory already holding receipt.json: a receipt is written once and never replaced. EMITTED_FILES = ('Audit.lean', 'Types.lean', 'Positive.lean', 'Census.lean') + tuple(c + '.lean' for c in CONTROLS) @@ -147,12 +222,13 @@ def admission_tokens(text): # constants equal the inventory exactly (a `where`-clause or unlisted-command declaration is refused whatever its # spelling); no ranged constant carries an internal-style name (a user-written `proof_1` is refused); the user-named # generated constants equal `census_auxiliary` exactly (so that whitelist can name only compiler-generated constants); -# internal generated constants are counted and otherwise ignored. +# internal generated constants are counted and otherwise ignored (the C26x modules add twelve at the pin: equation +# lemmas, abstracted proofs, a `_simp` auxiliary and the equation lemma Lean generated for Mathlib's `sigmaConst`). CENSUS = '''import TorusFiltration open Lean in #eval show Lean.Elab.Command.CommandElabM Unit from do let env ← Lean.getEnv - let modules : Array Lean.Name := #[`TorusTopology, `ClosedSuperlevel, `TorusFiltration] + let modules : Array Lean.Name := #[`TorusTopology, `ClosedSuperlevel, `SuperlevelBar, `OrdinaryH0, `TorusFiltration] let idxs := modules.filterMap env.getModuleIdx? if idxs.size != modules.size then throwError "census: a companion module is not imported" let names := env.constants.fold (init := (#[] : Array Lean.Name)) fun acc n _ => @@ -167,8 +243,10 @@ def admission_tokens(text): EVIDENCE_FILES = frozenset(EMITTED_FILES) | {label + ext for label in BUILDS for ext in ('.log', '.status')} \ | {control + ext for control in CONTROLS for ext in ('.log', '.status')} \ | {'leanchecker.cmd', 'packages.log', 'toolchain.log', 'source.json', 'tests.log', 'tests-optimized.log'} -if len(EVIDENCE_FILES) != 44: # an explicit check, not an `assert`: the gate must hold under -O too - raise RuntimeError('EVIDENCE_FILES must enumerate exactly 44 members') +# 12 emitted + 10 processes x 2 + 8 controls x 2 + 6 records = 54 (44 before the C263/C264 registration added two +# module builds and two controls). An explicit check, not an `assert`: the gate must hold under -O too. +if len(EVIDENCE_FILES) != 54: + raise RuntimeError('EVIDENCE_FILES must enumerate exactly 54 members') POSITIVE = '''import TorusFiltration open TorusFiltration @@ -273,10 +351,14 @@ def metadata(): require(isinstance(entry['git_blob'], str) and HEX40.fullmatch(entry['git_blob']), 'file git blob: ' + path) prov = meta['provenance'] require(isinstance(prov, dict), 'provenance object') - for key in ('claim', 'handoff_pr', 'handoff_comments', 'original_sha256', 'original_status', 'namespace_mapping', - 'source_author', 'compile_fixes_and_companion', 'organizational_independence_credit', 'human_review'): + for key in ('claim', 'handoff_pr', 'handoff_comments', 'original_sha256', 'original_bytes', 'original_status', + 'namespace_mapping', 'source_author', 'compile_fixes_and_companion', 'organizational_independence_credit', + 'human_review', 'successors'): require(key in prov, 'provenance key missing: ' + key) require(prov['claim'] == CLAIM and prov['original_sha256'] == ORIGINAL_SHA256, 'provenance identity') + # The C26x record is compared whole: a changed hash, byte count, author, census or status label (a self-awarded + # acceptance in `formal_status`, say) is refused as one mismatch, never partially accepted. + require(prov['original_bytes'] == ORIGINAL_BYTES and prov['successors'] == SUCCESSORS, 'successor provenance identity') require(prov['original_status'] == 'NOT_COMPILED' and prov['namespace_mapping'] == NAMESPACE_MAPPING, 'provenance labels') require(prov['organizational_independence_credit'] == 0 and prov['human_review'] == 'none', 'credit must stay zero') return meta @@ -346,13 +428,15 @@ def strip_comments(text): def scan_module(text, module): """Declaration inventory of one companion module by whitelist; refuses every line it cannot place. - Outside comments, a column-0 line may only be `import Mathlib[.…]` (before the namespace), - `noncomputable section`, `open `, `universe …`, `variable …`, the single - `namespace TorusFiltration` / `end TorusFiltration` pair, or a named `theorem`, `def`, - `noncomputable def`, `abbrev` or `instance` inside that namespace. Any other command keyword - anywhere in code (indented, after a declaration on the same line, `… in`), any `@[` or `#`, - any string literal and any admission token is refused. Not a Lean parser. + Outside comments, a column-0 line may only be `import Mathlib[.…]` or `import ` for a + companion module `M` listed before `module` in MODULES (both before the namespace), + `noncomputable section`, `open `, `open scoped `, `universe …`, + `variable …`, the single `namespace TorusFiltration` / `end TorusFiltration` pair, or a named + `theorem`, `def`, `noncomputable def`, `abbrev` or `instance` inside that namespace. Any other + command keyword anywhere in code (indented, after a declaration on the same line, `… in`), + any `@[` or `#`, any string literal and any admission token is refused. Not a Lean parser. """ + require(module in MODULES, 'not a companion module: ' + module) lines = code_lines(text) for number, code in enumerate(lines, 1): require('"' not in code, 'string literal in code: ' + module + ':' + str(number)) @@ -391,6 +475,10 @@ def scan_module(text, module): require(keyword is not None and PRELUDE[keyword].fullmatch(line), 'unexpected column-0 line in ' + where + ': ' + line[:60]) require(keyword != 'import' or state == 'prelude', 'import inside the namespace: ' + where) + if keyword == 'import' and line.split()[1] in MODULES: + # a companion import must name a module that precedes this one (acyclic, no self or forward import) + require(line.split()[1] in MODULES[:MODULES.index(module)], + 'companion import out of dependency order in ' + where + ': ' + line.split()[1]) rest = line[len(keyword):] found = command_token(rest) require(found is None, 'command token outside a column-0 declaration in ' + where + ': ' + (found or '')) @@ -407,7 +495,8 @@ def check_modules(meta, side): require(scan['theorem'] == meta['theorems'][module], 'theorem inventory differs from source: ' + module) for kind in ('abbrev', 'def', 'instance'): require(scan[kind] == meta['definitions'][module][kind], kind + ' inventory differs from source: ' + module) - require((side / (ROOT_MODULE + '.lean')).read_text(encoding='utf-8') == ROOT_SOURCE, 'root module must import exactly the two modules') + require((side / (ROOT_MODULE + '.lean')).read_text(encoding='utf-8') == ROOT_SOURCE, + 'root module must import exactly the four modules') def environment(root): diff --git a/companions/torus_filtration_20261011/replay.sh b/companions/torus_filtration_20261011/replay.sh index 05602a3f7..ff47d2393 100644 --- a/companions/torus_filtration_20261011/replay.sh +++ b/companions/torus_filtration_20261011/replay.sh @@ -1,10 +1,14 @@ #!/usr/bin/env bash -# Replay of the C254 torus-filtration companion. It runs neither formal/gate.py nor the formal -# tests: the companion consumes only the pinned toolchain, lakefile and dependency lock from -# formal/, and its evidence is kernel-checked declarations, not alignment or acceptance. +# Replay of the torus-filtration companion: TorusTopology and ClosedSuperlevel (C254) and the registered +# SuperlevelBar (C263) and OrdinaryH0 (C264) successors. It runs neither formal/gate.py nor the formal +# tests: the companion consumes only the pinned toolchain, lakefile and dependency lock from formal/, +# and its evidence is kernel-checked declarations, not alignment or acceptance. set -euo pipefail # The outer Python mode is the one named on each command line below, never an ambient PYTHONOPTIMIZE (C262 G1). unset PYTHONOPTIMIZE +# leanchecker over the five modules peaked at about 8.4-8.7 GiB resident at two threads and exceeded a 13.36 GiB +# memory limit at four (2026-10-11, this lane); default to the hosted job's two threads unless the operator sets otherwise. +export LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-2}" ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" SIDE="$ROOT/companions/torus_filtration_20261011" OUT="$ROOT/.lake/torus-filtration-evidence" @@ -38,25 +42,28 @@ run_lean() { } run_lean build-TorusTopology lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/TorusTopology.olean" "$TORUS_SIDE/TorusTopology.lean" run_lean build-ClosedSuperlevel lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/ClosedSuperlevel.olean" "$TORUS_SIDE/ClosedSuperlevel.lean" +run_lean build-SuperlevelBar lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/SuperlevelBar.olean" "$TORUS_SIDE/SuperlevelBar.lean" +run_lean build-OrdinaryH0 lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/OrdinaryH0.olean" "$TORUS_SIDE/OrdinaryH0.lean" run_lean build-TorusFiltration lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/TorusFiltration.olean" "$TORUS_SIDE/TorusFiltration.lean" run_lean positive lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Positive.lean" run_lean axioms lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Audit.lean" run_lean types lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Types.lean" run_lean census lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Census.lean" # Kernel replay of the companion modules' own declarations against the cached, prebuilt dependency -# .oleans (30 s at 2 threads locally). Both modules `import Mathlib`, so `--fresh` (re-check of the whole -# import closure) does not fit a hosted job: still running at 1500 s with 6.6 GB resident at 4 threads. +# .oleans (30 s at 2 threads locally for the three C254 modules, 53 s for the five). All four modules `import Mathlib` (OrdinaryH0 also imports +# ClosedSuperlevel), so `--fresh` (re-check of the whole import closure) does not fit a hosted job: still running +# at 1500 s with 6.6 GB resident at 4 threads. # TORUS_LEANCHECKER_FRESH=1 selects it for an operator's local run; the receipt records which mode ran. if [ "${TORUS_LEANCHECKER_FRESH:-0}" = 1 ]; then LEANCHECKER_COMMAND='leanchecker --fresh TorusFiltration' else - LEANCHECKER_COMMAND='leanchecker TorusTopology ClosedSuperlevel TorusFiltration' + LEANCHECKER_COMMAND='leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration' fi printf '%s\n' "$LEANCHECKER_COMMAND" > "$TORUS_OUT/leanchecker.cmd" # shellcheck disable=SC2086 run_lean leanchecker $LEANCHECKER_COMMAND # False statements about the companion's own definitions: Lean itself must refuse each with exactly `⊢ False`. -for control in RejectSuperlevelSignFlip RejectSuperlevelBelowThreshold RejectConstantNotPeriodic; do +for control in RejectSuperlevelSignFlip RejectSuperlevelBelowThreshold RejectConstantNotPeriodic RejectEssentialDeathBound RejectReducedPointClass; do code=0 lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/$control.lean" >"$TORUS_OUT/$control.log" 2>&1 || code=$? printf '%s\n' "$code" >"$TORUS_OUT/$control.status" diff --git a/companions/torus_filtration_20261011/test_torus_filtration.py b/companions/torus_filtration_20261011/test_torus_filtration.py index 0fd3c887c..ef12443fb 100644 --- a/companions/torus_filtration_20261011/test_torus_filtration.py +++ b/companions/torus_filtration_20261011/test_torus_filtration.py @@ -42,22 +42,69 @@ 'abbrev': [], 'def': ['superlevel_set', 'superlevel_inclusion', 'superlevel_componentMap', 'superlevel_componentInclusion', 'superlevel_filtration', 'superlevel_h0Filtration'], + 'instance': []}, + # C263 successor (346eea94…), as scan_module reports it + 'SuperlevelBar': { + 'theorem': '''superlevelBar_essential_iff superlevelBar_mem_lt_start superlevelBar_clearance_bddAbove + superlevelBar_clearance_empty_of_essential superlevelBar_death_eq_zero_of_empty + superlevelBar_death_eq_zero_of_essential superlevelBar_death_eq_sSup_of_nonempty superlevelBar_path_minimum + superlevelBar_clearance_nonempty superlevelBar_clearance_nonempty_iff superlevelBar_clearance_downward + superlevelBar_clearance_improve superlevelBar_strict_cut superlevelBar_death_le_start_of_nonempty + superlevelBar_death_le_start superlevelBar_clearance_eq_Iio superlevelBar_death_not_mem_clearance + superlevelBar_cut_unique superlevelBar_death_const superlevelBar_control_negative_essential'''.split(), + 'abbrev': ['superlevelBar_E'], + 'def': ['superlevelBar_isEssential', 'superlevelBar_clearanceSet', 'superlevelBar_deathHeight'], + 'instance': []}, + # C264 successor (3d6b0d6b…), as scan_module reports it: the two filtration declarations precede the homology ones + 'OrdinaryH0': { + 'theorem': '''ordinaryH0_componentCoproductMap_iota ordinaryH0_componentFiltration_map_iota + ordinaryH0_simplicialPointClass_iso ordinaryH0_simplicialPointClass_map ordinaryH0_toSSet_pointMap + ordinaryH0_pointClass_map ordinaryH0_pointClass_iso ordinaryH0_componentIota_isoInv ordinaryH0_hom_ext + ordinaryH0_iso_naturality ordinaryH0_pointClass_augmentation ordinaryH0_pointClass_ne_zero + ordinaryH0_pointClass_eq_of_component_eq ordinaryH0_sameComponent_difference_zero + ordinaryH0_pointClass_ne_of_component_ne ordinaryH0_pointClass_eq_iff ordinaryH0_difference_map + ordinaryH0_difference_map_eq_zero_iff ordinaryH0_filtration_naturality + ordinaryH0_filtration_difference_zero_iff_joinedIn'''.split(), + 'abbrev': [], + 'def': ['ordinaryH0_componentFunctor', 'ordinaryH0_componentCoproductFunctor', 'ordinaryH0_componentFiltration', + 'ordinaryH0_simplicialPointClass', 'ordinaryH0_pointClass', 'ordinaryH0_naturalIso', 'ordinaryH0_filtrationIso'], 'instance': []}} HANDOFF_COMMENTS = ('6111056103', '6111059166', '6111059498', '6111059848', '6111255007', '6111093545', '6111139060') +# Math- #428 (and the #419 allocation) comments the C26x successor record cites, per module. +SUCCESSOR_COMMENTS = {'SuperlevelBar.lean': {'6112439759', '6113033545', '6113229784'}, + 'OrdinaryH0.lean': {'6113276830', '6113277173', '6113277485', '6113300903', '6113372506', '6113438262'}} +SUCCESSOR_IDENTITY = {'SuperlevelBar.lean': ('346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9', 15309, + 'd74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8', 14904), + 'OrdinaryH0.lean': ('3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88', 19803, + '261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e', 18469)} LEAN_VERSION_LINE = 'Lean (version 4.34.1, x86_64-unknown-linux-gnu, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release)\n' FALSE_LOG = '/tmp/evidence/{0}.lean:4:2: error: unsolved goals\n⊢ False\n' SORRY_WARNING = "/tmp/evidence/RejectSorry.lean:2:8: warning: declaration uses `sorry`\n" INJECTED = "'injected' depends on axioms: [{0}]\n" -LEANCHECKER_MODULES = 'leanchecker TorusTopology ClosedSuperlevel TorusFiltration' +LEANCHECKER_MODULES = 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration' +LEANCHECKER_MODULES_BEFORE_C26X = 'leanchecker TorusTopology ClosedSuperlevel TorusFiltration' LEANCHECKER_FRESH = 'leanchecker --fresh TorusFiltration' EMITTED = ('Audit.lean', 'Types.lean', 'Positive.lean', 'Census.lean', 'RejectSuperlevelSignFlip.lean', - 'RejectSuperlevelBelowThreshold.lean', 'RejectConstantNotPeriodic.lean', 'RejectSorry.lean', 'RejectCustomAxiom.lean', - 'RejectNativeDecide.lean') + 'RejectSuperlevelBelowThreshold.lean', 'RejectConstantNotPeriodic.lean', 'RejectEssentialDeathBound.lean', + 'RejectReducedPointClass.lean', 'RejectSorry.lean', 'RejectCustomAxiom.lean', 'RejectNativeDecide.lean') PYTHON_LINE = 'TORUS_FILTRATION_PYTHON: optimize=%d' % sys.flags.optimize # Compiler-generated internal constants as the real census lists them (abstracted proofs, equation lemmas); the fixture -# census carries a few so the parser's `internal generated` branch is exercised. +# census carries a few so the parser's `internal generated` branch is exercised. The last twelve are exactly the +# `internal generated` rows of the C263 and C264 range-aware censuses at the pin (1 + 11); the first, +# `CategoryTheory.Limits.sigmaConst.eq_1`, is the equation lemma Lean generated for a Mathlib definition that +# OrdinaryH0.lean unfolds, attributed to the companion module, so the census parser must tolerate internal generated +# constants outside the companion namespace. INTERNAL_GENERATED = ('TorusFiltration.superlevel_set.eq_1', 'TorusFiltration.torus_periodBasis._proof_1', - 'TorusFiltration.torus_proj_eq_iff._abel_1_1') + 'TorusFiltration.torus_proj_eq_iff._abel_1_1', + 'TorusFiltration.superlevelBar_deathHeight.eq_1', + 'CategoryTheory.Limits.sigmaConst.eq_1', 'TorusFiltration.ordinaryH0_componentCoproductFunctor.eq_1', + 'TorusFiltration.ordinaryH0_componentFunctor._proof_1', 'TorusFiltration.ordinaryH0_componentFunctor._proof_2', + 'TorusFiltration.ordinaryH0_componentFunctor.eq_1', 'TorusFiltration.ordinaryH0_hom_ext._simp_1_1', + 'TorusFiltration.ordinaryH0_simplicialPointClass._proof_1', + 'TorusFiltration.ordinaryH0_simplicialPointClass._proof_2', + 'TorusFiltration.ordinaryH0_simplicialPointClass._proof_3', + 'TorusFiltration.ordinaryH0_simplicialPointClass._proof_4', + 'TorusFiltration.ordinaryH0_simplicialPointClass.eq_1') # The outer interpreter mode goes into the test transcript (tests.log / tests-optimized.log), so the hosted # evidence records which mode each suite ran in (C262 G1). print('TORUS_FILTRATION_TESTS: outer optimize=%d' % sys.flags.optimize, file=sys.stderr) @@ -290,10 +337,15 @@ def setUpClass(cls): def test_inventory_constants(self): names = [n for m in INVENTORY.values() for kind in m.values() for n in kind] self.assertEqual(len(names), len(set(names))) - self.assertEqual(sum(len(m['theorem']) for m in INVENTORY.values()), 41) - self.assertEqual([len(INVENTORY[m]['theorem']) for m in ('TorusTopology', 'ClosedSuperlevel')], [21, 20]) - self.assertEqual(sum(len(m['def']) for m in INVENTORY.values()), 12) - self.assertEqual(sum(len(m['abbrev']) + len(m['instance']) for m in INVENTORY.values()), 5) + self.assertEqual(sum(len(m['theorem']) for m in INVENTORY.values()), 81) + self.assertEqual([len(INVENTORY[m]['theorem']) for m in ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0')], + [21, 20, 20, 20]) + self.assertEqual(sum(len(m['def']) for m in INVENTORY.values()), 22) + self.assertEqual([len(INVENTORY[m]['def']) for m in INVENTORY], [6, 6, 3, 7]) + self.assertEqual(sum(len(m['abbrev']) for m in INVENTORY.values()), 3) + self.assertEqual(sum(len(m['instance']) for m in INVENTORY.values()), 3) + self.assertEqual(sum(len(kind) for m in INVENTORY.values() for kind in m.values()), 109) + self.assertEqual(len(INTERNAL_GENERATED), 15) self.assertTrue(all(re.fullmatch(self.c.IDENT, n) for n in names)) self.assertEqual(tuple(INVENTORY), self.c.MODULES) @@ -303,13 +355,44 @@ def test_source_files_inventory_provenance_and_identities(self): self.assertEqual(meta['theorems'][module], INVENTORY[module]['theorem']) for kind in ('abbrev', 'def', 'instance'): self.assertEqual(meta['definitions'][module][kind], INVENTORY[module][kind]) - self.assertEqual(len(self.c.targets(meta)), 58) + self.assertEqual(len(self.c.targets(meta)), 109) self.assertEqual(self.c.theorem_targets(meta)[0], 'TorusFiltration.torus_field_latticeVec_formula') + self.assertEqual(self.c.theorem_targets(meta)[-1], 'TorusFiltration.ordinaryH0_filtration_difference_zero_iff_joinedIn') prov = meta['provenance'] self.assertEqual(set(HANDOFF_COMMENTS), set(prov['handoff_comments'].values())) self.assertEqual(prov['handoff_pr'], 'd6g8k5htny-coder/Math-#419') self.assertIn('OpenAI/Codex', prov['source_author']) self.assertIn('Anthropic/Claude', prov['compile_fixes_and_companion']) + # The C26x successor record: handoff and successor identities, cited comments, honesty labels; and the registered + # module bytes in the tree ARE the recorded successors (the fixture cannot check this, its modules are placeholders). + self.assertEqual(set(prov['successors']), set(SUCCESSOR_IDENTITY)) + self.assertEqual(prov['successors'], self.c.SUCCESSORS) + self.assertEqual(prov['original_bytes'], self.c.ORIGINAL_BYTES) + self.assertEqual(set(self.c.ORIGINAL_BYTES), set(self.c.ORIGINAL_SHA256)) + for name, (successor, successor_bytes, handoff, handoff_bytes) in SUCCESSOR_IDENTITY.items(): + record = prov['successors'][name] + self.assertEqual((record['successor_sha256'], record['successor_bytes']), (successor, successor_bytes), name) + self.assertEqual((record['handoff_sha256'], record['handoff_bytes']), (handoff, handoff_bytes), name) + key = next(k for k in self.c.ORIGINAL_SHA256 if k.endswith('/' + name)) + self.assertEqual((self.c.ORIGINAL_SHA256[key], self.c.ORIGINAL_BYTES[key]), (handoff, handoff_bytes), name) + self.assertEqual(set(record['comments'].values()), SUCCESSOR_COMMENTS[name], name) + self.assertEqual(record['organizational_independence_credit'], 0) + self.assertTrue(record['formal_status'].startswith('FORMAL_HOLD'), name) + self.assertIn('OpenAI/Codex', record['source_author']) + self.assertIn('Anthropic/Claude', record['successor_author']) + self.assertIn('TorusFiltration', record['namespace']) + tracked = ROOT / self.c.PACKAGE / name + if tracked.is_file(): + actual = self.c.identity(tracked.read_bytes()) + self.assertEqual((actual['sha256'], actual['bytes']), (successor, successor_bytes), 'tracked module is not the recorded successor: ' + name) + self.assertEqual(meta['files'][self.c.PACKAGE + '/' + name]['sha256'], successor, name) + self.assertEqual(prov['successors']['SuperlevelBar.lean']['imports'], ['Mathlib']) + self.assertEqual(prov['successors']['OrdinaryH0.lean']['imports'], ['Mathlib', 'ClosedSuperlevel']) + self.assertIn('ite_eq_left', prov['successors']['SuperlevelBar.lean']['successor_changes']) + self.assertIn('6113438262', prov['successors']['OrdinaryH0.lean']['successor_changes']) + self.assertIn('25 constants = 24 user range + 0 user generated + 1 internal generated', prov['successors']['SuperlevelBar.lean']['census_at_pin']) + self.assertIn('38 constants = 27 user range + 0 user generated + 11 internal generated', prov['successors']['OrdinaryH0.lean']['census_at_pin']) + self.assertIn('authored directly in namespace TorusFiltration', prov['namespace_mapping']) modules = {self.c.PACKAGE + '/' + m + '.lean' for m in self.c.MODULES} for path in self.c.REQUIRED_FILES: target = ROOT / path @@ -351,7 +434,8 @@ def test_comment_lexer_follows_lean_comment_rules(self): def test_module_scan_accepts_only_the_whitelisted_shapes(self): good = placeholder_module('ClosedSuperlevel') inventory = INVENTORY['ClosedSuperlevel'] - prelude = ('import Mathlib\nimport Mathlib.Topology.Basic\n\nnoncomputable section\n\nopen CategoryTheory Topology\n\n' + prelude = ('import Mathlib\nimport Mathlib.Topology.Basic\nimport TorusTopology\n\nnoncomputable section\n\n' + 'open CategoryTheory Topology\nopen scoped Simplicial\n\n' 'universe w v u\n\nnamespace TorusFiltration\n/-- Control: a docstring\nwith a column-0 continuation line ' 'mentioning theorem and sorry -/\nvariable {C : Type u} [Category.{v} C]\n [Preadditive C] [CategoryWithHomology C]\n') for text in (good, good + '-- sorry in a comment is text\n', @@ -363,6 +447,16 @@ def test_module_scan_accepts_only_the_whitelisted_shapes(self): good.replace('theorem superlevel_mono : True := trivial', 'theorem superlevel_mono\n (h : True) : True := h')): with self.subTest(text=text[-80:]): self.assertEqual(self.c.scan_module(text, 'ClosedSuperlevel'), inventory) + # Since the C263/C264 registration: a companion module may import the companion modules listed before it in + # MODULES (OrdinaryH0.lean imports ClosedSuperlevel), and `open scoped ` is a prelude line + # (OrdinaryH0.lean opens the scoped simplicial notation). Only those; see the refusals below. + h0 = placeholder_module('OrdinaryH0') + for text in (h0.replace('import Mathlib\n', 'import Mathlib\nimport ClosedSuperlevel\n', 1), + h0.replace('import Mathlib\n', 'import Mathlib\nimport TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\n', 1), + h0.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial\n', 1), + h0.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial CategoryTheory.Limits\n', 1)): + self.assertEqual(self.c.scan_module(text, 'OrdinaryH0'), INVENTORY['OrdinaryH0']) + self.assertEqual(self.c.MODULES, ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0')) def test_module_scan_refuses_admissions_and_unexpected_kinds(self): good = placeholder_module('ClosedSuperlevel') @@ -464,6 +558,23 @@ def inject(line): (inject('initialize hidden : Nat ← pure 0'), unexpected), (inject('import Hidden'), unexpected), (inject('import Mathlib'), 'import inside the namespace: ClosedSuperlevel:'), + (inject('import TorusTopology'), 'import inside the namespace: ClosedSuperlevel:'), + # companion imports: only modules BEFORE this one in MODULES, never itself, a later module or the root + (good.replace('import Mathlib\n', 'import Mathlib\nimport ClosedSuperlevel\n', 1), 'companion import out of dependency order in ClosedSuperlevel:2: ClosedSuperlevel'), + (good.replace('import Mathlib\n', 'import Mathlib\nimport SuperlevelBar\n', 1), 'companion import out of dependency order in ClosedSuperlevel:2: SuperlevelBar'), + (good.replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0\n', 1), 'companion import out of dependency order in ClosedSuperlevel:2: OrdinaryH0'), + (good.replace('import Mathlib\n', 'import Mathlib\nimport TorusFiltration\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import Mathlib\nimport TorusTopology.Hidden\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import Mathlib\nimport TorusTopology Hidden\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import TorusTopology\n', 1).replace('namespace TorusFiltration\n', 'namespace TorusFiltration\nimport Mathlib\n'), 'import inside the namespace: ClosedSuperlevel:'), + # `open scoped`: capitalized namespaces only, nothing else on the line, column 0 only + (good.replace('import Mathlib\n', 'import Mathlib\nopen scoped simplicial\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import Mathlib\nopen scoped\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial in\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial theorem hidden : True := trivial\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import Mathlib\n open scoped Simplicial\n', 1), command), + (good.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial\n', 1), unexpected), + (good.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial\n', 1), unexpected), (inject("theorem hidden' : True := trivial"), unexpected), (inject('theorem hidden.name : True := trivial'), unexpected), (inject('theorem'), unexpected), @@ -488,6 +599,13 @@ def inject(line): for text, message in cases: with self.subTest(message=message, text=text[-70:]), self.assertRaisesRegex(ValueError, re.escape(message)): self.c.scan_module(text, 'ClosedSuperlevel') + # The first module may import nothing but Mathlib; a module name outside MODULES is not scanned at all. + with self.assertRaisesRegex(ValueError, 'companion import out of dependency order in TorusTopology:2: ClosedSuperlevel'): + self.c.scan_module(placeholder_module('TorusTopology').replace('import Mathlib\n', 'import Mathlib\nimport ClosedSuperlevel\n', 1), 'TorusTopology') + with self.assertRaisesRegex(ValueError, 'not a companion module: TorusFiltration'): + self.c.scan_module(good, 'TorusFiltration') + with self.assertRaisesRegex(ValueError, 'not a companion module: Other'): + self.c.scan_module(good, 'Other') # Every command keyword the scanner knows is refused somewhere other than the start of a whitelisted line, # indented after the namespace opening included (the C262 G2 position). for keyword in self.c.COMMANDS: @@ -579,7 +697,7 @@ def test_audit_axioms_rules(self): for targets in ([], ['TorusFiltration.a', 'TorusFiltration.a'], 'TorusFiltration.a'): with self.subTest(targets=targets), self.assertRaisesRegex(ValueError, 'empty or duplicate target list'): self.c.audit_axioms(good, targets) - duplicated = {'theorems': {'TorusTopology': ['a'], 'ClosedSuperlevel': ['a']}, + duplicated = {'theorems': {m: ['a'] if m in self.c.MODULES[:2] else [] for m in self.c.MODULES}, 'definitions': {m: {'abbrev': [], 'def': [], 'instance': []} for m in self.c.MODULES}} with self.assertRaisesRegex(ValueError, 'duplicate or empty target list'): self.c.targets(duplicated) @@ -620,6 +738,9 @@ def test_leanchecker_mode_accepts_exactly_the_two_recorded_invocations(self): self.assertEqual(self.c.leanchecker_mode(LEANCHECKER_FRESH + '\n'), 'fresh') self.assertEqual(self.c.LEANCHECKER, {LEANCHECKER_MODULES: 'modules', LEANCHECKER_FRESH: 'fresh'}) for bad in ('', 'leanchecker TorusFiltration', 'leanchecker --fresh TorusTopology', 'leanchecker TorusTopology ClosedSuperlevel', + LEANCHECKER_MODULES_BEFORE_C26X, 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0', + 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar TorusFiltration', + 'leanchecker TorusTopology ClosedSuperlevel OrdinaryH0 SuperlevelBar TorusFiltration', LEANCHECKER_MODULES + ' Extra', 'leanchecker --verbose ' + LEANCHECKER_MODULES[12:], 'lean ' + LEANCHECKER_MODULES[12:], LEANCHECKER_MODULES + '\n' + LEANCHECKER_FRESH): with self.subTest(bad=bad), self.assertRaisesRegex(ValueError, 'unrecognized leanchecker invocation'): @@ -636,12 +757,13 @@ def test_emit_writes_exactly_the_audit_types_positive_and_controls(self): census = (out / 'Census.lean').read_text() self.assertTrue(census.startswith('import TorusFiltration\n')) for needed in ('isInternalDetail', 'findDeclarationRanges?', 'getModuleIdxFor?', '`TorusTopology', '`ClosedSuperlevel', - '`TorusFiltration', 'CENSUS_END', '"internal" else "user"', '"range" else "generated"'): + '`SuperlevelBar, `OrdinaryH0, `TorusFiltration', 'CENSUS_END', '"internal" else "user"', '"range" else "generated"'): self.assertIn(needed, census) + self.assertIn('#[`TorusTopology, `ClosedSuperlevel, `SuperlevelBar, `OrdinaryH0, `TorusFiltration]', census) audit = (out / 'Audit.lean').read_text().splitlines() self.assertEqual(audit[0], 'import TorusFiltration') self.assertEqual(audit[1:], ['#print axioms ' + n for n in self.c.targets(meta)]) - self.assertEqual(len(audit[1:]), 58) + self.assertEqual(len(audit[1:]), 109) types = (out / 'Types.lean').read_text().splitlines() self.assertEqual(types[:2], ['import TorusFiltration', 'set_option pp.explicit true']) self.assertEqual(types[2:], ['#check ' + n for n in self.c.theorem_targets(meta)]) @@ -662,6 +784,25 @@ def test_emit_writes_exactly_the_audit_types_positive_and_controls(self): self.assertIn('#print axioms injected', text) self.assertEqual(set(self.c.FALSE_CONTROLS) | set(self.c.INJECTIONS), set(self.c.CONTROLS)) self.assertGreaterEqual(len(self.c.FALSE_CONTROLS), 1) + # One false control per module at least, each naming one of that module's own definitions (the C26x controls + # name superlevelBar_deathHeight and ordinaryH0_pointClass); none of them is proved by a hypothesis-free `rfl`. + for prefix, names in (('superlevel_', ('RejectSuperlevelSignFlip', 'RejectSuperlevelBelowThreshold')), + ('torus_', ('RejectConstantNotPeriodic',)), ('superlevelBar_', ('RejectEssentialDeathBound',)), + ('ordinaryH0_', ('RejectReducedPointClass',))): + for name in names: + self.assertIn(prefix, self.c.FALSE_CONTROLS[name][0], name) + self.assertEqual(self.c.FALSE_CONTROLS['RejectEssentialDeathBound'], + ('superlevelBar_deathHeight (fun _ : superlevelBar_E 1 => (-1 : ℝ)) 0 ≤ (-1 : ℝ)', 'norm_num [superlevelBar_death_const]')) + self.assertEqual(self.c.FALSE_CONTROLS['RejectReducedPointClass'][1], 'simp [ordinaryH0_pointClass_augmentation]') + self.assertIn('ordinaryH0_pointClass (TopCat.of Unit) (ModuleCat.of ℤ ℤ) ()', self.c.FALSE_CONTROLS['RejectReducedPointClass'][0]) + self.assertIn('≠ CategoryTheory.CategoryStruct.id (ModuleCat.of ℤ ℤ)', self.c.FALSE_CONTROLS['RejectReducedPointClass'][0]) + self.assertEqual(list(self.c.CONTROLS), ['RejectSuperlevelSignFlip', 'RejectSuperlevelBelowThreshold', 'RejectConstantNotPeriodic', + 'RejectEssentialDeathBound', 'RejectReducedPointClass', 'RejectSorry', 'RejectCustomAxiom', + 'RejectNativeDecide']) + self.assertEqual(len(self.c.EVIDENCE_FILES), 54) + self.assertEqual(self.c.BUILDS, ('build-TorusTopology', 'build-ClosedSuperlevel', 'build-SuperlevelBar', 'build-OrdinaryH0', + 'build-TorusFiltration', 'positive', 'axioms', 'types', 'census', 'leanchecker')) + self.assertEqual(self.c.ROOT_SOURCE, 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\n') self.assertEqual({v[1] for v in self.c.INJECTIONS.values()}, {'sorryAx', 'hiddenPremise', 'injected._native.native_decide.ax_1_1'}) self.assertTrue(all(re.fullmatch(self.c.NAME, v[1]) and v[1] not in self.c.ALLOWED for v in self.c.INJECTIONS.values())) @@ -726,9 +867,16 @@ def test_replay_contract(self): 'run_lean census lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Census.lean"', 'set -euo pipefail\n# The outer Python mode is the one named on each command line below, never an ambient PYTHONOPTIMIZE (C262 G1).\nunset PYTHONOPTIMIZE\n'): self.assertIn(required, self.replay, required) - for module in ('TorusTopology', 'ClosedSuperlevel', 'TorusFiltration'): - self.assertIn('run_lean build-%s lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/%s.olean" "$TORUS_SIDE/%s.lean"' - % (module, module, module), self.replay) + positions = [] + for module in ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0', 'TorusFiltration'): + line = ('run_lean build-%s lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/%s.olean" "$TORUS_SIDE/%s.lean"' + % (module, module, module)) + self.assertEqual(self.replay.count(line), 1, module) + positions.append(self.replay.index(line)) + # dependency order: TorusTopology, ClosedSuperlevel, SuperlevelBar, OrdinaryH0 (imports ClosedSuperlevel), then the root + self.assertEqual(positions, sorted(positions)) + self.assertLess(positions[-1], self.replay.index('run_lean positive')) + self.assertEqual(len(re.findall(r'^run_lean build-', self.replay, re.M)), 5) commands = '\n'.join(line for line in self.replay.splitlines() if not line.lstrip().startswith('#')) for forbidden in ('gate.py', 'formal/tests', 'lake build', 'lake update', 'lake exe cache', 'formal-evidence', 'ResearchFormalCoreR1'): @@ -758,8 +906,13 @@ def test_documents_keep_the_status_vocabulary(self): for required in ('Scientific effect', 'NONE', 'credit', 'PENDING_INDEPENDENT_REVIEW', 'OpenAI/Codex', 'Anthropic/Claude', '8a5c7a24-784b-4aaa-b951-cd9f37b0dc64', 'efa80d28', '1fed3eda', 'ResearchFormalCoreR1.', 'TorusFiltration.', 'PairLawInterface.p', - 'critical-level attainment', 'once-counting', LEANCHECKER_MODULES): + 'critical-level attainment', 'once-counting', LEANCHECKER_MODULES, + # C263/C264 registration: handoff and successor identities, the fixes, the census, FORMAL HOLD + 'd74dc8b2', '346eea94', '261dd052', '3d6b0d6b', 'ite_eq_left', '6113438262', '6113033545', '6113372506', + '25 = 24 + 0 + 1', '38 = 27 + 0 + 11', 'FORMAL HOLD', 'superlevelBar_', 'ordinaryH0_', + 'nonauthor exact-source review'): self.assertIn(required, text, name + ' lacks ' + required) + self.assertNotIn(LEANCHECKER_MODULES_BEFORE_C26X + '`', text, name + ' still names the pre-registration leanchecker command as current') self.assertNotIn('`leanchecker --fresh` re-checked', text, name + ' describes the withdrawn --fresh step as run') self.assertNotIn('runs `leanchecker --fresh TorusFiltration`', text) prose = re.sub(r'`[^`\n]*`', '', text) @@ -775,8 +928,15 @@ def test_documents_keep_the_status_vocabulary(self): # The control table quotes each emitted false statement verbatim, and the .olean hazard is stated. for statement, _ in self.c.FALSE_CONTROLS.values(): self.assertIn('`' + statement + '`', readme, 'control statement not quoted verbatim: ' + statement) - for required in ('.olean', 'never be committed', 'NOT_RUN', 'TORUS_LEANCHECKER_FRESH', 'leanchecker.cmd'): + for required in ('.olean', 'never be committed', 'NOT_RUN', 'TORUS_LEANCHECKER_FRESH', 'leanchecker.cmd', + 'exactly the 54 evidence files', 'Registration is not review'): self.assertIn(required, readme, 'README lacks ' + required) + for stale in ('exactly the 44 evidence files', 'those 44 files', '41 theorems and 17 definitions', 'the 58 declarations', + 'two-line root module', 'six negative', 'Both modules `import Mathlib`'): + self.assertNotIn(stale, readme, 'README keeps a pre-registration count: ' + stale) + scope = (SIDE / 'SCOPE.md').read_text(encoding='utf-8') + for stale in ('41 theorem statements and 17 audited definitions', 'these 58 declarations', 'exactly these 58'): + self.assertNotIn(stale, scope, 'SCOPE keeps a pre-registration count: ' + stale) class SourceFixture(FixtureCase): @@ -788,10 +948,11 @@ def test_clean_fixture_passes_and_records_identity(self): result = json.loads(run.stdout) self.assertEqual(result['checked_commit'], f.git('rev-parse', 'HEAD').strip()) self.assertEqual(set(result['sources']), set(self.c.REQUIRED_FILES) | {self.c.PACKAGE + '/SOURCE_FILES.json'}) - self.assertEqual(len(result['declarations']), 58) + self.assertEqual(len(result['declarations']), 109) self.assertEqual(result['environment'], {'lean_toolchain': 'leanprover/lean4:v4.34.1', 'dependency_revisions': f.revisions}) self.assertEqual(result['run_id'], 'local') + self.assertEqual(len(result['theorems']), 81) hosted = {'GITHUB_ACTIONS': 'true', 'GITHUB_SHA': result['checked_commit'], 'GITHUB_REPOSITORY': self.c.REPO, 'GITHUB_RUN_ID': '77', 'GITHUB_RUN_ATTEMPT': '2'} run = f.run('source', env=hosted) @@ -886,8 +1047,31 @@ def test_module_mutations_are_detected(self): self.assertEqual(f.run('source').returncode, 0) (f.side / 'TorusFiltration.lean').write_text('import TorusTopology\n') f.restore() - self.assertFails(f.run('source'), 'root module must import exactly the two modules') + self.assertFails(f.run('source'), 'root module must import exactly the four modules') + # the pre-registration root (two imports) is refused too; so is a reordered or duplicated import list + for root in ('import TorusTopology\nimport ClosedSuperlevel\n', + 'import TorusTopology\nimport ClosedSuperlevel\nimport OrdinaryH0\nimport SuperlevelBar\n', + 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\nimport OrdinaryH0\n', + 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0'): + (f.side / 'TorusFiltration.lean').write_text(root) + f.restore() + self.assertFails(f.run('source'), 'root module must import exactly the four modules') (f.side / 'TorusFiltration.lean').write_text(self.c.ROOT_SOURCE) + # companion imports through the CLI: OrdinaryH0 may import ClosedSuperlevel (as the registered module does); + # ClosedSuperlevel may not import SuperlevelBar, and no module may import the root + h0 = f.side / 'OrdinaryH0.lean' + h0_original = h0.read_text() + h0.write_text(h0_original.replace('import Mathlib\n', 'import Mathlib\nimport ClosedSuperlevel\n', 1)) + f.restore() + self.assertEqual(f.run('source').returncode, 0, 'a companion import in dependency order is source') + h0.write_text(h0_original.replace('import Mathlib\n', 'import Mathlib\nimport TorusFiltration\n', 1)) + f.restore() + self.assertFails(f.run('source'), 'unexpected column-0 line in OrdinaryH0:2: import TorusFiltration') + h0.write_text(h0_original) + module.write_text(original.replace('import Mathlib\n', 'import Mathlib\nimport SuperlevelBar\n', 1)) + f.restore() + self.assertFails(f.run('source'), 'companion import out of dependency order in ClosedSuperlevel:2: SuperlevelBar') + module.write_text(original) f.regenerate() meta = json.loads((f.side / 'SOURCE_FILES.json').read_text()) del meta['files'][self.c.PACKAGE + '/TorusTopology.lean'] @@ -917,7 +1101,9 @@ def test_environment_pins_are_enforced(self): class MetadataFixture(FixtureCase): - """Every honesty label and schema rule of SOURCE_FILES.json is enforced through the CLI, one field at a time.""" + """The honesty labels and schema rules of SOURCE_FILES.json are enforced through the CLI, one field at a time, + except seven fields of the successor record (handoff byte count and status, lane, authors, namespace, imports, + change summary), which are refused only through the whole-record comparison in check.py metadata().""" def test_each_label_and_schema_rule_withholds_source(self): c = self.c @@ -946,6 +1132,22 @@ def mutate(m): (setter(('provenance', 'human_review'), 'self'), 'credit must stay zero'), (setter(('provenance', 'claim'), c.CLAIM[:-1] + '5'), 'provenance identity'), (setter(('provenance', 'original_sha256', next(iter(original))), '0' * 64), 'provenance identity'), + (setter(('provenance', 'original_bytes', 'C263-handoff/SuperlevelBar.lean'), 14905), 'successor provenance identity'), + (deleter(('provenance', 'original_bytes', 'C264-handoff/OrdinaryH0.lean')), 'successor provenance identity'), + (setter(('provenance', 'successors', 'SuperlevelBar.lean', 'successor_sha256'), '0' * 64), 'successor provenance identity'), + (setter(('provenance', 'successors', 'OrdinaryH0.lean', 'successor_bytes'), 19802), 'successor provenance identity'), + (setter(('provenance', 'successors', 'OrdinaryH0.lean', 'handoff_sha256'), '0' * 64), 'successor provenance identity'), + (setter(('provenance', 'successors', 'SuperlevelBar.lean', 'formal_status'), 'ACCEPTED'), 'successor provenance identity'), + (setter(('provenance', 'successors', 'OrdinaryH0.lean', 'formal_status'), 'FORMAL_HOLD lifted'), 'successor provenance identity'), + (setter(('provenance', 'successors', 'SuperlevelBar.lean', 'organizational_independence_credit'), 1), 'successor provenance identity'), + (setter(('provenance', 'successors', 'OrdinaryH0.lean', 'census_at_pin'), '27 constants'), 'successor provenance identity'), + (deleter(('provenance', 'successors', 'OrdinaryH0.lean', 'comments', 'owner_repair_handoff_428')), 'successor provenance identity'), + (deleter(('provenance', 'successors', 'OrdinaryH0.lean')), 'successor provenance identity'), + (setter(('provenance', 'successors', 'Third.lean'), {}), 'successor provenance identity'), + (deleter(('provenance', 'successors')), 'provenance key missing: successors'), + (deleter(('provenance', 'original_bytes')), 'provenance key missing: original_bytes'), + (setter(('provenance', 'original_sha256', 'C263-handoff/SuperlevelBar.lean'), '0' * 64), 'provenance identity'), + (deleter(('provenance', 'original_sha256', 'C264-handoff/OrdinaryH0.lean')), 'provenance identity'), (setter(('provenance', 'original_status'), 'COMPILED'), 'provenance labels'), (setter(('provenance', 'namespace_mapping'), 'TorusFiltration. -> TorusFiltration.'), 'provenance labels'), (deleter(('provenance', 'human_review')), 'provenance key missing: human_review'), @@ -969,6 +1171,13 @@ def mutate(m): (setter(('namespace',), 'ResearchFormalCoreR1'), 'namespace or root module'), (setter(('root_module',), 'TorusTopology'), 'namespace or root module'), (setter(('modules',), ['ClosedSuperlevel', 'TorusTopology']), 'module list'), + (setter(('modules',), ['TorusTopology', 'ClosedSuperlevel']), 'module list'), + (setter(('modules',), ['TorusTopology', 'ClosedSuperlevel', 'OrdinaryH0', 'SuperlevelBar']), 'module list'), + (deleter(('theorems', 'OrdinaryH0')), 'per-module inventory keys'), + (deleter(('definitions', 'SuperlevelBar')), 'per-module inventory keys'), + (lambda m: m['theorems']['OrdinaryH0'].append('superlevelBar_strict_cut'), 'duplicate declaration name'), + (setter(('theorems', 'SuperlevelBar', 0), 'superlevelBar_essential_iff\u03b9'), 'invalid declaration name in SuperlevelBar'), + (setter(('theorems', 'OrdinaryH0', 0), 'ordinaryH0_componentCoproductMap_ι'), 'invalid declaration name in OrdinaryH0'), (deleter(('definitions', 'TorusTopology', 'instance')), 'definition kinds: TorusTopology'), (setter(('theorems', 'TorusTopology', 0), 'bad-name'), 'invalid declaration name in TorusTopology'), (setter(('definitions', 'TorusTopology', 'def', 0), 7), 'invalid declaration name in TorusTopology'), @@ -1012,10 +1221,13 @@ def test_complete_evidence_yields_a_bounded_receipt(self): self.assertIs(receipt['scientific_acceptance'], False) self.assertEqual(receipt['lean_version'], LEAN_VERSION_LINE.strip()) self.assertEqual(receipt['dependency_revisions'], f.revisions) - self.assertEqual(len(receipt['declarations']), 58) - self.assertEqual(len(receipt['axioms']), 58) - self.assertEqual(receipt['theorem_count'], 41) - self.assertEqual(receipt['definition_count'], {'abbrev': 2, 'def': 12, 'instance': 3}) + self.assertEqual(len(receipt['declarations']), 109) + self.assertEqual(len(receipt['axioms']), 58 + 24 + 27) + self.assertEqual(receipt['theorem_count'], 81) + self.assertEqual(receipt['definition_count'], {'abbrev': 3, 'def': 22, 'instance': 3}) + self.assertEqual(receipt['provenance']['successors'], self.c.SUCCESSORS) + self.assertEqual(receipt['provenance']['original_bytes'], self.c.ORIGINAL_BYTES) + self.assertEqual(len(receipt['provenance']['original_sha256']), 4) self.assertEqual(receipt['negative_controls'], {**{k: 'REJECTED_BY_LEAN' for k in self.c.FALSE_CONTROLS}, **{k: 'REJECTED_BY_AXIOM_AUDIT' for k in self.c.INJECTIONS}}) @@ -1028,13 +1240,18 @@ def test_complete_evidence_yields_a_bounded_receipt(self): self.assertEqual(hashlib.sha256((out / name).read_bytes()).hexdigest(), digest, name) self.assertEqual(set(receipt['log_sha256']), {p.name for p in out.iterdir() if p.is_file()} - {'receipt.json'}) self.assertEqual(set(receipt['log_sha256']), set(self.c.EVIDENCE_FILES)) - self.assertEqual(len(receipt['log_sha256']), 44) - self.assertEqual(receipt['census'], {'constants': 58 + len(self.c.metadata()['census_auxiliary']) + len(INTERNAL_GENERATED), - 'user_declarations': 58, + self.assertEqual(len(receipt['log_sha256']), 54) + self.assertEqual(receipt['census'], {'constants': 109 + len(self.c.metadata()['census_auxiliary']) + len(INTERNAL_GENERATED), + 'user_declarations': 109, 'generated_user': sorted(self.c.metadata()['census_auxiliary']), 'internal_generated': len(INTERNAL_GENERATED)}) self.assertIn('census.log', receipt['log_sha256']) self.assertIn('axioms.log', receipt['log_sha256']) + for name in ('build-SuperlevelBar', 'build-OrdinaryH0', 'RejectEssentialDeathBound', 'RejectReducedPointClass'): + self.assertIn(name + '.log', receipt['log_sha256']) + self.assertIn(name + '.status', receipt['log_sha256']) + self.assertIn('RejectEssentialDeathBound.lean', receipt['log_sha256']) + self.assertIn('RejectReducedPointClass.lean', receipt['log_sha256']) self.assertIn('leanchecker.cmd', receipt['log_sha256']) self.assertIn('Positive.lean', receipt['log_sha256']) self.assertIn('tests-optimized.log', receipt['log_sha256']) @@ -1078,6 +1295,9 @@ def census_without(name): return ''.join(body) + 'CENSUS_END %d\n' % len(body) cases = [ ('build-TorusTopology.status', '1\n', 'missing successful process: build-TorusTopology'), + ('build-SuperlevelBar.status', '1\n', 'missing successful process: build-SuperlevelBar'), + ('build-OrdinaryH0.status', '', 'missing successful process: build-OrdinaryH0'), + ('leanchecker.cmd', LEANCHECKER_MODULES_BEFORE_C26X + '\n', "unrecognized leanchecker invocation: '" + LEANCHECKER_MODULES_BEFORE_C26X + "'"), ('leanchecker.status', '', 'missing successful process: leanchecker'), ('leanchecker.cmd', 'leanchecker TorusFiltration\n', "unrecognized leanchecker invocation: 'leanchecker TorusFiltration'"), ('leanchecker.cmd', 'leanchecker --fresh TorusTopology\n', 'unrecognized leanchecker invocation'), @@ -1108,6 +1328,13 @@ def census_without(name): ('RejectSuperlevelSignFlip.log', FALSE_LOG.format('RejectSuperlevelSignFlip').replace('False', 'True'), 'not the intended False-goal diagnostic'), ('RejectSuperlevelSignFlip.status', '0\n', 'false-statement control must exit exactly one'), + ('RejectEssentialDeathBound.log', FALSE_LOG.format('RejectEssentialDeathBound').replace('⊢ False', '⊢ 1 ≤ 0'), + 'not the intended False-goal diagnostic: RejectEssentialDeathBound'), + ('RejectEssentialDeathBound.status', '0\n', 'false-statement control must exit exactly one'), + ('RejectReducedPointClass.log', '', 'not the intended False-goal diagnostic: RejectReducedPointClass'), + ('RejectReducedPointClass.log', FALSE_LOG.format('RejectReducedPointClass') + 'error: This simp argument is unused\n', + 'not the intended False-goal diagnostic: RejectReducedPointClass'), + ('RejectReducedPointClass.status', '2\n', 'false-statement control must exit exactly one'), ('RejectSorry.status', '1\n', 'injection control must be accepted by Lean'), ('RejectSorry.log', SORRY_WARNING + INJECTED.format('propext'), 'not the intended injected axiom report'), ('RejectNativeDecide.log', INJECTED.format('sorryAx'), 'not the intended injected axiom report'), @@ -1120,7 +1347,11 @@ def census_without(name): ('RejectSorry.lean', (out / 'RejectSorry.lean').read_text().replace('by sorry', 'trivial'), 'emitted Lean file changed across execution: RejectSorry.lean'), ('RejectConstantNotPeriodic.lean', 'import TorusFiltration\n', - 'emitted Lean file changed across execution: RejectConstantNotPeriodic.lean')] + 'emitted Lean file changed across execution: RejectConstantNotPeriodic.lean'), + ('RejectReducedPointClass.lean', (out / 'RejectReducedPointClass.lean').read_text().replace('≠', '='), + 'emitted Lean file changed across execution: RejectReducedPointClass.lean'), + ('Census.lean', (out / 'Census.lean').read_text().replace(', `OrdinaryH0', ''), + 'emitted Lean file changed across execution: Census.lean')] for name, content, message in cases: with self.subTest(name=name, message=message): saved = (out / name).read_text() @@ -1130,7 +1361,7 @@ def census_without(name): self.assertFalse((out / 'receipt.json').exists(), 'receipt written despite refusal') finally: (out / name).write_text(saved) - # C262 G3: every one of the 44 required evidence members is required; removing any one withholds the receipt. + # C262 G3: every one of the 54 required evidence members is required; removing any one withholds the receipt. self.assertEqual({p.name for p in out.iterdir()}, set(self.c.EVIDENCE_FILES)) for name in sorted(self.c.EVIDENCE_FILES): with self.subTest(removed=name): From f13aa5fb4e8fc68efbfd25a236a422c7d8dc0f38 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Oct 2026 02:36:52 +0000 Subject: [PATCH 5/5] Companion torus_filtration_20261011: register the owner-authored OrdinaryH0Controls fixtures and three false controls (C264 owner task item 4; not a review, FORMAL HOLD unchanged) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One forward commit on top of the registration head 940dffc9. It registers one owner-authored Lean module and three false controls in the existing gate; it moves no status label. Module. OrdinaryH0Controls.lean (29590 B, 453 lines, sha256 df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184), written by this lane for C264 owner task item 4 (Math- #428 comment 6113277485) against the corrected CONTROL_OBLIGATIONS of comment 6113277173; imports Mathlib and OrdinaryH0; namespace TorusFiltration, prefix ordinaryH0Control_; 37 theorems, 3 abbrevs, 4 defs, 0 instances. Not a handoff successor (no handoff bytes), not a review of OrdinaryH0. Its first compiled form (e825837f..., 28503 B, 440 lines) said the OrdinaryH0 successor "is FORMAL HOLD until a nonauthor exact-source review of the compiled successor". The one docstring paragraph now says instead that the handoffs rest FORMAL HOLD on their own listed conditions (6113277485 item 5 and 6113372506; for C263, 6113033545 item 4), among them a distinct review of the source-bound execution output and source-bound hosted evidence and custody, which they say a source review alone does not meet; that the nonauthor engineering readback of 4c33d8cd..940dffc9 (review 5485829137, 2026-10-12 01:16Z, PASS) read the successor bytes for identity and registration only and records credit 0; that since 01:32Z a nonauthor exact-source review exists, source-scoped only (review 5485883117, Muse Spark / Meta, PASS source-scoped for each module, count corrected in comment 6116328276), whose reviewer did not run Lean and keeps Lean execution as an open condition under FORMAL HOLD, and which states no organizational-independence credit and was posted from the same project account; that FORMAL HOLD is unchanged, its disposition is for the C263/C264 handoff owners and alignment still needs a nonzero-credit reviewer; and that the fixtures lift nothing. No declaration changed; the module was recompiled and its axioms and census re-run after the edit. The four earlier modules and the Actions workflow file are byte-identical. Root module TorusFiltration.lean gains `import OrdinaryH0Controls` as its fifth line. check.py. MODULES, REQUIRED_FILES, BUILDS (build-OrdinaryH0Controls after build-OrdinaryH0), ROOT_SOURCE, the census module array and the modules-mode leanchecker command (six modules; the five-module form is now refused as the five-module change refused the three-module form). FALSE_CONTROLS gains RejectMergerKillsPointClass, RejectSeparationWithoutNonzeroCoeff and RejectNonmergerKillsDifference (the statements and tactics of the item-4 controls specification), with a comment stating each intended reason. EVIDENCE_FILES 54 -> 65 (2 for build-OrdinaryH0Controls, 9 for the three controls) with its explicit count check. Provenance: OWNER_MODULES records the module (author, task 6113277485 item 4, specification 6113277173, sha256 and bytes, imports, census 48 = 44 + 0 + 4, not a handoff successor, not a review, FORMAL HOLD of OrdinaryH0 unchanged, credit 0); metadata() requires provenance.owner_modules to equal it whole, like SUCCESSORS. NAMESPACE_MAPPING names the controls module. The scanner's rules are unchanged (its companion-import form follows MODULES). census_auxiliary gains no entry. The comment above SUCCESSORS now says that FORMAL HOLD rests on the handoffs' listed conditions and that formal_status is the registration commit's transcription, naming one of them; the formal_status labels themselves are unchanged. test_torus_filtration.py: the inventory of the new module as scan_module reports it; the four internal generated names of its census; every count this change moves (118 theorems, 153 declarations, 6 abbrevs, 26 defs, 65 evidence members, 19 internal generated rows); the owner record and the tracked bytes against OWNER_IDENTITY; thirteen single-field or whole-entry mutations of the owner record through the CLI (identity, author, kind, review status, credit, census, a dropped comment pointer, an added field, a dropped or added entry, the record copied into the successor record, the key removed); the pre-controls root, five-module leanchecker command and module lists refused; companion-import order for the new module; the exact item-4 controls and their tactics naming fixture theorems; and the three controls' Lean diagnostics and their true siblings' diagnostics (CONTROL_LOGS, DISCRIMINATOR_LOGS) as negative controls of negative and finish. The status-vocabulary test requires the handoffs' listed conditions, the open condition, the same-account and nonzero-credit statements, the dated companion note on the C254 exclusion and the reported-not-adopted hosted run, and refuses the corrected phrasings (FORMAL HOLD presented as tied to one review that now exists, "until 01:32Z no nonauthor review", "records none since", "beyond the discrete cases", "each statement applies one of the C264 theorems", "concrete instances of those C264 statements"). 29 tests (28 before) pass in both Python modes. replay.sh: the build line, the leanchecker command, the control loop, comments with the measured six-module figures. README.md and SCOPE.md: a dated section for the item-4 controls (what each fixture shows, the three controls and their intended reasons, the discriminators, the evidence-count change, what it does not establish), every moved count, and the two documentation items riding this commit (Math- #428 comment 6116225936): the C254 naturality exclusion keeps its copied words and gains a dated companion note (C254 alone did not establish it; OrdinaryH0.lean establishes the stated ordinary-H0 naturality only), and the statements that no review of the compiled successors existed are time-scoped to 940dffc9, with the engineering readback 5485829137 (01:16Z, identity and registration only, credit 0) and the source-scoped review 5485883117 (01:32Z, no credit stated, Lean execution kept open) recorded with verdict and credit apart. FORMAL HOLD is described as resting on the handoffs' own listed conditions, not on one review (the registration section discloses its earlier one-condition wording; the transcribed label is quoted unchanged). Hosted run 38187870416 of 940dffc9 is recorded as completed with conclusion success, as reported by 5485829137, not re-inspected and its receipt not adopted. The controls module is described as applying seven of the 20 C264 theorems and three of its definitions; its thirteen premise lemmas name no C264 theorem. No label moves; provenance.successors.*.formal_status keeps the text transcribed at 940dffc9. SOURCE_FILES.json regenerated, last, by the out-of-tree generator, which also requires the owner module to carry the recorded identity. Checked locally at Lean v4.34.1 / Mathlib d13f23b7 on the registered bytes before this commit, one Lean process at a time, two threads: all six modules compile with warnings as errors (exit 0, empty logs); Audit (153 #print axioms, the 44 new ones within propext, Classical.choice, Quot.sound), Types (118 #check), Census (181 constants = 153 user range + 1 user generated + 27 internal generated) and Positive exit 0. The emitted gate files are byte-identical to those of the four earlier local forms of this commit (64b51aea and 9e91f9f8, whose module differed only in the docstring paragraph, and d042e9a2 and ec7bbe7c, with these Lean bytes; all superseded, never pushed). On those forms `leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 OrdinaryH0Controls TorusFiltration` exited 0 with no output, the eight false controls exited 1 with exactly `⊢ False`, the three injections were refused by the audit, the three true siblings left other diagnostics, which check.py negative refuses, and all four full local replays passed (leanchecker sampled peaks 9.31, 9.06, 8.98 and 9.15 GiB; 8.64 GiB in the first pre-commit run). These are records of computations on a worktree, not a receipt. Registration is not review and not acceptance. The fixtures apply seven of the C264 theorems to known cases; they are not a review of OrdinaryH0 or SuperlevelBar, they do not lift FORMAL HOLD, and they do not mark item 4 closed. Alignment PENDING_INDEPENDENT_REVIEW; organizational-independence credit 0 (the same project account wrote, compiled and registered the module). Scientific effect NONE. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Cz7WZybv8znP64SpPj6sWY --- .../OrdinaryH0Controls.lean | 453 ++++++++++++++++++ .../torus_filtration_20261011/README.md | 367 +++++++++++--- companions/torus_filtration_20261011/SCOPE.md | 120 ++++- .../SOURCE_FILES.json | 121 ++++- .../TorusFiltration.lean | 1 + companions/torus_filtration_20261011/check.py | 98 +++- .../torus_filtration_20261011/replay.sh | 22 +- .../test_torus_filtration.py | 343 ++++++++++--- 8 files changed, 1336 insertions(+), 189 deletions(-) create mode 100644 companions/torus_filtration_20261011/OrdinaryH0Controls.lean diff --git a/companions/torus_filtration_20261011/OrdinaryH0Controls.lean b/companions/torus_filtration_20261011/OrdinaryH0Controls.lean new file mode 100644 index 000000000..187bbcadb --- /dev/null +++ b/companions/torus_filtration_20261011/OrdinaryH0Controls.lean @@ -0,0 +1,453 @@ +import Mathlib +import OrdinaryH0 + +/-! +# Instantiated ordinary-H0 controls for the C264 module + +C264 owner task item 4 (Math- #428 comment 6113277485): concrete fixtures for the +CONTROL_OBLIGATIONS matrix quoted in the C264 nonauthor source review (Math- #428 comment +6113277173), exercised against the registered `OrdinaryH0` successor that this module +imports: SHA-256 3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88, +19803 bytes, the owner repair of the handoff bytes SHA-256 +261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e (18469 bytes). That +successor stands under the C264 handoff's own FORMAL HOLD; registration is not review. The +handoffs rest that hold on their own listed conditions (Math- #428 comments 6113277485 item +5 and 6113372506; for C263, 6113033545 item 4), among them a distinct review of the +source-bound execution output and source-bound hosted evidence and custody; they say a +source review alone does not meet them. The C264 nonauthor source review (Math- #428 +comment 6113277173) read the handoff bytes, not the successor. The nonauthor engineering +readback of 4c33d8cd..940dffc9 (Math- #428 review 5485829137, 01:16Z on 2026-10-12, PASS) +read the successor bytes for identity and registration only and records +organizational-independence credit 0. Since 01:32Z on 2026-10-12 a nonauthor exact-source +review of the compiled successors exists, source-scoped only: Math- #428 review 5485883117 +(Muse Spark / Meta, first read, PASS source-scoped for each module; count corrected in Math- +#428 comment 6116328276). Its reviewer did not run Lean and keeps Lean execution as an open +condition under FORMAL HOLD; it states no organizational-independence credit and was posted +from the same project account. FORMAL HOLD is unchanged; its disposition is for the +C263/C264 handoff owners, and alignment still needs a reviewer with nonzero +organizational-independence credit. These fixtures are not a review of `OrdinaryH0` and +lift nothing. +Universe 0 throughout: spaces in `TopCat.{0}`, coefficients in `ModuleCat.{0} ℤ`. + +Every premise is proved inside the fixture: the nonzero identities of `ℤ` and of `ZMod 2`, +the zero identity of the zero module, the path joining `0` and `1` in `ℝ`, the separation +of distinct points of a discrete space, the target-component equalities and separations +under the collapse `Bool → Unit` and the first projection `Bool × Bool → Bool`, and the +absence of a path through `0` in the closed superlevel `{x | 1/4 ≤ x ^ 2}`. No hypothesis, +compatibility field or axiom states a naturality, merger or separation fact. + +The fixtures keep the death of a difference apart from the survival of each individual +point class: a merger kills the difference while each image class stays nonzero. One +non-injective map (the projection) kills one difference and keeps another, and a strict +closed-superlevel inclusion keeps a difference alive. With zero coefficients ordinary H0 +of every space in `TopCat.{0}` is a zero object through the module's natural comparison, +so the two point classes of `Bool` coincide although their path components differ: the +nonzero-coefficient hypothesis of the separation statements cannot be dropped. With +`ZMod 2` coefficients, a characteristic-two object, the separation holds. + +Author: Anthropic/Claude lane (companion owner), delegated AI work for Dylan Roy. +Compilation and kernel audit of these bytes are recorded only where a run is reported. +Organizational-independence credit 0. Scientific effect NONE. + +These are instantiated controls of the categorical H0/path-component comparison only. +They supply no Morse chart, critical-level attainment theorem, interval decomposition, +elder correspondence, Field adapter, count identity, stochastic law, or scientific-status +promotion. +-/ + +noncomputable section + +open CategoryTheory Limits AlgebraicTopology + +namespace TorusFiltration + +/-- Proves: nothing; it names the integer coefficient object `ℤ` as a `ℤ`-module at universe 0. +Method: Mathlib's `ModuleCat.of`. +Does not establish: any homology computation. -/ +abbrev ordinaryH0Control_intCoeff : ModuleCat.{0} ℤ := ModuleCat.of ℤ ℤ + +/-- Proves: nothing; it names the zero coefficient object, the one-point `ℤ`-module at universe 0. +Method: Mathlib's `ModuleCat.of` on `PUnit`. +Does not establish: any homology computation. -/ +abbrev ordinaryH0Control_zeroCoeff : ModuleCat.{0} ℤ := ModuleCat.of ℤ PUnit.{1} + +/-- Proves: nothing; it names the characteristic-two coefficient object `ZMod 2` as a `ℤ`-module at universe 0. +Method: Mathlib's `ModuleCat.of`. +Does not establish: any homology computation. -/ +abbrev ordinaryH0Control_mod2Coeff : ModuleCat.{0} ℤ := ModuleCat.of ℤ (ZMod 2) + +/-- Proves: the identity of the integer coefficient object is not the zero morphism. +Method: evaluate both morphisms at `1 : ℤ`, where they give `1` and `0`. +Does not establish: nonvanishing of any homology class by itself. -/ +theorem ordinaryH0Control_intCoeff_id_ne_zero : + (𝟙 ordinaryH0Control_intCoeff : ordinaryH0Control_intCoeff ⟶ ordinaryH0Control_intCoeff) ≠ 0 := by + intro h + have h1 : (1 : ℤ) = 0 := + congrArg (fun f : ordinaryH0Control_intCoeff ⟶ ordinaryH0Control_intCoeff => f.hom (1 : ℤ)) h + exact one_ne_zero h1 + +/-- Proves: the identity of the `ZMod 2` coefficient object is not the zero morphism. +Method: evaluate both morphisms at `1 : ZMod 2`, where they give `1` and `0`, which differ by `decide`. +Does not establish: nonvanishing of any homology class by itself. -/ +theorem ordinaryH0Control_mod2Coeff_id_ne_zero : + (𝟙 ordinaryH0Control_mod2Coeff : ordinaryH0Control_mod2Coeff ⟶ ordinaryH0Control_mod2Coeff) ≠ 0 := by + intro h + have h1 : (1 : ZMod 2) = 0 := + congrArg (fun f : ordinaryH0Control_mod2Coeff ⟶ ordinaryH0Control_mod2Coeff => f.hom (1 : ZMod 2)) h + exact absurd h1 (by decide) + +/-- Proves: the `ZMod 2` coefficient object has characteristic two: its identity added to itself is zero. +Method: pointwise, `x + x = 0` in `ZMod 2` by Mathlib's characteristic-two identity. +Does not establish: any homology computation. -/ +theorem ordinaryH0Control_mod2Coeff_id_add_self : + (𝟙 ordinaryH0Control_mod2Coeff : ordinaryH0Control_mod2Coeff ⟶ ordinaryH0Control_mod2Coeff) + + 𝟙 ordinaryH0Control_mod2Coeff = 0 := by + ext x + change x + x = 0 + exact CharTwo.add_self_eq_zero x + +/-- Proves: the one-point module is a zero object of `ModuleCat ℤ`. +Method: Mathlib's zero-object criterion for a subsingleton module. +Does not establish: vanishing of homology with nonzero coefficients. -/ +theorem ordinaryH0Control_zeroCoeff_isZero : IsZero ordinaryH0Control_zeroCoeff := + ModuleCat.isZero_of_subsingleton _ + +/-- Proves: the identity of the zero coefficient object is the zero morphism. +Method: any two morphisms out of a zero object agree. +Does not establish: that the zero coefficient object satisfies the nonzero-coefficient hypothesis. -/ +theorem ordinaryH0Control_zeroCoeff_id_eq_zero : + (𝟙 ordinaryH0Control_zeroCoeff : ordinaryH0Control_zeroCoeff ⟶ ordinaryH0Control_zeroCoeff) = 0 := + ordinaryH0Control_zeroCoeff_isZero.eq_of_src _ _ + +/-- Proves: the empty space has no path component. +Method: every component is the class of a point, and the empty space has no point. +Does not establish: anything about a nonempty space. -/ +theorem ordinaryH0Control_empty_components : IsEmpty (ZerothHomotopy (TopCat.of Empty)) := by + constructor + intro q + obtain ⟨x, rfl⟩ := ZerothHomotopy.mk_surjective q + exact Empty.elim x + +/-- Proves: the component-indexed coproduct of the empty space is a zero object for every coefficient module. +Method: its identity and zero morphism agree on every (absent) coproduct inclusion. +Does not establish: vanishing for a nonempty space with nonzero coefficients. -/ +theorem ordinaryH0Control_empty_componentCoproduct_isZero (R : ModuleCat.{0} ℤ) : + IsZero ((ordinaryH0_componentCoproductFunctor R).obj (TopCat.of Empty)) := by + rw [IsZero.iff_id_eq_zero] + change 𝟙 (∐ fun _ : ZerothHomotopy (TopCat.of Empty) => R) = 0 + exact Sigma.hom_ext _ _ (fun q => (ordinaryH0Control_empty_components.false q).elim) + +/-- Proves: actual ordinary singular H0 of the empty space with integer coefficients is a zero object. +Method: transport the empty-coproduct zero object along the proved natural comparison `ordinaryH0_naturalIso`. +Does not establish: H0 of the empty space for coefficients other than `ℤ` (the zero-module case is `ordinaryH0Control_zeroCoeff_h0_isZero`), or anything about a nonempty space; no nonempty or `PathConnectedSpace` hypothesis is used. -/ +theorem ordinaryH0Control_empty_h0_isZero : + IsZero (((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).obj + (TopCat.of Empty)) := + (ordinaryH0Control_empty_componentCoproduct_isZero ordinaryH0Control_intCoeff).of_iso + ((ordinaryH0_naturalIso ordinaryH0Control_intCoeff).app (TopCat.of Empty)) + +/-- Proves: with zero coefficients the component-indexed coproduct of every space is a zero object. +Method: its identity and zero morphism agree on every coproduct inclusion, each out of the zero module. +Does not establish: vanishing with nonzero coefficients. -/ +theorem ordinaryH0Control_zeroCoeff_componentCoproduct_isZero (X : TopCat.{0}) : + IsZero ((ordinaryH0_componentCoproductFunctor ordinaryH0Control_zeroCoeff).obj X) := by + rw [IsZero.iff_id_eq_zero] + change 𝟙 (∐ fun _ : ZerothHomotopy X => ordinaryH0Control_zeroCoeff) = 0 + exact Sigma.hom_ext _ _ (fun _ => ordinaryH0Control_zeroCoeff_isZero.eq_of_src _ _) + +/-- Proves: with zero coefficients actual ordinary singular H0 of every space is a zero object. +Method: transport along the module's natural comparison `ordinaryH0_naturalIso` instantiated at the zero module. +Does not establish: any statement for nonzero coefficients, or that component distinctions are visible with zero coefficients. -/ +theorem ordinaryH0Control_zeroCoeff_h0_isZero (X : TopCat.{0}) : + IsZero (((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_zeroCoeff).obj X) := + (ordinaryH0Control_zeroCoeff_componentCoproduct_isZero X).of_iso + ((ordinaryH0_naturalIso ordinaryH0Control_zeroCoeff).app X) + +/-- Proves: the point class of the one-point space with integer coefficients augments to the identity of `ℤ`. +Method: specialize the module's ordinary augmentation formula. +Does not establish: reduced-H0 vanishing; this is the ordinary point class. -/ +theorem ordinaryH0Control_point_augmentation : + ordinaryH0_pointClass (TopCat.of Unit) ordinaryH0Control_intCoeff () ≫ + TopCat.singularHomology₀ε (TopCat.of Unit) ordinaryH0Control_intCoeff = + 𝟙 ordinaryH0Control_intCoeff := + ordinaryH0_pointClass_augmentation _ _ _ + +/-- Proves: the point class of the one-point space with integer coefficients is nonzero. +Method: the module's nonvanishing theorem with the proved nonzero identity of `ℤ`. +Does not establish: nonvanishing with zero coefficients. -/ +theorem ordinaryH0Control_point_ne_zero : + ordinaryH0_pointClass (TopCat.of Unit) ordinaryH0Control_intCoeff () ≠ 0 := + ordinaryH0_pointClass_ne_zero (TopCat.of Unit) ordinaryH0Control_intCoeff + ordinaryH0Control_intCoeff_id_ne_zero () + +/-- Proves: actual ordinary singular H0 of the one-point space with integer coefficients is not a zero object. +Method: a zero target would force the nonzero point class to vanish. +Does not establish: a computation of that H0 beyond its nonvanishing. -/ +theorem ordinaryH0Control_point_h0_not_isZero : + ¬ IsZero (((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).obj + (TopCat.of Unit)) := + fun h => ordinaryH0Control_point_ne_zero (h.eq_of_tgt _ _) + +/-- Proves: `0` and `1` lie in the same actual path component of the real line. +Method: the explicit path `t ↦ t` along the unit interval. +Does not establish: path-connectedness of any closed superlevel. -/ +theorem ordinaryH0Control_line_component_eq : + ZerothHomotopy.mk (0 : ℝ) = ZerothHomotopy.mk (1 : ℝ) := + ZerothHomotopy.sound + { toFun := fun t => (t : ℝ) + continuous_toFun := continuous_subtype_val + source' := rfl + target' := rfl } + +/-- Proves: with integer coefficients the point classes of `0` and `1` in the real line have zero difference. +Method: the module's same-component theorem with the proved path premise. +Does not establish: that either individual point class dies. -/ +theorem ordinaryH0Control_line_difference_zero_int : + ordinaryH0_pointClass (TopCat.of ℝ) ordinaryH0Control_intCoeff (0 : ℝ) - + ordinaryH0_pointClass (TopCat.of ℝ) ordinaryH0Control_intCoeff (1 : ℝ) = 0 := + ordinaryH0_sameComponent_difference_zero _ _ _ _ ordinaryH0Control_line_component_eq + +/-- Proves: with zero coefficients the point classes of `0` and `1` in the real line have zero difference. +Method: the module's same-component theorem, which carries no coefficient hypothesis. +Does not establish: any separation statement for zero coefficients. -/ +theorem ordinaryH0Control_line_difference_zero_zeroCoeff : + ordinaryH0_pointClass (TopCat.of ℝ) ordinaryH0Control_zeroCoeff (0 : ℝ) - + ordinaryH0_pointClass (TopCat.of ℝ) ordinaryH0Control_zeroCoeff (1 : ℝ) = 0 := + ordinaryH0_sameComponent_difference_zero _ _ _ _ ordinaryH0Control_line_component_eq + +/-- Proves: with integer coefficients each of the two same-component point classes in the real line is nonzero. +Method: the module's nonvanishing theorem with the proved nonzero identity of `ℤ`. +Does not establish: distinctness of the two classes, which are equal. -/ +theorem ordinaryH0Control_line_classes_ne_zero : + ordinaryH0_pointClass (TopCat.of ℝ) ordinaryH0Control_intCoeff (0 : ℝ) ≠ 0 ∧ + ordinaryH0_pointClass (TopCat.of ℝ) ordinaryH0Control_intCoeff (1 : ℝ) ≠ 0 := + ⟨ordinaryH0_pointClass_ne_zero _ _ ordinaryH0Control_intCoeff_id_ne_zero _, + ordinaryH0_pointClass_ne_zero _ _ ordinaryH0Control_intCoeff_id_ne_zero _⟩ + +/-- Proves: distinct points of a discrete space lie in distinct actual path components. +Method: a path is a continuous map from the connected unit interval into a discrete space, hence constant. +Does not establish: anything about path components of a non-discrete space. -/ +theorem ordinaryH0Control_discrete_component_ne {X : Type} [TopologicalSpace X] [DiscreteTopology X] + {x y : X} (hxy : x ≠ y) : ZerothHomotopy.mk x ≠ ZerothHomotopy.mk y := by + intro h + obtain ⟨p⟩ : Joined x y := Quotient.exact h + have hc : p 0 = p 1 := PreconnectedSpace.constant inferInstance p.continuous + rw [p.source, p.target] at hc + exact hxy hc + +/-- Proves: `true` and `false` lie in distinct actual path components of the discrete space `Bool`. +Method: the discrete-space separation above with `true ≠ false` by `decide`. +Does not establish: anything about connected components of other spaces. -/ +theorem ordinaryH0Control_bool_component_ne : + ZerothHomotopy.mk true ≠ ZerothHomotopy.mk false := + ordinaryH0Control_discrete_component_ne (by decide) + +/-- Proves: with integer coefficients the point classes of `true` and `false` in `Bool` differ. +Method: the module's separation theorem with the two proved premises. +Does not establish: separation with zero coefficients. -/ +theorem ordinaryH0Control_bool_pointClass_ne : + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff true ≠ + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff false := + ordinaryH0_pointClass_ne_of_component_ne _ _ ordinaryH0Control_intCoeff_id_ne_zero _ _ + ordinaryH0Control_bool_component_ne + +/-- Proves: with `ZMod 2` coefficients, a characteristic-two object, the point classes of `true` and `false` in `Bool` differ. +Method: the module's separation theorem with the proved nonzero identity of `ZMod 2` and the proved component separation. +Does not establish: separation for every characteristic-two coefficient object, or with zero coefficients. -/ +theorem ordinaryH0Control_bool_pointClass_ne_mod2 : + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_mod2Coeff true ≠ + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_mod2Coeff false := + ordinaryH0_pointClass_ne_of_component_ne _ _ ordinaryH0Control_mod2Coeff_id_ne_zero _ _ + ordinaryH0Control_bool_component_ne + +/-- Proves: nothing; it names the continuous collapse of `Bool` onto the one-point space. +Method: Mathlib's constant continuous map. +Does not establish: any homology statement by itself. -/ +def ordinaryH0Control_collapse : TopCat.of Bool ⟶ TopCat.of Unit := + TopCat.ofHom (ContinuousMap.const Bool ()) + +/-- Proves: with integer coefficients the collapse kills the difference of the two point classes of `Bool`. +Method: the module's merger criterion with the proved target-component equality in the one-point space. +Does not establish: that an individual point class dies. -/ +theorem ordinaryH0Control_collapse_difference_zero : + (ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff true - + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff false) ≫ + ((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map + ordinaryH0Control_collapse = 0 := + (ordinaryH0_difference_map_eq_zero_iff _ ordinaryH0Control_intCoeff_id_ne_zero _ _ _).2 rfl + +/-- Proves: with integer coefficients each image point class under the collapse is nonzero. +Method: actual point-class transport followed by the module's nonvanishing theorem. +Does not establish: distinctness of the two image classes, which are equal. -/ +theorem ordinaryH0Control_collapse_image_ne_zero (b : Bool) : + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff b ≫ + ((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map + ordinaryH0Control_collapse ≠ 0 := by + rw [ordinaryH0_pointClass_map] + exact ordinaryH0_pointClass_ne_zero _ _ ordinaryH0Control_intCoeff_id_ne_zero _ + +/-- Proves: a merger kills the difference of the two point classes of `Bool` while each image class survives. +Method: combine the two collapse controls above. +Does not establish: a Morse merger event, elder selection or death height. -/ +theorem ordinaryH0Control_collapse_difference_dies_classes_survive : + (ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff true - + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff false) ≫ + ((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map + ordinaryH0Control_collapse = 0 ∧ + ∀ b : Bool, ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff b ≫ + ((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map + ordinaryH0Control_collapse ≠ 0 := + ⟨ordinaryH0Control_collapse_difference_zero, ordinaryH0Control_collapse_image_ne_zero⟩ + +/-- Proves: nothing; it names the continuous first projection of the discrete square `Bool × Bool` onto `Bool`, a non-injective map. +Method: Mathlib's continuous first projection. +Does not establish: any homology statement by itself. -/ +def ordinaryH0Control_fst : TopCat.of (Bool × Bool) ⟶ TopCat.of Bool := + TopCat.ofHom ⟨Prod.fst, continuous_fst⟩ + +/-- Proves: with integer coefficients, before any map, the differences of the classes of `(true, false)` and `(true, true)`, and of `(true, false)` and `(false, true)`, in the discrete square are both nonzero. +Method: the module's separation theorem with the proved discrete-space component separation, then `sub_ne_zero`. +Does not establish: any statement about their images. -/ +theorem ordinaryH0Control_square_differences_ne_zero : + ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, false) : Bool × Bool) - + ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, true) : Bool × Bool) ≠ 0 ∧ + ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, false) : Bool × Bool) - + ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((false, true) : Bool × Bool) ≠ 0 := + ⟨sub_ne_zero.mpr (ordinaryH0_pointClass_ne_of_component_ne _ _ ordinaryH0Control_intCoeff_id_ne_zero _ _ + (ordinaryH0Control_discrete_component_ne (X := Bool × Bool) (by decide))), + sub_ne_zero.mpr (ordinaryH0_pointClass_ne_of_component_ne _ _ ordinaryH0Control_intCoeff_id_ne_zero _ _ + (ordinaryH0Control_discrete_component_ne (X := Bool × Bool) (by decide)))⟩ + +/-- Proves: with integer coefficients the projection kills the difference of the classes of `(true, false)` and `(true, true)`, whose images coincide. +Method: the module's merger criterion with the proved target-component equality. +Does not establish: that an individual point class dies. -/ +theorem ordinaryH0Control_fst_difference_zero : + (ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, false) : Bool × Bool) - + ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, true) : Bool × Bool)) ≫ + ((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map + ordinaryH0Control_fst = 0 := + (ordinaryH0_difference_map_eq_zero_iff _ ordinaryH0Control_intCoeff_id_ne_zero _ _ _).2 rfl + +/-- Proves: with integer coefficients the same non-injective projection keeps the difference of the classes of `(true, false)` and `(false, true)` nonzero, since their images `true` and `false` stay in distinct components. +Method: the module's merger criterion, used contrapositively with the proved separation of the image components. +Does not establish: injectivity of the induced H0 map, which fails on the first pair. -/ +theorem ordinaryH0Control_fst_difference_ne_zero : + (ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, false) : Bool × Bool) - + ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((false, true) : Bool × Bool)) ≫ + ((singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map + ordinaryH0Control_fst ≠ 0 := by + rw [Ne, ordinaryH0_difference_map_eq_zero_iff _ ordinaryH0Control_intCoeff_id_ne_zero] + exact ordinaryH0Control_bool_component_ne + +/-- Proves: with zero coefficients the point classes of `true` and `false` in `Bool` are equal. +Method: any two morphisms out of the zero coefficient object agree. +Does not establish: equality of their path components, which differ. -/ +theorem ordinaryH0Control_bool_zeroCoeff_eq : + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff true = + ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff false := + ordinaryH0Control_zeroCoeff_isZero.eq_of_src _ _ + +/-- Proves: with zero coefficients the point class of the one-point space is zero. +Method: any two morphisms out of the zero coefficient object agree. +Does not establish: vanishing of ordinary H0 with nonzero coefficients. -/ +theorem ordinaryH0Control_point_zeroCoeff_eq_zero : + ordinaryH0_pointClass (TopCat.of Unit) ordinaryH0Control_zeroCoeff () = 0 := + ordinaryH0Control_zeroCoeff_isZero.eq_of_src _ _ + +/-- Proves: the separation statement is false once its nonzero-coefficient hypothesis is deleted. +Method: the zero-coefficient fixture on `Bool` has distinct components and equal point classes. +Does not establish: any failure of the module's statements, which retain that hypothesis. -/ +theorem ordinaryH0Control_separation_needs_nonzero : + ¬ ∀ (X : TopCat.{0}) (R : ModuleCat.{0} ℤ) (x y : X), + ZerothHomotopy.mk x ≠ ZerothHomotopy.mk y → + ordinaryH0_pointClass X R x ≠ ordinaryH0_pointClass X R y := + fun h => h (TopCat.of Bool) ordinaryH0Control_zeroCoeff true false + ordinaryH0Control_bool_component_ne ordinaryH0Control_bool_zeroCoeff_eq + +/-- Proves: the nonvanishing statement is false once its nonzero-coefficient hypothesis is deleted. +Method: the zero-coefficient fixture on the one-point space has a zero point class. +Does not establish: any failure of the module's statements, which retain that hypothesis. -/ +theorem ordinaryH0Control_nonvanishing_needs_nonzero : + ¬ ∀ (X : TopCat.{0}) (R : ModuleCat.{0} ℤ) (x : X), ordinaryH0_pointClass X R x ≠ 0 := + fun h => h (TopCat.of Unit) ordinaryH0Control_zeroCoeff () ordinaryH0Control_point_zeroCoeff_eq_zero + +/-- Proves: nothing; it names the point `-1` of the closed superlevel of `x ↦ x ^ 2` at parameter `-1`. +Method: membership is `-(-1) ≤ (-1) ^ 2`, checked by `norm_num`. +Does not establish: any component statement by itself. -/ +def ordinaryH0Control_parabolaLeft : superlevel_set (fun x : ℝ => x ^ 2) (-1) := + ⟨-1, by norm_num [superlevel_set]⟩ + +/-- Proves: nothing; it names the point `1` of the closed superlevel of `x ↦ x ^ 2` at parameter `-1`. +Method: membership is `-(-1) ≤ 1 ^ 2`, checked by `norm_num`. +Does not establish: any component statement by itself. -/ +def ordinaryH0Control_parabolaRight : superlevel_set (fun x : ℝ => x ^ 2) (-1) := + ⟨1, by norm_num [superlevel_set]⟩ + +/-- Proves: the closed-superlevel parameter `-1` lies below `-1/4`, so the inclusion of the level at `-1` into the level at `-1/4` exists. +Method: `norm_num`. +Does not establish: any component or homology statement by itself. -/ +theorem ordinaryH0Control_parabola_le : (-1 : ℝ) ≤ -1 / 4 := by + norm_num + +/-- Proves: the inclusion from parameter `-1` to `-1/4` is strict: `-1 < -1/4`, and `1/2` lies in the level `{x | 1/4 ≤ x ^ 2}` but not in `{x | 1 ≤ x ^ 2}`. +Method: `norm_num` on the three numeric facts. +Does not establish: any component or homology statement by itself. -/ +theorem ordinaryH0Control_parabola_strict_growth : + (-1 : ℝ) < -1 / 4 ∧ (1 / 2 : ℝ) ∈ superlevel_set (fun x : ℝ => x ^ 2) (-1 / 4) ∧ + (1 / 2 : ℝ) ∉ superlevel_set (fun x : ℝ => x ^ 2) (-1) := by + refine ⟨by norm_num, ?_, ?_⟩ <;> norm_num [superlevel_set] + +/-- Proves: `-1` and `1` are not joined inside the closed superlevel `{x | 1/4 ≤ x ^ 2}` of `x ↦ x ^ 2` at parameter `-1/4`. +Method: intermediate value theorem; a joining path would pass through `0`, which lies outside that level. +Does not establish: a first merger level or threshold attainment. -/ +theorem ordinaryH0Control_parabola_not_joined_quarter : + ¬ JoinedIn (superlevel_set (fun x : ℝ => x ^ 2) (-1 / 4)) + ordinaryH0Control_parabolaLeft.val ordinaryH0Control_parabolaRight.val := by + rintro ⟨γ, hγ⟩ + obtain ⟨t, ht⟩ : (0 : ℝ) ∈ Set.range γ := + intermediate_value_univ 0 1 γ.continuous + ⟨by norm_num [ordinaryH0Control_parabolaLeft], by norm_num [ordinaryH0Control_parabolaRight]⟩ + have hmem := hγ t + rw [ht] at hmem + norm_num [superlevel_set] at hmem + +/-- Proves: `-1` and `1` are joined inside the closed superlevel of `x ↦ x ^ 2` at parameter `0`, which is the whole line. +Method: the straight segment lies in that level because squares are nonnegative. +Does not establish: path-connectedness of any other level. -/ +theorem ordinaryH0Control_parabola_joined : + JoinedIn (superlevel_set (fun x : ℝ => x ^ 2) 0) + ordinaryH0Control_parabolaLeft.val ordinaryH0Control_parabolaRight.val := + JoinedIn.of_segment_subset (by + intro z _ + show -(0 : ℝ) ≤ z ^ 2 + rw [neg_zero] + exact sq_nonneg z) + +/-- Proves: with integer coefficients the closed-superlevel inclusion from parameter `-1` to `0` kills the difference of the classes of `-1` and `1`. +Method: the module's filtration criterion with the proved target-level path. +Does not establish: that either included point class dies, or that `0` is the first merger level. -/ +theorem ordinaryH0Control_parabola_difference_zero : + (ordinaryH0_pointClass (TopCat.of (superlevel_set (fun x : ℝ => x ^ 2) (-1))) + ordinaryH0Control_intCoeff ordinaryH0Control_parabolaLeft - + ordinaryH0_pointClass (TopCat.of (superlevel_set (fun x : ℝ => x ^ 2) (-1))) + ordinaryH0Control_intCoeff ordinaryH0Control_parabolaRight) ≫ + (superlevel_h0Filtration (fun x : ℝ => x ^ 2) ordinaryH0Control_intCoeff).map + (homOfLE (neg_nonpos.mpr zero_le_one : (-1 : ℝ) ≤ 0)) = 0 := + (ordinaryH0_filtration_difference_zero_iff_joinedIn _ _ ordinaryH0Control_intCoeff_id_ne_zero + _ _ _).2 ordinaryH0Control_parabola_joined + +/-- Proves: with integer coefficients the strict closed-superlevel inclusion from parameter `-1` to `-1/4` keeps the difference of the classes of `-1` and `1` nonzero. +Method: the module's filtration criterion, used contrapositively with the proved absence of a path in the target level. +Does not establish: the behaviour at any parameter strictly between `-1/4` and `0`, or the first merger level. -/ +theorem ordinaryH0Control_parabola_strict_difference_ne_zero : + (ordinaryH0_pointClass (TopCat.of (superlevel_set (fun x : ℝ => x ^ 2) (-1))) + ordinaryH0Control_intCoeff ordinaryH0Control_parabolaLeft - + ordinaryH0_pointClass (TopCat.of (superlevel_set (fun x : ℝ => x ^ 2) (-1))) + ordinaryH0Control_intCoeff ordinaryH0Control_parabolaRight) ≫ + (superlevel_h0Filtration (fun x : ℝ => x ^ 2) ordinaryH0Control_intCoeff).map + (homOfLE ordinaryH0Control_parabola_le) ≠ 0 := fun h => + ordinaryH0Control_parabola_not_joined_quarter + ((ordinaryH0_filtration_difference_zero_iff_joinedIn _ _ ordinaryH0Control_intCoeff_id_ne_zero + _ _ _).1 h) + +end TorusFiltration diff --git a/companions/torus_filtration_20261011/README.md b/companions/torus_filtration_20261011/README.md index 671b4cb7c..5efed09b4 100644 --- a/companions/torus_filtration_20261011/README.md +++ b/companions/torus_filtration_20261011/README.md @@ -2,11 +2,24 @@ Dylan Roy — delegated AI work. Source authors: OpenAI/Codex lanes (C254 for `TorusTopology` and `ClosedSuperlevel`; C263 for `SuperlevelBar`; C264 for `OrdinaryH0`). Compile fixes, the C264 -owner repair and the companion: Anthropic/Claude lane. Scientific effect **NONE**. +owner repair, the owner-authored controls module `OrdinaryH0Controls` (C264 owner task item 4) +and the companion: Anthropic/Claude lane. Scientific effect **NONE**. Organizational-independence credit **0** for every lane; no human review. Alignment status `PENDING_INDEPENDENT_REVIEW`. The two C26x modules are registered here as compiled successors -under the handoffs' own **FORMAL HOLD**, which stands until a nonauthor exact-source review of the -compiled bytes (see [C263 and C264 registration](#c263-and-c264-registration-2026-10-11)). +under the handoffs' own **FORMAL HOLD** (see [C263 and C264 registration](#c263-and-c264-registration-2026-10-11)). +That hold rests on the handoffs' own listed conditions (Math- #428 comments 6113033545 item 4, +6113372506 and 6113277485 item 5), among them a distinct review of the source-bound execution +output and source-bound hosted evidence and custody; the handoffs say a source review alone does +not meet them. Since 2026-10-12 01:32Z a nonauthor exact-source review of the compiled successors +exists, source-scoped only (Math- #428 review 5485883117, PASS source-scoped for each module): its +reviewer did not run Lean and keeps Lean execution as an open condition under FORMAL HOLD, and it +states no organizational-independence credit and was posted from the same project account. The +engineering registration readback 5485829137 (01:16Z, PASS, identity and registration only) +records credit 0. FORMAL HOLD is unchanged: +its disposition is for the C263/C264 handoff owners, not this companion, and alignment still needs a +reviewer with nonzero organizational-independence credit. +`OrdinaryH0Controls` is not a review and lifts nothing (see +[C264 owner task item 4 controls](#c264-owner-task-item-4-controls-2026-10-12)). Nothing here promotes, discharges or reclassifies any claim. ## Purpose and route rationale @@ -24,9 +37,10 @@ primary manifest at SHA-256 `40cb6ffc…` and the gate at `278989bb…`; any cha review scope for all three. The C255 route finding (6111255007) therefore recommended an isolated companion. This directory is that companion: -- it holds the compile-fixed modules under namespace `TorusFiltration` and a four-line root module - (`import TorusTopology`, `import ClosedSuperlevel`, `import SuperlevelBar`, `import OrdinaryH0`, in - dependency order; the two C26x modules joined on 2026-10-11); +- it holds the compile-fixed modules and the owner-authored controls module under namespace + `TorusFiltration` and a five-line root module (`import TorusTopology`, `import ClosedSuperlevel`, + `import SuperlevelBar`, `import OrdinaryH0`, `import OrdinaryH0Controls`, in dependency order; the + two C26x modules joined on 2026-10-11, the controls module on 2026-10-12); - it compiles them against the **same** pinned toolchain and dependency lock as `formal/` (`formal/lean-toolchain`, `formal/lakefile.toml`, `formal/lake-manifest.json`), which it reads but never edits; @@ -42,27 +56,31 @@ isolated companion. This directory is that companion: | This lane | local elaboration report 6111093545; pickup 6111139060 | | Original `TorusTopology.lean` (NOT_COMPILED) | SHA-256 `efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4`, 11542 bytes | | Original `ClosedSuperlevel.lean` (NOT_COMPILED) | SHA-256 `1fed3edada12b4dc7f5fcf874dae7ccde5d8f65af63cf103159debe58ba6789e`, 7827 bytes | -| Namespace mapping | `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion); no other name changes. `SuperlevelBar` and `OrdinaryH0` were authored directly in namespace `TorusFiltration` | +| Namespace mapping | `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion); no other name changes. `SuperlevelBar` and `OrdinaryH0` were authored directly in namespace `TorusFiltration`, and so was the owner-authored `OrdinaryH0Controls` | | C263 handoff `SuperlevelBar.lean` (failed at the pin with warnings as errors) | SHA-256 `d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8`, 14904 bytes; Math- PR #428 comments 6113033147 (source), 6113033351 (nonauthor source review), 6113033545 (final handoff audit and owner task: 28/28 static checks, formal acceptance HOLD); allocation PR #419 comment 6112439759; this lane's compile report 428/6113229784 | | Registered `SuperlevelBar.lean` (successor) | SHA-256 `346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9`, 15309 bytes; imports `Mathlib` only | | C264 handoff `OrdinaryH0.lean` (failed at the pin with warnings as errors) | SHA-256 `261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e`, 18469 bytes; Math- PR #428 comments 6113276830 (source, delivery 1/3), 6113277173 (nonauthor source review, 2/3), 6113277485 (verification and owner task, 3/3); this lane's failed-compile record 428/6113300903; owner repair handoff 428/6113372506; this lane's repair report with the full diff 428/6113438262 | | Registered `OrdinaryH0.lean` (successor) | SHA-256 `3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88`, 19803 bytes; imports `Mathlib` and `ClosedSuperlevel` | +| Owner-authored `OrdinaryH0Controls.lean` (C264 owner task item 4; no handoff bytes, not a successor) | SHA-256 `df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184`, 29590 bytes; imports `Mathlib` and `OrdinaryH0`; Math- PR #428 comments 6113277485 (C264 owner task, item 4) and 6113277173 (the corrected CONTROL_OBLIGATIONS it instantiates); author: Anthropic/Claude lane | | Toolchain | `leanprover/lean4:v4.34.1`, release commit `5045d0056413266e57c625dcd7c365b10e377c52`; Mathlib `d13f23b723b8a846827a245b89c10fc7d3f11612` via `formal/lake-manifest.json` | `SOURCE_FILES.json` records bytes, SHA-256 and Git blob of every tracked companion file and the workflow, the per-module declaration inventory and this provenance. `check.py source` refuses to run unless the tracked tree, the working bytes and that manifest agree. -## What the 81 theorems and 28 definitions establish +## What the 118 theorems and 35 definitions establish Topology and scaffolding only: the period-lattice quotient, descent of periodic functions, path lifting with an **existential** endpoint, closed superlevel inclusions and their path-component and singular-H0 maps (C254); the total strict-clearance set, its real death value with an explicit empty-set default of `0`, and the exact strict supremum cut for continuous Euclidean heights (C263); and the natural comparison of Mathlib's actual ordinary singular H0 with component-indexed -coproducts, restricted along the closed-superlevel filtration (C264). The sources label these +coproducts, restricted along the closed-superlevel filtration (C264); and fixtures that apply +seven of the 20 C264 theorems, neither naturality theorem among them, to named spaces and +coefficient modules, every premise proved inside the fixture (`OrdinaryH0Controls`, +owner-authored for C264 owner task item 4). The sources label these `proved`; the hosted receipt may call them `kernel-checked`; neither label is alignment or -acceptance. 109 declarations in all: 21 + 20 + 20 + 20 theorems, 3 abbrevs, 22 defs, 3 instances. +acceptance. 153 declarations in all: 21 + 20 + 20 + 20 + 37 theorems, 6 abbrevs, 26 defs, 3 instances. ### `TorusTopology` (21 theorems; 2 abbrevs, 6 defs, 3 instances) @@ -170,6 +188,40 @@ the required coproducts and homology; the nonzero/distinction statements require | `ordinaryH0_filtration_naturality` | the H0/component square at every ordered closed-superlevel inclusion `s ≤ t` | | `ordinaryH0_filtration_difference_zero_iff_joinedIn` | under a closed-superlevel inclusion the difference of two point classes vanishes exactly when the points are `JoinedIn` the target closed superlevel (`𝟙 R ≠ 0`) | +### `OrdinaryH0Controls` (37 theorems; 3 abbrevs, 4 defs) — C264 owner task item 4: instantiated ordinary-H0 controls + +Owner-authored by this lane against the registered `OrdinaryH0` successor (it imports `Mathlib` and +`OrdinaryH0`); not a handoff module and not a review. Universe 0 throughout: spaces in `TopCat.{0}`, +coefficients in `ModuleCat.{0} ℤ`. Every premise is proved inside the fixture (nonzero identities, +the zero identity of the zero module, explicit paths, discrete separations, image-component +equalities and separations, the absence of a path through `0`); no hypothesis, compatibility field +or axiom states a naturality, merger or separation fact. The thirteen premise lemmas (coefficient +identities, the empty space's lack of components, explicit paths, discrete separations, the parabola +levels) are about the fixtures alone and are proved directly, naming no C264 theorem. The other 24 +theorems concern C264's point classes, its natural isomorphism and its component coproduct (or +Mathlib's H0 through them) on cases whose answer is known independently; fourteen of them apply one +of the C264 theorems above by name, seven distinct ones (`ordinaryH0_pointClass_augmentation`, +`ordinaryH0_pointClass_ne_zero`, `ordinaryH0_sameComponent_difference_zero`, +`ordinaryH0_pointClass_ne_of_component_ne`, `ordinaryH0_pointClass_map`, +`ordinaryH0_difference_map_eq_zero_iff`, `ordinaryH0_filtration_difference_zero_iff_joinedIn`); the +module names no other C264 theorem. + +| Declarations | What they state | +|---|---| +| `ordinaryH0Control_intCoeff`, `ordinaryH0Control_zeroCoeff`, `ordinaryH0Control_mod2Coeff` (abbrevs) | the coefficient objects `ℤ`, the one-point module `PUnit` and `ZMod 2`, each as an object of `ModuleCat.{0} ℤ` | +| `ordinaryH0Control_intCoeff_id_ne_zero`, `ordinaryH0Control_mod2Coeff_id_ne_zero`, `ordinaryH0Control_mod2Coeff_id_add_self` | `𝟙 R ≠ 0` for `ℤ` and for `ZMod 2` (evaluation at `1`); `𝟙 + 𝟙 = 0` on `ZMod 2`, the characteristic-two object | +| `ordinaryH0Control_zeroCoeff_isZero`, `ordinaryH0Control_zeroCoeff_id_eq_zero` | the one-point module is a zero object, and its identity is the zero morphism | +| `ordinaryH0Control_empty_components`, `ordinaryH0Control_empty_componentCoproduct_isZero`, `ordinaryH0Control_empty_h0_isZero` | empty space: no path component; its component coproduct is a zero object for every coefficient module; actual singular H0 with `ℤ` coefficients is a zero object (transported along `ordinaryH0_naturalIso`) | +| `ordinaryH0Control_zeroCoeff_componentCoproduct_isZero`, `ordinaryH0Control_zeroCoeff_h0_isZero` | with zero coefficients the component coproduct and actual singular H0 of every space in `TopCat.{0}` are zero objects | +| `ordinaryH0Control_point_augmentation`, `ordinaryH0Control_point_ne_zero`, `ordinaryH0Control_point_h0_not_isZero` | one-point space with `ℤ` coefficients: the point class augments to `𝟙`, is nonzero, and H0 is not a zero object (ordinary, not reduced, H0) | +| `ordinaryH0Control_line_component_eq`, `ordinaryH0Control_line_difference_zero_int`, `ordinaryH0Control_line_difference_zero_zeroCoeff`, `ordinaryH0Control_line_classes_ne_zero` | `0` and `1` share a path component of `ℝ` (the path `t ↦ t`); the difference of their point classes is `0` with `ℤ` and with zero coefficients; with `ℤ` each of the two classes is nonzero | +| `ordinaryH0Control_discrete_component_ne`, `ordinaryH0Control_bool_component_ne` | distinct points of a discrete space lie in distinct path components (a path into a discrete space is constant); so do `true` and `false` in `Bool` | +| `ordinaryH0Control_bool_pointClass_ne`, `ordinaryH0Control_bool_pointClass_ne_mod2` | the two point classes of `Bool` differ with `ℤ` and with `ZMod 2` coefficients | +| `ordinaryH0Control_collapse` (def), `ordinaryH0Control_collapse_difference_zero`, `ordinaryH0Control_collapse_image_ne_zero`, `ordinaryH0Control_collapse_difference_dies_classes_survive` | merger: the collapse `Bool → Unit` kills the difference of the two point classes while each image class stays nonzero | +| `ordinaryH0Control_fst` (def), `ordinaryH0Control_square_differences_ne_zero`, `ordinaryH0Control_fst_difference_zero`, `ordinaryH0Control_fst_difference_ne_zero` | the non-injective first projection `Bool × Bool → Bool`: before the map both differences below are nonzero; it kills the difference of the classes of `(true, false)` and `(true, true)` (same image) and keeps that of `(true, false)` and `(false, true)` nonzero (images in distinct components) | +| `ordinaryH0Control_bool_zeroCoeff_eq`, `ordinaryH0Control_point_zeroCoeff_eq_zero`, `ordinaryH0Control_separation_needs_nonzero`, `ordinaryH0Control_nonvanishing_needs_nonzero` | zero coefficients: the two point classes of `Bool` are equal although their components differ, and the point class of the one-point space is `0`; hence the separation and nonvanishing statements are false once `𝟙 R ≠ 0` is deleted (the C264 statements keep that hypothesis) | +| `ordinaryH0Control_parabolaLeft`, `ordinaryH0Control_parabolaRight` (defs), `ordinaryH0Control_parabola_le`, `ordinaryH0Control_parabola_strict_growth`, `ordinaryH0Control_parabola_not_joined_quarter`, `ordinaryH0Control_parabola_joined`, `ordinaryH0Control_parabola_difference_zero`, `ordinaryH0Control_parabola_strict_difference_ne_zero` | closed superlevels of `x ↦ x ^ 2`: the points `-1` and `1` of the level at parameter `-1`; the strict inclusion into the level at `-1/4` (which gains `1/2`) keeps the difference of their classes nonzero, since no path joins them in `{x | 1/4 ≤ x ^ 2}` (intermediate value theorem through `0`); the inclusion into the level at `0`, the whole line, kills it | + Audited definitions: `torus_E`, `torus_quotient` (abbrev); `torus_latticeVec`, `torus_periodBasis`, `torus_periodLattice`, `torus_proj`, `torus_isPeriodic`, `torus_descend`; instances `torus_lattice_discrete`, `torus_lattice_addSubgroup_discrete`, `torus_lattice_isZLattice`; @@ -177,7 +229,9 @@ Audited definitions: `torus_E`, `torus_quotient` (abbrev); `torus_latticeVec`, ` `superlevel_filtration`, `superlevel_h0Filtration`; `superlevelBar_E` (abbrev), `superlevelBar_isEssential`, `superlevelBar_clearanceSet`, `superlevelBar_deathHeight`; `ordinaryH0_componentFunctor`, `ordinaryH0_componentCoproductFunctor`, `ordinaryH0_componentFiltration`, `ordinaryH0_simplicialPointClass`, -`ordinaryH0_pointClass`, `ordinaryH0_naturalIso`, `ordinaryH0_filtrationIso`. Every one of the 109 +`ordinaryH0_pointClass`, `ordinaryH0_naturalIso`, `ordinaryH0_filtrationIso`; `ordinaryH0Control_intCoeff`, +`ordinaryH0Control_zeroCoeff`, `ordinaryH0Control_mod2Coeff` (abbrev), `ordinaryH0Control_collapse`, +`ordinaryH0Control_fst`, `ordinaryH0Control_parabolaLeft`, `ordinaryH0Control_parabolaRight`. Every one of the 153 declarations is a `#print axioms` target. ## What is NOT established @@ -191,7 +245,10 @@ Copied from the handoff's own exclusions (TORUS_FILTRATION.md, source review F3 components for an arbitrary continuous height; - label tracking, elder events, once-counting; - naturality comparing the displayed component maps with singular-H0 generators beyond the - functor laws actually proved; + functor laws actually proved; (companion note, 2026-10-12, Math- #428 comment 6116225936, not + part of the copied exclusion: C254 alone did not establish this; C264's `OrdinaryH0.lean` + establishes the stated ordinary-H0 naturality only (`ordinaryH0_iso_naturality`, + `ordinaryH0_naturalIso`, `ordinaryH0_filtration_naturality`), and nothing beyond it) - any interval decomposition, tameness, finiteness, barcode or endpoint-preserving bar bijection; - any identification of `PairLawInterface.p`, or any other interface predicate of C253; - smooth quotient charts, Morse index transfer, handle analysis, critical-free band invariance; @@ -224,13 +281,38 @@ Copied from the C264 module's own docstrings (`OrdinaryH0.lean`): elder selection, death height or barcode; strict-level conventions; the later interval, elder, maximum/saddle, count, Field or stochastic bridges. +Copied from the controls module's own docstrings (`OrdinaryH0Controls.lean`): + +- any Morse chart, critical-level attainment theorem, interval decomposition, elder correspondence, + Field adapter, count identity, stochastic law, or scientific-status promotion; any review of + `OrdinaryH0` or lift of FORMAL HOLD; +- the death of an individual point class under a merger (the fixtures kill the difference and keep + each class); injectivity of the induced H0 map (it fails on the first projection); a Morse merger + event, elder selection or death height; a first merger level, threshold attainment or the + behaviour at a parameter strictly between `-1/4` and `0`; separation for every characteristic-two + coefficient object or with zero coefficients; a computation of H0 of the point beyond its + nonvanishing; H0 of the empty space for coefficients other than `ℤ` and the zero module; + path components of a non-discrete space beyond the explicit cases. + Compile success, the axiom audit, `leanchecker` and the negative controls say that Lean elaborated these statements with these proofs at this pin. They do not say that the statements are the ones the research programme needs; that is the pending independent alignment review. -For the two C26x modules there is, in addition, no nonauthor review of the compiled successor -bytes yet: the C263 nonauthor source review (6113033351) and the C264 nonauthor source review -(6113277173) read the handoff bytes, not the successors, and both lanes' handoffs keep formal -acceptance on HOLD until such a review exists. +For the two C26x modules: the C263 nonauthor source review (6113033351) and the C264 nonauthor +source review (6113277173) read the handoff bytes, not the successors. At the registration commit +`940dffc9` (2026-10-11) no nonauthor review of the compiled successor bytes existed, and this +paragraph said so. Until 2026-10-12 01:32Z no nonauthor exact-source (mathematical) review of them +existed; the nonauthor engineering registration readback of `4c33d8cd..940dffc9` (Math- #428 review +5485829137, 2026-10-12 01:16Z, PASS) read those bytes for identity and registration only, and records +organizational-independence credit 0. Since 01:32Z Math- #428 review 5485883117 (Muse Spark / Meta, +first read, PASS source-scoped for each module; count corrected in comment 6116328276) is such a +review, source-scoped only: its reviewer did not run Lean and keeps Lean execution as an open +condition under FORMAL HOLD, and it states no organizational-independence credit and was posted from +the same project account. Both handoffs keep formal acceptance on HOLD on their own listed +conditions (6113033545 item 4; 6113372506; 6113277485 item 5), among them a distinct review of the +source-bound execution output and source-bound hosted evidence and custody, which they say a source +review alone does not meet; its disposition is for the C263/C264 handoff owners and nothing in this +companion moves it. Alignment still needs a reviewer with nonzero organizational-independence +credit. No review of the `OrdinaryH0Controls` bytes is recorded. ## Compile fixes at the pin @@ -305,11 +387,23 @@ bounded repair to this lane as the actual repair author (428/6113372506). The re 20 theorem and 7 definition names are the handoff's except the three ASCII `iota` respellings above, in the successor's file order. +`OrdinaryH0Controls.lean` is not a handoff module and carries no compile fix: this lane wrote it against the registered +`OrdinaryH0` successor and compiled it at the pin with warnings as errors before registration (first compiled form +SHA-256 `e825837f3b0e43553a3a2f48ca48e4150182ad160eb0d7e1a10c141f9c395056`, 28503 bytes, 440 lines). The registered +bytes (`df9d3645…`, 29590 bytes, 453 lines) differ from that form only in one module-docstring paragraph, which now +records that FORMAL HOLD rests on the handoffs' own listed conditions, that the source-scoped review 5485883117 +(Lean execution kept as an open condition, no credit stated) and the engineering readback 5485829137 (credit 0) +exist, and that FORMAL HOLD is unchanged; no declaration changed, and the module was recompiled, its axioms and its +census re-run after the edit (see +[C264 owner task item 4 controls](#c264-owner-task-item-4-controls-2026-10-12)). + The C254 module docstrings still read `C254 proposed source. Compilation and kernel audit: NOT_RUN.` (line 6 of each file), and `OrdinaryH0.lean` reads `C264 isolated source candidate. Compilation and kernel audit: NOT_RUN.` (line 7); `SuperlevelBar.lean` says of itself that it makes no execution claim. Those lines are the handoffs' own status labels, retained verbatim as -transcribed source labels; they are not updated by this companion. Whether the modules compiled +transcribed source labels; they are not updated by this companion. `OrdinaryH0Controls.lean`, the +owner-authored module, says that compilation and kernel audit of its bytes are recorded only +where a run is reported, and names no run. Whether the modules compiled and were replayed through the kernel is recorded in the hosted `receipt.json` (`formalization_status`, `leanchecker`), never in the module text, so the module lines under-state and the receipt is the record. @@ -319,15 +413,17 @@ under-state and the receipt is the record. Every C254 declaration keeps its handoff name: `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion). The C263 and C264 modules were authored directly in namespace `TorusFiltration` (there is no handoff namespace to map); the only C264 renames are the three -ASCII `iota` spellings listed above. The inventory lists in `SOURCE_FILES.json` are derived from -the originals by column-0 scans (`^theorem`, `^(noncomputable )?def`, `^abbrev`, `^instance`). +ASCII `iota` spellings listed above. The owner-authored `OrdinaryH0Controls` was also written +directly in namespace `TorusFiltration`, every name carrying the prefix `ordinaryH0Control_`. The +inventory lists in `SOURCE_FILES.json` are derived from the originals (for `OrdinaryH0Controls`, +from the module itself) by column-0 scans (`^theorem`, `^(noncomputable )?def`, `^abbrev`, `^instance`). `check.py source` re-derives them from the companion modules with a whitelist scanner (`scan_module`, not a Lean parser) and refuses any module whose scan differs. The scanner strips comments (`--`, nested `/- -/`, `/-- -/`, `/-! -/`) and then permits, at column 0, only: `import Mathlib` or `import Mathlib.…`, or `import ` for a companion module `M` that precedes -the scanned module in `MODULES` (`OrdinaryH0.lean` imports `ClosedSuperlevel`; a self, forward or -root import is refused as `companion import out of dependency order`; both only before the -namespace), `noncomputable section`, `open `, `open scoped ` +the scanned module in `MODULES` (`OrdinaryH0.lean` imports `ClosedSuperlevel`, +`OrdinaryH0Controls.lean` imports `OrdinaryH0`; a self, forward or root import is refused as +`companion import out of dependency order`; both only before the namespace), `noncomputable section`, `open `, `open scoped ` (`OrdinaryH0.lean` opens the scoped simplicial notation; capitalized names only, nothing else on the line), `universe …`, `variable …`, exactly one `namespace TorusFiltration` / `end TorusFiltration` pair, and inside it a named `theorem`, `def`, `noncomputable def`, `abbrev` @@ -374,21 +470,22 @@ refuse. The lexer also treats a closed block comment as a token separator (`theo is `theorem hidden`) and lexes numerals as Lean does (`0alias` is `0` then `alias`; `0x1Ftheorem` is `0x1F` then `theorem`), both found by that verification. **The declaration census the receipt stands on is therefore not the scanner but `Census.lean`**, emitted by `check.py emit` and run -by the replay: Lean itself lists every constant the five companion modules (the four modules and +by the replay: Lean itself lists every constant the six companion modules (the five modules and the root) add to the environment, tagged `internal` or `user` (`Name.isInternalDetail`: `_`-prefixed, `eq_n`, `match_n`, `proof_n`, `omega_n` or numeric components) and `range` or `generated` (whether Lean recorded a declaration range, which every declaration elaborated from source syntax carries and compiler-generated constants lack). `check.py finish` requires the -user-named ranged constants to equal the 109 inventoried names exactly, refuses any ranged +user-named ranged constants to equal the 153 inventoried names exactly, refuses any ranged constant with an internal-style name (a `where`-clause `proof_1` written by hand), and requires the user-named generated constants to equal `census_auxiliary` in `SOURCE_FILES.json` exactly (today `TorusFiltration.torus_periodBasis.congr_simp`, the simp-congruence lemma Lean generates -for `torus_periodBasis`; the C263 and C264 modules add no user-named generated constant), so that +for `torus_periodBasis`; the C263, C264 and controls modules add no user-named generated constant), so that list can name only constants Lean generated; internal generated constants (abstracted proofs, equation lemmas, `_simp` auxiliaries, and `CategoryTheory.Limits.sigmaConst.eq_1`, the equation lemma Lean generated for a Mathlib definition that `OrdinaryH0.lean` unfolds and attributed to -that module) are counted and otherwise ignored: 23 at the pin for the five modules, of which 12 -belong to the C26x pair. A declaration +that module) are counted and otherwise ignored: 27 at the pin for the six modules, of which 12 +belong to the C26x pair and 4 to `OrdinaryH0Controls` (`_proof_1` and `eq_1` of +`ordinaryH0Control_parabolaLeft` and `ordinaryH0Control_parabolaRight`). A declaration the scanner missed is refused by the receipt whatever its spelling, because it was elaborated from source and therefore carries a range. A compile fix that needs a refused form must extend the scanner, the inventory and, for a new compiler-generated constant, `census_auxiliary`. @@ -416,12 +513,13 @@ cache for `formal/` retrieved: The replay: binds HEAD to the manifest (`check.py source`), runs the Python tests in normal and `-O` modes, emits the Lean audit files, then inside `lake env bash` from `formal/` records `lean --version` and every installed package HEAD, compiles `TorusTopology`, `ClosedSuperlevel`, -`SuperlevelBar`, `OrdinaryH0` (in that dependency order) and the root `TorusFiltration` with -`-DwarningAsError=true`, compiles `Positive.lean` (six concrete applications of the C254 -theorems; unchanged by the registration), `Audit.lean` (109 `#print axioms`), `Types.lean` (81 -`#check` with `pp.explicit`), `Census.lean` (the elaborated declaration census above), runs -`leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration`, and runs -eight negative controls. The replay unsets `PYTHONOPTIMIZE` first, so each Python invocation runs in exactly the +`SuperlevelBar`, `OrdinaryH0`, `OrdinaryH0Controls` (in that dependency order) and the root +`TorusFiltration` with `-DwarningAsError=true`, compiles `Positive.lean` (six concrete applications +of the C254 theorems; unchanged by both registrations), `Audit.lean` (153 `#print axioms`), +`Types.lean` (118 `#check` with `pp.explicit`), `Census.lean` (the elaborated declaration census +above), runs +`leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 OrdinaryH0Controls TorusFiltration`, +and runs eleven negative controls. The replay unsets `PYTHONOPTIMIZE` first, so each Python invocation runs in exactly the mode its command line names, and every `check.py` invocation prints the mode it runs in (`TORUS_FILTRATION_PYTHON: optimize=N`) to the job log (an invocation that argparse rejects exits 2 before that line; the replay never issues one). @@ -435,6 +533,9 @@ elaborated as `example : := by ` and must fail with exactly | `RejectConstantNotPeriodic` | false statement `¬ torus_isPeriodic 1 (1 : ℝ) (fun _ => (0 : ℝ))`, tactic `simp [torus_isPeriodic]` | exit 1, `⊢ False` | | `RejectEssentialDeathBound` (C263) | false statement `superlevelBar_deathHeight (fun _ : superlevelBar_E 1 => (-1 : ℝ)) 0 ≤ (-1 : ℝ)` (the death/start bound on the essential default branch: the constant `-1` has death `0` by `superlevelBar_death_const`, and `0 ≤ -1` is false; the proposition of the C263 handoff's `FALSE_CONTROL_PROPOSAL` (Math- #428 comment 6113033351), whose tactic `rw [superlevelBar_death_const 1 (-1) (0 : superlevelBar_E 1)]; norm_num` is replaced here by `norm_num [superlevelBar_death_const]`), tactic `norm_num [superlevelBar_death_const]` | exit 1, `⊢ False` | | `RejectReducedPointClass` (C264) | false statement `CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of Unit) (ModuleCat.of ℤ ℤ) ()) (TopCat.singularHomology₀ε (TopCat.of Unit) (ModuleCat.of ℤ ℤ)) ≠ CategoryTheory.CategoryStruct.id (ModuleCat.of ℤ ℤ)` (the ordinary point class of the one-point space with `ℤ`-module coefficients is **not** augmented to the identity, which is what a reduced-H0 substitution would give; `ordinaryH0_pointClass_augmentation` says it is the identity; the notation `≫`/`𝟙` is spelled out because the emitted file opens only `TorusFiltration`), tactic `simp [ordinaryH0_pointClass_augmentation]` | exit 1, `⊢ False` | +| `RejectMergerKillsPointClass` (C264 item 4) | false statement `CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff true) (((AlgebraicTopology.singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map ordinaryH0Control_collapse) = 0` (the collapse `Bool → Unit` kills the individual point class of `true`; a merger kills the difference, not the class, and `ordinaryH0Control_collapse_image_ne_zero` says the image class is nonzero), tactic `simp only [ordinaryH0Control_collapse_image_ne_zero]` | exit 1, `⊢ False` | +| `RejectSeparationWithoutNonzeroCoeff` (C264 item 4) | false statement `ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff true ≠ ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff false` (the two point classes of `Bool` differ with zero coefficients; `ordinaryH0Control_bool_zeroCoeff_eq` says they are equal, so the separation statement needs `𝟙 R ≠ 0`), tactic `simp [ordinaryH0Control_bool_zeroCoeff_eq]` | exit 1, `⊢ False` | +| `RejectNonmergerKillsDifference` (C264 item 4) | false statement `CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, false) : Bool × Bool) - ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((false, true) : Bool × Bool)) (((AlgebraicTopology.singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map ordinaryH0Control_fst) = 0` (the non-injective projection kills a difference whose images `true` and `false` stay in distinct components; `ordinaryH0Control_fst_difference_ne_zero` says it does not), tactic `simp only [ordinaryH0Control_fst_difference_ne_zero]` | exit 1, `⊢ False` | | `RejectSorry` | `theorem injected : False := by sorry` | exit 0 with the `sorry` warning; audit refuses `sorryAx` | | `RejectCustomAxiom` | `axiom hiddenPremise : False` behind one intermediate theorem | exit 0; audit refuses `hiddenPremise` | | `RejectNativeDecide` | `native_decide` proof | exit 0; audit refuses `injected._native.native_decide.ax_1_1` | @@ -444,39 +545,45 @@ and only the axiom audit refuses them, which is what the audit is for. `check.py `re.fullmatch` on each log, so a crash, an extra error or a different exit code is a failed control, not a passed one. `check.py finish` refuses an evidence directory that already holds `receipt.json` (a receipt is written once and never replaced; a new attempt needs a fresh -directory) and requires exactly the 54 evidence files, each a regular file and nothing else: the -twelve emitted Lean files (`Audit.lean`, `Types.lean`, `Positive.lean`, `Census.lean` and the -eight controls' `.lean`), a `.log` and `.status` pair for each of the ten Lean processes (five -module builds, `positive`, `axioms`, `types`, `census`, `leanchecker`), the eight controls' +directory) and requires exactly the 65 evidence files, each a regular file and nothing else: the +fifteen emitted Lean files (`Audit.lean`, `Types.lean`, `Positive.lean`, `Census.lean` and the +eleven controls' `.lean`), a `.log` and `.status` pair for each of the eleven Lean processes (six +module builds, `positive`, `axioms`, `types`, `census`, `leanchecker`), the eleven controls' `.log`/`.status`, `leanchecker.cmd`, `packages.log`, `toolchain.log`, `source.json`, `tests.log` and `tests-optimized.log` (`EVIDENCE_FILES` in `check.py`; C262 finding G3; 44 -members before the C263/C264 registration added two builds and two controls). It then -re-runs the source binding, re-derives the twelve emitted Lean files and requires byte equality +members before the C263/C264 registration added two builds and two controls, 54 before the +item-4 controls added one build and three controls). It then +re-runs the source binding, re-derives the fifteen emitted Lean files and requires byte equality with the ones Lean consumed, checks every status, the toolchain line, the installed package HEADs against `formal/lake-manifest.json`, the recorded `leanchecker` invocation, the axiom and -type inventories, the declaration census and the eight controls, and writes `receipt.json` with -`log_sha256` over exactly those 54 files, created exclusively (`O_EXCL`, `O_NOFOLLOW`). The +type inventories, the declaration census and the eleven controls, and writes `receipt.json` with +`log_sha256` over exactly those 65 files, created exclusively (`O_EXCL`, `O_NOFOLLOW`). The evidence directory `.lake/torus-filtration-evidence` must not pre-exist. ### What `leanchecker` checks here, and why not `--fresh` -All four modules `import Mathlib` (`OrdinaryH0` also imports `ClosedSuperlevel`), so their import closure is all of Mathlib (6.1 GB of `.olean` +All five modules `import Mathlib` (`OrdinaryH0` also imports `ClosedSuperlevel`, `OrdinaryH0Controls` also imports `OrdinaryH0`), so their import closure is all of Mathlib (6.1 GB of `.olean` files at the pin). `leanchecker --fresh TorusFiltration`, the shape of the D2 companions' step (`leanchecker --fresh D2MomentBridge`, affordable there only because that module imports `Mathlib.Tactic` and one Bochner file), re-checks that entire closure from scratch: measured locally against the pinned cache at 4 threads it was still running at 1500 s with 6.6 GB resident, so it cannot complete inside a hosted job. The hosted -default is therefore `leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration` -(before the C263/C264 registration it named the three C254 modules; `check.py finish` now refuses that -shorter form): leanchecker +default is therefore `leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 OrdinaryH0Controls TorusFiltration` +(before the C263/C264 registration it named the three C254 modules, and before the item-4 controls the +four modules and the root; `check.py finish` now refuses both shorter forms): leanchecker builds the environment from the cached, prebuilt dependency `.olean` files (trusted, exactly as -`lean` itself trusts them when compiling the modules) and replays every declaration of the five +`lean` itself trusts them when compiling the modules) and replays every declaration of the six named modules through the kernel. Measured locally at `LEAN_NUM_THREADS=2`: 30 s wall and 6.6 GB resident for the three C254 modules; 53 s for the five (2026-10-11, this lane's pre-commit run on the -registered bytes) with a peak of about 8.4 to 8.7 GiB resident (two runs, sampled every 2 s), no output on success (one -`lean` compile of `ClosedSuperlevel.lean` takes 9 s and 6.8 GB; `OrdinaryH0.lean` compiles in 12 s). +registered bytes) with a peak of about 8.4 to 8.7 GiB resident (two runs, sampled every 2 s); for the +six (2026-10-12, this lane, the registered Lean bytes, sampled every 1 s), 75 s wall including the +`lake env` start-up with a sampled peak of 8.64 GiB in the pre-commit run, and about 56 s of +`leanchecker` itself with a sampled peak of 9.31 GiB inside a full local replay, no output on success (one +`lean` compile of `ClosedSuperlevel.lean` takes 9 s and 6.8 GB; `OrdinaryH0.lean` compiles in 12 s, +`OrdinaryH0Controls.lean` in 12 s at a sampled peak of 6.5 GiB). With `LEAN_NUM_THREADS` unset on a four-core machine the five-module `leanchecker` exceeded a 13.36 GiB memory limit and was killed (twice, 2026-10-11), so `replay.sh` defaults `LEAN_NUM_THREADS` -to 2, the hosted job's setting, when the operator has not set it. `replay.sh` writes the exact invocation to +to 2, the hosted job's setting, when the operator has not set it; the six-module form was run only +at two threads. `replay.sh` writes the exact invocation to `leanchecker.cmd`; `check.py finish` accepts only the two pinned forms, requires the modules-mode log to be empty, and copies command and mode into `receipt.json` under `leanchecker`. An operator who wants the whole-closure re-check runs @@ -492,16 +599,24 @@ Hosted duration: measured on the first green run, replay step itself 1 min 27 s at `LEAN_NUM_THREADS=2`; artifact `torus-filtration-38165155316-1`, 42 files, 22,572 bytes, SHA-256 `c9bf02d33ddd9addb5d2883af982827b44ef3fd5e84d877ed78504efe8f19c0d`. The workflow's `timeout-minutes: 45` is kept: a cache miss or a slow runner needs the margin and -lowering it buys nothing. One hosted completion is recorded here; every later run's receipt stands +lowering it buys nothing. One hosted completion is measured here; every later run's receipt stands on its own, and a receipt is a record of a computation, not evidence of alignment. That measured run predates the C263/C264 registration (three module builds, six controls, 41 evidence files, 42 with the receipt); the registered set (five builds, the census, eight controls, 54 files) adds, relative to that run, the census `lean` run (from the C262 AMEND), two `lean` compiles of about 10 and 12 s, two control runs of about 10 s each and about 23 s more of `leanchecker` (30 s to 53 s), at `LEAN_NUM_THREADS=2`, measured -locally; the registered set has no hosted completion yet. +locally. At the registration commit the registered set had no hosted completion. Hosted run +[38187870416](https://github.com/d6g8k5htny-coder/Math-/actions/runs/38187870416) of `940dffc9` (created +2026-10-12T00:24:18Z) later completed with conclusion success, as reported by the engineering readback +5485829137 (credit 0), which inspected its artifact 11719939176 and receipt (GitHub's run record, read by this lane on +2026-10-12, shows the same status, conclusion and head); this lane has not downloaded or re-inspected that +artifact, and this README does not adopt its receipt or its timings. The item-4 set (six builds, the census, +eleven controls, 65 files) adds one `lean` compile of about 12 s and three control runs of about 10 s each, +and the six-module `leanchecker` took 56 to 75 s locally (with and without `lake env` start-up; measured 2026-10-12 at `LEAN_NUM_THREADS=2`; +a full local replay took 279 s); the item-4 commit has no hosted completion recorded here. The replay writes `TorusTopology.olean`, `ClosedSuperlevel.olean`, `SuperlevelBar.olean`, -`OrdinaryH0.olean` and `TorusFiltration.olean` +`OrdinaryH0.olean`, `OrdinaryH0Controls.olean` and `TorusFiltration.olean` into the companion directory (Lean needs them on `LEAN_PATH` for the root module and the audit files). They are build artefacts and must never be committed: the repository has no root `.gitignore`, `git add -A` would stage them, and `check.py source` then refuses the companion @@ -563,16 +678,49 @@ narrower attribution stands for those runs and is not revised. unchanged. The workflow's comment counting "twelve `lean` invocations" is therefore stale (17 now: five module builds, the positive, audit, types and census files, and eight controls); the file is kept byte-identical rather than edited for a comment. Details in [C263 and C264 registration](#c263-and-c264-registration-2026-10-11). +- C264 owner task item 4 controls (2026-10-12, one forward commit on top of the registration head `940dffc9`): the + owner-authored `OrdinaryH0Controls.lean` (df9d3645…) is added as module five; the root module imports five modules; + `check.py` gains the module build, the six-module `leanchecker` command (the five-module form is now refused), a + census over six modules, the three false controls `RejectMergerKillsPointClass`, + `RejectSeparationWithoutNonzeroCoeff` and `RejectNonmergerKillsDifference`, and the owner-module record + `provenance.owner_modules` (compared whole, like the successor record; a changed hash, byte count, author, census, + comment pointer, kind or review status is refused); `EVIDENCE_FILES` goes from 54 to 65 members. The scanner's + rules are unchanged (its companion-import form follows `MODULES`, so `OrdinaryH0Controls.lean` may import the four + modules before it and no scanned module may import it). `Positive.lean`, the eight earlier controls' emitted files, + the four earlier modules and the Actions workflow file are byte-for-byte unchanged (the workflow's stale comment + now undercounts further: 21 `lean` invocations, six module builds, the positive, audit, types and census files, and + eleven controls). The same commit time-scopes the + statements that no review of the compiled successors existed (true at `940dffc9`; the engineering registration + readback 5485829137 exists since 2026-10-12 01:16Z, credit 0, and the source-scoped review 5485883117 since 01:32Z, + no credit stated, Lean execution kept open), restates FORMAL HOLD as resting on the handoffs' own listed conditions + rather than on one review, records that hosted run 38187870416 of `940dffc9` completed (as reported, not adopted), + and marks the relabel of the C254 naturality exclusion (Math- #428 comment 6116225936) as a dated companion note; + no label moves. + Details in [C264 owner task item 4 controls](#c264-owner-task-item-4-controls-2026-10-12). ## C263 and C264 registration (2026-10-11) This commit registers two compiled Lean modules in the gate. **Registration is not review and not acceptance.** It records that the successor bytes elaborate at the pin and binds them to the -gate; it moves no status label. Both handoffs keep their own label, **FORMAL HOLD**, which stands -until a nonauthor exact-source review of the compiled successors exists; the C263 (6113033351) -and C264 (6113277173) nonauthor source reviews read the handoff bytes, not the successors, and -this lane (compile fix, repair, registration) is the same project account as the companion, -organizational-independence credit 0. +gate; it moves no status label. Both handoffs keep their own label, **FORMAL HOLD**, which rests +on the handoffs' own listed conditions (6113033545 item 4; 6113372506; 6113277485 item 5): among +them a nonauthor exact-source review of the compiled successors, a distinct review of the +source-bound execution output and source-bound hosted evidence and custody; the handoffs say a +source review alone does not meet them. The C263 (6113033351) and C264 (6113277173) nonauthor +source reviews read the handoff bytes, not the successors, and this lane (compile fix, repair, +registration) is the same project account as the companion, organizational-independence credit +0. (This section describes the registration commit `940dffc9` of 2026-10-11. At that commit this +paragraph said that FORMAL HOLD stands until a nonauthor exact-source review of the compiled +successors exists, which names only one of the handoffs' conditions; corrected on 2026-10-12. On +2026-10-12 the nonauthor engineering readback of `4c33d8cd..940dffc9`, Math- #428 review 5485829137 +(01:16Z, PASS, identity and registration only, organizational-independence credit 0 as it records), +was posted, and since 01:32Z a nonauthor exact-source review of the compiled successors exists, +source-scoped only: Math- #428 review 5485883117, Muse Spark / Meta, first read, PASS source-scoped +for each module, count corrected in comment 6116328276; its reviewer did not run Lean and keeps Lean +execution as an open condition under FORMAL HOLD, and it states no organizational-independence +credit and was posted from the same project account. FORMAL HOLD is unchanged and its disposition +is for the C263/C264 handoff owners; no label below moves, and the record +`provenance.successors.*.formal_status` keeps the text this commit transcribed.) | Item | `SuperlevelBar.lean` (C263) | `OrdinaryH0.lean` (C264) | |---|---|---| @@ -587,31 +735,124 @@ organizational-independence credit 0. | `census_auxiliary` | no new entry | no new entry | | `#print axioms` | all 24 within `{propext, Classical.choice, Quot.sound}` | all 27 within the same set | | New false control | `RejectEssentialDeathBound` | `RejectReducedPointClass` | -| Status | FORMAL HOLD (handoff's own label) until a nonauthor exact-source review of the compiled successor | FORMAL HOLD, same | +| Status | FORMAL HOLD (handoff's own label), on the handoff's own listed conditions (6113033545 item 4); `provenance.successors` records it as `FORMAL_HOLD until a nonauthor exact-source review of the compiled successor; registration is not review`, this commit's transcription, which names one of those conditions only | FORMAL HOLD, same (conditions: 6113372506; 6113277485 item 5) | What this commit does not establish: that either module's statements are the ones the research programme needs (alignment stays `PENDING_INDEPENDENT_REVIEW`); any of the exclusions the modules' own docstrings list (above, [What is NOT established](#what-is-not-established)); a Field or Lifetime inhabitant, a Field adapter or any coupling to the `Specifications` package of PR #419; an elder relation, bar pairing, finite-bar count, interval decomposition or stochastic law; any -review of the compiled successors (none exists: this lane compiled, repaired and registered them and has not reviewed them); any -organizational-independence credit; any hosted receipt for the registered set (a green hosted -run of this commit would produce one, and a receipt is a record of a computation). The compile fix +review of the compiled successors (none existed at this commit, 2026-10-11: this lane compiled, repaired and registered +them and has not reviewed them; since 2026-10-12 the engineering registration readback 5485829137, 01:16Z, credit 0, +and the source-scoped review 5485883117, 01:32Z, no credit stated, Lean execution kept open, exist, recorded above); +any organizational-independence credit; any hosted receipt for the registered set (none existed at this commit; hosted +run 38187870416 of `940dffc9` later completed with conclusion success, as reported by the engineering readback +5485829137; this lane has not re-inspected it and this README does not adopt its receipt; a receipt is a record of a +computation). The compile fix and the repair changed proof text and declaration spellings; whether every statement still says what the handoffs intended is part of the pending review, not something this registration decides. The concrete ordinary-H0 controls the C264 handoff asks for (item 4 of its owner task, Math- #428 comment 6113277485: empty, point, two-component, merge/non-merge and zero-coefficient cases with premises proved in concrete fixtures) are not provided here: this commit adds one false control (`RejectReducedPointClass`) and no positive -fixture, and that obligation stays open. `provenance.original_status` (`NOT_COMPILED`) records the two C254 handoff +fixture, and that obligation stays open at this commit. The owner-authored fixtures added on 2026-10-12 are described +in [C264 owner task item 4 controls](#c264-owner-task-item-4-controls-2026-10-12); that later commit does not mark the +item closed. `provenance.original_status` (`NOT_COMPILED`) records the two C254 handoff modules at delivery; the C263 and C264 handoffs' statuses are `provenance.successors.*.handoff_status`. Local evidence for this commit (one run of each build, the emitted audit, types, census and positive files, the five-module `leanchecker` and the two new controls, all exit 0 or the pinned `⊢ False`, this lane, 2026-10-11) is a record of a computation on an unverified worktree, not a receipt. +## C264 owner task item 4 controls (2026-10-12) + +This commit registers one owner-authored Lean module, `OrdinaryH0Controls.lean`, and three false +controls against it. **Registration is not review**, and these fixtures are not a review of +`OrdinaryH0`: they apply seven of its 20 theorems and three of its seven definitions +(`ordinaryH0_pointClass`, `ordinaryH0_naturalIso`, `ordinaryH0_componentCoproductFunctor`) to named +spaces and coefficient modules with every premise proved, so that those statements are seen in use, +and the nonzero-coefficient hypothesis seen to be needed, on cases whose answer is known +independently. The FORMAL HOLD of `SuperlevelBar` and `OrdinaryH0` is unchanged (it rests on the +handoffs' own listed conditions; the source-scoped review 5485883117 that now exists, which states no +organizational-independence credit and was posted from the same project account, retains it and keeps +Lean execution as an open condition; its disposition is for the C263/C264 handoff owners); +alignment stays `PENDING_INDEPENDENT_REVIEW`; organizational-independence credit 0 (the same project +account wrote, compiled and registered the module); scientific effect NONE. + +| Item | `OrdinaryH0Controls.lean` | +|---|---| +| Task | C264 owner task, item 4 (Math- #428 comment 6113277485, which names this lane as recipient and gate owner) | +| Specification | the corrected CONTROL_OBLIGATIONS of Math- #428 comment 6113277173 | +| Author | Anthropic/Claude lane (companion owner), delegated AI work for Dylan Roy; not a handoff successor (no handoff bytes exist) | +| Registered bytes | SHA-256 `df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184`, 29590 bytes, 453 lines | +| First compiled form | SHA-256 `e825837f3b0e43553a3a2f48ca48e4150182ad160eb0d7e1a10c141f9c395056`, 28503 bytes, 440 lines; the registered bytes change only the module-docstring paragraph on review status (FORMAL HOLD rests on the handoffs' listed conditions; the source-scoped review 5485883117, no credit stated, and the engineering readback 5485829137, credit 0, exist; FORMAL HOLD unchanged); no declaration changed | +| Imports | `Mathlib`, `OrdinaryH0` | +| Declarations | 37 theorems, 3 abbrevs, 4 defs, 0 instances; every name prefixed `ordinaryH0Control_` | +| Range-aware census at the pin | 48 = 44 + 0 + 4 (user range + user generated + internal generated: `_proof_1` and `eq_1` of `ordinaryH0Control_parabolaLeft` and `ordinaryH0Control_parabolaRight`) | +| `census_auxiliary` | no new entry | +| `#print axioms` | all 44 within `{propext, Classical.choice, Quot.sound}` | +| New false controls | `RejectMergerKillsPointClass`, `RejectSeparationWithoutNonzeroCoeff`, `RejectNonmergerKillsDifference` | +| Provenance | `provenance.owner_modules` in `SOURCE_FILES.json`, compared whole with `OWNER_MODULES` in `check.py`; the protocol tests refuse tracked bytes that are not the recorded identity | +| Status | registered; no review of these bytes is recorded; FORMAL HOLD of `OrdinaryH0` unchanged; credit 0 | + +What the fixtures show (the declarations are listed under +[`OrdinaryH0Controls`](#ordinaryh0controls-37-theorems-3-abbrevs-4-defs--c264-owner-task-item-4-instantiated-ordinary-h0-controls)): +the empty space has zero H0 (with `ℤ` and with zero coefficients); the point has a nonzero, +augmented point class with `ℤ` coefficients (ordinary, not reduced, H0); two points of one path +component (`0`, `1` in `ℝ`) have zero difference and nonzero classes; two path components (`Bool`) +have distinct classes with `ℤ` and with `ZMod 2` coefficients; a merger (the collapse +`Bool → Unit`) kills the difference while each image class survives; a non-injective map (the +first projection of `Bool × Bool`) kills one difference and keeps another; with zero coefficients +all of H0 is a zero object, the two classes of `Bool` coincide and the point class vanishes, so +the separation and nonvanishing statements are false without `𝟙 R ≠ 0`; along the closed +superlevels of `x ↦ x ^ 2` a strict inclusion keeps a difference alive and the inclusion into the +whole line kills it. + +The three controls, each a false statement about the fixtures whose tactic rewrites with the true +fixture theorem it contradicts and must leave exactly `⊢ False`: + +| Control | Intended reason for refusal | Diagnostic pinned from Lean at the pin | +|---|---|---| +| `RejectMergerKillsPointClass` | a merger kills the difference, not the individual class: `ordinaryH0Control_collapse_image_ne_zero` rewrites `pointClass true ≫ map collapse = 0` to `False` | `RejectMergerKillsPointClass.lean:3:255: error: unsolved goals` / `⊢ False`, exit 1 | +| `RejectSeparationWithoutNonzeroCoeff` | with zero coefficients the two classes of `Bool` are equal (`ordinaryH0Control_bool_zeroCoeff_eq`), so the separation statement needs `𝟙 R ≠ 0` | `RejectSeparationWithoutNonzeroCoeff.lean:3:160: error: unsolved goals` / `⊢ False`, exit 1 | +| `RejectNonmergerKillsDifference` | the projection keeps the difference of `(true, false)` and `(false, true)`, whose images stay in distinct components (`ordinaryH0Control_fst_difference_ne_zero`) | `RejectNonmergerKillsDifference.lean:3:391: error: unsolved goals` / `⊢ False`, exit 1 | + +Discriminators: the same tactic was applied, in the same emitted format and under the same file +name, to each control's **true** sibling statement (the difference under the collapse; the +`ℤ`-coefficient separation of `Bool`; the difference of `(true, false)` and `(true, true)` under +the projection) and compiled at the pin. Lean printed `` `simp` made no progress `` for the first +and third, and for the second an unsolved goal that is not `False` together with an unused-simp-argument +error; `check.py negative` refuses all three as `not the intended False-goal diagnostic`. So each +control's `⊢ False` comes from the falsehood of its statement, not from a tactic that turns any goal +into `False`. The six diagnostics (three controls, three siblings) are pinned in the protocol tests +(`CONTROL_LOGS`, `DISCRIMINATOR_LOGS`), where the sibling logs are negative controls of both +`negative` and `finish`. The sibling runs are local records of this lane (2026-10-12), not +members of the evidence directory; the control runs are, and the receipt hashes their logs. + +Evidence count: `EVIDENCE_FILES` goes from 54 to 65 members: `build-OrdinaryH0Controls.log` and +`.status` (2), and for each of the three controls its `.lean`, `.log` and `.status` (9). The census +grows from 133 to 181 constants (153 user range, the one user-generated `congr_simp`, 27 internal +generated), `Audit.lean` from 109 to 153 `#print axioms`, `Types.lean` from 81 to 118 `#check`, +and the `leanchecker` command names six modules. + +What this commit does not establish: any review of `OrdinaryH0` or of `SuperlevelBar` (FORMAL HOLD +unchanged for both); that the fixtures meet every row of the CONTROL_OBLIGATIONS matrix, or that +item 4 of the C264 owner task is closed (no label moves here); any Morse chart, critical-level +attainment theorem, interval decomposition, elder correspondence, count identity, Field adapter, +stochastic law or scientific-status promotion; a first merger level or threshold attainment; any +statement about connected (as opposed to path) components; a fixture for any of the 13 C264 +theorems the module does not name (among them `ordinaryH0_iso_naturality` and +`ordinaryH0_filtration_naturality`); alignment +(`PENDING_INDEPENDENT_REVIEW`); any organizational-independence credit (0). This lane's own +adversarial checks of the module before registration (kernel, specification and delta passes, a +fix round) were the same project account, credit 0, and are not a review. Local evidence for this +commit (each module build, the emitted positive, audit, types and census files, the six-module +`leanchecker`, the eleven controls and the three siblings, exit 0 or the pinned diagnostic, this +lane, 2026-10-12) is a record of a computation on a worktree, not a receipt. + ## What this companion does not do It does not modify `formal/`, the D2 companions or their workflows. It does not enter the q0 dependency graph, raise any claim's grade, or substitute for the nonauthor source review, the independent alignment review or the operator's decisions. It does not lift the C263 or C264 -FORMAL HOLD, and it does not review the successor bytes it registers. The hosted receipt is a +FORMAL HOLD, and it does not review the successor bytes it registers; `OrdinaryH0Controls` is not +a review of `OrdinaryH0`. The hosted receipt is a record of a computation, not evidence of alignment with the research programme. diff --git a/companions/torus_filtration_20261011/SCOPE.md b/companions/torus_filtration_20261011/SCOPE.md index 5d0b673aa..1a9b5caf6 100644 --- a/companions/torus_filtration_20261011/SCOPE.md +++ b/companions/torus_filtration_20261011/SCOPE.md @@ -2,20 +2,35 @@ Dylan Roy — delegated AI work. Source authors: OpenAI/Codex lanes (C254: `TorusTopology`, `ClosedSuperlevel`; C263: `SuperlevelBar`; C264: `OrdinaryH0`). Compile fixes, the C264 owner -repair and the companion: Anthropic/Claude lane. Scientific effect NONE; +repair, the owner-authored controls module `OrdinaryH0Controls` (C264 owner task item 4) and the +companion: Anthropic/Claude lane. Scientific effect NONE; organizational-independence credit 0; no human review; alignment `PENDING_INDEPENDENT_REVIEW`. -This note fixes what the 81 theorem statements and 28 audited definitions of the four modules -(`TorusTopology.lean`, `ClosedSuperlevel.lean`, `SuperlevelBar.lean`, `OrdinaryH0.lean`; 109 -declarations) cover and what they do not. An independent reviewer must compare each Lean +This note fixes what the 118 theorem statements and 35 audited definitions of the five modules +(`TorusTopology.lean`, `ClosedSuperlevel.lean`, `SuperlevelBar.lean`, `OrdinaryH0.lean`, +`OrdinaryH0Controls.lean`; 153 declarations) cover and what they do not. An independent reviewer must compare each Lean statement with this note and with the handoffs' own scope (TORUS_FILTRATION.md in comment 6111059166 for C254; the module docstrings and Math- #428 comments 6113033545 and 6113372506 for C263 and C264) before any alignment record is written. The compile fixes and the C264 repair changed proof terms, resolved names and three declaration spellings at the pin; whether every statement still says what the handoffs intended is part of that review, not something this note decides. The C263 and C264 modules are registered under the handoffs' own FORMAL HOLD, which -stands until a nonauthor exact-source review of the compiled successor bytes; registration is -not review. +rests on the handoffs' own listed conditions (Math- #428 comments 6113033545 item 4, 6113372506 +and 6113277485 item 5), among them a nonauthor exact-source review of the compiled successor +bytes, a distinct review of the source-bound execution output and source-bound hosted evidence and +custody; the handoffs say a source review alone does not meet them. Registration is not review. At +the registration commit `940dffc9` (2026-10-11) no nonauthor exact-source review of the successor +bytes existed. On 2026-10-12 the nonauthor engineering registration readback of +`4c33d8cd..940dffc9`, Math- #428 review 5485829137 (01:16Z, PASS, identity and registration only), +was posted and records organizational-independence credit 0; since 01:32Z Math- #428 review +5485883117 (Muse Spark / Meta, first read, PASS source-scoped for each module; count corrected in +comment 6116328276) is an exact-source review, source-scoped only: its reviewer did not run Lean and +keeps Lean execution as an open condition under FORMAL HOLD, and it states no +organizational-independence credit and was posted from the same project account. FORMAL HOLD is +unchanged; its disposition is for the C263/C264 handoff owners, alignment still needs a reviewer +with nonzero organizational-independence credit, and this note moves no label. `OrdinaryH0Controls` +applies seven of the 20 C264 theorems (and three of its definitions) to concrete fixtures; it is not +a handoff module, not a review of `OrdinaryH0`, and lifts nothing. ## Bound sources @@ -26,7 +41,8 @@ not review. 6111059498 (nonauthor source review: COMPILATION HOLD), 6111059848, 6111255007 (route finding); this lane: 6111093545 (local elaboration report), 6111139060 (pickup). - Namespace mapping `ResearchFormalCoreR1.` (handoff) -> `TorusFiltration.` (companion); - `SuperlevelBar` and `OrdinaryH0` were authored directly in namespace `TorusFiltration`. + `SuperlevelBar` and `OrdinaryH0` were authored directly in namespace `TorusFiltration`, and so + was the owner-authored `OrdinaryH0Controls`. - C263 handoff `SuperlevelBar.lean` SHA-256 `d74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8` (14904 bytes; Math- #428 comments 6113033147, 6113033351, 6113033545; allocation #419 comment 6112439759), failed at the @@ -43,6 +59,12 @@ not review. scope split, explicit `rw`/`erw` naturality proof, `Functor.isoWhiskerLeft`, three ASCII `iota` names, docstring lines, no statement changed; imports `Mathlib` and `ClosedSuperlevel`. Census at the pin 38 = 27 + 0 + 11. +- Owner-authored `OrdinaryH0Controls.lean` (C264 owner task item 4, Math- #428 comment + 6113277485, against the corrected CONTROL_OBLIGATIONS of comment 6113277173; no handoff bytes, + not a successor): SHA-256 `df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184` + (29590 bytes; first compiled form `e825837f…`, 28503 bytes, differing only in the + module-docstring paragraph on review status); imports `Mathlib` and `OrdinaryH0`; 37 theorems, + 3 abbrevs, 4 defs, prefix `ordinaryH0Control_`. Census at the pin 48 = 44 + 0 + 4. - Pinned environment read from `formal/`: `leanprover/lean4:v4.34.1`, Mathlib `d13f23b723b8a846827a245b89c10fc7d3f11612`; nothing from the core is imported or pinned. @@ -70,6 +92,15 @@ not review. | `ordinaryH0_iso_naturality` (with `ordinaryH0_naturalIso`) | Mathlib's objectwise comparison `TopCat.singularHomology₀Iso` commutes with every continuous map, proved from actual zero-cycle generators (the repaired proof: explicit reassociation of both sides), so it assembles into a natural isomorphism `(singularHomologyFunctor C 0).obj R ≅ ordinaryH0_componentCoproductFunctor R` | naturality by an added assumption or compatibility record (none is used); an interval decomposition or persistence-bar classification | | `ordinaryH0_pointClass_augmentation`, `ordinaryH0_pointClass_ne_zero`, `ordinaryH0_pointClass_eq_of_component_eq`, `ordinaryH0_sameComponent_difference_zero`, `ordinaryH0_pointClass_ne_of_component_ne`, `ordinaryH0_pointClass_eq_iff`, `ordinaryH0_difference_map`, `ordinaryH0_difference_map_eq_zero_iff` | the ordinary point class composed with `singularHomology₀ε` is `𝟙 R`; with `𝟙 R ≠ 0` it is nonzero and two point classes are equal exactly when the path components are; same-component differences are `0` for any coefficients; the induced map of a difference is the difference of image classes and, with `𝟙 R ≠ 0`, vanishes exactly when the image points share a component | any nonzero or distinction claim for a zero coefficient object; reduced-H0 vanishing (the ordinary point class is retained); equality of connected and path-connected components; death of the individual point classes; a Morse merger event, elder selection, death height or barcode | | `ordinaryH0_filtration_naturality`, `ordinaryH0_filtration_difference_zero_iff_joinedIn` (with `ordinaryH0_componentFiltration`, `ordinaryH0_filtrationIso`) | `superlevel_h0Filtration g R ≅ superlevel_filtration g ⋙ ordinaryH0_componentCoproductFunctor R` (`Functor.isoWhiskerLeft`); the H0/component square at every `s ≤ t`; with `𝟙 R ≠ 0`, the difference of two point classes of `superlevel_set g s` dies under the inclusion into `superlevel_set g t` exactly when the points are `JoinedIn` the target closed superlevel | strict-level conventions; attainment of a critical death threshold; an elder or barcode theorem; the later interval, elder, maximum/saddle, count, Field or stochastic bridges; any Morse chart, critical-level attainment theorem, elder correspondence, Field adapter, count identity or stochastic law | +| `ordinaryH0Control_intCoeff_id_ne_zero`, `ordinaryH0Control_mod2Coeff_id_ne_zero`, `ordinaryH0Control_mod2Coeff_id_add_self`, `ordinaryH0Control_zeroCoeff_isZero`, `ordinaryH0Control_zeroCoeff_id_eq_zero` (with the abbrevs `ordinaryH0Control_intCoeff`, `ordinaryH0Control_zeroCoeff`, `ordinaryH0Control_mod2Coeff`) (C264 item 4) | coefficient fixtures in `ModuleCat.{0} ℤ`: `𝟙 ℤ ≠ 0`, `𝟙 (ZMod 2) ≠ 0` and `𝟙 + 𝟙 = 0` on `ZMod 2`; the one-point module is a zero object with `𝟙 = 0` | any homology computation by itself | +| `ordinaryH0Control_empty_components`, `ordinaryH0Control_empty_componentCoproduct_isZero`, `ordinaryH0Control_empty_h0_isZero`, `ordinaryH0Control_zeroCoeff_componentCoproduct_isZero`, `ordinaryH0Control_zeroCoeff_h0_isZero` | the empty space has no path component, a zero component coproduct for every coefficient module and zero actual singular H0 with `ℤ` coefficients; with zero coefficients the component coproduct and actual singular H0 of every space in `TopCat.{0}` are zero objects (transported along `ordinaryH0_naturalIso`) | H0 of the empty space for other coefficients; vanishing with nonzero coefficients for a nonempty space | +| `ordinaryH0Control_point_augmentation`, `ordinaryH0Control_point_ne_zero`, `ordinaryH0Control_point_h0_not_isZero` | one-point space, `ℤ` coefficients: the point class augments to `𝟙`, is nonzero, and H0 is not a zero object | reduced-H0 vanishing (refuted here for the ordinary class); a computation of that H0 beyond its nonvanishing | +| `ordinaryH0Control_line_component_eq`, `ordinaryH0Control_line_difference_zero_int`, `ordinaryH0Control_line_difference_zero_zeroCoeff`, `ordinaryH0Control_line_classes_ne_zero` | `0` and `1` share a path component of `ℝ`; their point-class difference is `0` with `ℤ` and with zero coefficients; with `ℤ` each class is nonzero | the death of either class; path-connectedness of any closed superlevel | +| `ordinaryH0Control_discrete_component_ne`, `ordinaryH0Control_bool_component_ne`, `ordinaryH0Control_bool_pointClass_ne`, `ordinaryH0Control_bool_pointClass_ne_mod2` | distinct points of a discrete space lie in distinct path components; the two point classes of `Bool` differ with `ℤ` and with `ZMod 2` coefficients | path components of a non-discrete space; separation for every characteristic-two object or with zero coefficients | +| `ordinaryH0Control_collapse_difference_zero`, `ordinaryH0Control_collapse_image_ne_zero`, `ordinaryH0Control_collapse_difference_dies_classes_survive` (with `ordinaryH0Control_collapse`) | merger fixture: the collapse `Bool → Unit` kills the difference of the two point classes while each image class stays nonzero | a Morse merger event, elder selection or death height; the death of an individual class | +| `ordinaryH0Control_square_differences_ne_zero`, `ordinaryH0Control_fst_difference_zero`, `ordinaryH0Control_fst_difference_ne_zero` (with `ordinaryH0Control_fst`) | non-merger fixture: the non-injective first projection `Bool × Bool → Bool` kills the difference of `(true, false)` and `(true, true)` and keeps that of `(true, false)` and `(false, true)` nonzero; both differences are nonzero before the map | injectivity of the induced H0 map (which fails on the first pair) | +| `ordinaryH0Control_bool_zeroCoeff_eq`, `ordinaryH0Control_point_zeroCoeff_eq_zero`, `ordinaryH0Control_separation_needs_nonzero`, `ordinaryH0Control_nonvanishing_needs_nonzero` | with zero coefficients the two point classes of `Bool` are equal although the components differ and the point class of the point is `0`; so the separation and nonvanishing statements are false without `𝟙 R ≠ 0` | any failure of the C264 statements, which keep that hypothesis | +| `ordinaryH0Control_parabola_le`, `ordinaryH0Control_parabola_strict_growth`, `ordinaryH0Control_parabola_not_joined_quarter`, `ordinaryH0Control_parabola_joined`, `ordinaryH0Control_parabola_difference_zero`, `ordinaryH0Control_parabola_strict_difference_ne_zero` (with `ordinaryH0Control_parabolaLeft`, `ordinaryH0Control_parabolaRight`) | filtration fixture for `x ↦ x ^ 2`: `-1` and `1` in the closed superlevel at parameter `-1`; the strict inclusion into the level at `-1/4` keeps the difference of their classes nonzero (no path through `0` in `{x | 1/4 ≤ x ^ 2}`); the inclusion into the level at `0`, the whole line, kills it | a first merger level, threshold attainment, the behaviour strictly between `-1/4` and `0`; any Morse, interval, elder, count, Field or stochastic statement | The audited definitions (`torus_E`, `torus_quotient`, `torus_latticeVec`, `torus_periodBasis`, `torus_periodLattice`, `torus_proj`, `torus_isPeriodic`, `torus_descend`, the three lattice @@ -78,8 +109,11 @@ instances, `superlevel_set`, `superlevel_inclusion`, `superlevel_componentMap`, `superlevelBar_E`, `superlevelBar_isEssential`, `superlevelBar_clearanceSet`, `superlevelBar_deathHeight`, `ordinaryH0_componentFunctor`, `ordinaryH0_componentCoproductFunctor`, `ordinaryH0_componentFiltration`, `ordinaryH0_simplicialPointClass`, `ordinaryH0_pointClass`, -`ordinaryH0_naturalIso`, `ordinaryH0_filtrationIso`) are constructions, not claims; they are -audited so that no hidden axiom enters through a definition. +`ordinaryH0_naturalIso`, `ordinaryH0_filtrationIso`, `ordinaryH0Control_intCoeff`, +`ordinaryH0Control_zeroCoeff`, `ordinaryH0Control_mod2Coeff`, `ordinaryH0Control_collapse`, +`ordinaryH0Control_fst`, `ordinaryH0Control_parabolaLeft`, `ordinaryH0Control_parabolaRight`) are +constructions and fixtures, not claims; they are audited so that no hidden axiom enters through a +definition. ## Controls in the replay @@ -90,11 +124,19 @@ audited so that no hidden axiom enters through a definition. | `RejectConstantNotPeriodic` | the negation of a periodicity instance that `Positive.lean` uses (`fun _ _ => rfl`); `⊢ False` | | `RejectEssentialDeathBound` (C263) | the death/start bound asserted on the essential default branch: `superlevelBar_deathHeight (fun _ : superlevelBar_E 1 => (-1 : ℝ)) 0 ≤ (-1 : ℝ)`; `superlevelBar_death_const` reduces the death to `0` and `0 ≤ -1` is false (the proposition of the C263 handoff's `FALSE_CONTROL_PROPOSAL` (Math- #428 comment 6113033351), whose tactic `rw [superlevelBar_death_const 1 (-1) (0 : superlevelBar_E 1)]; norm_num` is replaced here by `norm_num [superlevelBar_death_const]`); `⊢ False` | | `RejectReducedPointClass` (C264) | a reduced-H0 substitution: the ordinary point class of the one-point space with `ℤ`-module coefficients asserted NOT to be augmented to the identity; `ordinaryH0_pointClass_augmentation` rewrites it to `𝟙 R ≠ 𝟙 R`; `⊢ False` | +| `RejectMergerKillsPointClass` (C264 item 4) | a merger confused with the death of a class: the collapse `Bool → Unit` asserted to kill the individual point class of `true`; `ordinaryH0Control_collapse_image_ne_zero` rewrites it to `False`; `⊢ False` | +| `RejectSeparationWithoutNonzeroCoeff` (C264 item 4) | a separation claim without its coefficient hypothesis: the two point classes of `Bool` asserted to differ with zero coefficients; `ordinaryH0Control_bool_zeroCoeff_eq` rewrites it to `False`; `⊢ False` | +| `RejectNonmergerKillsDifference` (C264 item 4) | a non-injective map confused with a merger: the projection `Bool × Bool → Bool` asserted to kill the difference of `(true, false)` and `(false, true)`, whose images stay in distinct components; `ordinaryH0Control_fst_difference_ne_zero` rewrites it to `False`; `⊢ False` | | `RejectSorry`, `RejectCustomAxiom`, `RejectNativeDecide` | an admitted proof, a hidden premise behind an intermediate theorem, and a native-code decision each pass Lean (exit 0) and must be refused by the transitive axiom audit (`sorryAx`, `hiddenPremise`, `injected._native.native_decide.ax_1_1`) | Each control is matched by `re.fullmatch` against its pinned diagnostic; the false-statement diagnostics and the three injection reports were pinned from actual Lean 4.34.1 output at the -Mathlib `d13f23b7` pin. A crash, an extra message or a different exit code fails the control. +Mathlib `d13f23b7` pin. A crash, an extra message or a different exit code fails the control. For +the three item-4 controls the same tactic on each control's true sibling statement was run at the +pin and leaves a different diagnostic (`` `simp` made no progress ``, or a goal other than `False` +with an unused simp argument), which `negative` refuses; those sibling logs are pinned in the +protocol tests as negative controls, so each control's `⊢ False` is attributable to the falsehood +of its statement. The Python suite additionally refuses every weakening of `check.py` it knows about (wrong diagnostic, wrong exit code, unknown control, `sorryAx`, unknown or missing audit target, unrecognized audit text, missing or extra type, a diagnostic after the type listing, membership @@ -116,7 +158,11 @@ optimization mode from the outer test interpreter, which the fixture checks on e since the C263/C264 registration, a companion import of the module itself, of a later module or of the root, an `open scoped` line with a lowercase or missing namespace or anything else on the line, the pre-registration two-import root module and three-module `leanchecker` command, a -module name outside `MODULES`, and single-field changes to the successor record (a changed +module name outside `MODULES`, since the item-4 controls the pre-controls four-import root module and five-module +`leanchecker` command, an import of `OrdinaryH0Controls` by an earlier module, the three item-4 controls' true-sibling +diagnostics, single-field changes to the owner-module record of `OrdinaryH0Controls` (hash, byte count, author, kind, +review status, census, credit, a dropped comment pointer, an added field, a dropped or added entry, the record copied +into the successor record), and single-field changes to the successor record (a changed handoff or successor hash, a successor byte count or a C26x entry of `provenance.original_bytes`, a changed census line, a nonzero credit, a lifted or self-awarded `formal_status`, a dropped comment pointer, a dropped or added module entry); its remaining fields (handoff byte count and status, lane, authors, namespace, imports, change summary) are refused through the whole-record @@ -124,13 +170,13 @@ comparison in `metadata`, not by a control of their own). ## Evidence boundary -A green hosted run establishes, for these 109 declarations at this toolchain and dependency +A green hosted run establishes, for these 153 declarations at this toolchain and dependency lock, that Lean elaborated them with warnings as errors, that Lean's own census of the -constants the five modules (the four modules and the root) add to the environment -(`Census.lean`, with declaration-range and internal-name tags) has exactly these 109 as its +constants the six modules (the five modules and the root) add to the environment +(`Census.lean`, with declaration-range and internal-name tags) has exactly these 153 as its user-written declarations and exactly the one named compiler-generated auxiliary (internal -generated constants, 23 at the pin, are counted and otherwise ignored), that -`leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration` replayed the +generated constants, 27 at the pin, are counted and otherwise ignored), that +`leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 OrdinaryH0Controls TorusFiltration` replayed the companion modules' own declarations through the kernel against the cached, prebuilt dependency `.olean` files (the import closure, all of Mathlib, is trusted from that cache and not re-checked; a `--fresh` @@ -144,15 +190,49 @@ nothing beyond it), interval decomposition, bar bijection, elder events, once-co identification of `PairLawInterface.p`, an inhabitant of the Field or Lifetime record, a Field adapter, a Morse chart, a count identity, a Gaussian or stochastic law, closed-threshold attainment at the C263 death height, reduced-H0 vanishing, or any claim for a zero coefficient -object. The receipt's `formalization_status: kernel-checked` is a +object; and, for `OrdinaryH0Controls`, nothing beyond its fixtures: no review of `OrdinaryH0`, no +first merger level or threshold attainment, no statement that its fixtures meet every row of the +CONTROL_OBLIGATIONS matrix or that item 4 of the C264 owner task is closed. The receipt's `formalization_status: kernel-checked` is a record of that computation; `alignment_status` remains `PENDING_INDEPENDENT_REVIEW` and `scientific_acceptance` remains `false` until an independent reviewer with nonzero organizational-independence credit records otherwise. For `SuperlevelBar` and `OrdinaryH0` the -handoffs' own FORMAL HOLD stands in addition until a nonauthor exact-source review of the compiled -successor bytes (346eea94…, 3d6b0d6b…) exists; the registration of 2026-10-11 is not that review, -and the compiler, repairer and registrar of both successors is the companion's own lane at +handoffs' own FORMAL HOLD stands in addition, on the handoffs' own listed conditions (6113033545 +item 4; 6113372506; 6113277485 item 5), among them a nonauthor exact-source review of the compiled +successor bytes (346eea94…, 3d6b0d6b…), a distinct review of the source-bound execution output and +source-bound hosted evidence and custody, which they say a source review alone does not meet. At the +registration commit `940dffc9` no nonauthor review of those bytes existed. The engineering +registration readback 5485829137 (2026-10-12 01:16Z, identity and registration only, credit 0) and, +since 2026-10-12 01:32Z, the source-scoped review 5485883117 (its reviewer did not run Lean and keeps +Lean execution as an open condition under FORMAL HOLD; no organizational-independence credit stated, +posted from the same project account) exist; neither is a nonzero-credit review, and FORMAL HOLD is +unchanged, its disposition being for the C263/C264 handoff owners. The registration of 2026-10-11 is +not a review, and the compiler, repairer and registrar of both successors, and the author and +registrar of `OrdinaryH0Controls` (df9d3645…), is the companion's own lane at organizational-independence credit 0. Aging approves nothing. +## C264 owner task item 4 controls (2026-10-12) + +The owner-authored `OrdinaryH0Controls.lean` (task: Math- #428 comment 6113277485, item 4; +specification: the corrected CONTROL_OBLIGATIONS of comment 6113277173) applies seven of the 20 +C264 theorems and three of its definitions to named spaces and coefficient modules with every premise +proved in the fixture (its thirteen premise lemmas name no C264 theorem): the +empty space, the point, one path component (`0`, `1` in `ℝ`), two components (`Bool`), a merger +(the collapse `Bool → Unit`: the difference dies, each class survives), a non-injective non-merger +(the projection of `Bool × Bool`: one difference dies, another survives), zero coefficients (all +of H0 is zero, so separation and nonvanishing need `𝟙 R ≠ 0`), characteristic two (`ZMod 2` +separates), and a closed-superlevel filtration of `x ↦ x ^ 2` (a strict inclusion keeps a +difference, the inclusion into the whole line kills it). It is registered with three false +controls (`RejectMergerKillsPointClass`, `RejectSeparationWithoutNonzeroCoeff`, +`RejectNonmergerKillsDifference`, table above), each refused with exactly `⊢ False` and each +discriminated from its true sibling statement. The evidence directory grows from 54 to 65 members +(one build pair, three control triples); the census from 133 to 181 constants (153 user range, 1 +user generated, 27 internal generated). It does not establish: a review of `OrdinaryH0` or +`SuperlevelBar` (FORMAL HOLD unchanged for both); alignment (`PENDING_INDEPENDENT_REVIEW`); that +item 4 is closed (no label moves); any Morse chart, critical-level attainment, interval +decomposition, elder correspondence, count identity, Field adapter or stochastic law; any statement +about connected (as opposed to path) components; a fixture for the 13 C264 theorems it does not +name; any organizational-independence credit (0). + ## Reproduction bash companions/torus_filtration_20261011/replay.sh diff --git a/companions/torus_filtration_20261011/SOURCE_FILES.json b/companions/torus_filtration_20261011/SOURCE_FILES.json index 839dafcca..5248b61fa 100644 --- a/companions/torus_filtration_20261011/SOURCE_FILES.json +++ b/companions/torus_filtration_20261011/SOURCE_FILES.json @@ -29,6 +29,20 @@ ], "instance": [] }, + "OrdinaryH0Controls": { + "abbrev": [ + "ordinaryH0Control_intCoeff", + "ordinaryH0Control_zeroCoeff", + "ordinaryH0Control_mod2Coeff" + ], + "def": [ + "ordinaryH0Control_collapse", + "ordinaryH0Control_fst", + "ordinaryH0Control_parabolaLeft", + "ordinaryH0Control_parabolaRight" + ], + "instance": [] + }, "SuperlevelBar": { "abbrev": [ "superlevelBar_E" @@ -76,15 +90,20 @@ "git_blob": "7bc5f80028271e0e33d857e60496ca4cadaa9364", "sha256": "3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88" }, + "companions/torus_filtration_20261011/OrdinaryH0Controls.lean": { + "bytes": 29590, + "git_blob": "187bbcadb16213f6bb3ddbee28897685e1cedcd7", + "sha256": "df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184" + }, "companions/torus_filtration_20261011/README.md": { - "bytes": 56162, - "git_blob": "671b4cb7c295461efb3e4922537f476139177dfb", - "sha256": "f1e0a8c57012a024f744da74229885bb3062e0db842ad36ba489dbb7e06f74fe" + "bytes": 83629, + "git_blob": "5efed09b417eb9703268bed915b704bb301fbfa5", + "sha256": "a8d5c8dc1b9fb92572ad8b0d75753bf2a732beecbe55c1af58622775642d5d00" }, "companions/torus_filtration_20261011/SCOPE.md": { - "bytes": 22627, - "git_blob": "5d0b673aa604173c2161d839f700d4c397ea7bfb", - "sha256": "b2239cf0548f87b588925eb9d86aa17b74dff7774d2653925d4d888389977072" + "bytes": 34269, + "git_blob": "1a9b5caf64e5699a9e32e60e7bd3571bcd4ac983", + "sha256": "b5daf6e22f6b738497f6df4fa9ec99622d95e41f952dd9dbdf196fa40a14b86f" }, "companions/torus_filtration_20261011/SuperlevelBar.lean": { "bytes": 15309, @@ -92,9 +111,9 @@ "sha256": "346eea948e18d5904422904006827930e27d3141ccbc19ee8ac2c24bcf65a4a9" }, "companions/torus_filtration_20261011/TorusFiltration.lean": { - "bytes": 84, - "git_blob": "29e41ef12ae1a24eb36de48b9ee0738fc939d77b", - "sha256": "33b88648df5c0144a492544f3da83e6ebbe72aadc6fccc1ece930335ad2a3af5" + "bytes": 110, + "git_blob": "eb4bfab626feea0bbd45387fc23ae774e3663ec3", + "sha256": "09887f618ac7fbe7ac9569c185a6e28bb8ee39a0f75e2909bc46e49b35f9d07a" }, "companions/torus_filtration_20261011/TorusTopology.lean": { "bytes": 12257, @@ -102,26 +121,27 @@ "sha256": "ddb145b3f791c181d4f2a51e54e711937297bd6476ba55bcd5252b7ddb57cfe1" }, "companions/torus_filtration_20261011/check.py": { - "bytes": 49482, - "git_blob": "999eb4bf06273e572f19e9e34125898657832a8c", - "sha256": "c4416dc9e890895156bec553971d4dbcb0f4a6feeddaa9fcdbe055e405f4cf0a" + "bytes": 55524, + "git_blob": "f225c0534af6da636f9fde21745b15383cea9ef0", + "sha256": "0bd3b51f207a0a57457173290dfdb295935fa9d65b74bfbe13c46f4d16c18874" }, "companions/torus_filtration_20261011/replay.sh": { - "bytes": 5236, - "git_blob": "ff47d2393e341232273186d5e9ff44559eac1e3d", - "sha256": "34b739182179806a802633eff78b2006c8e5baa49cd04652f951a121a3bc8f2d" + "bytes": 5765, + "git_blob": "c654e50413aab00ed402d0ef7228063749b3695b", + "sha256": "7e25689e51c52786ac1ac92f805b441c0304e420381c7cfc2512fa62346049a4" }, "companions/torus_filtration_20261011/test_torus_filtration.py": { - "bytes": 108149, - "git_blob": "ef12443fb8b2d6e0cbb61706d45d023815bad261", - "sha256": "007365ea76c68f59ff85f3190dff6fe0a3676ade44915fa2f260542f02be8a84" + "bytes": 132040, + "git_blob": "9aeae2df61c21d147f10227da274aaf6e0c000f8", + "sha256": "aed03604172e9ba35aaedd70297601a39aa3979efbbe18143d0329502418d97b" } }, "modules": [ "TorusTopology", "ClosedSuperlevel", "SuperlevelBar", - "OrdinaryH0" + "OrdinaryH0", + "OrdinaryH0Controls" ], "namespace": "TorusFiltration", "provenance": { @@ -138,7 +158,7 @@ }, "handoff_pr": "d6g8k5htny-coder/Math-#419", "human_review": "none", - "namespace_mapping": "ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion) for TorusTopology and ClosedSuperlevel; SuperlevelBar and OrdinaryH0 were authored directly in namespace TorusFiltration", + "namespace_mapping": "ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion) for TorusTopology and ClosedSuperlevel; SuperlevelBar and OrdinaryH0 were authored directly in namespace TorusFiltration, and so was the owner-authored OrdinaryH0Controls", "organizational_independence_credit": 0, "original_bytes": { "C263-handoff/SuperlevelBar.lean": 14904, @@ -153,6 +173,28 @@ "ResearchFormalCoreR1/TorusTopology.lean": "efa80d2879758b6d6473a0024a308ff758c308cdc8e4b5f400f39dde63a7f6f4" }, "original_status": "NOT_COMPILED", + "owner_modules": { + "OrdinaryH0Controls.lean": { + "author": "Anthropic/Claude lane (companion owner), delegated AI work for Dylan Roy", + "bytes": 29590, + "census_at_pin": "48 constants = 44 user range + 0 user generated + 4 internal generated (ordinaryH0Control_parabolaLeft and ordinaryH0Control_parabolaRight: _proof_1 and eq_1 each)", + "comments": { + "control_obligations_specification_428": "6113277173", + "owner_task_item_4_428": "6113277485" + }, + "declarations": "37 theorems, 3 abbrevs, 4 defs, 0 instances", + "imports": [ + "Mathlib", + "OrdinaryH0" + ], + "kind": "owner-authored controls module; not a handoff successor (no handoff bytes exist); not a review", + "lane": "C264 owner task item 4 (instantiated ordinary-H0 controls)", + "namespace": "authored directly in namespace TorusFiltration; every declaration carries the prefix ordinaryH0Control_", + "organizational_independence_credit": 0, + "review_status": "not a review of OrdinaryH0 and lifts nothing: the FORMAL HOLD of OrdinaryH0 (and of SuperlevelBar) is unchanged; no review of these bytes is recorded; registration is not review", + "sha256": "df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184" + } + }, "source_author": "OpenAI/Codex lane (C254), delegated AI work for Dylan Roy", "successors": { "OrdinaryH0.lean": { @@ -255,6 +297,45 @@ "ordinaryH0_filtration_naturality", "ordinaryH0_filtration_difference_zero_iff_joinedIn" ], + "OrdinaryH0Controls": [ + "ordinaryH0Control_intCoeff_id_ne_zero", + "ordinaryH0Control_mod2Coeff_id_ne_zero", + "ordinaryH0Control_mod2Coeff_id_add_self", + "ordinaryH0Control_zeroCoeff_isZero", + "ordinaryH0Control_zeroCoeff_id_eq_zero", + "ordinaryH0Control_empty_components", + "ordinaryH0Control_empty_componentCoproduct_isZero", + "ordinaryH0Control_empty_h0_isZero", + "ordinaryH0Control_zeroCoeff_componentCoproduct_isZero", + "ordinaryH0Control_zeroCoeff_h0_isZero", + "ordinaryH0Control_point_augmentation", + "ordinaryH0Control_point_ne_zero", + "ordinaryH0Control_point_h0_not_isZero", + "ordinaryH0Control_line_component_eq", + "ordinaryH0Control_line_difference_zero_int", + "ordinaryH0Control_line_difference_zero_zeroCoeff", + "ordinaryH0Control_line_classes_ne_zero", + "ordinaryH0Control_discrete_component_ne", + "ordinaryH0Control_bool_component_ne", + "ordinaryH0Control_bool_pointClass_ne", + "ordinaryH0Control_bool_pointClass_ne_mod2", + "ordinaryH0Control_collapse_difference_zero", + "ordinaryH0Control_collapse_image_ne_zero", + "ordinaryH0Control_collapse_difference_dies_classes_survive", + "ordinaryH0Control_square_differences_ne_zero", + "ordinaryH0Control_fst_difference_zero", + "ordinaryH0Control_fst_difference_ne_zero", + "ordinaryH0Control_bool_zeroCoeff_eq", + "ordinaryH0Control_point_zeroCoeff_eq_zero", + "ordinaryH0Control_separation_needs_nonzero", + "ordinaryH0Control_nonvanishing_needs_nonzero", + "ordinaryH0Control_parabola_le", + "ordinaryH0Control_parabola_strict_growth", + "ordinaryH0Control_parabola_not_joined_quarter", + "ordinaryH0Control_parabola_joined", + "ordinaryH0Control_parabola_difference_zero", + "ordinaryH0Control_parabola_strict_difference_ne_zero" + ], "SuperlevelBar": [ "superlevelBar_essential_iff", "superlevelBar_mem_lt_start", diff --git a/companions/torus_filtration_20261011/TorusFiltration.lean b/companions/torus_filtration_20261011/TorusFiltration.lean index 29e41ef12..eb4bfab62 100644 --- a/companions/torus_filtration_20261011/TorusFiltration.lean +++ b/companions/torus_filtration_20261011/TorusFiltration.lean @@ -2,3 +2,4 @@ import TorusTopology import ClosedSuperlevel import SuperlevelBar import OrdinaryH0 +import OrdinaryH0Controls diff --git a/companions/torus_filtration_20261011/check.py b/companions/torus_filtration_20261011/check.py index 999eb4bf0..f225c0534 100644 --- a/companions/torus_filtration_20261011/check.py +++ b/companions/torus_filtration_20261011/check.py @@ -2,8 +2,9 @@ """Source-bound evidence driver for the torus-filtration companion (stdlib only). The companion holds the C254 torus/closed-superlevel modules and, since the C263/C264 -registration, the strict-cut module SuperlevelBar and the ordinary-H0 module OrdinaryH0. -Not an acceptance engine, not a general Lean parser, not a review. It binds the +registration, the strict-cut module SuperlevelBar and the ordinary-H0 module OrdinaryH0; since 2026-10-12 also the +owner-authored OrdinaryH0Controls (instantiated ordinary-H0 controls for C264 owner task item 4; not a handoff +successor, not a review). Not an acceptance engine, not a general Lean parser, not a review. It binds the companion's bytes to Git HEAD, emits the audit/type/positive/negative Lean files, refuses negative-control logs that are not the intended diagnostic, and writes a receipt that records what ran. The companion consumes nothing from formal/ except @@ -27,12 +28,12 @@ REPO = 'd6g8k5htny-coder/Math-' NAMESPACE = 'TorusFiltration' # Dependency order: a module may `import` only Mathlib and companion modules listed before it (scan_module). -MODULES = ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0') +MODULES = ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0', 'OrdinaryH0Controls') ROOT_MODULE = 'TorusFiltration' ROOT_SOURCE = ''.join('import ' + m + '\n' for m in MODULES) REQUIRED_FILES = tuple(PACKAGE + '/' + n for n in ( 'TorusFiltration.lean', 'TorusTopology.lean', 'ClosedSuperlevel.lean', 'SuperlevelBar.lean', 'OrdinaryH0.lean', - 'check.py', 'replay.sh', 'test_torus_filtration.py', 'README.md', 'SCOPE.md')) + (WORKFLOW,) + 'OrdinaryH0Controls.lean', 'check.py', 'replay.sh', 'test_torus_filtration.py', 'README.md', 'SCOPE.md')) + (WORKFLOW,) PINNED_CORE = ('formal/lakefile.toml', 'formal/lake-manifest.json', 'formal/lean-toolchain') TOOLCHAIN = 'leanprover/lean4:v4.34.1' LEAN_VERSION = re.compile(r'Lean \(version 4\.34\.1, [^()\r\n]+, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release\)') @@ -51,8 +52,13 @@ # protocol tests (InventoryTests, run by the replay) and the out-of-tree generator require the tracked module bytes to carry exactly these identities, so # neither successor changes by a byte without this record changing with it. Every label here is transcribed from the # handoffs (Math- #428 comments 6113033545 and 6113372506) or records a computation of this lane; FORMAL HOLD is the -# handoffs' own acceptance status and stands until a nonauthor exact-source review of the compiled successor bytes. -# Registration is not review, not acceptance; organizational-independence credit 0 (same project account). +# handoffs' own acceptance status. It rests on the handoffs' own listed conditions (6113033545 item 4, 6113372506, +# 6113277485 item 5), among them a nonauthor exact-source review of the compiled successor bytes, a distinct review of +# the source-bound execution output and source-bound hosted evidence and custody; a source review alone does not meet +# them. `formal_status` below is the registration commit's transcription, naming one of those conditions; it is kept +# unchanged, and no review recorded since moves it (2026-10-12: engineering readback 5485829137, credit 0; +# source-scoped review 5485883117, no organizational-independence credit stated, same project account). Registration +# is not review, not acceptance; organizational-independence credit 0 (same project account). SUCCESSORS = { 'SuperlevelBar.lean': { 'lane': 'C263', @@ -94,8 +100,29 @@ 'owner_repair_handoff_428': '6113372506', 'repair_report_this_lane_428': '6113438262'}, 'formal_status': 'FORMAL_HOLD until a nonauthor exact-source review of the compiled successor; registration is not review', 'organizational_independence_credit': 0}} +# Owner-authored modules: no handoff bytes, no successor relation. OrdinaryH0Controls.lean holds the instantiated +# ordinary-H0 controls this lane wrote for C264 owner task item 4 (Math- #428 comment 6113277485) against the corrected +# CONTROL_OBLIGATIONS of comment 6113277173. `metadata` requires SOURCE_FILES.json to carry exactly this record (compared +# whole, like SUCCESSORS); the protocol tests and the out-of-tree generator require the tracked module bytes to carry +# exactly this identity. It is not a review of OrdinaryH0, lifts no FORMAL HOLD and moves no label; credit 0. +OWNER_MODULES = { + 'OrdinaryH0Controls.lean': { + 'lane': 'C264 owner task item 4 (instantiated ordinary-H0 controls)', + 'author': 'Anthropic/Claude lane (companion owner), delegated AI work for Dylan Roy', + 'kind': 'owner-authored controls module; not a handoff successor (no handoff bytes exist); not a review', + 'sha256': 'df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184', 'bytes': 29590, + 'imports': ['Mathlib', 'OrdinaryH0'], + 'namespace': 'authored directly in namespace TorusFiltration; every declaration carries the prefix ordinaryH0Control_', + 'declarations': '37 theorems, 3 abbrevs, 4 defs, 0 instances', + 'census_at_pin': '48 constants = 44 user range + 0 user generated + 4 internal generated (ordinaryH0Control_parabolaLeft ' + 'and ordinaryH0Control_parabolaRight: _proof_1 and eq_1 each)', + 'comments': {'owner_task_item_4_428': '6113277485', 'control_obligations_specification_428': '6113277173'}, + 'review_status': 'not a review of OrdinaryH0 and lifts nothing: the FORMAL HOLD of OrdinaryH0 (and of SuperlevelBar) ' + 'is unchanged; no review of these bytes is recorded; registration is not review', + 'organizational_independence_credit': 0}} NAMESPACE_MAPPING = ('ResearchFormalCoreR1. (handoff) -> TorusFiltration. (companion) for TorusTopology and ClosedSuperlevel; ' - 'SuperlevelBar and OrdinaryH0 were authored directly in namespace TorusFiltration') + 'SuperlevelBar and OrdinaryH0 were authored directly in namespace TorusFiltration, and so was the ' + 'owner-authored OrdinaryH0Controls') # Own copy of formal/gate.py's audit rules; the companion imports nothing from the core. ALLOWED = frozenset({'propext', 'Classical.choice', 'Quot.sound'}) NAME = r'[A-Za-z_][A-Za-z0-9_.]*' @@ -104,10 +131,12 @@ HEX40 = re.compile(r'[0-9a-f]{40}') HEX64 = re.compile(r'[0-9a-f]{64}') BUILDS = tuple('build-' + m for m in MODULES + (ROOT_MODULE,)) + ('positive', 'axioms', 'types', 'census', 'leanchecker') -# The leanchecker invocations replay.sh may record in leanchecker.cmd. All four modules `import Mathlib`, so +# The leanchecker invocations replay.sh may record in leanchecker.cmd. All five modules `import Mathlib`, so # `--fresh` (kernel re-check of the whole import closure) exceeds a hosted job: measured locally at 4 threads # it was still running at 1500 s with 6.6 GB resident. The hosted default replays the companion's own -# declarations against the cached, prebuilt dependency .oleans (33 s at 2 threads locally for the C254 pair). +# declarations against the cached, prebuilt dependency .oleans (33 s at 2 threads locally for the C254 pair). The +# modules form names every companion module and the root; a shorter form (the three-module form before the C263/C264 +# registration, the five-module form before OrdinaryH0Controls) is refused. LEANCHECKER = {'leanchecker ' + ' '.join(MODULES + (ROOT_MODULE,)): 'modules', 'leanchecker --fresh TorusFiltration': 'fresh'} ADMISSION = ('sorry', 'sorryAx', 'admit', 'axiom', 'native_decide', 'ofReduceBool', 'trustCompiler', 'unsafe', @@ -172,7 +201,8 @@ def admission_tokens(text): return [token for token in ADMISSION if token in present] DECLARATION = re.compile(r'(theorem|abbrev|instance|def|noncomputable def) (' + IDENT + r')(?=$|[\s:(\[{⦃])') # Column-0 prelude lines. `import` admits Mathlib and, since the C263/C264 registration, a companion module named in -# MODULES (scan_module further requires it to precede the importing module in MODULES: no self, forward or root import). +# MODULES (scan_module further requires it to precede the importing module in MODULES: no self, forward or root import; +# OrdinaryH0.lean imports ClosedSuperlevel and OrdinaryH0Controls.lean imports OrdinaryH0). # `open scoped ` activates scoped notation and instances only, a strictly smaller effect than the `open` # already admitted; both lines appear in OrdinaryH0.lean. Keys are tried in order, so `open scoped` precedes `open`. PRELUDE = {'import': re.compile(r'import (?:Mathlib(?:\.[A-Za-z0-9_]+)*|' + '|'.join(MODULES) + ')'), @@ -188,6 +218,16 @@ def admission_tokens(text): # RejectReducedPointClass asserts that the ordinary point class of the one-point space with ℤ-module coefficients is NOT # augmented to the identity, which is what reduced H0 would give and what ordinaryH0_pointClass_augmentation refutes. # Both diagnostics were pinned from actual Lean 4.34.1 output at the Mathlib d13f23b7 pin against the registered bytes. +# The three C264 item-4 controls (2026-10-12) are false statements about the fixtures of OrdinaryH0Controls.lean, each +# closed to `⊢ False` by rewriting with the true fixture theorem it contradicts: RejectMergerKillsPointClass asserts that +# the collapse Bool -> Unit kills the individual point class of `true` (a merger kills the difference, not the class; +# ordinaryH0Control_collapse_image_ne_zero); RejectSeparationWithoutNonzeroCoeff asserts that the two point classes of +# Bool differ with zero coefficients (ordinaryH0Control_bool_zeroCoeff_eq: they are equal, so the separation needs +# `𝟙 R ≠ 0`); RejectNonmergerKillsDifference asserts that the non-injective projection Bool × Bool -> Bool kills the +# difference of the classes of (true, false) and (false, true), whose images stay in distinct components +# (ordinaryH0Control_fst_difference_ne_zero). The same tactic on each control's true sibling statement leaves a +# different diagnostic (`simp` made no progress, or a goal other than `False` plus an unused simp argument), which +# `negative` refuses; all six diagnostics were pinned from actual Lean 4.34.1 output at the d13f23b7 pin. FALSE_CONTROLS = { 'RejectSuperlevelSignFlip': ('() ∈ superlevel_set (fun _ : Unit => (0 : ℝ)) (-1)', 'norm_num [superlevel_set]'), 'RejectSuperlevelBelowThreshold': ('(3 : ℝ) ∈ superlevel_set (fun x : ℝ => x) (-4)', 'norm_num [superlevel_set]'), @@ -197,7 +237,19 @@ def admission_tokens(text): 'RejectReducedPointClass': ('CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of Unit) (ModuleCat.of ℤ ℤ) ()) ' '(TopCat.singularHomology₀ε (TopCat.of Unit) (ModuleCat.of ℤ ℤ)) ' '≠ CategoryTheory.CategoryStruct.id (ModuleCat.of ℤ ℤ)', - 'simp [ordinaryH0_pointClass_augmentation]')} + 'simp [ordinaryH0_pointClass_augmentation]'), + 'RejectMergerKillsPointClass': ('CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff true) ' + '(((AlgebraicTopology.singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map ' + 'ordinaryH0Control_collapse) = 0', + 'simp only [ordinaryH0Control_collapse_image_ne_zero]'), + 'RejectSeparationWithoutNonzeroCoeff': ('ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff true ≠ ' + 'ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff false', + 'simp [ordinaryH0Control_bool_zeroCoeff_eq]'), + 'RejectNonmergerKillsDifference': ('CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ' + '((true, false) : Bool × Bool) - ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ' + '((false, true) : Bool × Bool)) (((AlgebraicTopology.singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ' + 'ordinaryH0Control_intCoeff).map ordinaryH0Control_fst) = 0', + 'simp only [ordinaryH0Control_fst_difference_ne_zero]')} # Admission injections; Lean accepts each file (exit 0), the transitive axiom audit must refuse it. # Diagnostics pinned from Lean 4.34.1 at the Mathlib d13f23b7 pin: the sorry warning uses backticks, and # native_decide introduces the auxiliary axiom `injected._native.native_decide.ax_1_1` (not Lean.ofReduceBool). @@ -209,8 +261,8 @@ def admission_tokens(text): 'RejectNativeDecide': ("theorem injected : (2 : Nat) + 2 = 4 := by native_decide\n", 'injected._native.native_decide.ax_1_1', '')} CONTROLS = tuple(FALSE_CONTROLS) + tuple(INJECTIONS) -# The exact membership of the evidence directory when `finish` runs (C262 gate review G3): the twelve files emit() -# writes, a .log/.status pair per Lean process (five module builds, positive, axioms, types, census, leanchecker, eight +# The exact membership of the evidence directory when `finish` runs (C262 gate review G3): the fifteen files emit() +# writes, a .log/.status pair per Lean process (six module builds, positive, axioms, types, census, leanchecker, eleven # controls), the two protocol-test transcripts and the four environment records. # finish() refuses a directory with any member missing or unexpected, any member that is not a regular file, and # any directory already holding receipt.json: a receipt is written once and never replaced. @@ -223,12 +275,13 @@ def admission_tokens(text): # spelling); no ranged constant carries an internal-style name (a user-written `proof_1` is refused); the user-named # generated constants equal `census_auxiliary` exactly (so that whitelist can name only compiler-generated constants); # internal generated constants are counted and otherwise ignored (the C26x modules add twelve at the pin: equation -# lemmas, abstracted proofs, a `_simp` auxiliary and the equation lemma Lean generated for Mathlib's `sigmaConst`). +# lemmas, abstracted proofs, a `_simp` auxiliary and the equation lemma Lean generated for Mathlib's `sigmaConst`; +# OrdinaryH0Controls adds four: `_proof_1` and `eq_1` of its two subtype-point definitions). CENSUS = '''import TorusFiltration open Lean in #eval show Lean.Elab.Command.CommandElabM Unit from do let env ← Lean.getEnv - let modules : Array Lean.Name := #[`TorusTopology, `ClosedSuperlevel, `SuperlevelBar, `OrdinaryH0, `TorusFiltration] + let modules : Array Lean.Name := #[`TorusTopology, `ClosedSuperlevel, `SuperlevelBar, `OrdinaryH0, `OrdinaryH0Controls, `TorusFiltration] let idxs := modules.filterMap env.getModuleIdx? if idxs.size != modules.size then throwError "census: a companion module is not imported" let names := env.constants.fold (init := (#[] : Array Lean.Name)) fun acc n _ => @@ -243,10 +296,11 @@ def admission_tokens(text): EVIDENCE_FILES = frozenset(EMITTED_FILES) | {label + ext for label in BUILDS for ext in ('.log', '.status')} \ | {control + ext for control in CONTROLS for ext in ('.log', '.status')} \ | {'leanchecker.cmd', 'packages.log', 'toolchain.log', 'source.json', 'tests.log', 'tests-optimized.log'} -# 12 emitted + 10 processes x 2 + 8 controls x 2 + 6 records = 54 (44 before the C263/C264 registration added two -# module builds and two controls). An explicit check, not an `assert`: the gate must hold under -O too. -if len(EVIDENCE_FILES) != 54: - raise RuntimeError('EVIDENCE_FILES must enumerate exactly 54 members') +# 15 emitted + 11 processes x 2 + 11 controls x 2 + 6 records = 65 (44 before the C263/C264 registration added two +# module builds and two controls, 54 before OrdinaryH0Controls added one module build and three controls: 2 + 3 x 3). +# An explicit check, not an `assert`: the gate must hold under -O too. +if len(EVIDENCE_FILES) != 65: + raise RuntimeError('EVIDENCE_FILES must enumerate exactly 65 members') POSITIVE = '''import TorusFiltration open TorusFiltration @@ -353,12 +407,14 @@ def metadata(): require(isinstance(prov, dict), 'provenance object') for key in ('claim', 'handoff_pr', 'handoff_comments', 'original_sha256', 'original_bytes', 'original_status', 'namespace_mapping', 'source_author', 'compile_fixes_and_companion', 'organizational_independence_credit', - 'human_review', 'successors'): + 'human_review', 'successors', 'owner_modules'): require(key in prov, 'provenance key missing: ' + key) require(prov['claim'] == CLAIM and prov['original_sha256'] == ORIGINAL_SHA256, 'provenance identity') # The C26x record is compared whole: a changed hash, byte count, author, census or status label (a self-awarded # acceptance in `formal_status`, say) is refused as one mismatch, never partially accepted. require(prov['original_bytes'] == ORIGINAL_BYTES and prov['successors'] == SUCCESSORS, 'successor provenance identity') + # The owner-authored record is compared whole in the same way (identity, author, census, comments, review status). + require(prov['owner_modules'] == OWNER_MODULES, 'owner module provenance identity') require(prov['original_status'] == 'NOT_COMPILED' and prov['namespace_mapping'] == NAMESPACE_MAPPING, 'provenance labels') require(prov['organizational_independence_credit'] == 0 and prov['human_review'] == 'none', 'credit must stay zero') return meta @@ -496,7 +552,7 @@ def check_modules(meta, side): for kind in ('abbrev', 'def', 'instance'): require(scan[kind] == meta['definitions'][module][kind], kind + ' inventory differs from source: ' + module) require((side / (ROOT_MODULE + '.lean')).read_text(encoding='utf-8') == ROOT_SOURCE, - 'root module must import exactly the four modules') + 'root module must import exactly the five modules') def environment(root): diff --git a/companions/torus_filtration_20261011/replay.sh b/companions/torus_filtration_20261011/replay.sh index ff47d2393..c654e5041 100644 --- a/companions/torus_filtration_20261011/replay.sh +++ b/companions/torus_filtration_20261011/replay.sh @@ -1,13 +1,15 @@ #!/usr/bin/env bash -# Replay of the torus-filtration companion: TorusTopology and ClosedSuperlevel (C254) and the registered -# SuperlevelBar (C263) and OrdinaryH0 (C264) successors. It runs neither formal/gate.py nor the formal -# tests: the companion consumes only the pinned toolchain, lakefile and dependency lock from formal/, -# and its evidence is kernel-checked declarations, not alignment or acceptance. +# Replay of the torus-filtration companion: TorusTopology and ClosedSuperlevel (C254), the registered +# SuperlevelBar (C263) and OrdinaryH0 (C264) successors, and the owner-authored OrdinaryH0Controls (C264 owner +# task item 4). It runs neither formal/gate.py nor the formal tests: the companion consumes only the pinned +# toolchain, lakefile and dependency lock from formal/, and its evidence is kernel-checked declarations, not +# alignment or acceptance. set -euo pipefail # The outer Python mode is the one named on each command line below, never an ambient PYTHONOPTIMIZE (C262 G1). unset PYTHONOPTIMIZE # leanchecker over the five modules peaked at about 8.4-8.7 GiB resident at two threads and exceeded a 13.36 GiB -# memory limit at four (2026-10-11, this lane); default to the hosted job's two threads unless the operator sets otherwise. +# memory limit at four (2026-10-11, this lane); over the six, sampled peaks of 8.64 and 9.31 GiB in two runs at two +# threads (2026-10-12); default to the hosted job's two threads unless the operator sets otherwise. export LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-2}" ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" SIDE="$ROOT/companions/torus_filtration_20261011" @@ -44,26 +46,28 @@ run_lean build-TorusTopology lean -DwarningAsError=true --root="$TORUS_SIDE" -o run_lean build-ClosedSuperlevel lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/ClosedSuperlevel.olean" "$TORUS_SIDE/ClosedSuperlevel.lean" run_lean build-SuperlevelBar lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/SuperlevelBar.olean" "$TORUS_SIDE/SuperlevelBar.lean" run_lean build-OrdinaryH0 lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/OrdinaryH0.olean" "$TORUS_SIDE/OrdinaryH0.lean" +run_lean build-OrdinaryH0Controls lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/OrdinaryH0Controls.olean" "$TORUS_SIDE/OrdinaryH0Controls.lean" run_lean build-TorusFiltration lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/TorusFiltration.olean" "$TORUS_SIDE/TorusFiltration.lean" run_lean positive lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Positive.lean" run_lean axioms lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Audit.lean" run_lean types lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Types.lean" run_lean census lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/Census.lean" # Kernel replay of the companion modules' own declarations against the cached, prebuilt dependency -# .oleans (30 s at 2 threads locally for the three C254 modules, 53 s for the five). All four modules `import Mathlib` (OrdinaryH0 also imports -# ClosedSuperlevel), so `--fresh` (re-check of the whole import closure) does not fit a hosted job: still running +# .oleans (30 s at 2 threads locally for the three C254 modules, 53 s for the five, 56 s for the six, 75 s with the +# `lake env` start-up). All five modules `import Mathlib` (OrdinaryH0 also imports ClosedSuperlevel, OrdinaryH0Controls +# imports OrdinaryH0), so `--fresh` (re-check of the whole import closure) does not fit a hosted job: still running # at 1500 s with 6.6 GB resident at 4 threads. # TORUS_LEANCHECKER_FRESH=1 selects it for an operator's local run; the receipt records which mode ran. if [ "${TORUS_LEANCHECKER_FRESH:-0}" = 1 ]; then LEANCHECKER_COMMAND='leanchecker --fresh TorusFiltration' else - LEANCHECKER_COMMAND='leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration' + LEANCHECKER_COMMAND='leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 OrdinaryH0Controls TorusFiltration' fi printf '%s\n' "$LEANCHECKER_COMMAND" > "$TORUS_OUT/leanchecker.cmd" # shellcheck disable=SC2086 run_lean leanchecker $LEANCHECKER_COMMAND # False statements about the companion's own definitions: Lean itself must refuse each with exactly `⊢ False`. -for control in RejectSuperlevelSignFlip RejectSuperlevelBelowThreshold RejectConstantNotPeriodic RejectEssentialDeathBound RejectReducedPointClass; do +for control in RejectSuperlevelSignFlip RejectSuperlevelBelowThreshold RejectConstantNotPeriodic RejectEssentialDeathBound RejectReducedPointClass RejectMergerKillsPointClass RejectSeparationWithoutNonzeroCoeff RejectNonmergerKillsDifference; do code=0 lean -DwarningAsError=true --root="$TORUS_OUT" "$TORUS_OUT/$control.lean" >"$TORUS_OUT/$control.log" 2>&1 || code=$? printf '%s\n' "$code" >"$TORUS_OUT/$control.status" diff --git a/companions/torus_filtration_20261011/test_torus_filtration.py b/companions/torus_filtration_20261011/test_torus_filtration.py index ef12443fb..9aeae2df6 100644 --- a/companions/torus_filtration_20261011/test_torus_filtration.py +++ b/companions/torus_filtration_20261011/test_torus_filtration.py @@ -68,6 +68,27 @@ 'abbrev': [], 'def': ['ordinaryH0_componentFunctor', 'ordinaryH0_componentCoproductFunctor', 'ordinaryH0_componentFiltration', 'ordinaryH0_simplicialPointClass', 'ordinaryH0_pointClass', 'ordinaryH0_naturalIso', 'ordinaryH0_filtrationIso'], + 'instance': []}, + # owner-authored C264 item-4 controls (df9d3645…), as scan_module reports it; every name carries ordinaryH0Control_ + 'OrdinaryH0Controls': { + 'theorem': '''ordinaryH0Control_intCoeff_id_ne_zero ordinaryH0Control_mod2Coeff_id_ne_zero + ordinaryH0Control_mod2Coeff_id_add_self ordinaryH0Control_zeroCoeff_isZero ordinaryH0Control_zeroCoeff_id_eq_zero + ordinaryH0Control_empty_components ordinaryH0Control_empty_componentCoproduct_isZero ordinaryH0Control_empty_h0_isZero + ordinaryH0Control_zeroCoeff_componentCoproduct_isZero ordinaryH0Control_zeroCoeff_h0_isZero + ordinaryH0Control_point_augmentation ordinaryH0Control_point_ne_zero ordinaryH0Control_point_h0_not_isZero + ordinaryH0Control_line_component_eq ordinaryH0Control_line_difference_zero_int + ordinaryH0Control_line_difference_zero_zeroCoeff ordinaryH0Control_line_classes_ne_zero + ordinaryH0Control_discrete_component_ne ordinaryH0Control_bool_component_ne ordinaryH0Control_bool_pointClass_ne + ordinaryH0Control_bool_pointClass_ne_mod2 ordinaryH0Control_collapse_difference_zero + ordinaryH0Control_collapse_image_ne_zero ordinaryH0Control_collapse_difference_dies_classes_survive + ordinaryH0Control_square_differences_ne_zero ordinaryH0Control_fst_difference_zero + ordinaryH0Control_fst_difference_ne_zero ordinaryH0Control_bool_zeroCoeff_eq ordinaryH0Control_point_zeroCoeff_eq_zero + ordinaryH0Control_separation_needs_nonzero ordinaryH0Control_nonvanishing_needs_nonzero ordinaryH0Control_parabola_le + ordinaryH0Control_parabola_strict_growth ordinaryH0Control_parabola_not_joined_quarter ordinaryH0Control_parabola_joined + ordinaryH0Control_parabola_difference_zero ordinaryH0Control_parabola_strict_difference_ne_zero'''.split(), + 'abbrev': ['ordinaryH0Control_intCoeff', 'ordinaryH0Control_zeroCoeff', 'ordinaryH0Control_mod2Coeff'], + 'def': ['ordinaryH0Control_collapse', 'ordinaryH0Control_fst', 'ordinaryH0Control_parabolaLeft', + 'ordinaryH0Control_parabolaRight'], 'instance': []}} HANDOFF_COMMENTS = ('6111056103', '6111059166', '6111059498', '6111059848', '6111255007', '6111093545', '6111139060') # Math- #428 (and the #419 allocation) comments the C26x successor record cites, per module. @@ -77,20 +98,44 @@ 'd74dc8b2c25eff5b90ce7133e51a0888c7885cae24ca6d5e648bc514089637a8', 14904), 'OrdinaryH0.lean': ('3d6b0d6b53413c484b1d010bccf0d53ae7f75becb2d747868f22dbd673fe0a88', 19803, '261dd0526d42890d8a4ac1225fcf47228eb3c9799af4106cb643a528bcbf968e', 18469)} +# The owner-authored controls module (no handoff bytes): its identity and the Math- #428 comments its record cites +# (6113277485: C264 owner task, item 4; 6113277173: the corrected CONTROL_OBLIGATIONS it instantiates). +OWNER_IDENTITY = {'OrdinaryH0Controls.lean': ('df9d3645282ca526b67eca3d5db691b622092a14b5fddee9be21013e39666184', 29590)} +OWNER_COMMENTS = {'OrdinaryH0Controls.lean': {'6113277485', '6113277173'}} LEAN_VERSION_LINE = 'Lean (version 4.34.1, x86_64-unknown-linux-gnu, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release)\n' FALSE_LOG = '/tmp/evidence/{0}.lean:4:2: error: unsolved goals\n⊢ False\n' +# The item-4 controls as Lean 4.34.1 printed them at the Mathlib d13f23b7 pin (this lane's pre-commit run on the +# registered bytes, 2026-10-12; only the directory before the file name is shortened): each leaves exactly `⊢ False`. +CONTROL_LOGS = { + 'RejectMergerKillsPointClass': '/tmp/evidence/RejectMergerKillsPointClass.lean:3:255: error: unsolved goals\n⊢ False\n', + 'RejectSeparationWithoutNonzeroCoeff': '/tmp/evidence/RejectSeparationWithoutNonzeroCoeff.lean:3:160: error: unsolved goals\n⊢ False\n', + 'RejectNonmergerKillsDifference': '/tmp/evidence/RejectNonmergerKillsDifference.lean:3:391: error: unsolved goals\n⊢ False\n', +} +# Discriminators: the same tactic on each control's TRUE sibling statement (the difference under the collapse; the +# ℤ-coefficient separation of Bool; the (true, false)/(true, true) difference under the projection), emitted in the same +# format under the same file name and printed by Lean in the same run. Each is a different diagnostic, which `negative` +# must refuse: the controls' `⊢ False` comes from the falsehood of their statements, not from a tactic that turns any +# goal into False. +DISCRIMINATOR_LOGS = { + 'RejectMergerKillsPointClass': '/tmp/evidence/RejectMergerKillsPointClass.lean:4:2: error: `simp` made no progress\n', + 'RejectSeparationWithoutNonzeroCoeff': '/tmp/evidence/RejectSeparationWithoutNonzeroCoeff.lean:3:158: error: unsolved goals\n⊢ ¬ordinaryH0_pointClass (↧Bool) ordinaryH0Control_intCoeff true =\n ordinaryH0_pointClass (↧Bool) ordinaryH0Control_intCoeff false\n/tmp/evidence/RejectSeparationWithoutNonzeroCoeff.lean:4:8: error: This simp argument is unused:\n ordinaryH0Control_bool_zeroCoeff_eq\n\nHint: Omit it from the simp argument list.\n [apply] simp\n\nNote: This linter can be disabled with `set_option linter.unusedSimpArgs false`\n', + 'RejectNonmergerKillsDifference': '/tmp/evidence/RejectNonmergerKillsDifference.lean:4:2: error: `simp` made no progress\n', +} SORRY_WARNING = "/tmp/evidence/RejectSorry.lean:2:8: warning: declaration uses `sorry`\n" INJECTED = "'injected' depends on axioms: [{0}]\n" -LEANCHECKER_MODULES = 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration' +LEANCHECKER_MODULES = 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 OrdinaryH0Controls TorusFiltration' +LEANCHECKER_MODULES_BEFORE_CONTROLS = 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 TorusFiltration' LEANCHECKER_MODULES_BEFORE_C26X = 'leanchecker TorusTopology ClosedSuperlevel TorusFiltration' LEANCHECKER_FRESH = 'leanchecker --fresh TorusFiltration' EMITTED = ('Audit.lean', 'Types.lean', 'Positive.lean', 'Census.lean', 'RejectSuperlevelSignFlip.lean', 'RejectSuperlevelBelowThreshold.lean', 'RejectConstantNotPeriodic.lean', 'RejectEssentialDeathBound.lean', - 'RejectReducedPointClass.lean', 'RejectSorry.lean', 'RejectCustomAxiom.lean', 'RejectNativeDecide.lean') + 'RejectReducedPointClass.lean', 'RejectMergerKillsPointClass.lean', 'RejectSeparationWithoutNonzeroCoeff.lean', + 'RejectNonmergerKillsDifference.lean', 'RejectSorry.lean', 'RejectCustomAxiom.lean', 'RejectNativeDecide.lean') PYTHON_LINE = 'TORUS_FILTRATION_PYTHON: optimize=%d' % sys.flags.optimize # Compiler-generated internal constants as the real census lists them (abstracted proofs, equation lemmas); the fixture -# census carries a few so the parser's `internal generated` branch is exercised. The last twelve are exactly the -# `internal generated` rows of the C263 and C264 range-aware censuses at the pin (1 + 11); the first, +# census carries a few so the parser's `internal generated` branch is exercised. Rows four to fifteen are exactly the +# `internal generated` rows of the C263 and C264 range-aware censuses at the pin (1 + 11), and the last four those of +# OrdinaryH0Controls (`_proof_1` and `eq_1` of its two subtype-point definitions); the fifth, # `CategoryTheory.Limits.sigmaConst.eq_1`, is the equation lemma Lean generated for a Mathlib definition that # OrdinaryH0.lean unfolds, attributed to the companion module, so the census parser must tolerate internal generated # constants outside the companion namespace. @@ -104,7 +149,9 @@ 'TorusFiltration.ordinaryH0_simplicialPointClass._proof_2', 'TorusFiltration.ordinaryH0_simplicialPointClass._proof_3', 'TorusFiltration.ordinaryH0_simplicialPointClass._proof_4', - 'TorusFiltration.ordinaryH0_simplicialPointClass.eq_1') + 'TorusFiltration.ordinaryH0_simplicialPointClass.eq_1', + 'TorusFiltration.ordinaryH0Control_parabolaLeft._proof_1', 'TorusFiltration.ordinaryH0Control_parabolaLeft.eq_1', + 'TorusFiltration.ordinaryH0Control_parabolaRight._proof_1', 'TorusFiltration.ordinaryH0Control_parabolaRight.eq_1') # The outer interpreter mode goes into the test transcript (tests.log / tests-optimized.log), so the hosted # evidence records which mode each suite ran in (C262 G1). print('TORUS_FILTRATION_TESTS: outer optimize=%d' % sys.flags.optimize, file=sys.stderr) @@ -337,15 +384,21 @@ def setUpClass(cls): def test_inventory_constants(self): names = [n for m in INVENTORY.values() for kind in m.values() for n in kind] self.assertEqual(len(names), len(set(names))) - self.assertEqual(sum(len(m['theorem']) for m in INVENTORY.values()), 81) - self.assertEqual([len(INVENTORY[m]['theorem']) for m in ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0')], - [21, 20, 20, 20]) - self.assertEqual(sum(len(m['def']) for m in INVENTORY.values()), 22) - self.assertEqual([len(INVENTORY[m]['def']) for m in INVENTORY], [6, 6, 3, 7]) - self.assertEqual(sum(len(m['abbrev']) for m in INVENTORY.values()), 3) + self.assertEqual(sum(len(m['theorem']) for m in INVENTORY.values()), 118) + self.assertEqual([len(INVENTORY[m]['theorem']) for m in ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0', + 'OrdinaryH0Controls')], + [21, 20, 20, 20, 37]) + self.assertEqual(sum(len(m['def']) for m in INVENTORY.values()), 26) + self.assertEqual([len(INVENTORY[m]['def']) for m in INVENTORY], [6, 6, 3, 7, 4]) + self.assertEqual(sum(len(m['abbrev']) for m in INVENTORY.values()), 6) + self.assertEqual([len(INVENTORY[m]['abbrev']) for m in INVENTORY], [2, 0, 1, 0, 3]) self.assertEqual(sum(len(m['instance']) for m in INVENTORY.values()), 3) - self.assertEqual(sum(len(kind) for m in INVENTORY.values() for kind in m.values()), 109) - self.assertEqual(len(INTERNAL_GENERATED), 15) + self.assertEqual(sum(len(kind) for m in INVENTORY.values() for kind in m.values()), 153) + self.assertEqual(sum(len(kind) for kind in INVENTORY['OrdinaryH0Controls'].values()), 44) + # every declaration of the controls module carries its own prefix, and no other module uses it + self.assertTrue(all(n.startswith('ordinaryH0Control_') for kind in INVENTORY['OrdinaryH0Controls'].values() for n in kind)) + self.assertFalse(any(n.startswith('ordinaryH0Control_') for m in self.c.MODULES[:-1] for kind in INVENTORY[m].values() for n in kind)) + self.assertEqual(len(INTERNAL_GENERATED), 19) self.assertTrue(all(re.fullmatch(self.c.IDENT, n) for n in names)) self.assertEqual(tuple(INVENTORY), self.c.MODULES) @@ -355,9 +408,9 @@ def test_source_files_inventory_provenance_and_identities(self): self.assertEqual(meta['theorems'][module], INVENTORY[module]['theorem']) for kind in ('abbrev', 'def', 'instance'): self.assertEqual(meta['definitions'][module][kind], INVENTORY[module][kind]) - self.assertEqual(len(self.c.targets(meta)), 109) + self.assertEqual(len(self.c.targets(meta)), 153) self.assertEqual(self.c.theorem_targets(meta)[0], 'TorusFiltration.torus_field_latticeVec_formula') - self.assertEqual(self.c.theorem_targets(meta)[-1], 'TorusFiltration.ordinaryH0_filtration_difference_zero_iff_joinedIn') + self.assertEqual(self.c.theorem_targets(meta)[-1], 'TorusFiltration.ordinaryH0Control_parabola_strict_difference_ne_zero') prov = meta['provenance'] self.assertEqual(set(HANDOFF_COMMENTS), set(prov['handoff_comments'].values())) self.assertEqual(prov['handoff_pr'], 'd6g8k5htny-coder/Math-#419') @@ -393,6 +446,33 @@ def test_source_files_inventory_provenance_and_identities(self): self.assertIn('25 constants = 24 user range + 0 user generated + 1 internal generated', prov['successors']['SuperlevelBar.lean']['census_at_pin']) self.assertIn('38 constants = 27 user range + 0 user generated + 11 internal generated', prov['successors']['OrdinaryH0.lean']['census_at_pin']) self.assertIn('authored directly in namespace TorusFiltration', prov['namespace_mapping']) + self.assertIn('OrdinaryH0Controls', prov['namespace_mapping']) + # The owner-authored record: compared whole, its identity is the tracked module's, it cites the item-4 task and the + # CONTROL_OBLIGATIONS specification, it is not a handoff successor and not a review, and the FORMAL HOLD of + # OrdinaryH0 is recorded as unchanged; credit 0. + self.assertEqual(prov['owner_modules'], self.c.OWNER_MODULES) + self.assertEqual(set(prov['owner_modules']), set(OWNER_IDENTITY)) + self.assertFalse(set(prov['owner_modules']) & set(prov['successors'])) + for name, (digest, size) in OWNER_IDENTITY.items(): + record = prov['owner_modules'][name] + self.assertEqual((record['sha256'], record['bytes']), (digest, size), name) + self.assertEqual(set(record['comments'].values()), OWNER_COMMENTS[name], name) + self.assertEqual(record['organizational_independence_credit'], 0) + self.assertIn('Anthropic/Claude', record['author']) + self.assertIn('not a handoff successor', record['kind']) + self.assertIn('not a review', record['kind']) + self.assertIn('not a review of OrdinaryH0', record['review_status']) + self.assertIn('FORMAL HOLD of OrdinaryH0', record['review_status']) + self.assertIn('unchanged', record['review_status']) + self.assertEqual(record['imports'], ['Mathlib', 'OrdinaryH0']) + self.assertIn('48 constants = 44 user range + 0 user generated + 4 internal generated', record['census_at_pin']) + self.assertEqual(record['declarations'], '37 theorems, 3 abbrevs, 4 defs, 0 instances') + self.assertNotIn(name, {k.split('/')[-1] for k in self.c.ORIGINAL_SHA256}) + tracked = ROOT / self.c.PACKAGE / name + if tracked.is_file(): + actual = self.c.identity(tracked.read_bytes()) + self.assertEqual((actual['sha256'], actual['bytes']), (digest, size), 'tracked module is not the recorded owner module: ' + name) + self.assertEqual(meta['files'][self.c.PACKAGE + '/' + name]['sha256'], digest, name) modules = {self.c.PACKAGE + '/' + m + '.lean' for m in self.c.MODULES} for path in self.c.REQUIRED_FILES: target = ROOT / path @@ -456,7 +536,12 @@ def test_module_scan_accepts_only_the_whitelisted_shapes(self): h0.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial\n', 1), h0.replace('import Mathlib\n', 'import Mathlib\nopen scoped Simplicial CategoryTheory.Limits\n', 1)): self.assertEqual(self.c.scan_module(text, 'OrdinaryH0'), INVENTORY['OrdinaryH0']) - self.assertEqual(self.c.MODULES, ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0')) + # OrdinaryH0Controls.lean imports OrdinaryH0 (and may import any module before it) + controls = placeholder_module('OrdinaryH0Controls') + for text in (controls.replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0\n', 1), + controls.replace('import Mathlib\n', 'import Mathlib\nimport ClosedSuperlevel\nimport OrdinaryH0\n', 1)): + self.assertEqual(self.c.scan_module(text, 'OrdinaryH0Controls'), INVENTORY['OrdinaryH0Controls']) + self.assertEqual(self.c.MODULES, ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0', 'OrdinaryH0Controls')) def test_module_scan_refuses_admissions_and_unexpected_kinds(self): good = placeholder_module('ClosedSuperlevel') @@ -563,6 +648,7 @@ def inject(line): (good.replace('import Mathlib\n', 'import Mathlib\nimport ClosedSuperlevel\n', 1), 'companion import out of dependency order in ClosedSuperlevel:2: ClosedSuperlevel'), (good.replace('import Mathlib\n', 'import Mathlib\nimport SuperlevelBar\n', 1), 'companion import out of dependency order in ClosedSuperlevel:2: SuperlevelBar'), (good.replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0\n', 1), 'companion import out of dependency order in ClosedSuperlevel:2: OrdinaryH0'), + (good.replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0Controls\n', 1), 'companion import out of dependency order in ClosedSuperlevel:2: OrdinaryH0Controls'), (good.replace('import Mathlib\n', 'import Mathlib\nimport TorusFiltration\n', 1), unexpected), (good.replace('import Mathlib\n', 'import Mathlib\nimport TorusTopology.Hidden\n', 1), unexpected), (good.replace('import Mathlib\n', 'import Mathlib\nimport TorusTopology Hidden\n', 1), unexpected), @@ -602,6 +688,13 @@ def inject(line): # The first module may import nothing but Mathlib; a module name outside MODULES is not scanned at all. with self.assertRaisesRegex(ValueError, 'companion import out of dependency order in TorusTopology:2: ClosedSuperlevel'): self.c.scan_module(placeholder_module('TorusTopology').replace('import Mathlib\n', 'import Mathlib\nimport ClosedSuperlevel\n', 1), 'TorusTopology') + # The controls module comes last: OrdinaryH0 may not import it, nor may it import itself or the root. + with self.assertRaisesRegex(ValueError, 'companion import out of dependency order in OrdinaryH0:2: OrdinaryH0Controls'): + self.c.scan_module(placeholder_module('OrdinaryH0').replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0Controls\n', 1), 'OrdinaryH0') + with self.assertRaisesRegex(ValueError, 'companion import out of dependency order in OrdinaryH0Controls:2: OrdinaryH0Controls'): + self.c.scan_module(placeholder_module('OrdinaryH0Controls').replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0Controls\n', 1), 'OrdinaryH0Controls') + with self.assertRaisesRegex(ValueError, 'unexpected column-0 line in OrdinaryH0Controls:2: import TorusFiltration'): + self.c.scan_module(placeholder_module('OrdinaryH0Controls').replace('import Mathlib\n', 'import Mathlib\nimport TorusFiltration\n', 1), 'OrdinaryH0Controls') with self.assertRaisesRegex(ValueError, 'not a companion module: TorusFiltration'): self.c.scan_module(good, 'TorusFiltration') with self.assertRaisesRegex(ValueError, 'not a companion module: Other'): @@ -643,6 +736,26 @@ def test_negative_false_controls_accept_only_the_intended_diagnostic(self): with self.assertRaises(ValueError): self.c.negative(FALSE_LOG.format('Unknown'), 'Unknown', 1) + def test_item4_controls_accept_their_pinned_logs_and_refuse_their_true_siblings(self): + # The C264 item-4 controls: the diagnostics Lean printed for each control are accepted, and the diagnostics of the + # same tactic on each control's true sibling statement (same file name, same exit status 1) are refused, as are + # each control's log under another control's name and under a non-1 status. + self.assertEqual(set(CONTROL_LOGS), set(DISCRIMINATOR_LOGS)) + self.assertTrue(set(CONTROL_LOGS) <= set(self.c.FALSE_CONTROLS)) + for control, log in CONTROL_LOGS.items(): + self.assertEqual(self.c.negative(log, control, 1), 'REJECTED_BY_LEAN') + for status in (0, 2): + with self.subTest(control=control, status=status), self.assertRaisesRegex(ValueError, 'false-statement control must exit exactly one'): + self.c.negative(log, control, status) + for other in CONTROL_LOGS: + if other != control: + with self.subTest(control=control, other=other), self.assertRaisesRegex(ValueError, 'not the intended False-goal diagnostic: ' + other): + self.c.negative(log, other, 1) + for control, log in DISCRIMINATOR_LOGS.items(): + self.assertNotIn('⊢ False', log) + with self.subTest(discriminator=control), self.assertRaisesRegex(ValueError, 'not the intended False-goal diagnostic: ' + control): + self.c.negative(log, control, 1) + def test_negative_injection_controls_require_the_audit_to_refuse(self): for control, (_, forbidden, _) in self.c.INJECTIONS.items(): good = good_injection_log(self.c, control) @@ -739,6 +852,10 @@ def test_leanchecker_mode_accepts_exactly_the_two_recorded_invocations(self): self.assertEqual(self.c.LEANCHECKER, {LEANCHECKER_MODULES: 'modules', LEANCHECKER_FRESH: 'fresh'}) for bad in ('', 'leanchecker TorusFiltration', 'leanchecker --fresh TorusTopology', 'leanchecker TorusTopology ClosedSuperlevel', LEANCHECKER_MODULES_BEFORE_C26X, 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0', + LEANCHECKER_MODULES_BEFORE_CONTROLS, LEANCHECKER_MODULES_BEFORE_CONTROLS + ' OrdinaryH0Controls', + 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0 OrdinaryH0Controls', + 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar OrdinaryH0Controls OrdinaryH0 TorusFiltration', + 'leanchecker OrdinaryH0Controls', 'leanchecker TorusTopology ClosedSuperlevel SuperlevelBar TorusFiltration', 'leanchecker TorusTopology ClosedSuperlevel OrdinaryH0 SuperlevelBar TorusFiltration', LEANCHECKER_MODULES + ' Extra', 'leanchecker --verbose ' + LEANCHECKER_MODULES[12:], @@ -757,13 +874,14 @@ def test_emit_writes_exactly_the_audit_types_positive_and_controls(self): census = (out / 'Census.lean').read_text() self.assertTrue(census.startswith('import TorusFiltration\n')) for needed in ('isInternalDetail', 'findDeclarationRanges?', 'getModuleIdxFor?', '`TorusTopology', '`ClosedSuperlevel', - '`SuperlevelBar, `OrdinaryH0, `TorusFiltration', 'CENSUS_END', '"internal" else "user"', '"range" else "generated"'): + '`SuperlevelBar, `OrdinaryH0, `OrdinaryH0Controls, `TorusFiltration', 'CENSUS_END', '"internal" else "user"', + '"range" else "generated"'): self.assertIn(needed, census) - self.assertIn('#[`TorusTopology, `ClosedSuperlevel, `SuperlevelBar, `OrdinaryH0, `TorusFiltration]', census) + self.assertIn('#[`TorusTopology, `ClosedSuperlevel, `SuperlevelBar, `OrdinaryH0, `OrdinaryH0Controls, `TorusFiltration]', census) audit = (out / 'Audit.lean').read_text().splitlines() self.assertEqual(audit[0], 'import TorusFiltration') self.assertEqual(audit[1:], ['#print axioms ' + n for n in self.c.targets(meta)]) - self.assertEqual(len(audit[1:]), 109) + self.assertEqual(len(audit[1:]), 153) types = (out / 'Types.lean').read_text().splitlines() self.assertEqual(types[:2], ['import TorusFiltration', 'set_option pp.explicit true']) self.assertEqual(types[2:], ['#check ' + n for n in self.c.theorem_targets(meta)]) @@ -785,24 +903,45 @@ def test_emit_writes_exactly_the_audit_types_positive_and_controls(self): self.assertEqual(set(self.c.FALSE_CONTROLS) | set(self.c.INJECTIONS), set(self.c.CONTROLS)) self.assertGreaterEqual(len(self.c.FALSE_CONTROLS), 1) # One false control per module at least, each naming one of that module's own definitions (the C26x controls - # name superlevelBar_deathHeight and ordinaryH0_pointClass); none of them is proved by a hypothesis-free `rfl`. + # name superlevelBar_deathHeight and ordinaryH0_pointClass, the item-4 controls the fixtures of OrdinaryH0Controls); + # none of them is proved by a hypothesis-free `rfl`. + item4 = ('RejectMergerKillsPointClass', 'RejectSeparationWithoutNonzeroCoeff', 'RejectNonmergerKillsDifference') for prefix, names in (('superlevel_', ('RejectSuperlevelSignFlip', 'RejectSuperlevelBelowThreshold')), ('torus_', ('RejectConstantNotPeriodic',)), ('superlevelBar_', ('RejectEssentialDeathBound',)), - ('ordinaryH0_', ('RejectReducedPointClass',))): + ('ordinaryH0_', ('RejectReducedPointClass',) + item4), ('ordinaryH0Control_', item4)): for name in names: self.assertIn(prefix, self.c.FALSE_CONTROLS[name][0], name) + # The item-4 controls, exactly: each tactic rewrites with the true fixture theorem the statement contradicts. + self.assertEqual(self.c.FALSE_CONTROLS['RejectMergerKillsPointClass'], ( + 'CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff true) ' + '(((AlgebraicTopology.singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map ordinaryH0Control_collapse) = 0', + 'simp only [ordinaryH0Control_collapse_image_ne_zero]')) + self.assertEqual(self.c.FALSE_CONTROLS['RejectSeparationWithoutNonzeroCoeff'], ( + 'ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff true ≠ ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_zeroCoeff false', + 'simp [ordinaryH0Control_bool_zeroCoeff_eq]')) + self.assertEqual(self.c.FALSE_CONTROLS['RejectNonmergerKillsDifference'], ( + 'CategoryTheory.CategoryStruct.comp (ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((true, false) : Bool × Bool) ' + '- ordinaryH0_pointClass (TopCat.of (Bool × Bool)) ordinaryH0Control_intCoeff ((false, true) : Bool × Bool)) ' + '(((AlgebraicTopology.singularHomologyFunctor (ModuleCat.{0} ℤ) 0).obj ordinaryH0Control_intCoeff).map ordinaryH0Control_fst) = 0', + 'simp only [ordinaryH0Control_fst_difference_ne_zero]')) + for name in item4: + lemma = self.c.FALSE_CONTROLS[name][1].split('[')[1].rstrip(']') + self.assertIn(lemma, INVENTORY['OrdinaryH0Controls']['theorem'], name) self.assertEqual(self.c.FALSE_CONTROLS['RejectEssentialDeathBound'], ('superlevelBar_deathHeight (fun _ : superlevelBar_E 1 => (-1 : ℝ)) 0 ≤ (-1 : ℝ)', 'norm_num [superlevelBar_death_const]')) self.assertEqual(self.c.FALSE_CONTROLS['RejectReducedPointClass'][1], 'simp [ordinaryH0_pointClass_augmentation]') self.assertIn('ordinaryH0_pointClass (TopCat.of Unit) (ModuleCat.of ℤ ℤ) ()', self.c.FALSE_CONTROLS['RejectReducedPointClass'][0]) self.assertIn('≠ CategoryTheory.CategoryStruct.id (ModuleCat.of ℤ ℤ)', self.c.FALSE_CONTROLS['RejectReducedPointClass'][0]) self.assertEqual(list(self.c.CONTROLS), ['RejectSuperlevelSignFlip', 'RejectSuperlevelBelowThreshold', 'RejectConstantNotPeriodic', - 'RejectEssentialDeathBound', 'RejectReducedPointClass', 'RejectSorry', 'RejectCustomAxiom', - 'RejectNativeDecide']) - self.assertEqual(len(self.c.EVIDENCE_FILES), 54) + 'RejectEssentialDeathBound', 'RejectReducedPointClass', 'RejectMergerKillsPointClass', + 'RejectSeparationWithoutNonzeroCoeff', 'RejectNonmergerKillsDifference', 'RejectSorry', + 'RejectCustomAxiom', 'RejectNativeDecide']) + self.assertEqual(len(self.c.EVIDENCE_FILES), 65) self.assertEqual(self.c.BUILDS, ('build-TorusTopology', 'build-ClosedSuperlevel', 'build-SuperlevelBar', 'build-OrdinaryH0', - 'build-TorusFiltration', 'positive', 'axioms', 'types', 'census', 'leanchecker')) - self.assertEqual(self.c.ROOT_SOURCE, 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\n') + 'build-OrdinaryH0Controls', 'build-TorusFiltration', 'positive', 'axioms', 'types', 'census', + 'leanchecker')) + self.assertEqual(self.c.ROOT_SOURCE, 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\n' + 'import OrdinaryH0Controls\n') self.assertEqual({v[1] for v in self.c.INJECTIONS.values()}, {'sorryAx', 'hiddenPremise', 'injected._native.native_decide.ax_1_1'}) self.assertTrue(all(re.fullmatch(self.c.NAME, v[1]) and v[1] not in self.c.ALLOWED for v in self.c.INJECTIONS.values())) @@ -868,15 +1007,16 @@ def test_replay_contract(self): 'set -euo pipefail\n# The outer Python mode is the one named on each command line below, never an ambient PYTHONOPTIMIZE (C262 G1).\nunset PYTHONOPTIMIZE\n'): self.assertIn(required, self.replay, required) positions = [] - for module in ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0', 'TorusFiltration'): + for module in ('TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0', 'OrdinaryH0Controls', 'TorusFiltration'): line = ('run_lean build-%s lean -DwarningAsError=true --root="$TORUS_SIDE" -o "$TORUS_SIDE/%s.olean" "$TORUS_SIDE/%s.lean"' % (module, module, module)) self.assertEqual(self.replay.count(line), 1, module) positions.append(self.replay.index(line)) - # dependency order: TorusTopology, ClosedSuperlevel, SuperlevelBar, OrdinaryH0 (imports ClosedSuperlevel), then the root + # dependency order: TorusTopology, ClosedSuperlevel, SuperlevelBar, OrdinaryH0 (imports ClosedSuperlevel), + # OrdinaryH0Controls (imports OrdinaryH0), then the root self.assertEqual(positions, sorted(positions)) self.assertLess(positions[-1], self.replay.index('run_lean positive')) - self.assertEqual(len(re.findall(r'^run_lean build-', self.replay, re.M)), 5) + self.assertEqual(len(re.findall(r'^run_lean build-', self.replay, re.M)), 6) commands = '\n'.join(line for line in self.replay.splitlines() if not line.lstrip().startswith('#')) for forbidden in ('gate.py', 'formal/tests', 'lake build', 'lake update', 'lake exe cache', 'formal-evidence', 'ResearchFormalCoreR1'): @@ -910,9 +1050,29 @@ def test_documents_keep_the_status_vocabulary(self): # C263/C264 registration: handoff and successor identities, the fixes, the census, FORMAL HOLD 'd74dc8b2', '346eea94', '261dd052', '3d6b0d6b', 'ite_eq_left', '6113438262', '6113033545', '6113372506', '25 = 24 + 0 + 1', '38 = 27 + 0 + 11', 'FORMAL HOLD', 'superlevelBar_', 'ordinaryH0_', - 'nonauthor exact-source review'): + 'nonauthor exact-source review', + # C264 item-4 controls: the owner module, its identity, census, task and specification, the + # three controls, and the time-scoped pointers to the review and the readback (no label moves) + 'OrdinaryH0Controls', 'df9d3645', '48 = 44 + 0 + 4', 'ordinaryH0Control_', '6113277485', + '6113277173', 'RejectMergerKillsPointClass', 'RejectSeparationWithoutNonzeroCoeff', + 'RejectNonmergerKillsDifference', '5485883117', '5485829137', '2026-10-12 01:32Z', + 'C264 owner task item 4 controls (2026-10-12)', 'not a review', + # FORMAL HOLD rests on the handoffs' own listed conditions; the source-scoped review keeps + # Lean execution open and states no credit; the readback records credit 0 + '6113277485 item 5', 'open condition', 'same project account', 'nonzero organizational-independence credit'): self.assertIn(required, text, name + ' lacks ' + required) + flat = ' '.join(text.split()) + for stale in ( + # the hold presented as tied to one review that now exists (fix round of the item-4 commit) + 'The handoffs tied that hold', 'The handoffs tied it to', 'the handoffs tied to a nonauthor', + 'since 2026-10-12 01:32Z one does', 'Until 2026-10-12 01:32Z no nonauthor review of the compiled', + 'this README records none since', 'records none since', 'beyond the discrete cases', + 'Each statement applies one of the C264', 'instantiates the C264 statements', + 'concrete instances of those C264 statements', + 'so that each statement is seen in use'): + self.assertNotIn(stale, flat, name + ' keeps a corrected statement: ' + stale) self.assertNotIn(LEANCHECKER_MODULES_BEFORE_C26X + '`', text, name + ' still names the pre-registration leanchecker command as current') + self.assertNotIn(LEANCHECKER_MODULES_BEFORE_CONTROLS + '`', text, name + ' still names the pre-controls leanchecker command as current') self.assertNotIn('`leanchecker --fresh` re-checked', text, name + ' describes the withdrawn --fresh step as run') self.assertNotIn('runs `leanchecker --fresh TorusFiltration`', text) prose = re.sub(r'`[^`\n]*`', '', text) @@ -929,14 +1089,23 @@ def test_documents_keep_the_status_vocabulary(self): for statement, _ in self.c.FALSE_CONTROLS.values(): self.assertIn('`' + statement + '`', readme, 'control statement not quoted verbatim: ' + statement) for required in ('.olean', 'never be committed', 'NOT_RUN', 'TORUS_LEANCHECKER_FRESH', 'leanchecker.cmd', - 'exactly the 54 evidence files', 'Registration is not review'): + 'exactly the 65 evidence files', 'Registration is not review', 'OrdinaryH0Controls.olean', + '6116225936', 'C254 alone did not establish this', 'DISCRIMINATOR_LOGS', + # the relabel is a dated companion note, the hosted run of 940dffc9 is reported, not adopted + '(companion note, 2026-10-12, Math- #428 comment 6116225936, not\n part of the copied exclusion', + '38187870416', 'does not adopt its receipt', '01:16Z'): self.assertIn(required, readme, 'README lacks ' + required) for stale in ('exactly the 44 evidence files', 'those 44 files', '41 theorems and 17 definitions', 'the 58 declarations', - 'two-line root module', 'six negative', 'Both modules `import Mathlib`'): - self.assertNotIn(stale, readme, 'README keeps a pre-registration count: ' + stale) + 'two-line root module', 'six negative', 'Both modules `import Mathlib`', + # counts and phrases the item-4 controls commit moved + 'exactly the 54 evidence files', 'those 54 files', 'What the 81 theorems and 28 definitions', + 'Every one of the 109', 'four-line root module', 'the twelve emitted Lean files', + 'All four modules `import Mathlib`', '(none exists: this lane', 'no nonauthor review of the compiled successor\nbytes yet'): + self.assertNotIn(stale, readme, 'README keeps a superseded count or statement: ' + stale) scope = (SIDE / 'SCOPE.md').read_text(encoding='utf-8') - for stale in ('41 theorem statements and 17 audited definitions', 'these 58 declarations', 'exactly these 58'): - self.assertNotIn(stale, scope, 'SCOPE keeps a pre-registration count: ' + stale) + for stale in ('41 theorem statements and 17 audited definitions', 'these 58 declarations', 'exactly these 58', + '81 theorem statements and 28 audited definitions', 'these 109 declarations', 'exactly these 109'): + self.assertNotIn(stale, scope, 'SCOPE keeps a superseded count: ' + stale) class SourceFixture(FixtureCase): @@ -948,11 +1117,11 @@ def test_clean_fixture_passes_and_records_identity(self): result = json.loads(run.stdout) self.assertEqual(result['checked_commit'], f.git('rev-parse', 'HEAD').strip()) self.assertEqual(set(result['sources']), set(self.c.REQUIRED_FILES) | {self.c.PACKAGE + '/SOURCE_FILES.json'}) - self.assertEqual(len(result['declarations']), 109) + self.assertEqual(len(result['declarations']), 153) self.assertEqual(result['environment'], {'lean_toolchain': 'leanprover/lean4:v4.34.1', 'dependency_revisions': f.revisions}) self.assertEqual(result['run_id'], 'local') - self.assertEqual(len(result['theorems']), 81) + self.assertEqual(len(result['theorems']), 118) hosted = {'GITHUB_ACTIONS': 'true', 'GITHUB_SHA': result['checked_commit'], 'GITHUB_REPOSITORY': self.c.REPO, 'GITHUB_RUN_ID': '77', 'GITHUB_RUN_ATTEMPT': '2'} run = f.run('source', env=hosted) @@ -1047,15 +1216,18 @@ def test_module_mutations_are_detected(self): self.assertEqual(f.run('source').returncode, 0) (f.side / 'TorusFiltration.lean').write_text('import TorusTopology\n') f.restore() - self.assertFails(f.run('source'), 'root module must import exactly the four modules') - # the pre-registration root (two imports) is refused too; so is a reordered or duplicated import list + self.assertFails(f.run('source'), 'root module must import exactly the five modules') + # the pre-registration root (two imports) and the pre-controls root (four imports) are refused too; so is a + # reordered, duplicated or unterminated import list for root in ('import TorusTopology\nimport ClosedSuperlevel\n', - 'import TorusTopology\nimport ClosedSuperlevel\nimport OrdinaryH0\nimport SuperlevelBar\n', - 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\nimport OrdinaryH0\n', - 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0'): + 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\n', + 'import TorusTopology\nimport ClosedSuperlevel\nimport OrdinaryH0\nimport SuperlevelBar\nimport OrdinaryH0Controls\n', + 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0Controls\nimport OrdinaryH0\n', + 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\nimport OrdinaryH0Controls\nimport OrdinaryH0Controls\n', + 'import TorusTopology\nimport ClosedSuperlevel\nimport SuperlevelBar\nimport OrdinaryH0\nimport OrdinaryH0Controls'): (f.side / 'TorusFiltration.lean').write_text(root) f.restore() - self.assertFails(f.run('source'), 'root module must import exactly the four modules') + self.assertFails(f.run('source'), 'root module must import exactly the five modules') (f.side / 'TorusFiltration.lean').write_text(self.c.ROOT_SOURCE) # companion imports through the CLI: OrdinaryH0 may import ClosedSuperlevel (as the registered module does); # ClosedSuperlevel may not import SuperlevelBar, and no module may import the root @@ -1068,6 +1240,17 @@ def test_module_mutations_are_detected(self): f.restore() self.assertFails(f.run('source'), 'unexpected column-0 line in OrdinaryH0:2: import TorusFiltration') h0.write_text(h0_original) + # the controls module may import OrdinaryH0 (as the registered module does); OrdinaryH0 may not import it + controls = f.side / 'OrdinaryH0Controls.lean' + controls_original = controls.read_text() + controls.write_text(controls_original.replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0\n', 1)) + f.restore() + self.assertEqual(f.run('source').returncode, 0, 'the controls module importing OrdinaryH0 is source') + controls.write_text(controls_original) + h0.write_text(h0_original.replace('import Mathlib\n', 'import Mathlib\nimport OrdinaryH0Controls\n', 1)) + f.restore() + self.assertFails(f.run('source'), 'companion import out of dependency order in OrdinaryH0:2: OrdinaryH0Controls') + h0.write_text(h0_original) module.write_text(original.replace('import Mathlib\n', 'import Mathlib\nimport SuperlevelBar\n', 1)) f.restore() self.assertFails(f.run('source'), 'companion import out of dependency order in ClosedSuperlevel:2: SuperlevelBar') @@ -1103,7 +1286,9 @@ def test_environment_pins_are_enforced(self): class MetadataFixture(FixtureCase): """The honesty labels and schema rules of SOURCE_FILES.json are enforced through the CLI, one field at a time, except seven fields of the successor record (handoff byte count and status, lane, authors, namespace, imports, - change summary), which are refused only through the whole-record comparison in check.py metadata().""" + change summary), which are refused only through the whole-record comparison in check.py metadata(). The owner-module + record of OrdinaryH0Controls is compared whole too; its identity, author, review status, census, credit, comment + pointers and kind each have a single-field case below, and the record as a whole is required.""" def test_each_label_and_schema_rule_withholds_source(self): c = self.c @@ -1144,6 +1329,22 @@ def mutate(m): (deleter(('provenance', 'successors', 'OrdinaryH0.lean', 'comments', 'owner_repair_handoff_428')), 'successor provenance identity'), (deleter(('provenance', 'successors', 'OrdinaryH0.lean')), 'successor provenance identity'), (setter(('provenance', 'successors', 'Third.lean'), {}), 'successor provenance identity'), + # the owner-authored controls record (OrdinaryH0Controls.lean), compared whole + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'sha256'), '0' * 64), 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'bytes'), 28503), 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'author'), 'OpenAI/Codex lane'), 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'kind'), 'handoff successor'), 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'review_status'), 'review of OrdinaryH0; FORMAL HOLD lifted'), + 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'organizational_independence_credit'), 1), 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'census_at_pin'), '44 constants'), 'owner module provenance identity'), + (deleter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'comments', 'owner_task_item_4_428')), 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean', 'formal_status'), 'ACCEPTED'), 'owner module provenance identity'), + (deleter(('provenance', 'owner_modules', 'OrdinaryH0Controls.lean')), 'owner module provenance identity'), + (setter(('provenance', 'owner_modules', 'Other.lean'), {}), 'owner module provenance identity'), + (lambda m: m['provenance']['successors'].__setitem__('OrdinaryH0Controls.lean', m['provenance']['owner_modules']['OrdinaryH0Controls.lean']), + 'successor provenance identity'), + (deleter(('provenance', 'owner_modules')), 'provenance key missing: owner_modules'), (deleter(('provenance', 'successors')), 'provenance key missing: successors'), (deleter(('provenance', 'original_bytes')), 'provenance key missing: original_bytes'), (setter(('provenance', 'original_sha256', 'C263-handoff/SuperlevelBar.lean'), '0' * 64), 'provenance identity'), @@ -1173,6 +1374,12 @@ def mutate(m): (setter(('modules',), ['ClosedSuperlevel', 'TorusTopology']), 'module list'), (setter(('modules',), ['TorusTopology', 'ClosedSuperlevel']), 'module list'), (setter(('modules',), ['TorusTopology', 'ClosedSuperlevel', 'OrdinaryH0', 'SuperlevelBar']), 'module list'), + (setter(('modules',), ['TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0']), 'module list'), + (setter(('modules',), ['TorusTopology', 'ClosedSuperlevel', 'SuperlevelBar', 'OrdinaryH0Controls', 'OrdinaryH0']), 'module list'), + (deleter(('theorems', 'OrdinaryH0Controls')), 'per-module inventory keys'), + (deleter(('definitions', 'OrdinaryH0Controls')), 'per-module inventory keys'), + (lambda m: m['theorems']['OrdinaryH0Controls'].append('ordinaryH0_pointClass_eq_iff'), 'duplicate declaration name'), + (setter(('theorems', 'OrdinaryH0Controls'), []), 'empty theorem list: OrdinaryH0Controls'), (deleter(('theorems', 'OrdinaryH0')), 'per-module inventory keys'), (deleter(('definitions', 'SuperlevelBar')), 'per-module inventory keys'), (lambda m: m['theorems']['OrdinaryH0'].append('superlevelBar_strict_cut'), 'duplicate declaration name'), @@ -1221,11 +1428,12 @@ def test_complete_evidence_yields_a_bounded_receipt(self): self.assertIs(receipt['scientific_acceptance'], False) self.assertEqual(receipt['lean_version'], LEAN_VERSION_LINE.strip()) self.assertEqual(receipt['dependency_revisions'], f.revisions) - self.assertEqual(len(receipt['declarations']), 109) - self.assertEqual(len(receipt['axioms']), 58 + 24 + 27) - self.assertEqual(receipt['theorem_count'], 81) - self.assertEqual(receipt['definition_count'], {'abbrev': 3, 'def': 22, 'instance': 3}) + self.assertEqual(len(receipt['declarations']), 153) + self.assertEqual(len(receipt['axioms']), 58 + 24 + 27 + 44) + self.assertEqual(receipt['theorem_count'], 118) + self.assertEqual(receipt['definition_count'], {'abbrev': 6, 'def': 26, 'instance': 3}) self.assertEqual(receipt['provenance']['successors'], self.c.SUCCESSORS) + self.assertEqual(receipt['provenance']['owner_modules'], self.c.OWNER_MODULES) self.assertEqual(receipt['provenance']['original_bytes'], self.c.ORIGINAL_BYTES) self.assertEqual(len(receipt['provenance']['original_sha256']), 4) self.assertEqual(receipt['negative_controls'], @@ -1240,18 +1448,21 @@ def test_complete_evidence_yields_a_bounded_receipt(self): self.assertEqual(hashlib.sha256((out / name).read_bytes()).hexdigest(), digest, name) self.assertEqual(set(receipt['log_sha256']), {p.name for p in out.iterdir() if p.is_file()} - {'receipt.json'}) self.assertEqual(set(receipt['log_sha256']), set(self.c.EVIDENCE_FILES)) - self.assertEqual(len(receipt['log_sha256']), 54) - self.assertEqual(receipt['census'], {'constants': 109 + len(self.c.metadata()['census_auxiliary']) + len(INTERNAL_GENERATED), - 'user_declarations': 109, + self.assertEqual(len(receipt['log_sha256']), 65) + self.assertEqual(receipt['census'], {'constants': 153 + len(self.c.metadata()['census_auxiliary']) + len(INTERNAL_GENERATED), + 'user_declarations': 153, 'generated_user': sorted(self.c.metadata()['census_auxiliary']), 'internal_generated': len(INTERNAL_GENERATED)}) self.assertIn('census.log', receipt['log_sha256']) self.assertIn('axioms.log', receipt['log_sha256']) - for name in ('build-SuperlevelBar', 'build-OrdinaryH0', 'RejectEssentialDeathBound', 'RejectReducedPointClass'): + for name in ('build-SuperlevelBar', 'build-OrdinaryH0', 'build-OrdinaryH0Controls', 'RejectEssentialDeathBound', + 'RejectReducedPointClass', 'RejectMergerKillsPointClass', 'RejectSeparationWithoutNonzeroCoeff', + 'RejectNonmergerKillsDifference'): self.assertIn(name + '.log', receipt['log_sha256']) self.assertIn(name + '.status', receipt['log_sha256']) - self.assertIn('RejectEssentialDeathBound.lean', receipt['log_sha256']) - self.assertIn('RejectReducedPointClass.lean', receipt['log_sha256']) + for name in ('RejectEssentialDeathBound', 'RejectReducedPointClass', 'RejectMergerKillsPointClass', + 'RejectSeparationWithoutNonzeroCoeff', 'RejectNonmergerKillsDifference'): + self.assertIn(name + '.lean', receipt['log_sha256']) self.assertIn('leanchecker.cmd', receipt['log_sha256']) self.assertIn('Positive.lean', receipt['log_sha256']) self.assertIn('tests-optimized.log', receipt['log_sha256']) @@ -1297,7 +1508,9 @@ def census_without(name): ('build-TorusTopology.status', '1\n', 'missing successful process: build-TorusTopology'), ('build-SuperlevelBar.status', '1\n', 'missing successful process: build-SuperlevelBar'), ('build-OrdinaryH0.status', '', 'missing successful process: build-OrdinaryH0'), + ('build-OrdinaryH0Controls.status', '1\n', 'missing successful process: build-OrdinaryH0Controls'), ('leanchecker.cmd', LEANCHECKER_MODULES_BEFORE_C26X + '\n', "unrecognized leanchecker invocation: '" + LEANCHECKER_MODULES_BEFORE_C26X + "'"), + ('leanchecker.cmd', LEANCHECKER_MODULES_BEFORE_CONTROLS + '\n', "unrecognized leanchecker invocation: '" + LEANCHECKER_MODULES_BEFORE_CONTROLS + "'"), ('leanchecker.status', '', 'missing successful process: leanchecker'), ('leanchecker.cmd', 'leanchecker TorusFiltration\n', "unrecognized leanchecker invocation: 'leanchecker TorusFiltration'"), ('leanchecker.cmd', 'leanchecker --fresh TorusTopology\n', 'unrecognized leanchecker invocation'), @@ -1317,6 +1530,9 @@ def census_without(name): ('census.log', census_with(('TorusFiltration.superlevel_mono._hidden', 'internal range')), "user-written declarations with internal-style names: ['TorusFiltration.superlevel_mono._hidden']"), ('census.log', census_with(('TorusFiltration.superlevel_mono.other_simp', 'user generated')), "compiler-generated constants not listed in census_auxiliary: ['TorusFiltration.superlevel_mono.other_simp']"), ('census.log', census_without('TorusFiltration.superlevel_mono'), "inventory targets absent from the census: ['TorusFiltration.superlevel_mono']"), + ('census.log', census_without('TorusFiltration.ordinaryH0Control_collapse'), "inventory targets absent from the census: ['TorusFiltration.ordinaryH0Control_collapse']"), + ('census.log', census_with(('TorusFiltration.ordinaryH0Control_collapse.hidden', 'user range')), + "user-written declarations outside the inventory: ['TorusFiltration.ordinaryH0Control_collapse.hidden']"), ('census.log', census_without('TorusFiltration.torus_periodBasis.congr_simp'), "census_auxiliary entries absent or not compiler-generated: ['TorusFiltration.torus_periodBasis.congr_simp']"), ('census.log', (out / 'census.log').read_text().replace('TorusFiltration.torus_periodBasis.congr_simp user generated', 'TorusFiltration.torus_periodBasis.congr_simp user range'), "user-written declarations outside the inventory: ['TorusFiltration.torus_periodBasis.congr_simp']"), @@ -1335,6 +1551,19 @@ def census_without(name): ('RejectReducedPointClass.log', FALSE_LOG.format('RejectReducedPointClass') + 'error: This simp argument is unused\n', 'not the intended False-goal diagnostic: RejectReducedPointClass'), ('RejectReducedPointClass.status', '2\n', 'false-statement control must exit exactly one'), + # the item-4 controls: each true sibling's diagnostic (pinned from Lean, DISCRIMINATOR_LOGS) is refused + ('RejectMergerKillsPointClass.log', DISCRIMINATOR_LOGS['RejectMergerKillsPointClass'], + 'not the intended False-goal diagnostic: RejectMergerKillsPointClass'), + ('RejectSeparationWithoutNonzeroCoeff.log', DISCRIMINATOR_LOGS['RejectSeparationWithoutNonzeroCoeff'], + 'not the intended False-goal diagnostic: RejectSeparationWithoutNonzeroCoeff'), + ('RejectNonmergerKillsDifference.log', DISCRIMINATOR_LOGS['RejectNonmergerKillsDifference'], + 'not the intended False-goal diagnostic: RejectNonmergerKillsDifference'), + ('RejectNonmergerKillsDifference.status', '0\n', 'false-statement control must exit exactly one'), + ('RejectMergerKillsPointClass.lean', (out / 'RejectMergerKillsPointClass.lean').read_text().replace(' true)', ' true - ' + 'ordinaryH0_pointClass (TopCat.of Bool) ordinaryH0Control_intCoeff false)', 1), + 'emitted Lean file changed across execution: RejectMergerKillsPointClass.lean'), + ('RejectSeparationWithoutNonzeroCoeff.lean', (out / 'RejectSeparationWithoutNonzeroCoeff.lean').read_text().replace('zeroCoeff', 'intCoeff'), + 'emitted Lean file changed across execution: RejectSeparationWithoutNonzeroCoeff.lean'), ('RejectSorry.status', '1\n', 'injection control must be accepted by Lean'), ('RejectSorry.log', SORRY_WARNING + INJECTED.format('propext'), 'not the intended injected axiom report'), ('RejectNativeDecide.log', INJECTED.format('sorryAx'), 'not the intended injected axiom report'), @@ -1350,7 +1579,9 @@ def census_without(name): 'emitted Lean file changed across execution: RejectConstantNotPeriodic.lean'), ('RejectReducedPointClass.lean', (out / 'RejectReducedPointClass.lean').read_text().replace('≠', '='), 'emitted Lean file changed across execution: RejectReducedPointClass.lean'), - ('Census.lean', (out / 'Census.lean').read_text().replace(', `OrdinaryH0', ''), + ('Census.lean', (out / 'Census.lean').read_text().replace(', `OrdinaryH0,', ','), + 'emitted Lean file changed across execution: Census.lean'), + ('Census.lean', (out / 'Census.lean').read_text().replace(', `OrdinaryH0Controls', ''), 'emitted Lean file changed across execution: Census.lean')] for name, content, message in cases: with self.subTest(name=name, message=message): @@ -1361,7 +1592,7 @@ def census_without(name): self.assertFalse((out / 'receipt.json').exists(), 'receipt written despite refusal') finally: (out / name).write_text(saved) - # C262 G3: every one of the 54 required evidence members is required; removing any one withholds the receipt. + # C262 G3: every one of the 65 required evidence members is required; removing any one withholds the receipt. self.assertEqual({p.name for p in out.iterdir()}, set(self.c.EVIDENCE_FILES)) for name in sorted(self.c.EVIDENCE_FILES): with self.subTest(removed=name):