Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Kruskal: the sorted-edge exchange inequality

Proved
Algo2Lean.Kruskal.Scan.weight_le

by lunjia · Oct 10, 2026 · Mathlib 0df444a (Lean v4.33.1)

algo2leanalgorithmsclrsdata-structuresrunning-timetextbook

Suppose Scan pending selected result, the pending edges are in nondecreasing weight order, and the already selected edges form a forest. Let other be any competitor forest that contains every selected edge, uses only selected or pending edges, and connects the endpoints of every pending edge. Then

weight⁡(result)≤weight⁡(other).\operatorname{weight}(result)\le\operatorname{weight}(other).weight(result)≤weight(other).

Weights are arbitrary integers; equal weights are permitted. This pure graph theorem contains no union-find, heap, compiler or runtime hypothesis. It is the exchange argument underlying the minimum spanning forest result and the safe-edge principle of CLRS fourth-edition Theorem 21.1.

<!-- algo2lean-provenance-v0.1.4 -->

Algo2Lean provenance and reproduction. These definitions target Algo2Lean v0.1.4, using the compiler source at public commit 0f79d5e4242e6477531c9ee4410409f5b1c92f76, and Lean 4.33.1. The versioned compiler location is Algo2Lean v0.1.4. Compile all supplied .algo files and imports to reproduce the raw generated definitions. Release publication and exact website parity require their separately recorded checks; this metadata alone does not assert them. Prove2Me imports and declaration packaging are mechanically adapted, with original hashes, compiler-reported source ranges, and adaptations recorded in transplant provenance. Exact reproduction does not prove the compiler correct.

Preamble
import Definitions.Def_Algo2LeanLib_KruskalMath

set_option autoImplicit true
set_option backward.isDefEq.respectTransparency false
set_option backward.defeqAttrib.useBackward true

set_option autoImplicit false
Formal statement
theorem Algo2Lean.Kruskal.Scan.weight_le :
    ∀ {pending selected result : List.{0} Algo2Lean.Kruskal.Edge},
      Algo2Lean.Kruskal.Scan pending selected result →
        Algo2Lean.Kruskal.Sorted pending →
          Algo2Lean.Kruskal.Forest selected →
            ∀ (other : List.{0} Algo2Lean.Kruskal.Edge),
              Algo2Lean.Kruskal.Forest other →
                (∀ (edge : Algo2Lean.Kruskal.Edge),
                    Membership.mem.{0, 0} selected edge → Membership.mem.{0, 0} other edge) →
                  (∀ (edge : Algo2Lean.Kruskal.Edge),
                      Membership.mem.{0, 0} other edge →
                        Membership.mem.{0, 0} pending edge ∨ Membership.mem.{0, 0} selected edge) →
                    (∀ (edge : Algo2Lean.Kruskal.Edge),
                        Membership.mem.{0, 0} pending edge →
                          Algo2Lean.Kruskal.Connected other edge.source edge.target) →
                      LE.le.{0} (Algo2Lean.Kruskal.weight result) (Algo2Lean.Kruskal.weight other) := by
  sorry
Source
https://github.com/lunjiah/algo2lean/blob/0f79d5e4242e6477531c9ee4410409f5b1c92f76/Algo2LeanLib/KruskalMath.lean#L485-L558

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me