Skip to content

feat(ClusterExpansion): prove the general pathGraph closed form and drop the six decide instances - #4638

Merged
phasetr merged 4 commits into
mainfrom
feat/pathgraph-alternating-sum-closed-form
Jul 21, 2026
Merged

feat(ClusterExpansion): prove the general pathGraph closed form and drop the six decide instances#4638
phasetr merged 4 commits into
mainfrom
feat/pathgraph-alternating-sum-closed-form

Conversation

@phasetr

@phasetr phasetr commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Motivation

IsingModel/ClusterExpansion/GraphCases.lean proves alternatingConnectedSubgraphSum (pathGraph k) = ±1 separately for k = 3..8, each by decide +kernel. That file is the most expensive in the repository to elaborate (~36.8s wall even after PR #4629 cut it from 63.7s). A general closed form removes the decide dependence entirely, generalizes the result to every n, and is estimated to bring the file down to ~4-6s.

Statement

alternatingConnectedSubgraphSum (pathGraph (n+1)) = (-1)^n for all n.

Proof sketch

A connected spanning subgraph on n+1 vertices needs at least n edges (SimpleGraph.Connected.card_vert_le_card_edgeSet_add_one), and pathGraph (n+1) has exactly n edges (card_pathGraph_edgeFinset), so squeezing with Finset.eq_of_subset_of_card_le forces the subset to be the whole edge set; the converse direction is SimpleGraph.pathGraph_connected. Hence connectedSpanningEdgeSubsets (pathGraph (n+1)) = {edgeFinset} and the alternating sum collapses to a single term via Finset.sum_singleton. No acyclicity or bridge argument is needed — this is strictly simpler than the existing cycleGraph counterpart it is modelled on (CycleGraphAlternatingSum.lean:134,197).

Plan

Add IsingModel/ClusterExpansion/PathGraphAlternatingSum.lean (sibling of CycleGraphAlternatingSum.lean) with one private characterisation lemma and one public closed form; then replace the six decide proofs in GraphCases.lean with instantiations of it, verify the #check @ dumps are unchanged, and remove the now-unnecessary private DecidableRel (pathGraph k).Adj instances and the set_option maxHeartbeats 400000.

Note that the six instances are then reference-0 duplicates of the general form; whether to delete them outright (updating the docs/index.md and tex/proof-guide.tex mentions to cite the general theorem instead) is decided in this PR.

Review follow-up (commit d76f85d4)

Two review findings addressed:

  1. (Med) Umbrella root closure regression. Deleting GraphCases.lean removed the only path by which PathGraphAlternatingSum and CycleGraphAlternatingSum reached the IsingModel root import closure (previously GraphCases ← TanhBounds), leaving both modules orphaned: still built by the lakefile glob, but invisible to scripts/audit_gate.py V3, which runs #print axioms from a temporary file that only does import IsingModel. Both modules are now imported from IsingModel.lean (next to AlternatingFinThree), restoring auditability. Demonstrated: from a file whose sole import is IsingModel, both alternatingConnectedSubgraphSum_pathGraph and alternatingConnectedSubgraphSum_cycleGraph resolve and report [propext, Classical.choice, Quot.sound].
  2. (Low) Ambiguous doc comment. The value table in the doc comment of alternatingConnectedSubgraphSum_pathGraph wrote n = 2 ↦ 1 where n could be read as either the exponent or the vertex count; entries are now spelled n = 2 ↦ pathGraph 3 = 1, etc.

lake exe shake does not flag either new umbrella import as redundant. (It does report a pre-existing import-narrowing suggestion inside CycleGraphAlternatingSum.lean itself — AlternatingCompleteGraphAlternatingCompleteGraph.SignedSums — which predates this PR and is left alone.)

Out of scope for this PR, recorded for follow-up: three modules are orphaned from the root closure on main as well, i.e. not caused by this PR — ClusterExpansion.MayerCore.MayerTermThreeEval, PseudoMass.Composition, PseudoMass.FromParamsBounds.JZeroComparisons (0 importers on both main and this branch).

Verification checklist

  • The new module builds warning-free as part of the full build (this repo has autoImplicit on, so a missing import silently becomes an auto-bound implicit)
  • [~] #check @ dumps for the six instances identical before/after the proof replacement — superseded: the six per-n instances were deleted outright (commit 7274a9f5) rather than reproved, so there is no before/after dump to compare; rg confirms no remaining reference to any of the six names in IsingModel/, docs/index.md or tex/proof-guide.tex
  • lake build warning-free (5063 jobs, zero warning lines)
  • #print axioms = [propext, Classical.choice, Quot.sound] with no decide-specific assumptions — verified through import IsingModel, so V3 can see it
  • scripts/audit_gate.py --full V1-V4 all PASS (13 capstones)
  • lake exe GKSTest
  • No circular imports
  • [~] Measured elaboration time for GraphCases.lean reported before/after — moot: GraphCases.lean is deleted, so its full ~36.8s elaboration cost is removed rather than reduced
  • docs/tex updated to cite the general theorem (docs/index.md cites alternatingConnectedSubgraphSum_pathGraph; zero stale references to the six deleted per-n lemma names in docs/index.md / tex/proof-guide.tex)
  • CI green (run 29790889993, "build" check, 2m35s — https://github.com/phasetr/ising-model/actions/runs/29790889993/job/88512247083)

Part of #4637

🤖 Generated with Claude Code

phasetr and others added 3 commits July 21, 2026 08:54
…ating sum

Add `IsingModel/ClusterExpansion/PathGraphAlternatingSum.lean` proving

  alternatingConnectedSubgraphSum (pathGraph (n+1)) = (-1)^n   (all n : ℕ)

by a pure edge count: a connected spanning subgraph on `n+1` vertices needs at
least `n` edges (`Connected.card_vert_le_card_edgeSet_add_one`), the path has
exactly `n` (`card_pathGraph_edgeFinset`), so the full edge set is the unique
connected spanning subset (`pathGraph_connectedSpanning_charac`) and the sum
collapses to a single term.  No tree/bridge theory is needed.

Derive the six `…_pathGraph_{three,…,eight}` values in `GraphCases.lean` as
instances of the closed form, replacing the per-`n` `decide +kernel`
evaluations.  The six private `DecidableRel (pathGraph k).Adj` duplicates and
the `maxHeartbeats 400000` escalation are dropped; the imported
`TransferMatrix.pathGraph_decidableAdj` is definitionally equal, so the `#check`
dump of all six statements is unchanged.

`AnalyticityLambdaCapstones`/`AnalyticityLambdaPolymer` relied on reaching
`AlternatingCompleteGraph.MayerConnectedFilter` transitively through the import
of `CycleGraphAlternatingSum` that `GraphCases` no longer needs; make that
dependency explicit in both files.

`GraphCases` module build time: 38s -> 2.0s.

Part of #4637

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`alternatingConnectedSubgraphSum_pathGraph_{three,…,eight}` had zero consumers
anywhere in the library and are now plain instantiations of
`alternatingConnectedSubgraphSum_pathGraph`, which proves the same six values
(and `pathGraph 1 = 1`, `pathGraph 2 = -1` on top).  Deleting them follows the
policy already applied to the cycle-graph numerals in #4633/#4636.

Their derivability from the closed form is recorded permanently by the previous
commit, where the six statements — `#check` dump byte-identical to the
`decide +kernel` era — are closed by the general theorem.

`GraphCases.lean` held nothing else, so the module is removed and its sole
importer `StrictPositivity/TanhBounds.lean` is repointed at
`ClusterExpansion.HighTempGeneralRegularity`.

Docs: `docs/index.md` and `tex/proof-guide.tex` now cite the general path
formula (with the counting proof) instead of the per-`n` `decide` family and the
`maxHeartbeats 400000` regime, mirroring the existing cycle-formula paragraph.

Part of #4637

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@phasetr
phasetr force-pushed the feat/pathgraph-alternating-sum-closed-form branch from 6dabc7f to 7274a9f Compare July 21, 2026 00:07
Removing `GraphCases.lean` dropped `PathGraphAlternatingSum` and
`CycleGraphAlternatingSum` out of the `IsingModel` root import closure, leaving
them buildable (lakefile glob) but invisible to `scripts/audit_gate.py` V3,
which runs `#print axioms` from a file that only does `import IsingModel`.
Import both modules from the umbrella so their capstones stay auditable; both
now resolve through `import IsingModel` with axiom set
[propext, Classical.choice, Quot.sound].

Also disambiguate the value table in the doc comment of
`alternatingConnectedSubgraphSum_pathGraph`: `n` is the exponent, not the
vertex count, so the entries are now spelled `n = 2 ↦ pathGraph 3 = 1` etc.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@phasetr

phasetr commented Jul 21, 2026

Copy link
Copy Markdown
Owner Author

dev-issue-manager: pre-merge resolution verification (HEAD d76f85d)

Verdict: PASS. Merge-ready.

Independent re-verification (not relying on prior gate reports)

  • lake build: 5063 jobs, Build completed successfully, zero warning lines (only two unrelated pre-existing ring_nf info suggestions in Phi4AllOdd.lean / TwoSiteInteractingLayerOpenBoundaryWindow.lean, not touched by this PR).
  • #print axioms re-run from a fresh scratch file whose sole import is import IsingModel (mirrors audit_gate.py V3's method exactly):
    • alternatingConnectedSubgraphSum_pathGraph[propext, Classical.choice, Quot.sound]
    • alternatingConnectedSubgraphSum_cycleGraph[propext, Classical.choice, Quot.sound]
      This confirms the umbrella-closure fix (commit d76f85d4) actually restores V3 auditability of both modules, not just that the code builds.
  • python3 scripts/audit_gate.py --full: V1 PASS, V2 PASS, V3 PASS (13 capstones, axiom union = {Classical.choice, Quot.sound, propext}), V4 PASS.
  • lake exe GKSTest: === All tests passed ===.
  • CI (gh pr checks 4638): build check pass (run 29790889993, 2m35s).

Mathematical-content preservation (no information loss from the GraphCases.lean deletion)

  • IsingModel/ClusterExpansion/GraphCases.lean confirmed removed; PathGraphAlternatingSum.lean confirmed present with alternatingConnectedSubgraphSum_pathGraph (n : ℕ) : alternatingConnectedSubgraphSum (pathGraph (n+1)) = (-1)^n, doc comment spells out all 6 former per-n values (n=2..7 ↦ pathGraph 3..8).
  • docs/index.md cites the general theorem by name (alternatingConnectedSubgraphSum_pathGraph, ClusterExpansion/PathGraphAlternatingSum.lean) and explicitly records what it replaces (the former pathGraph_{three,...,eight} decide+kernel cases), including the build-time improvement (38s → 2s for the module).
  • grep/rg across docs/index.md, tex/proof-guide.tex, IsingModel/: zero remaining references to GraphCases, pathGraph_{three,four,five,six,seven,eight}, or cycleGraph_{three,...,seven} per-n names. No stale citations, no silent loss of the specific values (all 6 recoverable from the general theorem plus doc comment).

PR body checklist

Reviewed dev-implement's [~] (superseded/moot) judgments on the #check @ dump comparison and elaboration-time comparison — both correctly reflect that the comparison targets (GraphCases.lean, the six per-n decls) no longer exist post-deletion, so marking them [x] would have been false. Updated the final [ ] CI green to [x] now that CI is confirmed green (run 29790889993).

Full ledger

See .self-local/issues/4637.md for the updated tracking-issue mirror and follow-up disposition (orphan-module registration, PR-3 scope reduction to 12/22 Profile.lean declarations, CycleSeven.lean rename).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant