From 7d8a06a33d23f92c944dcaed51fe414312a4aa94 Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" Date: Mon, 9 Nov 2026 13:50:11 +0000 Subject: [PATCH 1/3] =?UTF-8?q?feat(resource):=20HubCeiling=20=E2=80=94=20?= =?UTF-8?q?hub=20ceilings,=20reach=20grades,=20weighted=20residue=20measur?= =?UTF-8?q?e=20(squeakwell=20R5=E2=80=93R7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New module Resource/HubCeiling.lean, parametric over the ResourceAlgebra interface, serving hyperpolymath/squeakwell's proof ladder: - R6 hub ceiling, element form: when the unit is the top of the order (OneTop, true at MinPlus and MinMax, refuted at MaxPlus by maxplus_not_one_top) every factor bounds the product (factor_le, factor_le_right); with absorption and idempotence this lifts to joins and generalised sums (zero_bot, join_bound, lsum_bound), to matrix products (matMul_row_bound, single_hub_ceiling) and, only under an explicit IsStar fixed-point hypothesis, to closures (single_hub_star_ceiling). TropicalAdapterPath.hub_ceiling is over List TransportClass and does not transfer literally; this is the algebraic kernel that does. - R7 reach grade: reachGrade A S m, the ⊞-sum of closure entries over an observed Bool set; monotone in the matrix (reachGrade_mono_mat) and in the observed set (reachGrade_mono_set, via the new lsum_filter_mono); an observed node has the full grade (one_le_reachGrade). - R5 weightedResidueMeasure w : ResidueMeasure (List M) R for ANY resource algebra (free-monoid homomorphism; only one_mul and mul_assoc used); the existing max-plus event counter is the constant-weight instance (weighted_counts_events). List M stays an opaque residue carrier. Wired into the Resource aggregator and the lean.yml axiom audit; PROOF-STATUS updated. Verified here: lake build (Lean 4.35.0, 21/21), #print axioms on every new headline shows propext/Quot.sound only. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01J4QvDizuhJtQDcxHxM2wj8 --- .github/workflows/lean.yml | 10 + PROOF-STATUS.adoc | 7 +- Resource.lean | 7 + Resource/HubCeiling.lean | 372 +++++++++++++++++++++++++++++++++++++ 4 files changed, 394 insertions(+), 2 deletions(-) create mode 100644 Resource/HubCeiling.lean diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index 6549508..7a81935 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -71,6 +71,16 @@ jobs: #print axioms Resource.Bridge.grade_le_sequential #print axioms Resource.Bridge.hub_ceiling_le #print axioms Resource.Bridge.embed_tcZero_ne_zero + -- HubCeiling: squeakwell R5–R7 (hub ceiling, reach grade, weighted residue measure) + #print axioms Resource.HubCeiling.factor_le + #print axioms Resource.HubCeiling.single_hub_ceiling + #print axioms Resource.HubCeiling.single_hub_star_ceiling + #print axioms Resource.HubCeiling.lsum_filter_mono + #print axioms Resource.HubCeiling.reachGrade_mono_mat + #print axioms Resource.HubCeiling.reachGrade_mono_set + #print axioms Resource.HubCeiling.one_le_reachGrade + #print axioms Resource.HubCeiling.weightedResidueMeasure + #print axioms Resource.HubCeiling.Witness.maxplus_not_one_top EOF out="$(lake env lean /tmp/axcheck.lean 2>&1)" echo "$out" diff --git a/PROOF-STATUS.adoc b/PROOF-STATUS.adoc index b6bc24c..a32d951 100644 --- a/PROOF-STATUS.adoc +++ b/PROOF-STATUS.adoc @@ -12,7 +12,7 @@ type-checked in this environment from what is CI-gated but not re-checked here. * Toolchain: **Lean 4 v4.35.0** (pinned in `lean-toolchain`), *no Mathlib* dependency (pure core Lean 4). * Command: `lake build` after `rm -rf .lake/build` (clean rebuild). -* Result: **Build completed successfully — 20/20 targets**, i.e. every Lean +* Result: **Build completed successfully — 21/21 targets** (2026-11-09, with `HubCeiling`), i.e. every Lean module type-checks. Modules (libs `Tropical` + `Resource`): @@ -22,7 +22,10 @@ Modules (libs `Tropical` + `Resource`): * `Resource.lean` aggregator + `Resource/Algebra/{Interface,Ordered,Dioid,ParametricLaws}.lean` (the ordered-semiring / resource-algebra interface + parametric transport theorem). * `Resource/Instances/{MaxPlus,MinPlus,MinMax,Linear,Affine}.lean` (concrete semirings). -* `Resource/{Bridge,Closure,Conformance,Stress,EchoBridge}.lean`. +* `Resource/{Bridge,Closure,Conformance,Stress,EchoBridge,HubCeiling}.lean` + (`HubCeiling` added 2026-11-09: hub ceilings, reach grades, weighted residue + measure for `hyperpolymath/squeakwell` rungs R5–R7; built here with + `lake build`, axiom audit `propext`/`Quot.sound` only, no `sorry`). Reproduce: [source,sh] diff --git a/Resource.lean b/Resource.lean index 11d5337..65ebf1c 100644 --- a/Resource.lean +++ b/Resource.lean @@ -14,6 +14,7 @@ import Resource.EchoBridge import Resource.Conformance import Resource.Bridge import Resource.Closure +import Resource.HubCeiling /-! # `Resource` — the resource-grade axis (aggregator) @@ -61,4 +62,10 @@ import Resource.Closure bottleneck). The `EntryBounded` / `AllPairsCosts` certificate and `matStar` monotonicity mirror `typed-wasm`'s Idris `Tropical.idr` onto the axis. + * `Resource.HubCeiling` — hub ceilings (`factor_le`, `single_hub_ceiling`, + `single_hub_star_ceiling` under an explicit `IsStar`), + reach grades over an observed set (`reachGrade`, + monotone in matrix and set; `one ⊑` on observed nodes), + and the generic `weightedResidueMeasure`. Serves + `hyperpolymath/squeakwell` rungs R5–R7. -/ diff --git a/Resource/HubCeiling.lean b/Resource/HubCeiling.lean new file mode 100644 index 0000000..a874f3b --- /dev/null +++ b/Resource/HubCeiling.lean @@ -0,0 +1,372 @@ +-- SPDX-License-Identifier: MPL-2.0 +-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +import Resource.Closure +import Resource.EchoBridge + +/-! + # Resource Algebra — hub ceilings, reach grades and weighted residue measures + + Author: Jonathan D.A. Jewell (hyperpolymath) + Verified: Lean 4.35.0 (pinned via `lean-toolchain`), `import Init` only (no + Mathlib). + + ## Why this module exists + + `hyperpolymath/squeakwell` (database recovery through cross-modal constraint + propagation on VeriSimDB) reads a modality's *reachability* through the + regeneration graph as a tropical grade: a recovered modality is only as good + as the worst hop that produced it. Its route plan (section 6, rungs R5–R7) + asks this axis for three things, each stated against the abstract + `ResourceAlgebra` interface so every tropical instance inherits it: + + * **R6 — hub ceiling, element form.** `TropicalAdapterPath.hub_ceiling` is a + statement about `List TransportClass` paths and does not transfer to the + matrix closure literally. The algebraic kernel does: when the + multiplicative unit is the **top** of the order (`∀ a, a ⊑ one` — true for + `MinPlus` and `MinMax`, false for `MaxPlus`), every factor bounds the + product: `a ⊠ b ⊑ a` and `a ⊠ b ⊑ b` (`factor_le`, `factor_le_right`). + With dioid absorption and idempotence this lifts to joins and to the + generalised sum (`join_bound`, `lsum_bound`), and then to matrix products + (`matMul_row_bound`, `single_hub_ceiling`). The *star* corollary + (`single_hub_star_ceiling`) is stated only under an explicit `IsStar` + hypothesis — the Kleene fixed-point equation `S = I ⊞ A ⊠ S` — because the + repository has no walk semantics for `matStar` in Lean; that larger item is + not on squeakwell's critical path. + * **R7 — reach grade.** `reachGrade A S m` is the `⊞`-sum of the closure + entries `A* k m` over the OBSERVED set `S` (a `Bool` predicate on nodes): + "how well can `m` be reached from what was actually observed". Proved: + monotone in the matrix (`reachGrade_mono_mat`), monotone in the observed + set (`reachGrade_mono_set`, via the new `lsum_filter_mono`), and an + observed modality has the full grade (`one_le_reachGrade`: `one ⊑ + reachGrade A S m` whenever `S m = true`). + * **R5 — weighted residue measure.** The generic free-monoid homomorphism + `weightedResidueMeasure w : ResidueMeasure (List M) R`, sending a residue + list to the `⊠`-product of its per-event weights. Only `one_mul` and + `mul_assoc` are used, so it is a `ResidueMeasure` for EVERY resource + algebra; `echoResidueAsMaxPlusCost` is recovered as the constant-weight + instance. Residues stay opaque: nothing here makes `List M` a resource + algebra (the `EchoBridge` boundary invariant is preserved). + + ## Hypotheses are explicit + + Nothing here extends the `ResourceAlgebra` interface. `one_top`, `Absorb` + and idempotence are taken as hypotheses where needed and discharged for + `MinPlus` and `MinMax` in §6; `MaxPlus` is shown NOT to satisfy `one_top`, + which is why the hub ceiling is a bottleneck/least-cost fact and not a + general one. + + Proof-debt-clean: no incomplete-proof tactics, no axiom declarations. +-/ + +namespace Resource.HubCeiling + +open scoped Resource.ResourceSemiring Resource.ResourceAlgebra +open Resource.Closure + +variable {R : Type u} [Resource.ResourceAlgebra R] + +-- ============================================================================ +-- 1. Element-level hub ceiling (R6) +-- ============================================================================ + +/-- The multiplicative unit is the top of the order: every grade refines + `one`. Holds in `MinPlus` / `MinMax` (`one = val 0`, the best grade); fails + in `MaxPlus`. -/ +abbrev OneTop (R : Type u) [Resource.ResourceAlgebra R] : Prop := + ∀ a : R, a ⊑ (Resource.ResourceSemiring.one : R) + +/-- Idempotent choice: `a ⊞ a = a` (the dioid law). -/ +abbrev Idem (R : Type u) [Resource.ResourceAlgebra R] : Prop := + ∀ a : R, (a ⊞ a) = a + +/-- **Hub ceiling, left factor.** A composed grade is no better than its first + factor: one bad hop caps the whole route. -/ +theorem factor_le (htop : OneTop R) (a b : R) : (a ⊠ b) ⊑ a := by + have h := Resource.ResourceAlgebra.mul_le_mul_left b (Resource.ResourceSemiring.one : R) (htop b) a + rw [Resource.ResourceSemiring.mul_one] at h + exact h + +/-- **Hub ceiling, right factor.** -/ +theorem factor_le_right (htop : OneTop R) (a b : R) : (a ⊠ b) ⊑ b := by + have h := Resource.ResourceAlgebra.mul_le_mul_right a (Resource.ResourceSemiring.one : R) (htop a) b + rw [Resource.ResourceSemiring.one_mul] at h + exact h + +/-- Under absorption `zero` is the bottom of the order ("no route" is the worst + grade). -/ +theorem zero_bot (hab : Absorb R) (a : R) : (Resource.ResourceSemiring.zero : R) ⊑ a := by + have h := hab (Resource.ResourceSemiring.zero : R) a + rw [Resource.ResourceSemiring.zero_add] at h + exact h + +/-- A join of two grades below `c` stays below `c` (needs idempotence). -/ +theorem join_bound (idem : Idem R) {a b c : R} (ha : a ⊑ c) (hb : b ⊑ c) : (a ⊞ b) ⊑ c := by + have h := Resource.add_le_add ha hb + rw [idem c] at h + exact h + +/-- The generalised sum of grades all below `c` is below `c`. -/ +theorem lsum_bound (idem : Idem R) (hab : Absorb R) {c : R} : + ∀ {l : List R}, (∀ x ∈ l, x ⊑ c) → lsum l ⊑ c := by + intro l + induction l with + | nil => intro _; exact zero_bot hab c + | cons x xs ih => + intro h + rw [lsum_cons] + exact join_bound idem (h x (List.mem_cons_self)) (ih (fun y hy => h y (List.mem_cons_of_mem _ hy))) + +/-- Each product term of a matrix entry is bounded by its left factor, so the + whole entry is bounded by the `⊞`-sum of the left row. -/ +theorem matMul_row_bound (htop : OneTop R) {n : Nat} (A B : Mat n R) (i j : Fin n) : + matMul A B i j ⊑ lsum ((allFins n).map (fun k => A i k)) := by + unfold matMul + refine lsum_mono (allFins n) (fun k => A i k ⊠ B k j) (fun k => A i k) ?_ + intro k _ + exact factor_le htop _ _ + +/-- A node `i` whose only outgoing edge goes to the hub `h`. -/ +def SingleHub {n : Nat} (A : Mat n R) (i h : Fin n) : Prop := + ∀ k, k ≠ h → A i k = (Resource.ResourceSemiring.zero : R) + +/-- **Single-hub ceiling.** If every route out of `i` passes through the hub + `h`, then every composed route from `i` is capped by the hub edge. -/ +theorem single_hub_ceiling (htop : OneTop R) (idem : Idem R) (hab : Absorb R) + {n : Nat} (A B : Mat n R) {i h : Fin n} (hs : SingleHub A i h) (j : Fin n) : + matMul A B i j ⊑ A i h := by + unfold matMul + apply lsum_bound idem hab + intro x hx + rcases List.mem_map.mp hx with ⟨k, _, rfl⟩ + by_cases hk : k = h + · subst hk; exact factor_le htop _ _ + · rw [hs k hk, Resource.ResourceSemiring.zero_mul] + exact zero_bot hab _ + +/-- The Kleene fixed-point equation. `matStar` is one solution in the walk + semantics this repository does not yet formalise in Lean; the corollary + below therefore takes the equation as an explicit hypothesis. -/ +def IsStar {n : Nat} (A S : Mat n R) : Prop := + S = matAdd matId (matMul A S) + +/-- **Single-hub ceiling for a closure.** Under `IsStar`, every off-diagonal + closure entry out of a single-hub node is capped by the hub edge. -/ +theorem single_hub_star_ceiling (htop : OneTop R) (idem : Idem R) (hab : Absorb R) + {n : Nat} {A S : Mat n R} (hS : IsStar A S) {i h : Fin n} (hs : SingleHub A i h) + (j : Fin n) (hij : i ≠ j) : S i j ⊑ A i h := by + have hentry : S i j = (matId i j ⊞ matMul A S i j) := + congrFun (congrFun hS i) j + rw [hentry] + have hid : matId (R := R) i j = (Resource.ResourceSemiring.zero : R) := by + unfold matId; simp [hij] + rw [hid, Resource.ResourceSemiring.zero_add] + exact single_hub_ceiling htop idem hab A S hs j + +-- ============================================================================ +-- 2. Sums over filtered lists (the lemma R7 needs) +-- ============================================================================ + +/-- Enlarging the observed set can only improve the sum: under absorption, + `lsum` over the `S`-filtered list refines `lsum` over the `T`-filtered list + whenever `S ⊆ T`. -/ +theorem lsum_filter_mono (hab : Absorb R) {β : Type v} (l : List β) (S T : β → Bool) + (f : β → R) (hST : ∀ b, S b = true → T b = true) : + lsum ((l.filter S).map f) ⊑ lsum ((l.filter T).map f) := by + induction l with + | nil => exact Resource.ResourceAlgebra.le_refl _ + | cons x xs ih => + by_cases hs : S x = true + · have ht : T x = true := hST x hs + rw [List.filter_cons_of_pos hs, List.filter_cons_of_pos ht] + simp only [List.map_cons, lsum_cons] + exact Resource.ResourceAlgebra.add_le_add_left _ _ ih _ + · have hs' : ¬ (S x = true) := hs + rw [List.filter_cons_of_neg hs'] + by_cases ht : T x = true + · rw [List.filter_cons_of_pos ht] + simp only [List.map_cons, lsum_cons] + refine Resource.ResourceAlgebra.le_trans _ _ _ ih ?_ + have h1 := hab (lsum ((xs.filter T).map f)) (f x) + rw [Resource.ResourceSemiring.add_comm] at h1 + exact h1 + · rw [List.filter_cons_of_neg ht] + exact ih + +-- ============================================================================ +-- 3. Reach grades (R7) +-- ============================================================================ + +/-- The reach grade of node `m` from the observed set `S`: the `⊞`-sum (best + choice) of the closure entries `A* k m` over the observed nodes `k`. -/ +def reachGrade {n : Nat} (A : Mat n R) (S : Fin n → Bool) (m : Fin n) : R := + lsum (((allFins n).filter S).map (fun k => matStar A k m)) + +/-- Refining the regeneration matrix refines every reach grade. -/ +theorem reachGrade_mono_mat {n : Nat} {A B : Mat n R} (hAB : A ⊑ₘ B) + (S : Fin n → Bool) (m : Fin n) : reachGrade A S m ⊑ reachGrade B S m := by + unfold reachGrade + refine lsum_mono _ (fun k => matStar A k m) (fun k => matStar B k m) ?_ + intro k _ + exact matStar_mono hAB k m + +/-- Observing more never lowers a reach grade. -/ +theorem reachGrade_mono_set (hab : Absorb R) {n : Nat} (A : Mat n R) + {S T : Fin n → Bool} (hST : ∀ k, S k = true → T k = true) (m : Fin n) : + reachGrade A S m ⊑ reachGrade A T m := + lsum_filter_mono hab (allFins n) S T (fun k => matStar A k m) hST + +/-- An observed node has the full grade: `one ⊑ reachGrade A S m` when + `S m = true` (the closure's free self-loop is among the summands). -/ +theorem one_le_reachGrade (hab : Absorb R) {n : Nat} (A : Mat (n + 1) R) + (S : Fin (n + 1) → Bool) (m : Fin (n + 1)) (hm : S m = true) : + (Resource.ResourceSemiring.one : R) ⊑ reachGrade A S m := by + unfold reachGrade + have hdiag : (Resource.ResourceSemiring.one : R) ⊑ matStar A m m := by + have h := id_le_star hab A m m + unfold matId at h + simpa using h + refine Resource.ResourceAlgebra.le_trans _ _ _ hdiag ?_ + apply le_lsum_of_mem hab + apply List.mem_map.mpr + refine ⟨m, ?_, rfl⟩ + exact List.mem_filter.mpr ⟨mem_allFins _ m, hm⟩ + +-- ============================================================================ +-- 4. Weighted residue measures (R5) +-- ============================================================================ + +end Resource.HubCeiling + +namespace Resource.HubCeiling + +open scoped Resource.ResourceSemiring Resource.ResourceAlgebra + +-- `ResidueMeasure` lives at `Type` (its carriers are `Type`, not `Type u`), so +-- this section is at universe zero. +variable {R : Type} [Resource.ResourceAlgebra R] + +/-- The `⊠`-product of per-event weights over a residue list. -/ +def weightedMeasure {M : Type} (w : M → R) : List M → R + | [] => Resource.ResourceSemiring.one + | (m :: l) => w m ⊠ weightedMeasure w l + +theorem weightedMeasure_append {M : Type} (w : M → R) (l₁ l₂ : List M) : + weightedMeasure w (l₁ ++ l₂) = weightedMeasure w l₁ ⊠ weightedMeasure w l₂ := by + induction l₁ with + | nil => + simp only [List.nil_append, weightedMeasure] + rw [Resource.ResourceSemiring.one_mul] + | cons x xs ih => + simp only [List.cons_append, weightedMeasure] + rw [ih, Resource.ResourceSemiring.mul_assoc] + +/-- **The generic weighted residue measure.** For ANY resource algebra `R` and + ANY weight `w : M → R`, the free monoid of residue events measures into `R` + as a monoid homomorphism (`one_mul` and `mul_assoc` are all that is used). + `List M` stays an opaque residue carrier; it is never a resource algebra. -/ +def weightedResidueMeasure {M : Type} (w : M → R) : Resource.ResidueMeasure (List M) R where + combine := List.append + empty := [] + measure := weightedMeasure w + measure_empty := rfl + measure_combine := weightedMeasure_append w + +end Resource.HubCeiling + +-- ============================================================================ +-- 5. The constant-weight instance recovers the existing bridge +-- ============================================================================ + +namespace Resource.HubCeiling.Witness + +open scoped Resource.ResourceSemiring Resource.ResourceAlgebra +open Resource.Closure Resource.HubCeiling + +/-- Counting residue events into max-plus is the weighted measure with the + constant weight `val 1` (`one_mul`-free: both sides compute to the length). -/ +theorem weighted_counts_events (l : List Unit) : + weightedMeasure (fun (_ : Unit) => Hyperpolymath.Tropical.Tropical.val 1) l + = Hyperpolymath.Tropical.Tropical.val l.length := by + induction l with + | nil => rfl + | cons x xs ih => + simp only [weightedMeasure, List.length_cons, ih] + show Hyperpolymath.Tropical.tMul _ _ = _ + simp [Hyperpolymath.Tropical.tMul, Nat.add_comm] + +-- ============================================================================ +-- 6. Instance witnesses — MinPlus and MinMax satisfy the hypotheses; MaxPlus +-- does not satisfy `OneTop` +-- ============================================================================ + +section MinMax +open Resource.Instances.MinMax + +/-- `one = val 0` is the top of the bottleneck order. -/ +theorem minmax_one_top : OneTop MinMax := by + intro a + cases a with + | top => exact MinMax.top_le _ + | val m => exact (MinMax.le_val_val m 0).mpr (Nat.zero_le m) + +theorem minmax_idem : Idem MinMax := by + intro a + show MinMax.add a a = a + exact MinMax.add_idem a + +/-- The single-hub ceiling instantiated at the bottleneck algebra: a + regeneration step through one hub is no better than the hub edge. -/ +example {A B : Mat 3 MinMax} {i h : Fin 3} (hs : SingleHub A i h) (j : Fin 3) : + matMul A B i j ⊑ A i h := + single_hub_ceiling minmax_one_top minmax_idem + Resource.Closure.Witness.minmax_absorb A B hs j + +/-- Reach grades are monotone in the observed set at `MinMax`. -/ +example {A : Mat 3 MinMax} {S T : Fin 3 → Bool} (h : ∀ k, S k = true → T k = true) (m : Fin 3) : + reachGrade A S m ⊑ reachGrade A T m := + reachGrade_mono_set Resource.Closure.Witness.minmax_absorb A h m + +/-- An observed modality has the full grade at `MinMax`. -/ +example {A : Mat 3 MinMax} (m : Fin 3) : + (Resource.ResourceSemiring.one : MinMax) ⊑ reachGrade A (fun _ => true) m := + one_le_reachGrade Resource.Closure.Witness.minmax_absorb A (fun _ => true) m rfl + +end MinMax + +section MinPlus +open Resource.Instances.MinPlus + +/-- `one = val 0` is the top of the least-cost order. -/ +theorem minplus_one_top : OneTop MinPlus := by + intro a + cases a with + | top => exact MinPlus.top_le _ + | val m => exact (MinPlus.le_val_val m 0).mpr (Nat.zero_le m) + +theorem minplus_idem : Idem MinPlus := by + intro a + show MinPlus.add a a = a + exact MinPlus.add_idem a + +example {A B : Mat 3 MinPlus} {i h : Fin 3} (hs : SingleHub A i h) (j : Fin 3) : + matMul A B i j ⊑ A i h := + single_hub_ceiling minplus_one_top minplus_idem + Resource.Closure.Witness.minplus_absorb A B hs j + +end MinPlus + +section MaxPlus +open Resource.Instances.MaxPlus + +/-- `MaxPlus` is NOT `OneTop`: `val 1` is strictly better than `one = val 0` in + the max-plus order, so the hub ceiling does not hold there. This is the + honest boundary of R6. -/ +theorem maxplus_not_one_top : ¬ OneTop Hyperpolymath.Tropical.Tropical := by + intro h + have h1 := h (Hyperpolymath.Tropical.Tropical.val 1) + have h2 := (le_val_val 1 0).mp h1 + omega + +end MaxPlus + +end Resource.HubCeiling.Witness From fee654041af811616c0568fa2decc85f2b7c3336 Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" Date: Mon, 9 Nov 2026 14:05:05 +0000 Subject: [PATCH 2/3] fix(hubceiling): correct the IsStar doc; enforce the axiom allowlist in the audit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two CodeRabbit findings on #67. - The doc comment on IsStar claimed matStar is a solution of the Kleene fixed-point equation in a walk semantics. It is not in general: for one MaxPlus node with a val 1 self-loop, matStar A = I = val 0 while I ⊞ A ⊠ I = val 1. The doc (and the module header) now say the finite sum does not satisfy the equation in general, which is exactly why single_hub_star_ceiling takes IsStar as an explicit hypothesis. - The lean.yml axiom audit only failed on `sorry` / `Classical.choice` text. It now also parses every "depends on axioms: [...]" line and fails if anything outside {propext, Quot.sound} appears, and fails on an elaboration error in the audit file itself. Checked locally: the current output yields an empty extras list, and a synthetic line with Classical.choice is caught. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01J4QvDizuhJtQDcxHxM2wj8 --- .github/workflows/lean.yml | 13 +++++++++++-- Resource/HubCeiling.lean | 16 ++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index 7a81935..66206d0 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -84,7 +84,16 @@ jobs: EOF out="$(lake env lean /tmp/axcheck.lean 2>&1)" echo "$out" - if echo "$out" | grep -qiE 'sorry|Classical\.choice'; then - echo "::error::axiom audit failed — sorry or Classical.choice present" + if echo "$out" | grep -qiE 'sorry|Classical\.choice|error'; then + echo "::error::axiom audit failed — sorry, Classical.choice or an elaboration error present" + exit 1 + fi + # Allowlist: every printed dependency must be propext or Quot.sound. + # Any other axiom (a project `axiom`, funext, Classical.*) fails the audit. + extra="$(echo "$out" | grep -o 'depends on axioms: \[[^]]*\]' \ + | sed -E 's/.*\[(.*)\]/\1/; s/,/ /g' | tr ' ' '\n' \ + | grep -v '^$' | grep -vxE 'propext|Quot\.sound' || true)" + if [ -n "$extra" ]; then + echo "::error::axiom audit failed — axioms outside the allowlist: $extra" exit 1 fi diff --git a/Resource/HubCeiling.lean b/Resource/HubCeiling.lean index a874f3b..61cfd5c 100644 --- a/Resource/HubCeiling.lean +++ b/Resource/HubCeiling.lean @@ -29,9 +29,11 @@ import Resource.EchoBridge generalised sum (`join_bound`, `lsum_bound`), and then to matrix products (`matMul_row_bound`, `single_hub_ceiling`). The *star* corollary (`single_hub_star_ceiling`) is stated only under an explicit `IsStar` - hypothesis — the Kleene fixed-point equation `S = I ⊞ A ⊠ S` — because the - repository has no walk semantics for `matStar` in Lean; that larger item is - not on squeakwell's critical path. + hypothesis — the Kleene fixed-point equation `S = I ⊞ A ⊠ S`. The finite + sum `matStar` does not satisfy that equation in general (a single `MaxPlus` + node with a positive self-loop is a counterexample), and the repository has + no walk semantics for `matStar` in Lean; that larger item is not on + squeakwell's critical path. * **R7 — reach grade.** `reachGrade A S m` is the `⊞`-sum of the closure entries `A* k m` over the OBSERVED set `S` (a `Bool` predicate on nodes): "how well can `m` be reached from what was actually observed". Proved: @@ -143,9 +145,11 @@ theorem single_hub_ceiling (htop : OneTop R) (idem : Idem R) (hab : Absorb R) · rw [hs k hk, Resource.ResourceSemiring.zero_mul] exact zero_bot hab _ -/-- The Kleene fixed-point equation. `matStar` is one solution in the walk - semantics this repository does not yet formalise in Lean; the corollary - below therefore takes the equation as an explicit hypothesis. -/ +/-- The Kleene fixed-point equation. The finite sum `matStar` does NOT + always satisfy it (one `MaxPlus` node with a `val 1` self-loop has + `matStar A = I = val 0` but `I ⊞ A ⊠ I = val 1`), and this repository + has no walk semantics in Lean under which it would; so the corollary + below takes the equation as an explicit hypothesis. -/ def IsStar {n : Nat} (A S : Mat n R) : Prop := S = matAdd matId (matMul A S) From 9cb503eca100e3fc8601a923e5017ec293206eba Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 15:56:36 +0000 Subject: [PATCH 3/3] ci(lean): axiom audit parses wrapped lists and fails on unparseable results CodeRabbit review on PR 67: the allowlist extraction matched "depends on axioms: [...]" one line at a time, so a list Lean wraps over several lines never matched and any axiom in it passed silently. - collapse the output's newlines before extracting the lists; - require one parsed verdict ("does not depend on any axioms" or a complete "depends on axioms: [...]") per "#print axioms" line, so an unparseable result fails instead of reading as "no axioms"; - tolerate only grep's no-match status (1) instead of "|| true". Tested: real `lake env lean` output passes (31/31 verdicts). Synthetic output with a wrapped list containing Project.myAxiom fails naming it (the old parser let it through); a missing verdict fails (30 for 31); a wrapped list of propext/Quot.sound passes. shellcheck clean. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDizuhJtQDcxHxM2wj8 --- .github/workflows/lean.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index 66206d0..93e09ba 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -88,11 +88,25 @@ jobs: echo "::error::axiom audit failed — sorry, Classical.choice or an elaboration error present" exit 1 fi + # Lean may wrap a long "depends on axioms: [...]" list over several + # lines, so parse the output with newlines collapsed to spaces. + flat="$(printf '%s' "$out" | tr '\n' ' ')" + # Every audited declaration must yield exactly one parsed verdict; + # an unparseable result fails instead of reading as "no axioms". + expected="$(grep -c '^#print axioms ' /tmp/axcheck.lean)" + verdicts="$(printf '%s' "$flat" \ + | grep -oE "does not depend on any axioms|depends on axioms: \[[^]]*\]" \ + | wc -l)" + if [ "$verdicts" -ne "$expected" ]; then + echo "::error::axiom audit failed — parsed $verdicts verdicts for $expected '#print axioms' lines" + exit 1 + fi # Allowlist: every printed dependency must be propext or Quot.sound. # Any other axiom (a project `axiom`, funext, Classical.*) fails the audit. - extra="$(echo "$out" | grep -o 'depends on axioms: \[[^]]*\]' \ + # grep exits 1 when nothing is left over (the good case); tolerate only that. + extra="$(printf '%s' "$flat" | grep -oE 'depends on axioms: \[[^]]*\]' \ | sed -E 's/.*\[(.*)\]/\1/; s/,/ /g' | tr ' ' '\n' \ - | grep -v '^$' | grep -vxE 'propext|Quot\.sound' || true)" + | grep -v '^$' | grep -vxE 'propext|Quot\.sound' || test "$?" -eq 1)" if [ -n "$extra" ]; then echo "::error::axiom audit failed — axioms outside the allowlist: $extra" exit 1