l3lab/ntp-mathlib huggingface dataset:
theorem interedges_mono (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) : interedges r s₂ t₂ ⊆ interedges r s₁ t₁ :=
  fun x ↦ by
    

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
hs : s₂ ⊆ s₁
ht : t₂ ⊆ t₁
x : α × β
⊢ x ∈ interedges r s₂ t₂ → x ∈ interedges r s₁ t₁

Next tactic:
simp_rw [mem_interedges_iff]
theorem interedges_mono (hs : s₂ ⊆ s₁) (ht : t₂ ⊆ t₁) : interedges r s₂ t₂ ⊆ interedges r s₁ t₁ :=
  fun x ↦ by
    simp_rw [mem_interedges_iff]
    

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
hs : s₂ ⊆ s₁
ht : t₂ ⊆ t₁
x : α × β
⊢ x.1 ∈ s₂ ∧ x.2 ∈ t₂ ∧ r x.1 x.2 → x.1 ∈ s₁ ∧ x.2 ∈ t₁ ∧ r x.1 x.2

Next tactic:
exact fun h ↦ ⟨hs h.1, ht h.2.1, h.2.2⟩
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 := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ card (interedges r s t) + card (interedges (fun x y => ¬r x y) s t) = card s * card t

Next tactic:
classical
  rw [← card_product, interedges, interedges, ← card_union_eq, filter_union_filter_neg_eq]
  exact disjoint_filter.2 fun _ _ ↦ Classical.not_not.2
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 := by
  classical
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ card (interedges r s t) + card (interedges (fun x y => ¬r x y) s t) = card s * card t

Next tactic:
rw [← card_product, interedges, interedges, ← card_union_eq, filter_union_filter_neg_eq]
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 := by
  classical
  rw [← card_product, interedges, interedges, ← card_union_eq, filter_union_filter_neg_eq]
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ Disjoint (filter (fun e => r e.1 e.2) (s ×ˢ t)) (filter (fun e => ¬r e.1 e.2) (s ×ˢ t))

Next tactic:
exact disjoint_filter.2 fun _ _ ↦ Classical.not_not.2
theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) :
    Disjoint (interedges r s t) (interedges r s' t) := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s s' : Finset α
hs : Disjoint s s'
t : Finset β
⊢ Disjoint (interedges r s t) (interedges r s' t)

Next tactic:
rw [Finset.disjoint_left] at hs ⊢
theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) :
    Disjoint (interedges r s t) (interedges r s' t) := by
  rw [Finset.disjoint_left] at hs ⊢
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s s' : Finset α
hs : ∀ ⦃a : α⦄, a ∈ s → a ∉ s'
t : Finset β
⊢ ∀ ⦃a : α × β⦄, a ∈ interedges r s t → a ∉ interedges r s' t

Next tactic:
intro _ hx hy
theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) :
    Disjoint (interedges r s t) (interedges r s' t) := by
  rw [Finset.disjoint_left] at hs ⊢
  intro _ hx hy
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s s' : Finset α
hs : ∀ ⦃a : α⦄, a ∈ s → a ∉ s'
t : Finset β
a✝ : α × β
hx : a✝ ∈ interedges r s t
hy : a✝ ∈ interedges r s' t
⊢ False

Next tactic:
rw [mem_interedges_iff] at hx hy
theorem interedges_disjoint_left {s s' : Finset α} (hs : Disjoint s s') (t : Finset β) :
    Disjoint (interedges r s t) (interedges r s' t) := by
  rw [Finset.disjoint_left] at hs ⊢
  intro _ hx hy
  rw [mem_interedges_iff] at hx hy
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s s' : Finset α
hs : ∀ ⦃a : α⦄, a ∈ s → a ∉ s'
t : Finset β
a✝ : α × β
hx : a✝.1 ∈ s ∧ a✝.2 ∈ t ∧ r a✝.1 a✝.2
hy : a✝.1 ∈ s' ∧ a✝.2 ∈ t ∧ r a✝.1 a✝.2
⊢ False

Next tactic:
exact hs hx.1 hy.1
theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') :
    Disjoint (interedges r s t) (interedges r s t') := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t t' : Finset β
ht : Disjoint t t'
⊢ Disjoint (interedges r s t) (interedges r s t')

Next tactic:
rw [Finset.disjoint_left] at ht ⊢
theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') :
    Disjoint (interedges r s t) (interedges r s t') := by
  rw [Finset.disjoint_left] at ht ⊢
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t t' : Finset β
ht : ∀ ⦃a : β⦄, a ∈ t → a ∉ t'
⊢ ∀ ⦃a : α × β⦄, a ∈ interedges r s t → a ∉ interedges r s t'

Next tactic:
intro _ hx hy
theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') :
    Disjoint (interedges r s t) (interedges r s t') := by
  rw [Finset.disjoint_left] at ht ⊢
  intro _ hx hy
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t t' : Finset β
ht : ∀ ⦃a : β⦄, a ∈ t → a ∉ t'
a✝ : α × β
hx : a✝ ∈ interedges r s t
hy : a✝ ∈ interedges r s t'
⊢ False

Next tactic:
rw [mem_interedges_iff] at hx hy
theorem interedges_disjoint_right (s : Finset α) {t t' : Finset β} (ht : Disjoint t t') :
    Disjoint (interedges r s t) (interedges r s t') := by
  rw [Finset.disjoint_left] at ht ⊢
  intro _ hx hy
  rw [mem_interedges_iff] at hx hy
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t t' : Finset β
ht : ∀ ⦃a : β⦄, a ∈ t → a ∉ t'
a✝ : α × β
hx : a✝.1 ∈ s ∧ a✝.2 ∈ t ∧ r a✝.1 a✝.2
hy : a✝.1 ∈ s ∧ a✝.2 ∈ t' ∧ r a✝.1 a✝.2
⊢ False

Next tactic:
exact ht hx.2.1 hy.2.1
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 := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
s : Finset ι
t : Finset β
f : ι → Finset α
⊢ interedges r (Finset.biUnion s f) t = Finset.biUnion s fun a => interedges r (f a) t

Next tactic:
ext
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 := by
  ext
  

Proof state:
case a
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
s : Finset ι
t : Finset β
f : ι → Finset α
a✝ : α × β
⊢ a✝ ∈ interedges r (Finset.biUnion s f) t ↔ a✝ ∈ Finset.biUnion s fun a => interedges r (f a) t

Next tactic:
simp only [mem_biUnion, mem_interedges_iff, exists_and_right, ← and_assoc]
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) := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
s : Finset α
t : Finset ι
f : ι → Finset β
⊢ interedges r s (Finset.biUnion t f) = Finset.biUnion t fun b => interedges r s (f b)

Next tactic:
ext a
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) := by
  ext a
  

Proof state:
case a
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a✝ : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
s : Finset α
t : Finset ι
f : ι → Finset β
a : α × β
⊢ a ∈ interedges r s (Finset.biUnion t f) ↔ a ∈ Finset.biUnion t fun b => interedges r s (f b)

Next tactic:
simp only [mem_interedges_iff, mem_biUnion]
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) := by
  ext a
  simp only [mem_interedges_iff, mem_biUnion]
  

Proof state:
case a
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a✝ : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
s : Finset α
t : Finset ι
f : ι → Finset β
a : α × β
⊢ a.1 ∈ s ∧ (∃ a_1 ∈ t, a.2 ∈ f a_1) ∧ r a.1 a.2 ↔ ∃ a_1 ∈ t, a.1 ∈ s ∧ a.2 ∈ f a_1 ∧ r a.1 a.2

Next tactic:
exact ⟨fun ⟨x₁, ⟨x₂, x₃, x₄⟩, x₅⟩ ↦ ⟨x₂, x₃, x₁, x₄, x₅⟩,
    fun ⟨x₂, x₃, x₁, x₄, x₅⟩ ↦ ⟨x₁, ⟨x₂, x₃, x₄⟩, x₅⟩⟩
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) := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
s : Finset ι
t : Finset κ
f : ι → Finset α
g : κ → Finset β
⊢ interedges r (Finset.biUnion s f) (Finset.biUnion t g) =
    Finset.biUnion (s ×ˢ t) fun ab => interedges r (f ab.1) (g ab.2)

Next tactic:
simp_rw [product_biUnion, interedges_biUnion_left, interedges_biUnion_right]
theorem edgeDensity_nonneg (s : Finset α) (t : Finset β) : 0 ≤ edgeDensity r s t := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ 0 ≤ edgeDensity r s t

Next tactic:
apply div_nonneg
theorem edgeDensity_nonneg (s : Finset α) (t : Finset β) : 0 ≤ edgeDensity r s t := by
  apply div_nonneg <;> 

Proof state:
case ha
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ 0 ≤ ↑(card (interedges r s t))

Next tactic:
exact mod_cast Nat.zero_le _
theorem edgeDensity_nonneg (s : Finset α) (t : Finset β) : 0 ≤ edgeDensity r s t := by
  apply div_nonneg <;> 

Proof state:
case hb
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ 0 ≤ ↑(card s) * ↑(card t)

Next tactic:
exact mod_cast Nat.zero_le _
theorem edgeDensity_le_one (s : Finset α) (t : Finset β) : edgeDensity r s t ≤ 1 := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ edgeDensity r s t ≤ 1

Next tactic:
apply div_le_one_of_le
theorem edgeDensity_le_one (s : Finset α) (t : Finset β) : edgeDensity r s t ≤ 1 := by
  apply div_le_one_of_le
  · 

Proof state:
case h
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ ↑(card (interedges r s t)) ≤ ↑(card s) * ↑(card t)

Next tactic:
exact mod_cast card_interedges_le_mul r s t
theorem edgeDensity_le_one (s : Finset α) (t : Finset β) : edgeDensity r s t ≤ 1 := by
  apply div_le_one_of_le
  · exact mod_cast card_interedges_le_mul r s t
  · 

Proof state:
case hb
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
t : Finset β
⊢ 0 ≤ ↑(card s) * ↑(card t)

Next tactic:
exact mod_cast Nat.zero_le _
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 := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
hs : Finset.Nonempty s
ht : Finset.Nonempty t
⊢ edgeDensity r s t + edgeDensity (fun x y => ¬r x y) s t = 1

Next tactic:
rw [edgeDensity, edgeDensity, div_add_div_same, div_eq_one_iff_eq]
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 := by
  rw [edgeDensity, edgeDensity, div_add_div_same, div_eq_one_iff_eq]
  · 

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
hs : Finset.Nonempty s
ht : Finset.Nonempty t
⊢ ↑(card (interedges r s t)) + ↑(card (interedges (fun x y => ¬r x y) s t)) = ↑(card s) * ↑(card t)

Next tactic:
exact mod_cast card_interedges_add_card_interedges_compl r s t
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 := by
  rw [edgeDensity, edgeDensity, div_add_div_same, div_eq_one_iff_eq]
  · exact mod_cast card_interedges_add_card_interedges_compl r s t
  · 

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
hs : Finset.Nonempty s
ht : Finset.Nonempty t
⊢ ↑(card s) * ↑(card t) ≠ 0

Next tactic:
exact mod_cast (mul_pos hs.card_pos ht.card_pos).ne'
@[simp]
theorem edgeDensity_empty_left (t : Finset β) : edgeDensity r ∅ t = 0 := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
t : Finset β
⊢ edgeDensity r ∅ t = 0

Next tactic:
rw [edgeDensity, Finset.card_empty, Nat.cast_zero, zero_mul, div_zero]
@[simp]
theorem edgeDensity_empty_right (s : Finset α) : edgeDensity r s ∅ = 0 := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝¹ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
s : Finset α
⊢ edgeDensity r s ∅ = 0

Next tactic:
rw [edgeDensity, Finset.card_empty, Nat.cast_zero, mul_zero, div_zero]
theorem card_interedges_finpartition_left [DecidableEq α] (P : Finpartition s) (t : Finset β) :
    (interedges r s t).card = ∑ a in P.parts, (interedges r a t).card := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq α
P : Finpartition s
t : Finset β
⊢ card (interedges r s t) = ∑ a in P.parts, card (interedges r a t)

Next tactic:
classical
  simp_rw [← P.biUnion_parts, interedges_biUnion_left, id.def]
  rw [card_biUnion]
  exact fun x hx y hy h ↦ interedges_disjoint_left r (P.disjoint hx hy h) _
theorem card_interedges_finpartition_left [DecidableEq α] (P : Finpartition s) (t : Finset β) :
    (interedges r s t).card = ∑ a in P.parts, (interedges r a t).card := by
  classical
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq α
P : Finpartition s
t : Finset β
⊢ card (interedges r s t) = ∑ a in P.parts, card (interedges r a t)

Next tactic:
simp_rw [← P.biUnion_parts, interedges_biUnion_left, id.def]
theorem card_interedges_finpartition_left [DecidableEq α] (P : Finpartition s) (t : Finset β) :
    (interedges r s t).card = ∑ a in P.parts, (interedges r a t).card := by
  classical
  simp_rw [← P.biUnion_parts, interedges_biUnion_left, id.def]
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq α
P : Finpartition s
t : Finset β
⊢ card (Finset.biUnion P.parts fun a => interedges r a t) = ∑ a in P.parts, card (interedges r a t)

Next tactic:
rw [card_biUnion]
theorem card_interedges_finpartition_left [DecidableEq α] (P : Finpartition s) (t : Finset β) :
    (interedges r s t).card = ∑ a in P.parts, (interedges r a t).card := by
  classical
  simp_rw [← P.biUnion_parts, interedges_biUnion_left, id.def]
  rw [card_biUnion]
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t✝ t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq α
P : Finpartition s
t : Finset β
⊢ ∀ x ∈ P.parts, ∀ y ∈ P.parts, x ≠ y → Disjoint (interedges r x t) (interedges r y t)

Next tactic:
exact fun x hx y hy h ↦ interedges_disjoint_left r (P.disjoint hx hy h) _
theorem card_interedges_finpartition_right [DecidableEq β] (s : Finset α) (P : Finpartition t) :
    (interedges r s t).card = ∑ b in P.parts, (interedges r s b).card := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq β
s : Finset α
P : Finpartition t
⊢ card (interedges r s t) = ∑ b in P.parts, card (interedges r s b)

Next tactic:
classical
  simp_rw [← P.biUnion_parts, interedges_biUnion_right, id]
  rw [card_biUnion]
  exact fun x hx y hy h ↦ interedges_disjoint_right r _ (P.disjoint hx hy h)
theorem card_interedges_finpartition_right [DecidableEq β] (s : Finset α) (P : Finpartition t) :
    (interedges r s t).card = ∑ b in P.parts, (interedges r s b).card := by
  classical
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq β
s : Finset α
P : Finpartition t
⊢ card (interedges r s t) = ∑ b in P.parts, card (interedges r s b)

Next tactic:
simp_rw [← P.biUnion_parts, interedges_biUnion_right, id]
theorem card_interedges_finpartition_right [DecidableEq β] (s : Finset α) (P : Finpartition t) :
    (interedges r s t).card = ∑ b in P.parts, (interedges r s b).card := by
  classical
  simp_rw [← P.biUnion_parts, interedges_biUnion_right, id]
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq β
s : Finset α
P : Finpartition t
⊢ card (Finset.biUnion P.parts fun b => interedges r s b) = ∑ b in P.parts, card (interedges r s b)

Next tactic:
rw [card_biUnion]
theorem card_interedges_finpartition_right [DecidableEq β] (s : Finset α) (P : Finpartition t) :
    (interedges r s t).card = ∑ b in P.parts, (interedges r s b).card := by
  classical
  simp_rw [← P.biUnion_parts, interedges_biUnion_right, id]
  rw [card_biUnion]
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝² : LinearOrderedField 𝕜
r : α → β → Prop
inst✝¹ : (a : α) → DecidablePred (r a)
s✝ s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝ : DecidableEq β
s : Finset α
P : Finpartition t
⊢ ∀ x ∈ P.parts, ∀ y ∈ P.parts, x ≠ y → Disjoint (interedges r s x) (interedges r s y)

Next tactic:
exact fun x hx y hy h ↦ interedges_disjoint_right r _ (P.disjoint hx hy h)
theorem card_interedges_finpartition [DecidableEq α] [DecidableEq β] (P : Finpartition s)
    (Q : Finpartition t) :
    (interedges r s t).card = ∑ ab in P.parts ×ˢ Q.parts, (interedges r ab.1 ab.2).card := by
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
P : Finpartition s
Q : Finpartition t
⊢ card (interedges r s t) = ∑ ab in P.parts ×ˢ Q.parts, card (interedges r ab.1 ab.2)

Next tactic:
rw [card_interedges_finpartition_left _ P, sum_product]
theorem card_interedges_finpartition [DecidableEq α] [DecidableEq β] (P : Finpartition s)
    (Q : Finpartition t) :
    (interedges r s t).card = ∑ ab in P.parts ×ˢ Q.parts, (interedges r ab.1 ab.2).card := by
  rw [card_interedges_finpartition_left _ P, sum_product]
  

Proof state:
𝕜 : Type u_1
ι : Type u_2
κ : Type u_3
α : Type u_4
β : Type u_5
inst✝³ : LinearOrderedField 𝕜
r : α → β → Prop
inst✝² : (a : α) → DecidablePred (r a)
s s₁ s₂ : Finset α
t t₁ t₂ : Finset β
a : α
b : β
δ : 𝕜
inst✝¹ : DecidableEq α
inst✝ : DecidableEq β
P : Finpartition s
Q : Finpartition t
⊢ ∑ a in P.parts, card (interedges r a t) = ∑ x in P.parts, ∑ y in Q.parts, card (interedges r (x, y).1 (x, y).2)

Next tactic:
congr