AFTD Auto-Formalizing Theoretical Domains

op861_dense_incidence_many_degrees

theoremverified

If a finite bipartite incidence set with sides totaling at most k vertices has at least k squared divided by 96 edges, then at least k divided by 192 vertices on the first side each have degree at least k divided by 192, with the inequalities interpreted without rounding by multiplying by the stated constants.

Statement

theorem op861_dense_incidence_many_degrees (α : Type*) [DecidableEq α]
    (k : ℕ) (U V : Finset α) (E : Finset (α × α))
    (hUV : Disjoint U V) (hsize : U.card + V.card ≤ k)
    (hE : ∀ e ∈ E, e.1 ∈ U ∧ e.2 ∈ V) (hdense : k^2 ≤ 96 * E.card) :
    k ≤ 192 * (U.filter (fun x => k ≤ 192 * (E.filter (fun e => e.1 = x)).card)).card
Source
The many-large-degrees step 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

The proof proceeds by contradiction: suppose fewer than k / 192 vertices in U have degree at least k / 192, and let S ⊆ U be the set of these high-degree vertices so that 192 * |S| < k. We partition the total number of edges into contributions from S and from U \ S. Vertices in S have degree bounded by |V| ≤ k, while vertices in U \ S have degree strictly less than k / 192. Scaling by 192 gives 192 * |E| ≤ 192 * |S| * k + |U \ S| * k < k^2 + k^2 = 2 * k^2, which contradicts the edge-density assumption 2 * k^2 ≤ 192 * |E|.

  1. Define the degree function and the subset S ⊆ U of high-degree vertices.

    Lines 6–7 create and immediately clear an unused duplicate of the disjointness hypothesis. Lines 8–9 define deg(x) as the number of edges with first coordinate x, and define S as the set of vertices in U whose degree satisfies k ≤ 192 * deg(x) (that is, deg(x) ≥ k / 192).

    lines 6–9

      have hUV' : Disjoint U V := hUV
      clear hUV'
      let deg : α → ℕ := fun x => (E.filter (fun e => e.1 = x)).card
      let S : Finset α := U.filter (fun x => k ≤ 192 * deg x)
  2. Assume for contradiction that 192 * |S| < k, and deduce that |V| ≤ k.

    We assume the negation ¬(k ≤ 192 * |S|) to derive a contradiction. Linear integer arithmetic (omega) turns this into 192 * |S| < k. From the total size bound |U| + |V| ≤ k and non-negativity of cardinals, omega also deduces |V| ≤ k.

    lines 10–13

      have hgoal : k ≤ 192 * S.card := by
        by_contra hcon
        have hSlt : 192 * S.card < k := by omega
        have hVk : V.card ≤ k := by omega
  3. Every vertex in U has degree at most |V|: ∀ x ∈ U, deg(x) ≤ |V|.

    For any vertex x ∈ U, the edges starting at x are mapped into V by the second projection e ↦ e.2 (since every edge lands in V by hypothesis hE). Two edges starting at x that agree on their second coordinate agree on both coordinates and are equal, making the map injective. By Finset.card_le_card_of_injOn, the number of such edges is at most |V|.

    lines 14–24

    uses Finset.card_le_card_of_injOn, Finset.mem_filter.mp, Finset.coe_filter, Set.mem_ofPred_eq

        have hdegV : ∀ x ∈ U, deg x ≤ V.card := by
          intro x hx
          dsimp [deg]
          apply Finset.card_le_card_of_injOn (fun e : α × α => e.2)
          · intro e he
            exact (hE e (Finset.mem_filter.mp he).1).2
          · intro e he f hf h
            simp only [Finset.coe_filter, Set.mem_ofPred_eq] at he hf
            ext
            · exact he.2.trans hf.2.symm
            · exact h
  4. The sum of all vertex degrees over U equals |E|.

    Since every edge in E has its first vertex in U (hypothesis hE), grouping E into fibers by its first coordinate via Finset.card_eq_sum_card_fiberwise shows that the sum of degrees over U equals |E|.

    lines 25–29

    uses Finset.card_eq_sum_card_fiberwise

        have hsum : (∑ x ∈ U, deg x) = E.card := by
          dsimp [deg]
          rw [← Finset.card_eq_sum_card_fiberwise]
          · intro e he
            exact (hE e he).1
  5. The total number of edges splits as |E| = ∑_{x ∈ S} deg(x) + ∑_{x ∈ U \ S} deg(x).

    Because S ⊆ U by Finset.filter_subset, Finset.sum_sdiff splits the sum of degrees over U into the sum over S and the sum over U \ S, which equals |E|.

    lines 30–33

    uses Finset.sum_sdiff, Finset.filter_subset

        have hsplit : E.card = (∑ x ∈ S, deg x) + (∑ x ∈ U \ S, deg x) := by
          rw [← hsum]
          have hsdiff := Finset.sum_sdiff (s₁ := S) (s₂ := U) (f := deg) (Finset.filter_subset _ _)
          omega
  6. The sum of degrees over S is at most |S| * k.

    Every vertex x ∈ S belongs to U (Finset.mem_of_mem_filter), so deg(x) ≤ |V| ≤ k by transitivity (le_trans). Summing this upper bound k over all x ∈ S via Finset.sum_le_sum and evaluating the constant sum with Finset.sum_const yields ∑_{x ∈ S} deg(x) ≤ |S| * k.

    lines 34–40

    uses Finset.sum_le_sum, le_trans, Finset.mem_of_mem_filter, Finset.sum_const

        have hhigh : (∑ x ∈ S, deg x) ≤ S.card * k := by
          calc
            (∑ x ∈ S, deg x) ≤ ∑ x ∈ S, k := by
              apply Finset.sum_le_sum
              intro x hx
              exact le_trans (hdegV x (Finset.mem_of_mem_filter x hx)) hVk
            _ = S.card * k := by simp [Finset.sum_const]
  7. The sum of degrees over low-degree vertices satisfies 192 * ∑_{x ∈ U \ S} deg(x) ≤ |U \ S| * k.

    Distributing the factor 192 into the sum (Finset.mul_sum), each term is 192 * deg(x). For any x ∈ U \ S, x belongs to U (Finset.mem_sdiff.mp) but not S. If k ≤ 192 * deg(x) held, x would belong to S (Finset.mem_filter.mpr), a contradiction; thus 192 * deg(x) ≤ k. Summing this bound over U \ S with Finset.sum_le_sum and Finset.sum_const gives |U \ S| * k.

    lines 41–56

    uses Finset.mul_sum, Finset.sum_le_sum, Finset.mem_sdiff.mp, Finset.mem_filter.mpr, Finset.sum_const

        have hlow : 192 * (∑ x ∈ U \ S, deg x) ≤ (U \ S).card * k := by
          calc
            192 * (∑ x ∈ U \ S, deg x) = ∑ x ∈ U \ S, 192 * deg x := by
              rw [Finset.mul_sum]
            _ ≤ ∑ x ∈ U \ S, k := by
              apply Finset.sum_le_sum
              intro x hx
              have hxU : x ∈ U := (Finset.mem_sdiff.mp hx).1
              have hxnot : x ∉ S := (Finset.mem_sdiff.mp hx).2
              have hnot : ¬ k ≤ 192 * deg x := by
                intro hle
                apply hxnot
                dsimp [S]
                exact Finset.mem_filter.mpr ⟨hxU, hle⟩
              omega
            _ = (U \ S).card * k := by simp [Finset.sum_const]
  8. The total edge count satisfies 192 * |E| ≤ 192 * (|S| * k) + |U \ S| * k.

    Multiplying the split of |E| by 192 and expanding gives 192 * ∑_{x ∈ S} deg(x) + 192 * ∑_{x ∈ U \ S} deg(x). We bound the first term using Nat.mul_le_mul_left applied to the high-degree bound, and the second term using the low-degree bound, adding them via Nat.add_le_add.

    lines 57–64

    uses Nat.add_le_add, Nat.mul_le_mul_left

        have hEdense : 192 * E.card ≤ 192 * (S.card * k) + (U \ S).card * k := by
          calc
            192 * E.card = 192 * ((∑ x ∈ S, deg x) + (∑ x ∈ U \ S, deg x)) := by rw [hsplit]
            _ = 192 * (∑ x ∈ S, deg x) + 192 * (∑ x ∈ U \ S, deg x) := by ring
            _ ≤ 192 * (S.card * k) + (U \ S).card * k := by
              apply Nat.add_le_add
              · exact Nat.mul_le_mul_left 192 hhigh
              · exact hlow
  9. The sizes of the partitioned subsets satisfy |U \ S| + |S| ≤ k.

    By Finset.card_sdiff_add_card_eq_card, |U \ S| + |S| = |U|. Since |U| + |V| ≤ k, linear arithmetic (omega) gives |U \ S| + |S| ≤ k.

    lines 65–67

    uses Finset.card_sdiff_add_card_eq_card, Finset.filter_subset

        have hpart : (U \ S).card + S.card ≤ k := by
          have h := Finset.card_sdiff_add_card_eq_card (s := S) (t := U) (Finset.filter_subset _ _)
          omega
  10. The contradiction hypothesis 192 * |S| < k leads to False. automation

    Doubling the density hypothesis gives 2 * k^2 ≤ 192 * |E|. But 192 * |E| ≤ (192 * |S|) * k + |U \ S| * k < k * k + k * k = 2 * k^2, which is an impossible contradiction. The nonlinear arithmetic tactic nlinarith derives False from these inequalities.

    line 68

        nlinarith
  11. The desired inequality k ≤ 192 * |{x ∈ U | k ≤ 192 * deg(x)}| holds.

    Unfolding S and deg in the intermediate result hgoal completes the proof.

    line 69

      simpa [S, deg] using hgoal
Finset.card_le_card_of_injOn
If a map f sends a finite set s into a finite set t and is injective on s, then |s| ≤ |t|.
Finset.card_sdiff_add_card_eq_card
If s ⊆ t, then |t \ s| + |s| = |t|.
Finset.card_eq_sum_card_fiberwise
If f maps s to t, the size of s equals the sum over b ∈ t of the sizes of the fibers {a ∈ s | f(a) = b}.
Finset.coe_filter
The coercion of a filtered finset to a set equals the set of elements satisfying the predicate.
Finset.filter_subset
A filtered finset is a subset of the original finset.
Finset.mem_filter.mp
If an element belongs to a filtered finset, it satisfies the predicate and belongs to the original finset.
Finset.mem_filter.mpr
An element belongs to a filtered finset if it belongs to the original finset and satisfies the predicate.
Finset.mem_sdiff.mp
If x ∈ s \ t, then x ∈ s and x ∉ t.
Finset.mem_of_mem_filter
An element belonging to a filtered finset belongs to the underlying finset.
Finset.mul_sum
Multiplication distributes over a finite sum: a * ∑ i ∈ s, f i = ∑ i ∈ s, a * f i.
Finset.sum_const
The sum of a constant value b over a finite set s equals |s| * b.
Finset.sum_le_sum
If f i ≤ g i for all i ∈ s, then ∑ i ∈ s, f i ≤ ∑ i ∈ s, g i.
Finset.sum_sdiff
If s₁ ⊆ s₂, then the sum over s₂ \ s₁ plus the sum over s₁ equals the sum over s₂.
le_trans
If a ≤ b and b ≤ c, then a ≤ c.
Nat.add_le_add
If a ≤ b and c ≤ d, then a + c ≤ b + d for natural numbers.
Nat.mul_le_mul_left
If n ≤ m, then k * n ≤ k * m for natural numbers.
Set.mem_ofPred_eq
An element x belongs to {y | p y} if and only if p x holds.

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

theorem op861_dense_incidence_many_degrees (α : Type*) [DecidableEq α]    (k : ℕ) (U V : Finset α) (E : Finset (α × α))    (hUV : Disjoint U V) (hsize : U.card + V.card ≤ k)    (hE : ∀ e ∈ E, e.1 ∈ U ∧ e.2 ∈ V) (hdense : k^2 ≤ 96 * E.card) :    k ≤ 192 * (U.filter (fun x => k ≤ 192 * (E.filter (fun e => e.1 = x)).card)).card := by  have hUV' : Disjoint U V := hUV  clear hUV'  let deg : α → ℕ := fun x => (E.filter (fun e => e.1 = x)).card  let S : Finset α := U.filter (fun x => k ≤ 192 * deg x)  have hgoal : k ≤ 192 * S.card := by    by_contra hcon    have hSlt : 192 * S.card < k := by omega    have hVk : V.card ≤ k := by omega    have hdegV : ∀ x ∈ U, deg x ≤ V.card := by      intro x hx      dsimp [deg]      apply Finset.card_le_card_of_injOn (fun e : α × α => e.2)      · intro e he        exact (hE e (Finset.mem_filter.mp he).1).2      · intro e he f hf h        simp only [Finset.coe_filter, Set.mem_ofPred_eq] at he hf        ext        · exact he.2.trans hf.2.symm        · exact h    have hsum : (∑ x ∈ U, deg x) = E.card := by      dsimp [deg]      rw [← Finset.card_eq_sum_card_fiberwise]      · intro e he        exact (hE e he).1    have hsplit : E.card = (∑ x ∈ S, deg x) + (∑ x ∈ U \ S, deg x) := by      rw [← hsum]      have hsdiff := Finset.sum_sdiff (s₁ := S) (s₂ := U) (f := deg) (Finset.filter_subset _ _)      omega    have hhigh : (∑ x ∈ S, deg x) ≤ S.card * k := by      calc        (∑ x ∈ S, deg x) ≤ ∑ x ∈ S, k := by          apply Finset.sum_le_sum          intro x hx          exact le_trans (hdegV x (Finset.mem_of_mem_filter x hx)) hVk        _ = S.card * k := by simp [Finset.sum_const]    have hlow : 192 * (∑ x ∈ U \ S, deg x) ≤ (U \ S).card * k := by      calc        192 * (∑ x ∈ U \ S, deg x) = ∑ x ∈ U \ S, 192 * deg x := by          rw [Finset.mul_sum]        _ ≤ ∑ x ∈ U \ S, k := by          apply Finset.sum_le_sum          intro x hx          have hxU : x ∈ U := (Finset.mem_sdiff.mp hx).1          have hxnot : x ∉ S := (Finset.mem_sdiff.mp hx).2          have hnot : ¬ k ≤ 192 * deg x := by            intro hle            apply hxnot            dsimp [S]            exact Finset.mem_filter.mpr ⟨hxU, hle⟩          omega        _ = (U \ S).card * k := by simp [Finset.sum_const]    have hEdense : 192 * E.card ≤ 192 * (S.card * k) + (U \ S).card * k := by      calc        192 * E.card = 192 * ((∑ x ∈ S, deg x) + (∑ x ∈ U \ S, deg x)) := by rw [hsplit]        _ = 192 * (∑ x ∈ S, deg x) + 192 * (∑ x ∈ U \ S, deg x) := by ring        _ ≤ 192 * (S.card * k) + (U \ S).card * k := by          apply Nat.add_le_add          · exact Nat.mul_le_mul_left 192 hhigh          · exact hlow    have hpart : (U \ S).card + S.card ≤ k := by      have h := Finset.card_sdiff_add_card_eq_card (s := S) (t := U) (Finset.filter_subset _ _)      omega    nlinarith  simpa [S, deg] using hgoal
See it in the graphDiscuss this resultChallenge it