AFTD Auto-Formalizing Theoretical Domains

Kruskal.totalWeight_erase

theoremverifiedimported Lean

Total weight after removing an edge. Let $\mathit{edges}$ be a list of weighted edges over $n$ vertices, and let $e$ be a weighted edge occurring in $\mathit{edges}$. Then the total weight of $\mathit{edges}$ equals the weight of $e$ plus the total weight of the list obtained by deleting the first occurrence of $e$ from $\mathit{edges}$.

Statement

set_option relaxedAutoImplicit false in
set_option autoImplicit false in
lemma Kruskal.totalWeight_erase {n : ℕ} (edges : List (WEdge n)) (e : WEdge n)
    (he : e ∈ edges) :
    totalWeight edges = e.weight + totalWeight (edges.erase e)
Source
TCSlib, `Kruskal.totalWeight_erase`
Lean proof
By [Your Name], [Partner's Name (if applicable)], from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Copyright (c) 2026 [Your Name] and [Partner's Name (if applicable)]. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.
Verified
07 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • Kruskal.totalWeight_nilTotal weight of the empty edge list. Over any number of vertices $n$, the total weight of the empty list of weighted edges is $0$; that…
  • Kruskal.WEdgeA weighted edge over $n$ vertices is a structure with two endpoints $u, v : \mathrm{Fin}\,n$ and a natural-number weight…
  • Kruskal.totalWeightThe total weight of an edge list is the sum of the weights of all its edges:…
Used by 1
  • Kruskal.processEdges_optimalOptimality of the greedy edge-selection sweep. Let $\mathit{edges}$ be a list of weighted edges on $n$ vertices, sorted in nondecreasing…

Lean source view module on GitHub

set_option relaxedAutoImplicit false inset_option autoImplicit false inlemma Kruskal.totalWeight_erase {n : ℕ} (edges : List (WEdge n)) (e : WEdge n)    (he : e ∈ edges) :    totalWeight edges = e.weight + totalWeight (edges.erase e) := by  unfold totalWeight  simpa using ((List.perm_cons_erase he).map WEdge.weight).sum_eq
See it in the graphDiscuss this resultChallenge it