File: Mathlib/Combinatorics/SimpleGraph/Density.lean

full_name: Rel.interedges
code: /-- Finset of edges of a relation between two finsets of vertices. -/
def interedges (s : Finset α) (t : Finset β) : Finset (α × β) 
goal: Finset (α × β)

full_name: Rel.edgeDensity
code: /-- Edge density of a relation between two finsets of vertices. -/
def edgeDensity (s : Finset α) (t : Finset β) : ℚ 
goal: ℚ

full_name: Rel.mem_interedges_iff
code: theorem mem_interedges_iff {x : α × β} : x ∈ interedges r s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ r x.1 x.2 
goal: x ∈ Rel.interedges r s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ r x.1 x.2

full_name: Rel.mk_mem_interedges_iff
code: theorem mk_mem_interedges_iff : (a, b) ∈ interedges r s t ↔ a ∈ s ∧ b ∈ t ∧ r a b 
goal: (a, b) ∈ Rel.interedges r s t ↔ a ∈ s ∧ b ∈ t ∧ r a b

full_name: Rel.interedges_empty_left
code: @[simp]
theorem interedges_empty_left (t : Finset β) : interedges r ∅ t = ∅ 
goal: Rel.interedges r ∅ t = ∅

full_name: Rel.interedges_mono
code: theorem interedges_mono (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) : interedges r s₂ t₂ ⊆ interedges r s₁ t₁ 
goal: Rel.interedges r s₂ t₂ ⊆ Rel.interedges r s₁ t₁

full_name: Rel.card_interedges_add_card_interedges_compl
code: theorem card_interedges_add_card_interedges_compl (s : Finset α) (t : Finset β) :
    (interedges r s t).card + (interedges (fun x y ↦ ¬r x y) s t).card = s.card * t.card 
goal: (Rel.interedges r s t).card + (Rel.interedges (fun x y => ¬r x y) s t).card = s.card * t.card

full_name: Rel.interedges_disjoint_left
code: theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) :
    Disjoint (interedges r s t) (interedges r s' t) 
goal: Disjoint (Rel.interedges r s t) (Rel.interedges r s' t)

full_name: Rel.interedges_disjoint_right
code: theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') :
    Disjoint (interedges r s t) (interedges r s t') 
goal: Disjoint (Rel.interedges r s t) (Rel.interedges r s t')

full_name: Rel.interedges_eq_biUnion
code: lemma interedges_eq_biUnion :
    interedges r s t = s.biUnion (fun x ↦ (t.filter (r x)).map ⟨(x, ·), Prod.mk.inj_left x⟩) 
goal: Rel.interedges r s t = s.biUnion fun x => Finset.map { toFun := fun x_1 => (x, x_1), inj' := ⋯ } (Finset.filter (r x) t)

full_name: Rel.interedges_biUnion_left
code: theorem interedges_biUnion_left (s : Finset ι) (t : Finset β) (f : ι → Finset α) :
    interedges r (s.biUnion f) t = s.biUnion fun a ↦ interedges r (f a) t 
goal: Rel.interedges r (s.biUnion f) t = s.biUnion fun a => Rel.interedges r (f a) t

full_name: Rel.interedges_biUnion_right
code: theorem interedges_biUnion_right (s : Finset α) (t : Finset ι) (f : ι → Finset β) :
    interedges r s (t.biUnion f) = t.biUnion fun b ↦ interedges r s (f b) 
goal: Rel.interedges r s (t.biUnion f) = t.biUnion fun b => Rel.interedges r s (f b)

full_name: Rel.interedges_biUnion
code: theorem interedges_biUnion (s : Finset ι) (t : Finset κ) (f : ι → Finset α) (g : κ → Finset β) :
    interedges r (s.biUnion f) (t.biUnion g) =
      (s ×ˢ t).biUnion fun ab ↦ interedges r (f ab.1) (g ab.2) 
goal: Rel.interedges r (s.biUnion f) (t.biUnion g) = (s ×ˢ t).biUnion fun ab => Rel.interedges r (f ab.1) (g ab.2)

full_name: Rel.card_interedges_le_mul
code: theorem card_interedges_le_mul (s : Finset α) (t : Finset β) :
    (interedges r s t).card ≤ s.card * t.card 
goal: (Rel.interedges r s t).card ≤ s.card * t.card

full_name: Rel.edgeDensity_nonneg
code: theorem edgeDensity_nonneg (s : Finset α) (t : Finset β) : 0 ≤ edgeDensity r s t 
goal: 0 ≤ Rel.edgeDensity r s t

full_name: Rel.edgeDensity_le_one
code: theorem edgeDensity_le_one (s : Finset α) (t : Finset β) : edgeDensity r s t ≤ 1 
goal: Rel.edgeDensity r s t ≤ 1

full_name: Rel.edgeDensity_add_edgeDensity_compl
code: theorem edgeDensity_add_edgeDensity_compl (hs : s.Nonempty) (ht : t.Nonempty) :
    edgeDensity r s t + edgeDensity (fun x y ↦ ¬r x y) s t = 1 
goal: Rel.edgeDensity r s t + Rel.edgeDensity (fun x y => ¬r x y) s t = 1

full_name: Rel.edgeDensity_empty_left
code: @[simp]
theorem edgeDensity_empty_left (t : Finset β) : edgeDensity r ∅ t = 0 
goal: Rel.edgeDensity r ∅ t = 0

full_name: Rel.edgeDensity_empty_right
code: @[simp]
theorem edgeDensity_empty_right (s : Finset α) : edgeDensity r s ∅ = 0 
goal: Rel.edgeDensity r s ∅ = 0

full_name: Rel.card_interedges_finpartition_left
code: theorem card_interedges_finpartition_left [DecidableEq α] (P : Finpartition s) (t : Finset β) :
    (interedges r s t).card = ∑ a ∈ P.parts, (interedges r a t).card 
goal: (Rel.interedges r s t).card = ∑ a ∈ P.parts, (Rel.interedges r a t).card

full_name: Rel.card_interedges_finpartition_right
code: theorem card_interedges_finpartition_right [DecidableEq β] (s : Finset α) (P : Finpartition t) :
    (interedges r s t).card = ∑ b ∈ P.parts, (interedges r s b).card 
goal: (Rel.interedges r s t).card = ∑ b ∈ P.parts, (Rel.interedges r s b).card

full_name: Rel.card_interedges_finpartition
code: theorem card_interedges_finpartition [DecidableEq α] [DecidableEq β] (P : Finpartition s)
    (Q : Finpartition t) :
    (interedges r s t).card = ∑ ab ∈ P.parts ×ˢ Q.parts, (interedges r ab.1 ab.2).card 
goal: (Rel.interedges r s t).card = ∑ ab ∈ P.parts ×ˢ Q.parts, (Rel.interedges r ab.1 ab.2).card

full_name: Rel.mul_edgeDensity_le_edgeDensity
code: theorem mul_edgeDensity_le_edgeDensity (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) (hs₂ : s₂.Nonempty)
    (ht₂ : t₂.Nonempty) :
    (s₂.card : ℚ) / s₁.card * (t₂.card / t₁.card) * edgeDensity r s₂ t₂ ≤ edgeDensity r s₁ t₁ 
goal: ↑s₂.card / ↑s₁.card * (↑t₂.card / ↑t₁.card) * Rel.edgeDensity r s₂ t₂ ≤ Rel.edgeDensity r s₁ t₁

full_name: Rel.edgeDensity_sub_edgeDensity_le_one_sub_mul
code: theorem edgeDensity_sub_edgeDensity_le_one_sub_mul (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) (hs₂ : s₂.Nonempty)
    (ht₂ : t₂.Nonempty) :
    edgeDensity r s₂ t₂ - edgeDensity r s₁ t₁ ≤ 1 - s₂.card / s₁.card * (t₂.card / t₁.card) 
goal: Rel.edgeDensity r s₂ t₂ - Rel.edgeDensity r s₁ t₁ ≤ 1 - ↑s₂.card / ↑s₁.card * (↑t₂.card / ↑t₁.card)

full_name: Rel.abs_edgeDensity_sub_edgeDensity_le_one_sub_mul
code: theorem abs_edgeDensity_sub_edgeDensity_le_one_sub_mul (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁)
    (hs₂ : s₂.Nonempty) (ht₂ : t₂.Nonempty) :
    |edgeDensity r s₂ t₂ - edgeDensity r s₁ t₁| ≤ 1 - s₂.card / s₁.card * (t₂.card / t₁.card) 
goal: |Rel.edgeDensity r s₂ t₂ - Rel.edgeDensity r s₁ t₁| ≤ 1 - ↑s₂.card / ↑s₁.card * (↑t₂.card / ↑t₁.card)

full_name: Rel.abs_edgeDensity_sub_edgeDensity_le_two_mul_sub_sq
code: theorem abs_edgeDensity_sub_edgeDensity_le_two_mul_sub_sq (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁)
    (hδ₀ : 0 ≤ δ) (hδ₁ : δ < 1) (hs₂ : (1 - δ) * s₁.card ≤ s₂.card)
    (ht₂ : (1 - δ) * t₁.card ≤ t₂.card) :
    |(edgeDensity r s₂ t₂ : 𝕜) - edgeDensity r s₁ t₁| ≤ 2 * δ - δ ^ 2 
goal: |↑(Rel.edgeDensity r s₂ t₂) - ↑(Rel.edgeDensity r s₁ t₁)| ≤ 2 * δ - δ ^ 2

full_name: Rel.abs_edgeDensity_sub_edgeDensity_le_two_mul
code: /-- If `s₂ ⊆ s₁`, `t₂ ⊆ t₁` and they take up all but a `δ`-proportion, then the difference in edge
densities is at most `2 * δ`. -/
theorem abs_edgeDensity_sub_edgeDensity_le_two_mul (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) (hδ : 0 ≤ δ)
    (hscard : (1 - δ) * s₁.card ≤ s₂.card) (htcard : (1 - δ) * t₁.card ≤ t₂.card) :
    |(edgeDensity r s₂ t₂ : 𝕜) - edgeDensity r s₁ t₁| ≤ 2 * δ 
goal: |↑(Rel.edgeDensity r s₂ t₂) - ↑(Rel.edgeDensity r s₁ t₁)| ≤ 2 * δ

full_name: Rel.swap_mem_interedges_iff
code: @[simp]
theorem swap_mem_interedges_iff (hr : Symmetric r) {x : α × α} :
    x.swap ∈ interedges r s t ↔ x ∈ interedges r t s 
goal: x.swap ∈ Rel.interedges r s t ↔ x ∈ Rel.interedges r t s

full_name: Rel.mk_mem_interedges_comm
code: theorem mk_mem_interedges_comm : (a, b) ∈ interedges r s t ↔ (b, a) ∈ interedges r t s 
goal: (a, b) ∈ Rel.interedges r s t ↔ (b, a) ∈ Rel.interedges r t s

full_name: Rel.card_interedges_comm
code: theorem card_interedges_comm (s t : Finset α) : (interedges r s t).card = (interedges r t s).card 
goal: (Rel.interedges r s t).card = (Rel.interedges r t s).card

full_name: Rel.edgeDensity_comm
code: theorem edgeDensity_comm (hr : Symmetric r) (s t : Finset α) :
    edgeDensity r s t = edgeDensity r t s 
goal: Rel.edgeDensity r s t = Rel.edgeDensity r t s

full_name: SimpleGraph.interedges
code: /-- Finset of edges of a relation between two finsets of vertices. -/
def interedges (s t : Finset α) : Finset (α × α) 
goal: Finset (α × α)

full_name: SimpleGraph.edgeDensity
code: /-- Density of edges of a graph between two finsets of vertices. -/
def edgeDensity : Finset α → Finset α → ℚ 
goal: Finset α → Finset α → ℚ

full_name: SimpleGraph.interedges_def
code: theorem interedges_def (s t : Finset α) :
    G.interedges s t = (s ×ˢ t).filter fun e ↦ G.Adj e.1 e.2 
goal: G.interedges s t = Finset.filter (fun e => G.Adj e.1 e.2) (s ×ˢ t)

full_name: SimpleGraph.edgeDensity_def
code: theorem edgeDensity_def (s t : Finset α) :
    G.edgeDensity s t = (G.interedges s t).card / (s.card * t.card) 
goal: G.edgeDensity s t = ↑(G.interedges s t).card / (↑s.card * ↑t.card)

full_name: SimpleGraph.card_interedges_div_card
code: theorem card_interedges_div_card (s t : Finset α) :
    ((G.interedges s t).card : ℚ) / (s.card * t.card) = G.edgeDensity s t 
goal: ↑(G.interedges s t).card / (↑s.card * ↑t.card) = G.edgeDensity s t

full_name: SimpleGraph.mem_interedges_iff
code: theorem mem_interedges_iff {x : α × α} : x ∈ G.interedges s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ G.Adj x.1 x.2 
goal: x ∈ G.interedges s t ↔ x.1 ∈ s ∧ x.2 ∈ t ∧ G.Adj x.1 x.2

full_name: SimpleGraph.mk_mem_interedges_iff
code: theorem mk_mem_interedges_iff : (a, b) ∈ G.interedges s t ↔ a ∈ s ∧ b ∈ t ∧ G.Adj a b 
goal: (a, b) ∈ G.interedges s t ↔ a ∈ s ∧ b ∈ t ∧ G.Adj a b

full_name: SimpleGraph.interedges_empty_left
code: @[simp]
theorem interedges_empty_left (t : Finset α) : G.interedges ∅ t = ∅ 
goal: G.interedges ∅ t = ∅

full_name: SimpleGraph.interedges_mono
code: theorem interedges_mono : s₂ ⊆ s₁ → t₂ ⊆ t₁ → G.interedges s₂ t₂ ⊆ G.interedges s₁ t₁ 
goal: s₂ ⊆ s₁ → t₂ ⊆ t₁ → G.interedges s₂ t₂ ⊆ G.interedges s₁ t₁

full_name: SimpleGraph.interedges_disjoint_left
code: theorem interedges_disjoint_left (hs : Disjoint s₁ s₂) (t : Finset α) :
    Disjoint (G.interedges s₁ t) (G.interedges s₂ t) 
goal: Disjoint (G.interedges s₁ t) (G.interedges s₂ t)

full_name: SimpleGraph.interedges_disjoint_right
code: theorem interedges_disjoint_right (s : Finset α) (ht : Disjoint t₁ t₂) :
    Disjoint (G.interedges s t₁) (G.interedges s t₂) 
goal: Disjoint (G.interedges s t₁) (G.interedges s t₂)

full_name: SimpleGraph.interedges_biUnion_left
code: theorem interedges_biUnion_left (s : Finset ι) (t : Finset α) (f : ι → Finset α) :
    G.interedges (s.biUnion f) t = s.biUnion fun a ↦ G.interedges (f a) t 
goal: G.interedges (s.biUnion f) t = s.biUnion fun a => G.interedges (f a) t

full_name: SimpleGraph.interedges_biUnion_right
code: theorem interedges_biUnion_right (s : Finset α) (t : Finset ι) (f : ι → Finset α) :
    G.interedges s (t.biUnion f) = t.biUnion fun b ↦ G.interedges s (f b) 
goal: G.interedges s (t.biUnion f) = t.biUnion fun b => G.interedges s (f b)

full_name: SimpleGraph.interedges_biUnion
code: theorem interedges_biUnion (s : Finset ι) (t : Finset κ) (f : ι → Finset α) (g : κ → Finset α) :
    G.interedges (s.biUnion f) (t.biUnion g) =
      (s ×ˢ t).biUnion fun ab ↦ G.interedges (f ab.1) (g ab.2) 
goal: G.interedges (s.biUnion f) (t.biUnion g) = (s ×ˢ t).biUnion fun ab => G.interedges (f ab.1) (g ab.2)

full_name: SimpleGraph.card_interedges_add_card_interedges_compl
code: theorem card_interedges_add_card_interedges_compl (h : Disjoint s t) :
    (G.interedges s t).card + (Gᶜ.interedges s t).card = s.card * t.card 
goal: (G.interedges s t).card + (Gᶜ.interedges s t).card = s.card * t.card

full_name: SimpleGraph.edgeDensity_add_edgeDensity_compl
code: theorem edgeDensity_add_edgeDensity_compl (hs : s.Nonempty) (ht : t.Nonempty) (h : Disjoint s t) :
    G.edgeDensity s t + Gᶜ.edgeDensity s t = 1 
goal: G.edgeDensity s t + Gᶜ.edgeDensity s t = 1

full_name: SimpleGraph.card_interedges_le_mul
code: theorem card_interedges_le_mul (s t : Finset α) : (G.interedges s t).card ≤ s.card * t.card 
goal: (G.interedges s t).card ≤ s.card * t.card

full_name: SimpleGraph.edgeDensity_nonneg
code: theorem edgeDensity_nonneg (s t : Finset α) : 0 ≤ G.edgeDensity s t 
goal: 0 ≤ G.edgeDensity s t

full_name: SimpleGraph.edgeDensity_le_one
code: theorem edgeDensity_le_one (s t : Finset α) : G.edgeDensity s t ≤ 1 
goal: G.edgeDensity s t ≤ 1

full_name: SimpleGraph.edgeDensity_empty_left
code: @[simp]
theorem edgeDensity_empty_left (t : Finset α) : G.edgeDensity ∅ t = 0 
goal: G.edgeDensity ∅ t = 0

full_name: SimpleGraph.edgeDensity_empty_right
code: @[simp]
theorem edgeDensity_empty_right (s : Finset α) : G.edgeDensity s ∅ = 0 
goal: G.edgeDensity s ∅ = 0

full_name: SimpleGraph.swap_mem_interedges_iff
code: @[simp]
theorem swap_mem_interedges_iff {x : α × α} : x.swap ∈ G.interedges s t ↔ x ∈ G.interedges t s 
goal: x.swap ∈ G.interedges s t ↔ x ∈ G.interedges t s

full_name: SimpleGraph.mk_mem_interedges_comm
code: theorem mk_mem_interedges_comm : (a, b) ∈ G.interedges s t ↔ (b, a) ∈ G.interedges t s 
goal: (a, b) ∈ G.interedges s t ↔ (b, a) ∈ G.interedges t s

full_name: SimpleGraph.edgeDensity_comm
code: theorem edgeDensity_comm (s t : Finset α) : G.edgeDensity s t = G.edgeDensity t s 
goal: G.edgeDensity s t = G.edgeDensity t s