Skip to content

refactor(PEPS): use prod comm equivalence in torus sum#3124

Draft
LionSR wants to merge 1 commit into
mainfrom
codex/torus-window-sum-prod-comm
Draft

refactor(PEPS): use prod comm equivalence in torus sum#3124
LionSR wants to merge 1 commit into
mainfrom
codex/torus-window-sum-prod-comm

Conversation

@LionSR

@LionSR LionSR commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Motivation

  • threeBlockBlueCoeff_comp in TNLean/PEPS/TorusWindowChain4.lean used a hand-built Finset.sum_nbij' to swap the product-configuration pair $(q_2, q_1) \leftrightarrow (q_1, q_2)$. Mathlib's Finset.sum_equiv along Equiv.prodComm is the canonical way to perform this reindexing.
  • Replacing the bespoke pair-swap with the standard Mathlib combinator reduces proof complexity without changing the mathematical content.

Description

  • TNLean/PEPS/TorusWindowChain4.lean (modified): in threeBlockBlueCoeff_comp, the explicit Finset.sum_nbij'-based pair-swap is replaced by Finset.sum_equiv Equiv.prodComm. The membership arguments for the separated and agreeing-pair index sets are preserved. The theorem statement and summands are unchanged.

Testing

  • lake env lean TNLean/PEPS/TorusWindowChain4.lean
  • lake build TNLean.PEPS.TorusWindowChain4 -q --log-level=info
  • lake build TNLean -q --log-level=info
  • rg -n "sorry|axiom|admit|native_decide|unsafeCast" TNLean/PEPS/TorusWindowChain4.lean — no new occurrences
  • Full build reports only pre-existing warnings and the existing TNLean/MPS/Periodic/Overlap/Case3.lean:586:14 sorry; no new failures from this change.

Note

Low Risk
Proof-only refactor in a PEPS Lean file; no runtime, API, or mathematical statement changes.

Overview
In threeBlockBlueCoeff_comp, the step that reindexes the product of two filtered virtual-config sums into the agreeing-pair fiber sum no longer uses a hand-built Finset.sum_nbij' with an explicit (q₂, q₁) ↔ (q₁, q₂) swap.

It now applies Finset.sum_equiv along Mathlib's Equiv.prodComm, with the same filter membership arguments packaged as rintro / constructor proofs for the separated vs agreeing-pair index sets. The theorem statement and summands are unchanged.

Reviewed by Cursor Bugbot for commit 1131034. Bugbot is set up for automated code reviews on this repo. Configure here.

@claude claude Bot added the cleanup Code cleanup and style fixes label Jun 20, 2026
@claude

claude Bot commented Jun 20, 2026

Copy link
Copy Markdown

PR cleanup

Field Before After
Title `refactor(PEPS): use prod comm equivalence in torus sum` unchanged (already compliant)
Body non-standard ## Summary / ## Validation headings restructured to ### Motivation / ### Description / ### Testing template; Cursor Bugbot block preserved verbatim
Labels (none) added: cleanup
Issue no issue found

No linked issue found. The branch name (codex/torus-window-sum-prod-comm) contains no issue-{N} pattern, the PR body has no Refs/Closes/Fixes/Addresses #N reference, and commit messages carry no issue link. The most related open issue is #2757 (Add blueprint entries for TorusWindowChain4 corner-extension transitivity theorems), but that covers blueprint/docstring work, not this proof-tactic refactor. If this PR addresses a specific issue, please add Addresses #N to the body footer.

Conventions: CONTRIBUTING.md

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: refactor(PEPS): use prod comm equivalence in torus sum

Verdict: APPROVE — no 🔴 or 🟡 issues found.

This is a tightly-scoped, proof-only refactor of the reindexing step inside threeBlockBlueCoeff_comp (TNLean/PEPS/TorusWindowChain4.lean:496). It replaces the hand-built Finset.sum_nbij' swap with Finset.sum_equiv (Equiv.prodComm _ _).

Correctness. The two are equivalent reindexings of the same product sum:

  • Equiv.prodComm sends (q₁, q₂) ↦ (q₂, q₁), matching the old forward map i := fun q => (q.2, q.1) and inverse j.
  • Finset.sum_equiv's membership obligation ∀ i, i ∈ s ↔ e i ∈ t is discharged by rintro ⟨q₁, q₂⟩; constructor, where the forward branch reuses the original i-membership argument and the backward branch reuses the original j-membership argument — both simp only/obtain/exact bodies are unchanged.
  • The summand equality hfg remains fun _ _ => rfl, as in the original sum_nbij' value argument; the summands are definitionally equal under the swap.

The theorem statement, summands, and surrounding fiberwise grouping (Finset.sum_fiberwise, mergeCollapse2) are untouched.

Proof integrity. No new sorry/axiom/admit/native_decide. The pre-existing TNLean/MPS/Periodic/Overlap/Case3.lean:586 sorry is unrelated to this PR.

Modularity. Net improvement: a project-local explicit bijection is replaced by the standard Mathlib Equiv.prodComm + Finset.sum_equiv pair.

Style, type-safety, performance, and documentation are unaffected (the explanatory comments on both membership branches are preserved).

Note: PR is currently in draft state.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blueprint ↔ Lean review (Categories A and B only)

Category A — Blueprint ↔ Lean equivalence and status accuracy

The only Lean declaration modified is TNLean.PEPS.threeBlockBlueCoeff_comp (pure tactic refactor; statement unchanged). Its blueprint counterpart is thm:peps_corner_extension_coefficient_composition in blueprint/src/chapter/ch24_peps_ft_torus.tex:881–898.

A.1 — Mathematical equivalence. The blueprint states
$$\sum_{\nu\in\partial S}\Phi_{R,S}(\mu,\sigma|{S\setminus R},\nu),\Phi{S,P}(\nu,\sigma|{P\setminus S},\omega) = P{V\setminus S},\Phi_{R,P}(\mu,\sigma|_{P\setminus R},\omega)$$
for nested regions $R\subseteq S\subseteq P$. The Lean statement expresses the same equation via regionInteriorBondProd, threeBlockBlueCoeff, and a sum over RegionBoundaryConfig A S, with matching implicit parameters hRS, hSP, bdryR, σ, bcP. No quantifier, hypothesis, or conclusion discrepancy. ✓

A.2 — \leanok accuracy. The statement-level \leanok at line 884 is valid: the Lean signature matches and the proof contains no sorry or admit. There is no \begin{proof}...\leanok...\end{proof} block for this theorem in the blueprint, but that is a pre-existing gap — this PR neither closes a sorry nor touches any .tex file, so it does not introduce or remove any status tags. ✓

A.3 / A.4. No \notready tags involved. No blueprint files changed. No declarations added or renamed. ✓

Category B — Prose quality

The PR changes only tactic proof lines. No docstrings, block comments, section names, or inline comments are added or modified. The two -- comments visible in the diff context are pre-existing and unchanged. No .tex files are touched. ✓


Summary: 0 equivalence mismatches, 0 stale \leanok, 0 prose issues.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: refactor(PEPS): use prod comm equivalence in torus sum

Summary

This is a concise, clean refactor that replaces an ad-hoc Finset.sum_nbij' call in threeBlockBlueCoeff_comp with the higher-level Finset.sum_equiv along Equiv.prodComm. The theorem statement, summands, and proof strategy are unchanged. All review categories pass.

Per-category assessment

Category Verdict
1. 🔴 Proof integrity ✅ Clean — no sorry, axiom, admit, native_decide, unsafeCast, circular reasoning, or debug artifacts introduced
2. 🔴 Proof correctness ✅ The equivalence swap (q₁, q₂) ↔ (q₂, q₁) is exactly what Equiv.prodComm provides; the membership is correctly proved by the constructor block, carrying forward the same membership reasoning as the original sum_nbij'
3. 🟡 Mathlib style ✅ Improves style — sum_equiv is the idiomatic Mathlib API for reindexing sums with equivalences
4. 🔴 Type safety ✅ No issues; build succeeds
5. 🟡 Performance ✅ Negligible; the proof is actually simpler
6. 🟡 Modularity ✅ Uses a standard Mathlib lemma instead of a hand-rolled sum_nbij' pattern
7. 🟡 Documentation ✅ The theorem already has a thorough docstring (lines 409–416) with paper citation
8. 🟡 Paper-gap notes N/A — no paper-gap documents changed

Verdict

APPROVE — no blocking or advisory issues.

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

Labels

cleanup Code cleanup and style fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants