Matrix Tree Theorem (0 sorry version)#3
Open
junaid-hasan wants to merge 19 commits into
Open
Conversation
Define signedIncMatrix using Sym2.lift with canonical orientation via LinearOrder min/max. Includes: - signedIncMatrix: Matrix V (Sym2 V) ℤ returning ±1/0 - signedIncMatrix_entry_fst: +1 for smaller endpoint - signedIncMatrix_entry_snd: -1 for larger endpoint - signedIncMatrix_entry_not_incident: 0 for non-incident pairs - reducedSignedIncMatrix: submatrix dropping root row - #eval! smoke tests on house graph confirm ±1/0 values - No Classical.choice or Nonempty; fully computable Other fixes: - Basic.lean: remove broken completeGraph test block, fix Irreflexive → Std.Irrefl compat - ForMathlib.lean: remove MultilinearMap.ext_ring (upstreamed) - MatrixTreeThm.lean: fix DecidableRel G.Adj instance binders - LeanGraphMatrices.lean: add SignIncMatrix import - lake-manifest.json: pin mathlib to v4.28.0 compatible revision - lean-toolchain: ensure v4.28.0 for Aristotle compat
…orics project (Issue 002) Key decisions: - Vendored CauchyBinet.lean and PermFinset.lean from faabian's project (Apache 2.0 licensed) - Changed import AlgebraicCombinatorics.Determinants.PermFinset → LeanGraphMatrices.PermFinset - Added attribution comments to both files - Replaced old sorried CauchyBinet.lean with complete, sorried-free proof - Removed reference to removed Matrix.det_mul' in MatrixTreeThm.lean Files changed: - LeanGraphMatrices/CauchyBinet.lean: complete rewrite (vendored, ~4060 lines) - LeanGraphMatrices/PermFinset.lean: new file (vendored, ~190 lines) - LeanGraphMatrices/MatrixTreeThm.lean: removed ref to Matrix.det_mul' Verification: - lake build LeanGraphMatrices.CauchyBinet: 0 errors - lake build LeanGraphMatrices.PermFinset: 0 errors - grep sorry: 0 sorries in vendored files - AlgebraicCombinatorics.CauchyBinet.cauchyBinet is accessible Next: Issue 003 (Laplacian incidence product), Issue 004 (spanning tree)
Key decisions: - Prove lapMatrix_eq_signedInc_mul_transpose: the full Laplacian equals signed incidence matrix times its transpose - Prove redLapMatrix_eq_reducedSignedInc_mul_transpose: reduced version - Add helper lemmas: signedIncMatrix_sq_eq_incMatrix, signedIncMatrix_mul_of_adj, signedIncMatrix_mul_of_not_adj - Use G.incidenceSet_inter_incidenceSet_of_adj/of_not_adj to control which edges contribute to the matrix product - Use Quot.exists_rep + Sym2.eq_swap to handle Sym2 quotient equality - Replace old sorried lapMatrix_incMatrix_prod / redLapMatrix_incMatrix_prod with new lemmas from SignIncMatrix - Replace old signIncMatrix (unoriented) with new signedIncMatrix - Add decide-based smoke test on house graph - Move issues 002 and 003 to done/ Files changed: - LeanGraphMatrices/SignIncMatrix.lean: +127 lines (lemmas + smoke test) - LeanGraphMatrices/MatrixTreeThm.lean: replaced old sorried lemmas, import SignIncMatrix, open Matrix for ᵀ notation - issues/done/002-vendor-cauchy-binet.md: moved - issues/done/003-laplacian-incidence-product.md: moved Verification: - lake build LeanGraphMatrices.SignIncMatrix: 0 errors - grep sorry SignIncMatrix.lean: 0 sorries - smoke test (example ... by decide): passes Next: Issue 004 (SpanningTree Fintype/leaf)
…e, partial exists_leaf (Issue 004) Key decisions: - Computable Decidable G.IsTree via decidable_of_iff with isTree_iff_connected_and_card and Fintype.card (not Nat.card) - Decidable G.Connected comes from WalkCounting import (no custom instance needed) - Noncomputable Fintype (SpanningTree G) via Fintype.ofFinite + Finite injectivity proof - exists_leaf lemma structured but has 3 sorries (degree-sum contradiction + Nat.card conversion) - Conclusion uses Nat.card instead of degree to avoid Fintype (neighborSet v) in lemma type - Added SpanningTree to LeanGraphMatrices.lean import list - Fixed MatrixTreeThm.lean: added missing DecidableRel G.Adj to lemma signatures, simplified isTree_iff_acyclic_and_card to sorry placeholder Files changed: - LeanGraphMatrices.lean: added SpanningTree import - LeanGraphMatrices/MatrixTreeThm.lean: fixed typeclass args, simplified placeholder lemma - LeanGraphMatrices/SpanningTree.lean: complete rewrite with decidable instances, Fintype, exists_leaf - issues/004-spanning-tree-fintype-leaf.md: updated acceptance criteria with progress notes Blockers/notes: - Computable Fintype needs edge-set enumeration approach for #eval to work - exists_leaf needs degree-sum proof (classic leaf-counting argument) - #eval smoke tests commented out pending computable Fintype
…p skeleton for signedInc_det_tree (Issue 005) Key decisions: - treeParent_edge_injective: proved using Walk.copy, IsPath.getVert_injOn, and the uniqueness of IsPath walks in a tree. The key case (x = parent(y) and y = parent(x)) leads to px.getVert 0 = px.getVert 2, contradicting IsPath injectivity. Uses a helper lemma h_getVert_inv for ▸-transport of getVert. - leaf_row_single_nonzero: proved using Set.ncard_eq_one (from Nat.card = 1) to show the neighbor set is a singleton, then treeParent_edge_injective for the contradiction when the leaf equals another vertex's parent. - det_factor_row_single: stated but sorried; the key lemma that if row r has only M[r][r] ≠ 0 then det = M[r][r] * det(minor). Proof sketch: Leibniz formula + Perm.subtypeCongr bijection. - signedInc_det_tree: stated but sorried; proof sketch is leaf induction using det_factor_row_single and exists_leaf. Files changed: - LeanGraphMatrices/TreeDet.lean: complete lemma implementations + sorry stubs - LeanGraphMatrices.lean: already has TreeDet import - LeanGraphMatrices/SpanningTree.lean: already complete (from prior work) Verification: - lake build LeanGraphMatrices.TreeDet: 0 errors, 2 sorries Blockers/notes: - det_factor_row_single needs the Perm.subtypeCongr bijection formalized - signedInc_det_tree needs induction on |V| with subtree construction - These 2 sorries are suitable for Aristotle submission
…ctor_row_single, signedInc_det_tree)
…e 005)
Key decisions:
- Aristotle proved all remaining sorries using the minimum-depth permutation argument
- Key lemma perm_eq_id_of_endpoint_condition: if σ(i) ∈ {i, parent(i)} ∀i, then σ = id.
Proof: pick minimum-depth vertex with σ(i) ≠ i; then σ(i) = parent(i),
but parent(i) has smaller depth so σ(parent(i)) = parent(i), contradicting injectivity.
- prod_eq_zero_of_perm_ne_one: for σ ≠ id, Leibniz product has a zero factor
- prod_pm_one: product of ±1 entries is ±1
- Main theorem: Leibniz formula → only identity contributes → ±1
Files changed:
- LeanGraphMatrices/TreeDet.lean: fully proved, 0 sorries
Verification:
- lake build: 0 errors, 0 sorries
- Aristotle project ID: eb602142-156e-4ec6-90b1-b337720b1745
Blockers/notes:
- Issue 005 is now complete
…e 006) Key decisions: - Proved via Aristotle (Harmonic ATP) with project ID d96425d5 - Unified proof: non-tree with |V|-1 edges ⟹ disconnected (uses Connected.exists_isTree_le + cardinality sandwich argument) - Key lemma det_zero_of_sum_rows_eq_zero: if a nonempty set of rows sums to zero column-wise, determinant is zero (via row operations) - Key lemma signedIncMatrix_sum_over_reachable_component_eq_zero: sum of signed incidence entries over a reachable component = 0 - Main proof assembly: 1. not tree → not connected (edgeGraph_not_tree_not_connected) 2. exists vertex u unreachable from q (connected_iff_exists_forall_reachable) 3. row sum over reachable component = 0 4. det = 0 via det_zero_of_sum_rows_eq_zero Files changed: - LeanGraphMatrices/NonTreeDet.lean: new file (234 lines, 0 sorries) - LeanGraphMatrices.lean: added NonTreeDet import Verification: - lake build: 0 errors, 0 sorries in NonTreeDet.lean - Aristotle project ID: d96425d5-c12a-42c7-b3cb-a1ab8352a9b9 Co-authored-by: Aristotle (Harmonic) <aristotle-harmonic@harmonic.fun> Blockers/notes: - Issue 006 is now complete - Next: Issue 007 (main theorem assembly)
For any finite simple graph G and any vertex q:
det(L₀(G, q)) = #{spanning trees of G}
where L₀(G, q) is the reduced Laplacian (Laplacian with q-th row/column removed).
Proof: Laplacian factorization (L₀ = B₀·B₀ᵀ) → Cauchy-Binet →
TreeDet (det = ±1 for trees) + NonTreeDet (det = 0 for non-trees) → sum = #trees.
All files: 0 sorries. Clean build (8035 jobs).
Prove Kirchhoff's Matrix-Tree Theorem via the Cauchy-Binet approach: det(reduced Laplacian) = number of spanning trees of G New files: - TreeDet.lean: signedInc_det_tree = ±1 - NonTreeDet.lean: signedInc_det_nontree = 0 Modified: - MatrixTreeThm.lean: full proof of matrix_tree_theorem - CauchyBinet.lean: adapted from faabian/algebraic-combinatorics (225 lines) - SignIncMatrix.lean: L = B·Bᵀ, reduced signed incidence matrix - SpanningTree.lean: cleaned imports Deleted: - PermFinset.lean (dead after CauchyBinet cleanup) Total: 1457 lines, 0 sorries, 0 axioms (beyond propext/Classical.choice/Quot.sound)
…o ForMathlib.lean, fix build warnings
- SignIncMatrix: add omit clauses, rename unused hij → _hij - TreeDet: add omit clauses for 5 theorems - NonTreeDet: remove unused simp args, add omit clauses for 4 theorems - MatrixTreeThm: remove unused simp args, add omit clauses for 9 theorems, rename unused hT → _hT, remove 4 redundant infer_instance lines - BLUEPRINT.md: 7-chapter document with architecture, dependencies, proof walkthroughs, and LaTeX mapping Build: 0 warnings, 0 sorries (in proof modules), 0 unused declarations
Author
Module Dependency Graph |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It looks like Matrix Tree Theorem is done!
There are 0 sorries, and 0 warnings.
In a future PR I might add a more human written version. The current version was possible via
It costed around $10 in API cost and used about 250 Million tokens (most were cached input so at cheaper rates). Also the cost is higher because in earlier runs I tried to use DeepSeek only and wasted a ton of tokens. I feel using Aristotle at the start would have made it much more efficient. However aristotle uses the grind tactic at a lot of places which makes it hard for a human to understand. This presents an opportunity for future readibility improvements.
I will add followup comments explaining the code and the lemmas and how they work.