Skip to content

refactor(MPS/RFP): use native commute algebra for complements#3271

Merged
LionSR merged 1 commit into
mainfrom
codex/native-pass-20260621k
Jun 21, 2026
Merged

refactor(MPS/RFP): use native commute algebra for complements#3271
LionSR merged 1 commit into
mainfrom
codex/native-pass-20260621k

Conversation

@LionSR

@LionSR LionSR commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Motivation

  • comm_of_complement_comm was a public wrapper with no callers outside TNLean/MPS/RFP/Decorrelation.lean.
  • The forward complement-commutation result can be proved directly using the native Commute algebra for endomorphisms.
  • Continues formalization of the decorrelation ↔ commuting parent Hamiltonian equivalence (arXiv:1606.00608, Appendix D, Proposition D.3); see RFP/MPDO 2/5 Commuting parent Hamiltonians and decorrelation theorem #234.

Description

  • Removes the unused reverse complement-commutation lemma comm_of_complement_comm from TNLean/MPS/RFP/Decorrelation.lean.
  • Rewrites complement_comm_of_comm through Commute.sub_left and Commute.sub_right, then translates back to composition notation.
  • Updates the module overview so it lists only the remaining public declarations.
  • Mathematical content is unchanged: [P, Q] = 0 → [1 − P, 1 − Q] = 0 remains as complement_comm_of_comm, and HasCommutingParentHam.complement_comm still calls the same forward lemma.

Testing

  • lake env lean TNLean/MPS/RFP/Decorrelation.lean
  • lake build TNLean.MPS.RFP.Decorrelation
  • git diff --check
  • scripts/blueprint_lean_sync.py --root . --ci
  • python3 scripts/check_reader_facing_prose.py was run; it reports pre-existing issue-number references outside this file.
  • rg -n "sorry|admit|axiom|native_decide|unsafeCast" TNLean/MPS/RFP/Decorrelation.lean || true

Addresses #234


Note

Low Risk
Local proof refactor in one Lean file; the removed theorem had no callers and the forward result's statement is unchanged.

Overview
Removes the unused reverse lemma comm_of_complement_comm and drops it from the module overview.

complement_comm_of_comm is re-proved via Mathlib's Commute API (sub_right / sub_left on complements) instead of expanding (1−P)(1−Q) with simp/abel. HasCommutingParentHam.complement_comm still calls the same forward lemma; behavior is unchanged.

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

@claude claude Bot added formalization Lean 4 formalization task parent-hamiltonian Parent Hamiltonian theory for MPS (RMP §IV.C) 1606.00608 arXiv:1606.00608 (MPDO RFP) rfp-mpdo Renormalization fixed points and MPDO theory labels Jun 21, 2026
@claude

claude Bot commented Jun 21, 2026

Copy link
Copy Markdown

PR cleanup

Field Before After
Title `refactor(MPS/RFP): use native commute algebra for complements` unchanged (already compliant)
Body "No linked issue identified." footer; Motivation lacked source citation Added Addresses #234; expanded Motivation with arXiv:1606.00608 Appendix D reference
Labels none added: formalization, parent-hamiltonian, 1606.00608, rfp-mpdo
Issue no issue linked linked to #234 (commuting parent Hamiltonians and decorrelation theorem)

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.

Blueprint ↔ Lean & Prose Review

0 equivalence mismatches · 0 stale tags · 0 prose issues

Category A — Blueprint ↔ Lean equivalence

Only TNLean/MPS/RFP/Decorrelation.lean is changed; no .tex file is touched.

comm_of_complement_comm (removed). No \lean{...} tag references this declaration anywhere in the blueprint. Its removal leaves no stale tag behind.

complement_comm_of_comm (proof rewritten, statement unchanged). This auxiliary lemma carries no direct blueprint tag. It is called by HasCommutingParentHam.complement_comm, whose blueprint entry (\lean{Decorrelation.HasCommutingParentHam.complement_comm}, ch13_parent_hamiltonian_decorrelation.tex lines 221–222) is unaffected. Checked on all A.1 axes:

  • Hypothesis: HasCommutingParentHam P_K bundles exactly the idempotent-product data the blueprint names ("$P_K = P_{AX} \circ P_{XB}$ is idempotent-product data"). ✓
  • Conclusion: Lean (id - h.P_AX) ∘ₗ (id - h.P_XB) = (id - h.P_XB) ∘ₗ (id - h.P_AX) matches blueprint $Q_{AX} \circ Q_{XB} = Q_{XB} \circ Q_{AX}$. ✓
  • Proof \leanok: the rewritten proof is sorry-free. ✓

Category B — Prose quality

The sole prose change removes the bullet for the deleted theorem from the module overview. No new text is added. No banned terms, Lean jargon, or word-only proof sketches are introduced.

@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(MPS/RFP): use native commute algebra for complements

Verdict: Approve. Clean, tightly-scoped refactor of TNLean/MPS/RFP/Decorrelation.lean. No 🔴 or 🟡 issues found.

What I checked

Proof integrity (🔴) — No sorry/admit/axiom/native_decide/unsafeCast introduced. lake build TNLean.MPS.RFP.Decorrelation completes successfully; the only warning is the pre-existing "Copyright too short!" header linter note, which appears in both touched modules and is unrelated to this diff.

Proof correctness (🔴) — The rewritten complement_comm_of_comm ([P, Q] = 0 → [1 − P, 1 − Q] = 0) is mathematically sound and well-structured:

  • hPQ : Commute P Q from P ∘ₗ Q = Q ∘ₗ P via Module.End.mul_eq_comp;
  • (Commute.one_right P).sub_right hPQ : Commute P (id − Q);
  • (Commute.one_left (id − Q)).sub_left hP_comp : Commute (id − P) (id − Q);
  • hcomp.eq, translated back to composition notation, closes the goal.

The statement of complement_comm_of_comm is unchanged, and HasCommutingParentHam.complement_comm still calls the same forward lemma. This is a genuine improvement over the prior simp/abel expansion — it delegates to Mathlib's Commute API rather than re-deriving the complement identity by hand.

Modularity / duplication (🟡) — The removed comm_of_complement_comm (reverse direction) has no callers in TNLean/, blueprint/, or scripts/ (it appears only in the .trusted-actions/ working snapshot, which is a copy of this same file). Removal is safe and reduces unused surface area.

Documentation (🟡) — The module overview docstring is correctly updated to drop the removed declaration.

Type safety / performance — No concerns; the proof is a handful of Commute combinators.

Blueprint ↔ Lean sync and prose are out of scope here (handled by the dedicated workflow); I note only that no \lean{comm_of_complement_comm} reference exists in blueprint/, so the removal does not leave a dangling declaration reference.

@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 Summary

The PR is clean and minimal — it removes an unused lemma comm_of_complement_comm and rewrites complement_comm_of_comm using Mathlib's idiomatic Commute API.

🔴 Proof Integrity — PASS

No sorry, admit, axiom, native_decide, or unsafeCast introduced. The removed lemma had zero callers throughout the codebase (confirmed by rg). No circular reasoning or castle-in-the-air issues.

🔴 Proof Correctness — PASS

The new proof of complement_comm_of_comm correctly chains Commute lemmas:

  1. hcomm : P ∘ₗ Q = Q ∘ₗ PCommute P Q via Module.End.mul_eq_comp
  2. Commute P Q + Commute.one_right PCommute P (id - Q) via sub_right
  3. Commute 1 (id - Q) + Commute P (id - Q)Commute (id - P) (id - Q) via sub_left
  4. Back to composition notation via Module.End.mul_eq_comp

All Mathlib API lemmas verified present: Commute.one_right (Algebra/Group/Commute/Defs.lean:125), Commute.one_left (Algebra/Group/Commute/Defs.lean:129), Commute.sub_right (Algebra/Ring/Commute.lean:97), Commute.sub_left (Algebra/Ring/Commute.lean:101), Module.End.mul_eq_comp (Algebra/Module/LinearMap/End.lean:53).

🟡 Mathlib Style — PASS

The proof uses idiomatic Commute algebra rather than simp/abel expansion. Variable names are clear. Module overview correctly updated to drop the removed lemma. The abel import is retained because frustration_free_ham_eq still uses it.

🔴 Type Safety — PASS

No type mismatches or coercion issues. The Commute API applies cleanly to E →ₗ[ℂ] E endomorphisms.

🟡 Performance — PASS

The new proof is 6 lines using standard Commute lemmas — no performance concerns.

🟡 Modularity & Duplication — PASS

Correctly uses existing Mathlib Commute API rather than re-proving algebraic identities from scratch.

🟡 Documentation — PASS

Module docstring updated to remove mention of comm_of_complement_comm.


Verdict: APPROVE. No blockers or issues requiring changes found.

@LionSR LionSR marked this pull request as ready for review June 21, 2026 01:29
@chatgpt-codex-connector

Copy link
Copy Markdown

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

@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 & Prose Review

0 equivalence mismatches · 0 stale tags · 0 prose issues

Category A — Blueprint ↔ Lean equivalence

Only TNLean/MPS/RFP/Decorrelation.lean is changed; no .tex file is touched.

comm_of_complement_comm (removed). grep over blueprint/src/ finds no \lean{comm_of_complement_comm} tag anywhere. Its removal leaves no dangling declaration reference and no stale \leanok behind. ✓

complement_comm_of_comm (proof rewritten, statement unchanged). The signature {P Q : E →ₗ[ℂ] E} (hcomm : P ∘ₗ Q = Q ∘ₗ P) : (id - P) ∘ₗ (id - Q) = (id - Q) ∘ₗ (id - P) is identical before and after the diff. No blueprint tag targets this auxiliary lemma directly. No \leanok status is affected. ✓

A.2 proof \leanok: The rewritten proof is sorry-free; no proof-level status tags require updating. ✓

Category B — Prose quality

The sole prose change deletes one module-docstring bullet (* \comm_of_complement_comm` — ...`). No new prose is introduced. No banned software-engineering terms, no Lean jargon in blueprint prose (no blueprint files are modified), and no word-only proof sketch is added or changed.

@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(MPS/RFP): use native commute algebra for complements

Verdict: APPROVE. Clean, minimal refactor with no issues across all review categories.

Category-by-category assessment

🔴 Proof integrity — PASS. No sorry, admit, axiom, native_decide, or unsafeCast anywhere in the diff. The removed lemma comm_of_complement_comm has zero callers in TNLean/, blueprint/, or scripts/ (confirmed by rg). No circular reasoning or ungrounded proof chains.

🔴 Proof correctness — PASS. The rewritten complement_comm_of_comm correctly proves [P, Q] = 0 → [1 − P, 1 − Q] = 0 using Mathlib's Commute subring structure:

  1. hPQ : Commute P Q from hcomm via Module.End.mul_eq_comp
  2. Commute.one_right P gives Commute P 1
  3. .sub_right hPQ yields Commute P (id − Q)
  4. Commute.one_left (id − Q) gives Commute 1 (id − Q)
  5. .sub_left hP_comp yields Commute (id − P) (id − Q)
  6. hcomp.eq translated back to composition notation closes the goal

Each Commute lemma is verified present in Mathlib (Algebra/Ring/Commute.lean). The proof is mathematically sound and idiomatically delegates to Mathlib's ring-theoretic Commute API rather than re-deriving algebraic identities by hand.

🟡 Mathlib style — PASS. Uses idiomatic Commute subring algebra rather than simp/abel expansion. Variable names are clear. The abel import is retained because frustration_free_ham_eq still uses it.

🔴 Type safety — PASS. No type mismatches or coercion issues. Commute applies cleanly to E →ₗ[ℂ] E endomorphisms via the Ring structure on Module.End.

🟡 Performance — PASS. Six lines of Commute combinators — no heavy tactics or recursion.

🟡 Modularity & duplication — PASS. Correctly uses existing Mathlib Commute API rather than re-proving the complement identity from scratch. The reverse lemma comm_of_complement_comm had no callers and was correctly removed.

🟡 Documentation — PASS. Module docstring accurately updated to drop the removed declaration. No new undocumented declarations.

🟡 Paper-gap notes — N/A. No paper-gap files changed.

Existing feedback

No unresolved review threads exist on this PR. All four prior bot reviews are APPROVED. No PR conversation comment requires follow-up.

@LionSR LionSR merged commit bcb78f5 into main Jun 21, 2026
36 checks passed
@LionSR LionSR deleted the codex/native-pass-20260621k branch June 21, 2026 01:33

@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(MPS/RFP): use native commute algebra for complements

Verdict: APPROVE. No 🔴 or 🟡 issues found. Focused, low-risk refactor of one file (TNLean/MPS/RFP/Decorrelation.lean).

Proof integrity 🔴 — clean

No sorry, admit, axiom, native_decide, or unsafeCast introduced; the file remains fully proved.

Proof correctness 🔴 — sound

The rewrite of LinearMap.complement_comm_of_comm ([P, Q] = 0 → [1 − P, 1 − Q] = 0) through the Commute API is correct, and I verified each step against Mathlib v4.31.0:

  • Module.End.mul_eq_comp : f * g = f.comp g := rfl (Mathlib/Algebra/Module/LinearMap/End.lean:53) justifies translating between * and ∘ₗ via simpa.
  • Commute.one_right/Commute.one_left (Mathlib/Algebra/Group/Commute/Defs.lean:125,129) and Commute.sub_right/Commute.sub_left (Mathlib/Algebra/Ring/Commute.lean:97,101) have the exact signatures the proof relies on:
    • (Commute.one_right P).sub_right hPQ : Commute P (1 − Q),
    • (Commute.one_left (id − Q)).sub_left hP_comp : Commute (1 − P) (id − Q).
  • The type ascriptions Commute P (id − Q) and Commute (id − P) (id − Q) typecheck because (1 : Module.End R M) = LinearMap.id := rfl (Module.End.one_eq_id, Mathlib/Algebra/Module/LinearMap/End.lean:51), so 1 − Q is definitionally id − Q.
  • hcomp.eq : (id − P) * (id − Q) = (id − Q) * (id − P) (Commute.eq, Mathlib/Algebra/Group/Commute/Defs.lean:54), and simpa [Module.End.mul_eq_comp] reduces it to the stated ∘ₗ goal.

The mathematical content is unchanged: the conclusion (id − P) ∘ₗ (id − Q) = (id − Q) ∘ₗ (id − P) and the hypothesis P ∘ₗ Q = Q ∘ₗ P are identical to the prior version. The new proof is shorter and more idiomatic than the previous simp + abel expansion.

Modularity & duplication 🟡 — improved

The removed reverse lemma LinearMap.comm_of_complement_comm has no callers anywhere in TNLean/, the blueprint, or docs/ (the only remaining hits are in the .trusted-actions/ snapshot, which is not part of the source tree). Removal is safe and reduces dead surface.

Documentation 🟡 — consistent

The module "Main results" overview is updated to drop the comm_of_complement_comm entry; the surviving complement_comm_of_comm docstring is unchanged and accurate.

Faithfulness / paper-gaps

No docs/paper-gaps/ files touched. The forward direction (the one cited toward arXiv:1606.00608 Appendix D, Proposition D.3) is preserved verbatim; the deletion only drops an unused converse, so the formalization's relationship to the source is unaffected.

Nice cleanup — approving.

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

Labels

1606.00608 arXiv:1606.00608 (MPDO RFP) formalization Lean 4 formalization task parent-hamiltonian Parent Hamiltonian theory for MPS (RMP §IV.C) rfp-mpdo Renormalization fixed points and MPDO theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants