AFTD Auto-Formalizing Theoretical Domains

size_priority_matching_symmDiff_card_le

theoremverified

For every n, every edge set E ⊆ Fin n × Fin n, and all real cost functions w₁ and w₂, the symmetric difference of the size-priority optimal matchings size_priority_matching n E w₁ and size_priority_matching n E w₂ has cardinality at most 2 * n.

Statement

theorem size_priority_matching_symmDiff_card_le (n : ℕ) (E : Finset (Fin n × Fin n))
    (w₁ w₂ : Fin n × Fin n → ℝ) :
    (symmDiff (size_priority_matching n E w₁) (size_priority_matching n E w₂)).card ≤ 2 * n
Source
arXiv:2601.20502, Optimal matching under size priority
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • size_priority_matching_card_leFor every n, every edge set E ⊆ Fin n × Fin n, and every real cost function w, the size-priority optimal matching size_priority_matching n…
  • size_priority_matchingA chosen size-priority optimal matching of the bipartite graph on Fin n + Fin n with edge set E under costs w (Hilbert's epsilon of…

Read back from the Lean

For every natural number n, every edge set E of pairs in Fin n × Fin n, and all weight functions w₁, w₂ : Fin n × Fin n → ℝ, the symmetric difference of the size-priority matchings selected for w₁ and w₂ from E has cardinality at most 2 * n.

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

Each size-priority optimal matching in an n × n bipartite graph contains at most n edges. The symmetric difference of any two matchings is contained in their union, so its cardinality is bounded above by the sum of their individual sizes. Since each matching has at most n edges, the cardinality of their symmetric difference cannot exceed n + n = 2n.

  1. Each of the two size-priority optimal matchings contains at most n edges.

    In any bipartite graph with vertex sets of size n, every matching has cardinality at most n. Applying size_priority_matching_card_le to weight functions w₁ and w₂ yields |size_priority_matching n E w₁| ≤ n (hypothesis h1) and |size_priority_matching n E w₂| ≤ n (hypothesis h2).

    lines 5–6

    uses size_priority_matching_card_le

      have h1 : (size_priority_matching n E w₁).card ≤ n := size_priority_matching_card_le n E w₁
      have h2 : (size_priority_matching n E w₂).card ≤ n := size_priority_matching_card_le n E w₂
  2. The cardinality of the symmetric difference of the two matchings is at most the sum of their cardinalities.

    We bound the symmetric difference via a chain of two inequalities. First, any edge in the symmetric difference belongs to size_priority_matching n E w₁ \ size_priority_matching n E w₂ or to size_priority_matching n E w₂ \ size_priority_matching n E w₁ by Finset.mem_symmDiff. Discarding the negative conditions via Or.inl and Or.inr shows the edge belongs to size_priority_matching n E w₁ or size_priority_matching n E w₂, which by Finset.mem_union means it belongs to their union. Because the symmetric difference is a subset of the union, Finset.card_le_card implies its cardinality is at most the cardinality of the union. Second, Finset.card_union_le bounds the cardinality of the union by the sum of the cardinalities of the two matchings.

    lines 7–16

    uses Finset.card_le_card, Finset.mem_symmDiff, Finset.mem_union, Or.inl, Or.inr, Finset.card_union_le

      have h := (show (symmDiff (size_priority_matching n E w₁) (size_priority_matching n E w₂)).card
          ≤ (size_priority_matching n E w₁).card + (size_priority_matching n E w₂).card from by
        calc (symmDiff (size_priority_matching n E w₁) (size_priority_matching n E w₂)).card
            ≤ (size_priority_matching n E w₁ ∪ size_priority_matching n E w₂).card := by
              apply Finset.card_le_card
              intro x hx
              rw [Finset.mem_symmDiff] at hx
              simp only [Finset.mem_union]
              exact hx.elim (fun h => Or.inl h.1) (fun h => Or.inr h.1)
        _ ≤ _ := Finset.card_union_le _ _)
  3. The symmetric difference of the two matchings has cardinality at most 2 * n.

    From the previous bounds, the symmetric difference has cardinality at most |size_priority_matching n E w₁| + |size_priority_matching n E w₂|, and each matching has cardinality at most n. Combining these inequalities gives an upper bound of n + n = 2 * n, which omega verifies by linear integer arithmetic.

    line 17

      omega
size_priority_matching_card_le
A size-priority optimal matching on a bipartite graph with vertex sets of size n has cardinality at most n.
Finset.card_le_card
If one finite set is a subset of another, its cardinality is less than or equal to the cardinality of the other set.
Finset.mem_symmDiff
An element belongs to the symmetric difference of two sets if and only if it belongs to the first set but not the second, or to the second set but not the first.
Finset.mem_union
An element belongs to the union of two sets if and only if it belongs to the first set or to the second set.
Or.inl
From a proof of proposition A, deduce the disjunction A ∨ B.
Or.inr
From a proof of proposition B, deduce the disjunction A ∨ B.
Finset.card_union_le
The cardinality of the union of two finite sets is at most the sum of their cardinalities.

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

/-- The symmetric difference of any two size-priority optimal matchings on Fin n + Fin n has cardinality at most 2n. -/theorem size_priority_matching_symmDiff_card_le (n : ℕ) (E : Finset (Fin n × Fin n))    (w₁ w₂ : Fin n × Fin n → ℝ) :    (symmDiff (size_priority_matching n E w₁) (size_priority_matching n E w₂)).card ≤ 2 * n := by  have h1 : (size_priority_matching n E w₁).card ≤ n := size_priority_matching_card_le n E w₁  have h2 : (size_priority_matching n E w₂).card ≤ n := size_priority_matching_card_le n E w₂  have h := (show (symmDiff (size_priority_matching n E w₁) (size_priority_matching n E w₂)).card      ≤ (size_priority_matching n E w₁).card + (size_priority_matching n E w₂).card from by    calc (symmDiff (size_priority_matching n E w₁) (size_priority_matching n E w₂)).card        ≤ (size_priority_matching n E w₁ ∪ size_priority_matching n E w₂).card := by          apply Finset.card_le_card          intro x hx          rw [Finset.mem_symmDiff] at hx          simp only [Finset.mem_union]          exact hx.elim (fun h => Or.inl h.1) (fun h => Or.inr h.1)    _ ≤ _ := Finset.card_union_le _ _)  omega
See it in the graphDiscuss this resultChallenge it