AFTD Auto-Formalizing Theoretical Domains

op861_finite_maxcut_half_edges

theoremverified

For a finite vertex set and any finite set of nonloop ordered edges with endpoints in it, some vertex subset cuts at least half of the edges.

Statement

theorem op861_finite_maxcut_half_edges (α : Type*) [DecidableEq α]
    (S : Finset α) (E : Finset (α × α))
    (hE : ∀ e ∈ E, e.1 ∈ S ∧ e.2 ∈ S ∧ e.1 ≠ e.2) :
    ∃ U : Finset α, U ⊆ S ∧ E.card ≤ 2 *
      (E.filter (fun e => (e.1 ∈ U ∧ e.2 ∉ U) ∨ (e.2 ∈ U ∧ e.1 ∉ U))).card
Source
The dense crossing-edge cut used in op861_dense_triangle_orientation_sqrt_cover.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
Used by 1

The proof, explained

We prove that in any finite graph with no self-loops, there exists a vertex cut containing at least half of the edges. By symmetry, toggling an endpoint of an edge toggles whether it is cut, so every nonloop edge is cut by exactly half of all vertex subsets. Double-counting shows that the average cut size across all subsets is |E| / 2, so by the averaging principle at least one subset must achieve a cut of at least this size.

  1. Toggling an element of S in a subset U ⊆ S produces another subset of S.

    Given U ⊆ S and u ∈ S, any element x in the symmetric difference U ∆ {u} either belongs to U \ {u} (so x ∈ S since U ⊆ S) or to {u} \ U (so x = u ∈ S). By case analysis on mem_symmDiff and rewriting with mem_singleton, every element belongs to S.

    lines 13–17

    uses mem_symmDiff, mem_singleton

      intro x hx
      rw [mem_symmDiff] at hx
      rcases hx with ⟨hxU, _⟩ | ⟨hxu, _⟩
      · exact hU hxU
      · rw [mem_singleton] at hxu; subst hxu; exact hu
  2. Flipping an endpoint of a nonloop edge toggles whether that edge is cut.

    For an edge e = (u, v) with distinct endpoints u ≠ v, replacing U with U ∆ {u} flips whether u is in the set while leaving the membership of v unchanged (mem_symmDiff). Substituting these into the definition of a cut edge, propositional logic (tauto) verifies that e is cut by U ∆ {u} if and only if e is not cut by U.

    lines 23–27

    uses mem_symmDiff

      dsimp [op861_finite_maxcut_half_edges_cut_prop]
      have h1 : e.1 ∈ symmDiff U {e.1} ↔ e.1 ∉ U := by simp [mem_symmDiff]
      have h2 : e.2 ∈ symmDiff U {e.1} ↔ e.2 ∈ U := by simp [mem_symmDiff, hne.symm]
      rw [h1, h2]
      tauto
  3. Every nonloop edge with an endpoint in S is cut by exactly half of the subsets of S.

    The powerset of S is partitioned into the collection A of subsets cutting e and the collection B of subsets not cutting e, so |A| + |B| = |powerset(S)| by card_filter_add_card_filter_not. The map U ↦ U ∆ {e.1} preserves inclusion in S (op861_finite_maxcut_half_edges_symmDiff_subset) and interchanges cutting and non-cutting subsets (op861_finite_maxcut_half_edges_cut_prop_symmDiff_left, not_not.mpr). Since taking symmetric difference with {e.1} twice is the identity (symmDiff_assoc, symmDiff_self, symmDiff_bot), this map is a bijection by card_bij', so |A| = |B|. Linear arithmetic then yields 2 * |A| = |powerset(S)|.

    lines 32–52

    uses card_filter_add_card_filter_not, card_bij', mem_filter, mem_powerset, op861_finite_maxcut_half_edges_symmDiff_subset, op861_finite_maxcut_half_edges_cut_prop_symmDiff_left, not_not.mpr, symmDiff_assoc, symmDiff_self, symmDiff_bot

      let A := (S.powerset).filter (fun U => op861_finite_maxcut_half_edges_cut_prop e U)
      let B := (S.powerset).filter (fun U => ¬ op861_finite_maxcut_half_edges_cut_prop e U)
      have hAB : A.card + B.card = (S.powerset).card :=
        card_filter_add_card_filter_not (op861_finite_maxcut_half_edges_cut_prop e)
      have heq : A.card = B.card := by
        refine card_bij' (fun U _ => symmDiff U {e.1}) (fun U _ => symmDiff U {e.1}) ?_ ?_ ?_ ?_
        · intro U hU
          rw [mem_filter, mem_powerset] at hU ⊢
          refine ⟨op861_finite_maxcut_half_edges_symmDiff_subset hU.1 he1, ?_⟩
          rw [op861_finite_maxcut_half_edges_cut_prop_symmDiff_left _ _ hne]
          exact not_not.mpr hU.2
        · intro U hU
          rw [mem_filter, mem_powerset] at hU ⊢
          refine ⟨op861_finite_maxcut_half_edges_symmDiff_subset hU.1 he1, ?_⟩
          rw [op861_finite_maxcut_half_edges_cut_prop_symmDiff_left _ _ hne]
          exact hU.2
        · intro U _
          rw [symmDiff_assoc, symmDiff_self, symmDiff_bot]
        · intro U _
          rw [symmDiff_assoc, symmDiff_self, symmDiff_bot]
      linarith
  4. The sum of cut sizes over all subsets equals the sum over all edges of the number of subsets cutting each edge.

    Expressing each set cardinality as a sum of 0-1 indicators via sum_boole, both sides become double sums of the indicator that edge e is cut by subset U. Swapping the order of summation using sum_comm establishes the equality.

    lines 58–67

    uses sum_boole, sum_comm

      have h1 : ∀ U, (E.filter (op861_finite_maxcut_half_edges_cut_prop · U)).card =
          ∑ e ∈ E, (if op861_finite_maxcut_half_edges_cut_prop e U then 1 else 0) := by
        intro U
        exact (sum_boole (op861_finite_maxcut_half_edges_cut_prop · U) E).symm
      have h2 : ∀ e, (S.powerset.filter (op861_finite_maxcut_half_edges_cut_prop e)).card =
          ∑ U ∈ S.powerset, (if op861_finite_maxcut_half_edges_cut_prop e U then 1 else 0) := by
        intro e
        exact (sum_boole (op861_finite_maxcut_half_edges_cut_prop e) S.powerset).symm
      simp_rw [h1, h2]
      exact sum_comm
  5. Summing twice the cut size over all vertex subsets of S equals |E| * |powerset(S)|.

    Moving the factor of 2 inside the sum and applying the double-counting identity gives ∑_{e ∈ E} 2 * |{U ⊆ S : U cuts e}|. Since every edge in E has endpoints in S with e.1 ≠ e.2, each term in the sum equals |powerset(S)| by op861_finite_maxcut_half_edges_card_filter_cut_prop_eq (congruence via sum_congr). Summing this constant over all edges in E yields |E| * |powerset(S)|.

    lines 74–81

    uses mul_sum, op861_finite_maxcut_half_edges_sum_cut_card, op861_finite_maxcut_half_edges_card_filter_cut_prop_eq, sum_congr

      rw [← mul_sum, op861_finite_maxcut_half_edges_sum_cut_card, mul_sum]
      have h : ∀ e ∈ E, 2 * (S.powerset.filter (op861_finite_maxcut_half_edges_cut_prop e)).card =
          S.powerset.card := by
        intro e he
        have he_props := hE e he
        exact op861_finite_maxcut_half_edges_card_filter_cut_prop_eq S e he_props.1 he_props.2.2
      rw [sum_congr rfl h]
      simp
  6. There exists a subset of S cutting at least half of the edges.

    The previous identity shows that ∑_{U ∈ powerset(S)} |E| = ∑_{U ∈ powerset(S)} 2 * |cut(U)|. Since the powerset of S is nonempty (Finset.powerset_nonempty), the averaging lemma Finset.exists_le_of_sum_le guarantees the existence of some U in the powerset of S (so U ⊆ S by Finset.mem_powerset) satisfying |E| ≤ 2 * |cut(U)|.

    lines 88–95

    uses op861_finite_maxcut_half_edges_two_mul_sum_cut, mul_comm, Finset.exists_le_of_sum_le, Finset.powerset_nonempty, le_of_eq, Finset.mem_powerset

      have h_sum : ∑ _ ∈ S.powerset, E.card =
          ∑ U ∈ S.powerset, 2 * (E.filter (op861_finite_maxcut_half_edges_cut_prop · U)).card := by
        rw [op861_finite_maxcut_half_edges_two_mul_sum_cut S E hE]
        simp [mul_comm]
      have h_ex := Finset.exists_le_of_sum_le (Finset.powerset_nonempty S) (le_of_eq h_sum)
      rcases h_ex with ⟨U, hU, hle⟩
      rw [Finset.mem_powerset] at hU
      exact ⟨U, hU, hle⟩
mem_symmDiff
An element belongs to the symmetric difference of two sets if and only if it belongs to one but not both.
mem_singleton
An element belongs to the singleton set {a} if and only if it equals a.
card_filter_add_card_filter_not
The number of elements in a finite set satisfying a predicate plus the number not satisfying it equals the total size of the set.
card_bij'
Two finite sets have equal cardinality if there exist maps between them that are mutual inverses.
mem_filter
An element belongs to a filtered sub-finset if and only if it is in the original set and satisfies the predicate.
mem_powerset
A set belongs to the powerset of t if and only if it is a subset of t.
op861_finite_maxcut_half_edges_symmDiff_subset
If U is a subset of S and u is an element of S, then the symmetric difference U ∆ {u} is also a subset of S.
op861_finite_maxcut_half_edges_cut_prop_symmDiff_left
For an edge with distinct endpoints, toggling the membership of its first endpoint in U toggles whether the edge is cut by U.
not_not.mpr
A proposition implies its double negation.
symmDiff_assoc
Symmetric difference is associative.
symmDiff_self
The symmetric difference of any set with itself is the empty set.
symmDiff_bot
The symmetric difference of any set with the empty set is the set itself.
sum_boole
The sum of the indicator values of a predicate over a finite set equals the cardinality of the subset satisfying the predicate.
sum_comm
The order of summation in a finite double sum can be exchanged.
mul_sum
Multiplication distributes over finite summation.
op861_finite_maxcut_half_edges_sum_cut_card
The sum over all vertex subsets of the number of edges they cut equals the sum over all edges of the number of subsets cutting them.
op861_finite_maxcut_half_edges_card_filter_cut_prop_eq
For any nonloop edge with an endpoint in S, exactly half of the subsets of S cut that edge.
sum_congr
Two finite sums are equal if their index sets coincide and their summands agree at every element.
op861_finite_maxcut_half_edges_two_mul_sum_cut
Summing twice the cut size over all vertex subsets of S yields |E| times the number of subsets of S.
mul_comm
Multiplication is commutative.
Finset.exists_le_of_sum_le
If the sum of f is at most the sum of g over a nonempty finite set, then f(i) ≤ g(i) for at least one element i.
Finset.powerset_nonempty
The powerset of any finite set is nonempty because it always contains the empty set.
le_of_eq
An equality implies the corresponding inequality.
Finset.mem_powerset
A finite set belongs to the powerset of t if and only if it is a subset of t.

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 Finsetdef op861_finite_maxcut_half_edges_cut_prop {α : Type*} (e : α × α) (U : Finset α) : Prop :=  (e.1 ∈ U ∧ e.2 ∉ U) ∨ (e.2 ∈ U ∧ e.1 ∉ U)instance {α : Type*} [DecidableEq α] (e : α × α) (U : Finset α) :    Decidable (op861_finite_maxcut_half_edges_cut_prop e U) :=  inferInstanceAs (Decidable ((e.1 ∈ U ∧ e.2 ∉ U) ∨ (e.2 ∈ U ∧ e.1 ∉ U)))theorem op861_finite_maxcut_half_edges_symmDiff_subset {α : Type*} [DecidableEq α]    {S U : Finset α} {u : α} (hU : U ⊆ S) (hu : u ∈ S) :    symmDiff U {u} ⊆ S := by  intro x hx  rw [mem_symmDiff] at hx  rcases hx with ⟨hxU, _⟩ | ⟨hxu, _⟩  · exact hU hxU  · rw [mem_singleton] at hxu; subst hxu; exact hutheorem op861_finite_maxcut_half_edges_cut_prop_symmDiff_left {α : Type*} [DecidableEq α]    (U : Finset α) (e : α × α) (hne : e.1 ≠ e.2) :    op861_finite_maxcut_half_edges_cut_prop e (symmDiff U {e.1}) ↔      ¬ op861_finite_maxcut_half_edges_cut_prop e U := by  dsimp [op861_finite_maxcut_half_edges_cut_prop]  have h1 : e.1 ∈ symmDiff U {e.1} ↔ e.1 ∉ U := by simp [mem_symmDiff]  have h2 : e.2 ∈ symmDiff U {e.1} ↔ e.2 ∈ U := by simp [mem_symmDiff, hne.symm]  rw [h1, h2]  tautotheorem op861_finite_maxcut_half_edges_card_filter_cut_prop_eq {α : Type*} [DecidableEq α]    (S : Finset α) (e : α × α) (he1 : e.1 ∈ S) (hne : e.1 ≠ e.2) :    2 * ((S.powerset).filter (fun U => op861_finite_maxcut_half_edges_cut_prop e U)).card = (S.powerset).card := by  let A := (S.powerset).filter (fun U => op861_finite_maxcut_half_edges_cut_prop e U)  let B := (S.powerset).filter (fun U => ¬ op861_finite_maxcut_half_edges_cut_prop e U)  have hAB : A.card + B.card = (S.powerset).card :=    card_filter_add_card_filter_not (op861_finite_maxcut_half_edges_cut_prop e)  have heq : A.card = B.card := by    refine card_bij' (fun U _ => symmDiff U {e.1}) (fun U _ => symmDiff U {e.1}) ?_ ?_ ?_ ?_    · intro U hU      rw [mem_filter, mem_powerset] at hU ⊢      refine ⟨op861_finite_maxcut_half_edges_symmDiff_subset hU.1 he1, ?_⟩      rw [op861_finite_maxcut_half_edges_cut_prop_symmDiff_left _ _ hne]      exact not_not.mpr hU.2    · intro U hU      rw [mem_filter, mem_powerset] at hU ⊢      refine ⟨op861_finite_maxcut_half_edges_symmDiff_subset hU.1 he1, ?_⟩      rw [op861_finite_maxcut_half_edges_cut_prop_symmDiff_left _ _ hne]      exact hU.2    · intro U _      rw [symmDiff_assoc, symmDiff_self, symmDiff_bot]    · intro U _      rw [symmDiff_assoc, symmDiff_self, symmDiff_bot]  linariththeorem op861_finite_maxcut_half_edges_sum_cut_card {α : Type*} [DecidableEq α]    (S : Finset α) (E : Finset (α × α)) :    ∑ U ∈ S.powerset, (E.filter (op861_finite_maxcut_half_edges_cut_prop · U)).card =    ∑ e ∈ E, (S.powerset.filter (op861_finite_maxcut_half_edges_cut_prop e)).card := by  have h1 : ∀ U, (E.filter (op861_finite_maxcut_half_edges_cut_prop · U)).card =      ∑ e ∈ E, (if op861_finite_maxcut_half_edges_cut_prop e U then 1 else 0) := by    intro U    exact (sum_boole (op861_finite_maxcut_half_edges_cut_prop · U) E).symm  have h2 : ∀ e, (S.powerset.filter (op861_finite_maxcut_half_edges_cut_prop e)).card =      ∑ U ∈ S.powerset, (if op861_finite_maxcut_half_edges_cut_prop e U then 1 else 0) := by    intro e    exact (sum_boole (op861_finite_maxcut_half_edges_cut_prop e) S.powerset).symm  simp_rw [h1, h2]  exact sum_commtheorem op861_finite_maxcut_half_edges_two_mul_sum_cut {α : Type*} [DecidableEq α]    (S : Finset α) (E : Finset (α × α))    (hE : ∀ e ∈ E, e.1 ∈ S ∧ e.2 ∈ S ∧ e.1 ≠ e.2) :    ∑ U ∈ S.powerset, 2 * (E.filter (op861_finite_maxcut_half_edges_cut_prop · U)).card =      E.card * S.powerset.card := by  rw [← mul_sum, op861_finite_maxcut_half_edges_sum_cut_card, mul_sum]  have h : ∀ e ∈ E, 2 * (S.powerset.filter (op861_finite_maxcut_half_edges_cut_prop e)).card =      S.powerset.card := by    intro e he    have he_props := hE e he    exact op861_finite_maxcut_half_edges_card_filter_cut_prop_eq S e he_props.1 he_props.2.2  rw [sum_congr rfl h]  simptheorem op861_finite_maxcut_half_edges (α : Type*) [DecidableEq α]    (S : Finset α) (E : Finset (α × α))    (hE : ∀ e ∈ E, e.1 ∈ S ∧ e.2 ∈ S ∧ e.1 ≠ e.2) :    ∃ U : Finset α, U ⊆ S ∧ E.card ≤ 2 *      (E.filter (fun e => (e.1 ∈ U ∧ e.2 ∉ U) ∨ (e.2 ∈ U ∧ e.1 ∉ U))).card := by  have h_sum : ∑ _ ∈ S.powerset, E.card =      ∑ U ∈ S.powerset, 2 * (E.filter (op861_finite_maxcut_half_edges_cut_prop · U)).card := by    rw [op861_finite_maxcut_half_edges_two_mul_sum_cut S E hE]    simp [mul_comm]  have h_ex := Finset.exists_le_of_sum_le (Finset.powerset_nonempty S) (le_of_eq h_sum)  rcases h_ex with ⟨U, hU, hle⟩  rw [Finset.mem_powerset] at hU  exact ⟨U, hU, hle⟩
See it in the graphDiscuss this resultChallenge it