AFTD Auto-Formalizing Theoretical Domains

metric_ball_volume_comparison_matroid_bases

theoremverifiedformalization

For every finite matroid M on a type α, any two bases A, B of M (satisfying M.IsBase A and M.IsBase B), and every natural number r, the cardinality (ncard) of the basis ball matroid_base_ball M A r is at most 4^(matroid_diam M) times the cardinality (ncard) of matroid_base_ball M B (2 * r).

Statement

theorem metric_ball_volume_comparison_matroid_bases {α : Type*} (M : Matroid α) [M.Finite]
    (A B : Set α) (hA : M.IsBase A) (hB : M.IsBase B) (r : ℕ) :
    (matroid_base_ball M A r).ncard ≤ 4 ^ (matroid_diam M) * (matroid_base_ball M B (2 * r)).ncard
Formalizes
arXiv:2611.27934 Lemma 4.11 -- The Power of Sampling for Finding Far-Apart Bases in Matroids
Verified
24 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • matroid_base_ballFor a matroid M, a basis B, and a radius r, the ball Ball_M(B, r) is the set of bases A of M such that |B \ A| ≤ r.
  • matroid_diamFor a matroid M on a type α, the diameter matroid_diam M is defined as the supremum in ℕ of the set of cardinalities (A \ B).ncard over…
  • exists_base_ball_imageLet M be a finite matroid, and let A, B be bases of M. For every base X in Ball_M(A, r), there exists a base Y in Ball_M(B, 2r) such that…

Read back from the Lean

For every type α, every finite matroid M on α, every pair of sets A and B that are bases of M (M.IsBase A and M.IsBase B), and every natural number r: The number of bases in the ball of radius r centered at A (i.e., bases A' of M such that (A \ A').ncard ≤ r) is less than or equal to 4 ^ (matroid_diam M) times the number of bases in the ball of radius 2 * r centered at B (i.e., bases B' of M such that (B \ B').ncard ≤ 2 * r), where matroid_diam M is the supremum over all pairs of bases X, Y of M of (X \ Y).ncard.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The theorem bounds the size of a radius-r basis ball around A by 4^(matroid_diam M) times the size of the radius-2r basis ball around B in a finite matroid. First, an auxiliary lemma shows that for any bases A and Y, the fiber of sets X whose differences with A are contained in those of Y has cardinality at most 4^(matroid_diam M), by an injective embedding into 𝒫(A \ Y) × 𝒫(Y \ A) and bounding |A \ Y| by the matroid diameter. Second, by a known covering lemma (exists_base_ball_image), the radius-r ball around A is covered by these fibers over all bases Y in the radius-2r ball around B. Applying the union bound and the fiber size bound yields the desired volume comparison inequality.

  1. Every set X is uniquely reconstructible from its differences with A via X = (A \ (A \ X)) ∪ (X \ A).

    Define S as the set of all sets X whose differences with A are contained in the corresponding differences of Y with A. By set extensionality, an element x belongs to X if and only if it is in A and not in A \ X, or in X \ A. Rewriting with definitions of union and set difference reduces this to a propositional equivalence, which is closed by propositional logic.

    lines 5–10

    uses Set.mem_union, Set.mem_sdiff

      classical
      set S : Set (Set α) := {X : Set α | X \ A ⊆ Y \ A ∧ A \ X ⊆ A \ Y} with hS
      have key : ∀ X : Set α, X = (A \ (A \ X)) ∪ (X \ A) := by
        intro X; ext x
        simp only [Set.mem_union, Set.mem_sdiff]
        tauto
  2. The assignment X ↦ (A \ X, X \ A) is injective on S, and maps S into 𝒫(A \ Y) ×ˢ 𝒫(Y \ A).

    If two sets X₁ and X₂ have equal differences A \ X₁ = A \ X₂ and X₁ \ A = X₂ \ A, reconstructing each using the identity from the previous step proves X₁ = X₂. Furthermore, by definition of S, every X ∈ S satisfies A \ X ⊆ A \ Y and X \ A ⊆ Y \ A, so the image pair belongs to the Cartesian product 𝒫(A \ Y) ×ˢ 𝒫(Y \ A).

    lines 11–18

    uses Prod.mk.injEq

      have hinj : Set.InjOn (fun X : Set α => (A \ X, X \ A)) S := by
        intro X1 _ X2 _ h
        simp only [Prod.mk.injEq] at h
        obtain ⟨h1, h2⟩ := h
        rw [key X1, key X2, h1, h2]
      have hsub : (fun X : Set α => (A \ X, X \ A)) '' S ⊆ (𝒫 (A \ Y)) ×ˢ (𝒫 (Y \ A)) := by
        rintro p ⟨X, hX, rfl⟩
        exact ⟨hX.2, hX.1⟩
  3. The cardinality of S is at most 2^(|A \ Y|) * 2^(|A \ Y|), and |Y \ A| = |A \ Y|.

    Since A and Y are bases of a finite matroid, the differences A \ Y and Y \ A are finite, which makes the product of their power sets finite. Injectivity ensures |S| is bounded by the cardinality of this product, which is 2^(|A \ Y|) * 2^(|Y \ A|). By equicardinality of symmetric differences between matroid bases, |Y \ A| = |A \ Y|.

    lines 19–25

    uses Set.ncard_le_ncard_of_injOn, Set.ncard_prod, Set.ncard_powerset

      have hfinA : (A \ Y).Finite := hA.finite.subset sdiff_subset
      have hfinYA : (Y \ A).Finite := hY.finite.subset sdiff_subset
      have hfinprod : ((𝒫 (A \ Y)) ×ˢ (𝒫 (Y \ A))).Finite := hfinA.powerset.prod hfinYA.powerset
      have h1 : S.ncard ≤ ((𝒫 (A \ Y)) ×ˢ (𝒫 (Y \ A))).ncard :=
        Set.ncard_le_ncard_of_injOn _ (fun X hX => hsub ⟨X, hX, rfl⟩) hinj hfinprod
      rw [Set.ncard_prod, Set.ncard_powerset (A \ Y) hfinA, Set.ncard_powerset (Y \ A) hfinYA] at h1
      have heq : (Y \ A).ncard = (A \ Y).ncard := (hA.ncard_sdiff_comm hY).symm
  4. The difference size |A \ Y| is bounded above by the matroid diameter matroid_diam M.

    For any pair of bases A' and B', the difference A' \ B' is contained in the finite ground set M.E, so its cardinality is bounded above by |M.E|. Therefore, the set of difference sizes between pairs of bases is bounded above. Since A and Y are bases, |A \ Y| belongs to this set, and by definition of the matroid diameter as the supremum, |A \ Y| ≤ matroid_diam M.

    lines 26–34

    uses Set.ncard_le_ncard, Set.sdiff_subset, le_csSup

      have hbdd : BddAbove { (A' \ B').ncard | (A' : Set α) (B' : Set α) (_ : M.IsBase A') (_ : M.IsBase B') } := by
        refine ⟨M.E.ncard, ?_⟩
        rintro b ⟨A', B', hA', hB', rfl⟩
        exact Set.ncard_le_ncard ((Set.sdiff_subset).trans hA'.subset_ground) M.ground_finite
      have hmem : (A \ Y).ncard ∈ { (A' \ B').ncard | (A' : Set α) (B' : Set α) (_ : M.IsBase A') (_ : M.IsBase B') } :=
        ⟨A, Y, hA, hY, rfl⟩
      have hdle : (A \ Y).ncard ≤ matroid_diam M := by
        rw [matroid_diam]
        exact le_csSup hbdd hmem
  5. The cardinality of S is at most 4^(matroid_diam M), completing the auxiliary lemma.

    Using |Y \ A| = |A \ Y|, the cardinality bound becomes 2^(|A \ Y|) * 2^(|A \ Y|) = (2 * 2)^(|A \ Y|) = 4^(|A \ Y|). Since 4 > 0 and |A \ Y| ≤ matroid_diam M, monotonicity of exponentiation gives 4^(|A \ Y|) ≤ 4^(matroid_diam M).

    lines 35–39

    uses Nat.mul_pow, Nat.pow_le_pow_right

      refine h1.trans ?_
      rw [heq]
      calc 2 ^ (A \ Y).ncard * 2 ^ (A \ Y).ncard = (2 * 2) ^ (A \ Y).ncard := (Nat.mul_pow 2 2 _).symm
        _ = 4 ^ (A \ Y).ncard := by norm_num
        _ ≤ 4 ^ matroid_diam M := Nat.pow_le_pow_right (by norm_num) hdle
  6. The radius-r basis ball around A is covered by the union of T(Y) over all Y in the radius-2r ball around B.

    Define T(Y) = {X | X \ A ⊆ Y \ A ∧ A \ X ⊆ A \ Y}. By the covering property exists_base_ball_image, for every base X in the radius-r ball around A, there exists a base Y in the radius-2r ball around B such that X ∈ T(Y). Hence the ball around A is contained in the union of T(Y) over all such Y.

    lines 45–50

    uses exists_base_ball_image, Set.mem_biUnion

      classical
      set T : Set α → Set (Set α) := fun Y => {X : Set α | X \ A ⊆ Y \ A ∧ A \ X ⊆ A \ Y} with hT
      have hsub : matroid_base_ball M A r ⊆ ⋃ Y ∈ matroid_base_ball M B (2*r), T Y := by
        intro X hX
        obtain ⟨Y, hY, h1, h2⟩ := exists_base_ball_image M hA hB r hX
        exact Set.mem_biUnion hY (show X ∈ T Y from ⟨h1, h2⟩)
  7. The ball around B and the covering union are finite sets.

    Every base in the ball around B is a subset of the finite ground set M.E, so the ball is finite. For any set X in the covering union, there is some base Y in the ball with X ∈ T(Y); every element x ∈ X is either in A ⊆ M.E or in X \ A ⊆ Y \ A ⊆ M.E. Thus every such X is a subset of M.E, which makes the covering union a subset of 𝒫(M.E) and therefore finite.

    lines 51–66

    uses Set.mem_iUnion

      have hfinB : (matroid_base_ball M B (2*r)).Finite :=
        M.ground_finite.powerset.subset (fun X hX => hX.1.subset_ground)
      have hunion_sub : (⋃ Y ∈ matroid_base_ball M B (2*r), T Y) ⊆ 𝒫 M.E := by
        intro X hX
        rw [Set.mem_iUnion] at hX
        obtain ⟨Y, hY⟩ := hX
        rw [Set.mem_iUnion] at hY
        obtain ⟨hYmem, hXY⟩ := hY
        show X ∈ 𝒫 M.E
        have hYbase : M.IsBase Y := hYmem.1
        intro x hx
        by_cases hxA : x ∈ A
        · exact hA.subset_ground hxA
        · exact hYbase.subset_ground (hXY.1 ⟨hx, hxA⟩).1
      have hfinU : (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).Finite :=
        M.ground_finite.powerset.subset hunion_sub
  8. The cardinality of the radius-r ball around A is at most the sum of |T(Y)| over the radius-2r ball around B, which is at most |Ball_M(B, 2r)| * 4^(matroid_diam M).

    By subset monotonicity, the cardinality of the ball around A is at most the cardinality of the covering union. By subadditivity of cardinality over finite unions, this is bounded by the sum of |T(Y)| over Y in the finset of the ball around B. By the auxiliary lemma, each term |T(Y)| is at most 4^(matroid_diam M). Summing this constant over the finset gives the finset cardinality times 4^(matroid_diam M).

    lines 67–78

    uses Set.ncard_le_ncard, Finset.set_ncard_biUnion_le, Set.Finite.mem_toFinset, Finset.sum_le_sum, metric_ball_volume_comparison_matroid_bases_aux, Finset.sum_const_nat

      have step1 : (matroid_base_ball M A r).ncard ≤ (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).ncard :=
        Set.ncard_le_ncard hsub hfinU
      have step2 : (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).ncard
          ≤ ∑ Y ∈ hfinB.toFinset, (T Y).ncard := by
        have h := Finset.set_ncard_biUnion_le hfinB.toFinset T
        simpa [Set.Finite.mem_toFinset] using h
      have step3 : ∑ Y ∈ hfinB.toFinset, (T Y).ncard ≤ ∑ Y ∈ hfinB.toFinset, 4 ^ (matroid_diam M) := by
        apply Finset.sum_le_sum
        intro Y hY
        exact metric_ball_volume_comparison_matroid_bases_aux M hA (hfinB.mem_toFinset.mp hY).1
      have step4 : ∑ Y ∈ hfinB.toFinset, 4 ^ (matroid_diam M) = hfinB.toFinset.card * 4 ^ (matroid_diam M) :=
        Finset.sum_const_nat (fun _ _ => rfl)
  9. The cardinality of Ball_M(A, r) is at most 4^(matroid_diam M) * |Ball_M(B, 2r)|.

    Chaining the four bounds established in the previous step gives |Ball_M(A, r)| ≤ |Ball_M(B, 2r)| * 4^(matroid_diam M). Converting the finset cardinality back to the set cardinality and commuting multiplication finishes the proof.

    lines 79–85

    uses Set.ncard_eq_toFinset_card, Nat.mul_comm

      calc (matroid_base_ball M A r).ncard
          ≤ (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).ncard := step1
        _ ≤ ∑ Y ∈ hfinB.toFinset, (T Y).ncard := step2
        _ ≤ ∑ Y ∈ hfinB.toFinset, 4 ^ (matroid_diam M) := step3
        _ = hfinB.toFinset.card * 4 ^ (matroid_diam M) := step4
        _ = 4 ^ (matroid_diam M) * (matroid_base_ball M B (2*r)).ncard := by
            rw [Set.ncard_eq_toFinset_card _ hfinB, Nat.mul_comm]
Set.mem_union
An element belongs to the union of two sets if and only if it belongs to at least one of them.
Set.mem_sdiff
An element belongs to the set difference s \ t if and only if it belongs to s and does not belong to t.
Prod.mk.injEq
Two ordered pairs are equal if and only if their respective first and second components are equal.
Set.ncard_le_ncard_of_injOn
If a map f sends a set s into a finite set t and is injective on s, then the cardinality of s is at most that of t.
Set.ncard_prod
The cardinality of the Cartesian product of two sets is the product of their cardinalities.
Set.ncard_powerset
The power set of a finite set s has cardinality 2^|s|.
Set.ncard_le_ncard
If a set s is a subset of a finite set t, then the cardinality of s is at most the cardinality of t.
Set.sdiff_subset
The set difference s \ t is a subset of s.
le_csSup
In a conditionally complete lattice, every element of a set bounded above is at most the supremum of that set.
Nat.mul_pow
For natural numbers a, b, n, (a * b)^n = a^n * b^n.
Nat.pow_le_pow_right
For a positive natural base n, the exponential function n^i is monotonically non-decreasing in the exponent i.
exists_base_ball_image
For any base X in the radius-r ball around A, there exists a base Y in the radius-2r ball around B such that X \ A ⊆ Y \ A and A \ X ⊆ A \ Y.
Set.mem_biUnion
An element y belongs to the bounded union ⋃ x ∈ s, t(x) if there exists x ∈ s with y ∈ t(x).
Set.mem_iUnion
An element belongs to an indexed union if and only if it belongs to at least one set in the family.
Finset.set_ncard_biUnion_le
The cardinality of a finite union of sets is bounded above by the sum of their individual cardinalities.
Set.Finite.mem_toFinset
An element belongs to the finset hs.toFinset if and only if it belongs to the underlying finite set s.
Finset.sum_le_sum
If f(i) ≤ g(i) for all indices i in a finset, then the sum of f over the finset is at most the sum of g.
metric_ball_volume_comparison_matroid_bases_aux
For bases A and Y of a finite matroid, the set of all X with X \ A ⊆ Y \ A and A \ X ⊆ A \ Y has cardinality at most 4^(matroid_diam M).
Finset.sum_const_nat
Summing a constant natural number m over a finset s equals the cardinality of s times m.
Set.ncard_eq_toFinset_card
The cardinality of a finite set s equals the cardinality of its associated finset hs.toFinset.
Nat.mul_comm
Multiplication of natural numbers is commutative: n * m = m * n.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

open Set inprivate lemma metric_ball_volume_comparison_matroid_bases_aux {α : Type*} (M : Matroid α) [M.Finite]    {A Y : Set α} (hA : M.IsBase A) (hY : M.IsBase Y) :    ({X : Set α | X \ A ⊆ Y \ A ∧ A \ X ⊆ A \ Y}).ncard ≤ 4 ^ (matroid_diam M) := by  classical  set S : Set (Set α) := {X : Set α | X \ A ⊆ Y \ A ∧ A \ X ⊆ A \ Y} with hS  have key : ∀ X : Set α, X = (A \ (A \ X)) ∪ (X \ A) := by    intro X; ext x    simp only [Set.mem_union, Set.mem_sdiff]    tauto  have hinj : Set.InjOn (fun X : Set α => (A \ X, X \ A)) S := by    intro X1 _ X2 _ h    simp only [Prod.mk.injEq] at h    obtain ⟨h1, h2⟩ := h    rw [key X1, key X2, h1, h2]  have hsub : (fun X : Set α => (A \ X, X \ A)) '' S ⊆ (𝒫 (A \ Y)) ×ˢ (𝒫 (Y \ A)) := by    rintro p ⟨X, hX, rfl⟩    exact ⟨hX.2, hX.1⟩  have hfinA : (A \ Y).Finite := hA.finite.subset sdiff_subset  have hfinYA : (Y \ A).Finite := hY.finite.subset sdiff_subset  have hfinprod : ((𝒫 (A \ Y)) ×ˢ (𝒫 (Y \ A))).Finite := hfinA.powerset.prod hfinYA.powerset  have h1 : S.ncard ≤ ((𝒫 (A \ Y)) ×ˢ (𝒫 (Y \ A))).ncard :=    Set.ncard_le_ncard_of_injOn _ (fun X hX => hsub ⟨X, hX, rfl⟩) hinj hfinprod  rw [Set.ncard_prod, Set.ncard_powerset (A \ Y) hfinA, Set.ncard_powerset (Y \ A) hfinYA] at h1  have heq : (Y \ A).ncard = (A \ Y).ncard := (hA.ncard_sdiff_comm hY).symm  have hbdd : BddAbove { (A' \ B').ncard | (A' : Set α) (B' : Set α) (_ : M.IsBase A') (_ : M.IsBase B') } := by    refine ⟨M.E.ncard, ?_⟩    rintro b ⟨A', B', hA', hB', rfl⟩    exact Set.ncard_le_ncard ((Set.sdiff_subset).trans hA'.subset_ground) M.ground_finite  have hmem : (A \ Y).ncard ∈ { (A' \ B').ncard | (A' : Set α) (B' : Set α) (_ : M.IsBase A') (_ : M.IsBase B') } :=    ⟨A, Y, hA, hY, rfl⟩  have hdle : (A \ Y).ncard ≤ matroid_diam M := by    rw [matroid_diam]    exact le_csSup hbdd hmem  refine h1.trans ?_  rw [heq]  calc 2 ^ (A \ Y).ncard * 2 ^ (A \ Y).ncard = (2 * 2) ^ (A \ Y).ncard := (Nat.mul_pow 2 2 _).symm    _ = 4 ^ (A \ Y).ncard := by norm_num    _ ≤ 4 ^ matroid_diam M := Nat.pow_le_pow_right (by norm_num) hdle/-- Metric ball volume comparison for matroid bases: |Ball_M(A, r)| ≤ 4^{diam(M)} |Ball_M(B, 2r)|. -/theorem metric_ball_volume_comparison_matroid_bases {α : Type*} (M : Matroid α) [M.Finite]    (A B : Set α) (hA : M.IsBase A) (hB : M.IsBase B) (r : ℕ) :    (matroid_base_ball M A r).ncard ≤ 4 ^ (matroid_diam M) * (matroid_base_ball M B (2 * r)).ncard := by  classical  set T : Set α → Set (Set α) := fun Y => {X : Set α | X \ A ⊆ Y \ A ∧ A \ X ⊆ A \ Y} with hT  have hsub : matroid_base_ball M A r ⊆ ⋃ Y ∈ matroid_base_ball M B (2*r), T Y := by    intro X hX    obtain ⟨Y, hY, h1, h2⟩ := exists_base_ball_image M hA hB r hX    exact Set.mem_biUnion hY (show X ∈ T Y from ⟨h1, h2⟩)  have hfinB : (matroid_base_ball M B (2*r)).Finite :=    M.ground_finite.powerset.subset (fun X hX => hX.1.subset_ground)  have hunion_sub : (⋃ Y ∈ matroid_base_ball M B (2*r), T Y) ⊆ 𝒫 M.E := by    intro X hX    rw [Set.mem_iUnion] at hX    obtain ⟨Y, hY⟩ := hX    rw [Set.mem_iUnion] at hY    obtain ⟨hYmem, hXY⟩ := hY    show X ∈ 𝒫 M.E    have hYbase : M.IsBase Y := hYmem.1    intro x hx    by_cases hxA : x ∈ A    · exact hA.subset_ground hxA    · exact hYbase.subset_ground (hXY.1 ⟨hx, hxA⟩).1  have hfinU : (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).Finite :=    M.ground_finite.powerset.subset hunion_sub  have step1 : (matroid_base_ball M A r).ncard ≤ (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).ncard :=    Set.ncard_le_ncard hsub hfinU  have step2 : (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).ncard      ≤ ∑ Y ∈ hfinB.toFinset, (T Y).ncard := by    have h := Finset.set_ncard_biUnion_le hfinB.toFinset T    simpa [Set.Finite.mem_toFinset] using h  have step3 : ∑ Y ∈ hfinB.toFinset, (T Y).ncard ≤ ∑ Y ∈ hfinB.toFinset, 4 ^ (matroid_diam M) := by    apply Finset.sum_le_sum    intro Y hY    exact metric_ball_volume_comparison_matroid_bases_aux M hA (hfinB.mem_toFinset.mp hY).1  have step4 : ∑ Y ∈ hfinB.toFinset, 4 ^ (matroid_diam M) = hfinB.toFinset.card * 4 ^ (matroid_diam M) :=    Finset.sum_const_nat (fun _ _ => rfl)  calc (matroid_base_ball M A r).ncard      ≤ (⋃ Y ∈ matroid_base_ball M B (2*r), T Y).ncard := step1    _ ≤ ∑ Y ∈ hfinB.toFinset, (T Y).ncard := step2    _ ≤ ∑ Y ∈ hfinB.toFinset, 4 ^ (matroid_diam M) := step3    _ = hfinB.toFinset.card * 4 ^ (matroid_diam M) := step4    _ = 4 ^ (matroid_diam M) * (matroid_base_ball M B (2*r)).ncard := by        rw [Set.ncard_eq_toFinset_card _ hfinB, Nat.mul_comm]
See it in the graphDiscuss this resultChallenge it