l3lab/ntp-mathlib huggingface dataset:
lemma collapse_modular (hu : a ∉ u) (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ ⦃s⦄, s ⊆ insert a u → ∀ ⦃t⦄, t ⊆ insert a u →  f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t))
    (𝒜 ℬ : Finset (Finset α)) :
    ∀ ⦃s⦄, s ⊆ u → ∀ ⦃t⦄, t ⊆ u → collapse 𝒜 a f₁ s * collapse ℬ a f₂ t ≤
      collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t) := by
  rintro s hsu t htu
  -- Gather a bunch of facts we'll need a lot
  have := hsu.trans $ subset_insert a _
  have := htu.trans $ subset_insert a _
  have := insert_subset_insert a hsu
  have := insert_subset_insert a htu
  have has := not_mem_mono hsu hu
  have hat := not_mem_mono htu hu
  have : a ∉ s ∩ t := not_mem_mono ((inter_subset_left _ t).trans hsu) hu
  have := not_mem_union.2 ⟨has, hat⟩
  rw [collapse_eq has]
  split_ifs
  · rw [collapse_eq hat]
    split_ifs
    · rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›) rfl
        (insert_inter_distrib _ _ _).symm, collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›)
        (union_mem_sups ‹_› ‹_›) rfl (insert_union_distrib _ _ _).symm]
      refine' ineq (h₁ _) (h₁ _) (h₂ _) (h₂ _) (h₃ _) (h₃ _) (h₄ _) (h₄ _) (h ‹_› ‹_›) _ _ _
      · simpa [*] using h ‹insert a s ⊆ _› ‹t ⊆ _›
      · simpa [*] using h ‹s ⊆ _› ‹insert a t ⊆ _›
      · simpa [*] using h ‹insert a s ⊆ _› ‹insert a t ⊆ _›
    · rw [add_zero, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›) (union_mem_sups ‹_› ‹_›) rfl
        (insert_union _ _ _), insert_inter_of_not_mem ‹_›, ← mul_add]
      exact mul_le_mul_of_nonneg_right (le_collapse_of_mem ‹_› h₃ rfl $ inter_mem_infs ‹_› ‹_›) $
        add_nonneg (h₄ _) $ h₄ _
    · rw [zero_add, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      

Proof state:
case pos
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜✝ ℬ✝ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s✝ t✝ u : Finset α
hu : a ∉ u
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ ⦃s : Finset α⦄, s ⊆ insert a u → ∀ ⦃t : Finset α⦄, t ⊆ insert a u → f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t)
𝒜 ℬ : Finset (Finset α)
s : Finset α
hsu : s ⊆ u
t : Finset α
htu : t ⊆ u
this✝⁴ : s ⊆ insert a u
this✝³ : t ⊆ insert a u
this✝² : insert a s ⊆ insert a u
this✝¹ : insert a t ⊆ insert a u
has : a ∉ s
hat : a ∉ t
this✝ : a ∉ s ∩ t
this : a ∉ s ∪ t
h✝³ : s ∈ 𝒜
h✝² : insert a s ∈ 𝒜
h✝¹ : t ∉ ℬ
h✝ : insert a t ∈ ℬ
⊢ f₃ (s ∩ insert a t) * f₄ (s ∪ insert a t) + f₃ (insert a s ∩ insert a t) * f₄ (insert a s ∪ insert a t) ≤
    collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t)

Next tactic:
rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›)
        (inter_insert_of_not_mem ‹_›) (insert_inter_distrib _ _ _).symm, union_insert,
        insert_union_distrib, ← add_mul]
lemma collapse_modular (hu : a ∉ u) (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ ⦃s⦄, s ⊆ insert a u → ∀ ⦃t⦄, t ⊆ insert a u →  f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t))
    (𝒜 ℬ : Finset (Finset α)) :
    ∀ ⦃s⦄, s ⊆ u → ∀ ⦃t⦄, t ⊆ u → collapse 𝒜 a f₁ s * collapse ℬ a f₂ t ≤
      collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t) := by
  rintro s hsu t htu
  -- Gather a bunch of facts we'll need a lot
  have := hsu.trans $ subset_insert a _
  have := htu.trans $ subset_insert a _
  have := insert_subset_insert a hsu
  have := insert_subset_insert a htu
  have has := not_mem_mono hsu hu
  have hat := not_mem_mono htu hu
  have : a ∉ s ∩ t := not_mem_mono ((inter_subset_left _ t).trans hsu) hu
  have := not_mem_union.2 ⟨has, hat⟩
  rw [collapse_eq has]
  split_ifs
  · rw [collapse_eq hat]
    split_ifs
    · rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›) rfl
        (insert_inter_distrib _ _ _).symm, collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›)
        (union_mem_sups ‹_› ‹_›) rfl (insert_union_distrib _ _ _).symm]
      refine' ineq (h₁ _) (h₁ _) (h₂ _) (h₂ _) (h₃ _) (h₃ _) (h₄ _) (h₄ _) (h ‹_› ‹_›) _ _ _
      · simpa [*] using h ‹insert a s ⊆ _› ‹t ⊆ _›
      · simpa [*] using h ‹s ⊆ _› ‹insert a t ⊆ _›
      · simpa [*] using h ‹insert a s ⊆ _› ‹insert a t ⊆ _›
    · rw [add_zero, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›) (union_mem_sups ‹_› ‹_›) rfl
        (insert_union _ _ _), insert_inter_of_not_mem ‹_›, ← mul_add]
      exact mul_le_mul_of_nonneg_right (le_collapse_of_mem ‹_› h₃ rfl $ inter_mem_infs ‹_› ‹_›) $
        add_nonneg (h₄ _) $ h₄ _
    · rw [zero_add, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›)
        (inter_insert_of_not_mem ‹_›) (insert_inter_distrib _ _ _).symm, union_insert,
        insert_union_distrib, ← add_mul]
      

Proof state:
case pos
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜✝ ℬ✝ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s✝ t✝ u : Finset α
hu : a ∉ u
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ ⦃s : Finset α⦄, s ⊆ insert a u → ∀ ⦃t : Finset α⦄, t ⊆ insert a u → f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t)
𝒜 ℬ : Finset (Finset α)
s : Finset α
hsu : s ⊆ u
t : Finset α
htu : t ⊆ u
this✝⁴ : s ⊆ insert a u
this✝³ : t ⊆ insert a u
this✝² : insert a s ⊆ insert a u
this✝¹ : insert a t ⊆ insert a u
has : a ∉ s
hat : a ∉ t
this✝ : a ∉ s ∩ t
this : a ∉ s ∪ t
h✝³ : s ∈ 𝒜
h✝² : insert a s ∈ 𝒜
h✝¹ : t ∉ ℬ
h✝ : insert a t ∈ ℬ
⊢ (f₃ (s ∩ insert a t) + f₃ (insert a s ∩ insert a t)) * f₄ (insert a s ∪ insert a t) ≤
    (f₃ (s ∩ insert a t) + f₃ (insert a s ∩ insert a t)) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t)

Next tactic:
exact mul_le_mul_of_nonneg_left (le_collapse_of_insert_mem ‹_› h₄
        (insert_union_distrib _ _ _).symm $ union_mem_sups ‹_› ‹_›) $ add_nonneg (h₃ _) $ h₃ _
lemma collapse_modular (hu : a ∉ u) (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ ⦃s⦄, s ⊆ insert a u → ∀ ⦃t⦄, t ⊆ insert a u →  f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t))
    (𝒜 ℬ : Finset (Finset α)) :
    ∀ ⦃s⦄, s ⊆ u → ∀ ⦃t⦄, t ⊆ u → collapse 𝒜 a f₁ s * collapse ℬ a f₂ t ≤
      collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t) := by
  rintro s hsu t htu
  -- Gather a bunch of facts we'll need a lot
  have := hsu.trans $ subset_insert a _
  have := htu.trans $ subset_insert a _
  have := insert_subset_insert a hsu
  have := insert_subset_insert a htu
  have has := not_mem_mono hsu hu
  have hat := not_mem_mono htu hu
  have : a ∉ s ∩ t := not_mem_mono ((inter_subset_left _ t).trans hsu) hu
  have := not_mem_union.2 ⟨has, hat⟩
  rw [collapse_eq has]
  split_ifs
  · rw [collapse_eq hat]
    split_ifs
    · rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›) rfl
        (insert_inter_distrib _ _ _).symm, collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›)
        (union_mem_sups ‹_› ‹_›) rfl (insert_union_distrib _ _ _).symm]
      refine' ineq (h₁ _) (h₁ _) (h₂ _) (h₂ _) (h₃ _) (h₃ _) (h₄ _) (h₄ _) (h ‹_› ‹_›) _ _ _
      · simpa [*] using h ‹insert a s ⊆ _› ‹t ⊆ _›
      · simpa [*] using h ‹s ⊆ _› ‹insert a t ⊆ _›
      · simpa [*] using h ‹insert a s ⊆ _› ‹insert a t ⊆ _›
    · rw [add_zero, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›) (union_mem_sups ‹_› ‹_›) rfl
        (insert_union _ _ _), insert_inter_of_not_mem ‹_›, ← mul_add]
      exact mul_le_mul_of_nonneg_right (le_collapse_of_mem ‹_› h₃ rfl $ inter_mem_infs ‹_› ‹_›) $
        add_nonneg (h₄ _) $ h₄ _
    · rw [zero_add, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›)
        (inter_insert_of_not_mem ‹_›) (insert_inter_distrib _ _ _).symm, union_insert,
        insert_union_distrib, ← add_mul]
      exact mul_le_mul_of_nonneg_left (le_collapse_of_insert_mem ‹_› h₄
        (insert_union_distrib _ _ _).symm $ union_mem_sups ‹_› ‹_›) $ add_nonneg (h₃ _) $ h₃ _
    · 

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜✝ ℬ✝ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s✝ t✝ u : Finset α
hu : a ∉ u
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ ⦃s : Finset α⦄, s ⊆ insert a u → ∀ ⦃t : Finset α⦄, t ⊆ insert a u → f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t)
𝒜 ℬ : Finset (Finset α)
s : Finset α
hsu : s ⊆ u
t : Finset α
htu : t ⊆ u
this✝⁴ : s ⊆ insert a u
this✝³ : t ⊆ insert a u
this✝² : insert a s ⊆ insert a u
this✝¹ : insert a t ⊆ insert a u
has : a ∉ s
hat : a ∉ t
this✝ : a ∉ s ∩ t
this : a ∉ s ∪ t
h✝³ : s ∈ 𝒜
h✝² : insert a s ∈ 𝒜
h✝¹ : t ∉ ℬ
h✝ : insert a t ∉ ℬ
⊢ (f₁ s + f₁ (insert a s)) * (0 + 0) ≤ collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t)

Next tactic:
rw [add_zero, mul_zero]
lemma collapse_modular (hu : a ∉ u) (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ ⦃s⦄, s ⊆ insert a u → ∀ ⦃t⦄, t ⊆ insert a u →  f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t))
    (𝒜 ℬ : Finset (Finset α)) :
    ∀ ⦃s⦄, s ⊆ u → ∀ ⦃t⦄, t ⊆ u → collapse 𝒜 a f₁ s * collapse ℬ a f₂ t ≤
      collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t) := by
  rintro s hsu t htu
  -- Gather a bunch of facts we'll need a lot
  have := hsu.trans $ subset_insert a _
  have := htu.trans $ subset_insert a _
  have := insert_subset_insert a hsu
  have := insert_subset_insert a htu
  have has := not_mem_mono hsu hu
  have hat := not_mem_mono htu hu
  have : a ∉ s ∩ t := not_mem_mono ((inter_subset_left _ t).trans hsu) hu
  have := not_mem_union.2 ⟨has, hat⟩
  rw [collapse_eq has]
  split_ifs
  · rw [collapse_eq hat]
    split_ifs
    · rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›) rfl
        (insert_inter_distrib _ _ _).symm, collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›)
        (union_mem_sups ‹_› ‹_›) rfl (insert_union_distrib _ _ _).symm]
      refine' ineq (h₁ _) (h₁ _) (h₂ _) (h₂ _) (h₃ _) (h₃ _) (h₄ _) (h₄ _) (h ‹_› ‹_›) _ _ _
      · simpa [*] using h ‹insert a s ⊆ _› ‹t ⊆ _›
      · simpa [*] using h ‹s ⊆ _› ‹insert a t ⊆ _›
      · simpa [*] using h ‹insert a s ⊆ _› ‹insert a t ⊆ _›
    · rw [add_zero, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›) (union_mem_sups ‹_› ‹_›) rfl
        (insert_union _ _ _), insert_inter_of_not_mem ‹_›, ← mul_add]
      exact mul_le_mul_of_nonneg_right (le_collapse_of_mem ‹_› h₃ rfl $ inter_mem_infs ‹_› ‹_›) $
        add_nonneg (h₄ _) $ h₄ _
    · rw [zero_add, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›)
        (inter_insert_of_not_mem ‹_›) (insert_inter_distrib _ _ _).symm, union_insert,
        insert_union_distrib, ← add_mul]
      exact mul_le_mul_of_nonneg_left (le_collapse_of_insert_mem ‹_› h₄
        (insert_union_distrib _ _ _).symm $ union_mem_sups ‹_› ‹_›) $ add_nonneg (h₃ _) $ h₃ _
    · rw [add_zero, mul_zero]
      

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜✝ ℬ✝ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s✝ t✝ u : Finset α
hu : a ∉ u
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ ⦃s : Finset α⦄, s ⊆ insert a u → ∀ ⦃t : Finset α⦄, t ⊆ insert a u → f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t)
𝒜 ℬ : Finset (Finset α)
s : Finset α
hsu : s ⊆ u
t : Finset α
htu : t ⊆ u
this✝⁴ : s ⊆ insert a u
this✝³ : t ⊆ insert a u
this✝² : insert a s ⊆ insert a u
this✝¹ : insert a t ⊆ insert a u
has : a ∉ s
hat : a ∉ t
this✝ : a ∉ s ∩ t
this : a ∉ s ∪ t
h✝³ : s ∈ 𝒜
h✝² : insert a s ∈ 𝒜
h✝¹ : t ∉ ℬ
h✝ : insert a t ∉ ℬ
⊢ 0 ≤ collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t)

Next tactic:
exact mul_nonneg (collapse_nonneg h₃ _) $ collapse_nonneg h₄ _
lemma collapse_modular (hu : a ∉ u) (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ ⦃s⦄, s ⊆ insert a u → ∀ ⦃t⦄, t ⊆ insert a u →  f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t))
    (𝒜 ℬ : Finset (Finset α)) :
    ∀ ⦃s⦄, s ⊆ u → ∀ ⦃t⦄, t ⊆ u → collapse 𝒜 a f₁ s * collapse ℬ a f₂ t ≤
      collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t) := by
  rintro s hsu t htu
  -- Gather a bunch of facts we'll need a lot
  have := hsu.trans $ subset_insert a _
  have := htu.trans $ subset_insert a _
  have := insert_subset_insert a hsu
  have := insert_subset_insert a htu
  have has := not_mem_mono hsu hu
  have hat := not_mem_mono htu hu
  have : a ∉ s ∩ t := not_mem_mono ((inter_subset_left _ t).trans hsu) hu
  have := not_mem_union.2 ⟨has, hat⟩
  rw [collapse_eq has]
  split_ifs
  · rw [collapse_eq hat]
    split_ifs
    · rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›) rfl
        (insert_inter_distrib _ _ _).symm, collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›)
        (union_mem_sups ‹_› ‹_›) rfl (insert_union_distrib _ _ _).symm]
      refine' ineq (h₁ _) (h₁ _) (h₂ _) (h₂ _) (h₃ _) (h₃ _) (h₄ _) (h₄ _) (h ‹_› ‹_›) _ _ _
      · simpa [*] using h ‹insert a s ⊆ _› ‹t ⊆ _›
      · simpa [*] using h ‹s ⊆ _› ‹insert a t ⊆ _›
      · simpa [*] using h ‹insert a s ⊆ _› ‹insert a t ⊆ _›
    · rw [add_zero, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›) (union_mem_sups ‹_› ‹_›) rfl
        (insert_union _ _ _), insert_inter_of_not_mem ‹_›, ← mul_add]
      exact mul_le_mul_of_nonneg_right (le_collapse_of_mem ‹_› h₃ rfl $ inter_mem_infs ‹_› ‹_›) $
        add_nonneg (h₄ _) $ h₄ _
    · rw [zero_add, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›)
        (inter_insert_of_not_mem ‹_›) (insert_inter_distrib _ _ _).symm, union_insert,
        insert_union_distrib, ← add_mul]
      exact mul_le_mul_of_nonneg_left (le_collapse_of_insert_mem ‹_› h₄
        (insert_union_distrib _ _ _).symm $ union_mem_sups ‹_› ‹_›) $ add_nonneg (h₃ _) $ h₃ _
    · rw [add_zero, mul_zero]
      exact mul_nonneg (collapse_nonneg h₃ _) $ collapse_nonneg h₄ _
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜✝ ℬ✝ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s✝ t✝ u : Finset α
hu : a ∉ u
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ ⦃s : Finset α⦄, s ⊆ insert a u → ∀ ⦃t : Finset α⦄, t ⊆ insert a u → f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t)
𝒜 ℬ : Finset (Finset α)
s : Finset α
hsu : s ⊆ u
t : Finset α
htu : t ⊆ u
this✝⁴ : s ⊆ insert a u
this✝³ : t ⊆ insert a u
this✝² : insert a s ⊆ insert a u
this✝¹ : insert a t ⊆ insert a u
has : a ∉ s
hat : a ∉ t
this✝ : a ∉ s ∩ t
this : a ∉ s ∪ t
h✝¹ : s ∈ 𝒜
h✝ : insert a s ∉ 𝒜
⊢ (f₁ s + 0) * collapse ℬ a f₂ t ≤ collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t)

Next tactic:
rw [add_zero, collapse_eq hat, mul_add]
lemma collapse_modular (hu : a ∉ u) (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ ⦃s⦄, s ⊆ insert a u → ∀ ⦃t⦄, t ⊆ insert a u →  f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t))
    (𝒜 ℬ : Finset (Finset α)) :
    ∀ ⦃s⦄, s ⊆ u → ∀ ⦃t⦄, t ⊆ u → collapse 𝒜 a f₁ s * collapse ℬ a f₂ t ≤
      collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t) := by
  rintro s hsu t htu
  -- Gather a bunch of facts we'll need a lot
  have := hsu.trans $ subset_insert a _
  have := htu.trans $ subset_insert a _
  have := insert_subset_insert a hsu
  have := insert_subset_insert a htu
  have has := not_mem_mono hsu hu
  have hat := not_mem_mono htu hu
  have : a ∉ s ∩ t := not_mem_mono ((inter_subset_left _ t).trans hsu) hu
  have := not_mem_union.2 ⟨has, hat⟩
  rw [collapse_eq has]
  split_ifs
  · rw [collapse_eq hat]
    split_ifs
    · rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›) rfl
        (insert_inter_distrib _ _ _).symm, collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›)
        (union_mem_sups ‹_› ‹_›) rfl (insert_union_distrib _ _ _).symm]
      refine' ineq (h₁ _) (h₁ _) (h₂ _) (h₂ _) (h₃ _) (h₃ _) (h₄ _) (h₄ _) (h ‹_› ‹_›) _ _ _
      · simpa [*] using h ‹insert a s ⊆ _› ‹t ⊆ _›
      · simpa [*] using h ‹s ⊆ _› ‹insert a t ⊆ _›
      · simpa [*] using h ‹insert a s ⊆ _› ‹insert a t ⊆ _›
    · rw [add_zero, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (union_mem_sups ‹_› ‹_›) (union_mem_sups ‹_› ‹_›) rfl
        (insert_union _ _ _), insert_inter_of_not_mem ‹_›, ← mul_add]
      exact mul_le_mul_of_nonneg_right (le_collapse_of_mem ‹_› h₃ rfl $ inter_mem_infs ‹_› ‹_›) $
        add_nonneg (h₄ _) $ h₄ _
    · rw [zero_add, add_mul]
      refine' (add_le_add (h ‹_› ‹_›) $ h ‹_› ‹_›).trans _
      rw [collapse_of_mem ‹_› (inter_mem_infs ‹_› ‹_›) (inter_mem_infs ‹_› ‹_›)
        (inter_insert_of_not_mem ‹_›) (insert_inter_distrib _ _ _).symm, union_insert,
        insert_union_distrib, ← add_mul]
      exact mul_le_mul_of_nonneg_left (le_collapse_of_insert_mem ‹_› h₄
        (insert_union_distrib _ _ _).symm $ union_mem_sups ‹_› ‹_›) $ add_nonneg (h₃ _) $ h₃ _
    · rw [add_zero, mul_zero]
      exact mul_nonneg (collapse_nonneg h₃ _) $ collapse_nonneg h₄ _
  · rw [add_zero, collapse_eq hat, mul_add]
    

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜✝ ℬ✝ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s✝ t✝ u : Finset α
hu : a ∉ u
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ ⦃s : Finset α⦄, s ⊆ insert a u → ∀ ⦃t : Finset α⦄, t ⊆ insert a u → f₁ s * f₂ t ≤ f₃ (s ∩ t) * f₄ (s ∪ t)
𝒜 ℬ : Finset (Finset α)
s : Finset α
hsu : s ⊆ u
t : Finset α
htu : t ⊆ u
this✝⁴ : s ⊆ insert a u
this✝³ : t ⊆ insert a u
this✝² : insert a s ⊆ insert a u
this✝¹ : insert a t ⊆ insert a u
has : a ∉ s
hat : a ∉ t
this✝ : a ∉ s ∩ t
this : a ∉ s ∪ t
h✝¹ : s ∈ 𝒜
h✝ : insert a s ∉ 𝒜
⊢ ((f₁ s * if t ∈ ℬ then f₂ t else 0) + f₁ s * if insert a t ∈ ℬ then f₂ (insert a t) else 0) ≤
    collapse (𝒜 ⊼ ℬ) a f₃ (s ∩ t) * collapse (𝒜 ⊻ ℬ) a f₄ (s ∪ t)

Next tactic:
split_ifs
lemma sum_collapse (h𝒜 : 𝒜 ⊆ (insert a u).powerset) (hu : a ∉ u) :
    ∑ s in u.powerset, collapse 𝒜 a f s = ∑ s in 𝒜, f s := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜 ℬ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s t u : Finset α
h𝒜 : 𝒜 ⊆ powerset (insert a u)
hu : a ∉ u
⊢ ∑ s in powerset u, collapse 𝒜 a f s = ∑ s in 𝒜, f s

Next tactic:
calc
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in u.powerset.image (insert a) ∩ 𝒜, f s := ?_
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in ((insert a u).powerset \ u.powerset) ∩ 𝒜, f s := ?_
    _ = ∑ s in 𝒜, f s := ?_
lemma sum_collapse (h𝒜 : 𝒜 ⊆ (insert a u).powerset) (hu : a ∉ u) :
    ∑ s in u.powerset, collapse 𝒜 a f s = ∑ s in 𝒜, f s := by
  calc
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in u.powerset.image (insert a) ∩ 𝒜, f s := ?_
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in ((insert a u).powerset \ u.powerset) ∩ 𝒜, f s := ?_
    _ = ∑ s in 𝒜, f s := ?_
  · 

Proof state:
case calc_1
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜 ℬ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s t u : Finset α
h𝒜 : 𝒜 ⊆ powerset (insert a u)
hu : a ∉ u
⊢ ∑ s in powerset u, collapse 𝒜 a f s = ∑ s in powerset u ∩ 𝒜, f s + ∑ s in image (insert a) (powerset u) ∩ 𝒜, f s

Next tactic:
rw [← sum_ite_mem, ← sum_ite_mem, sum_image, ← sum_add_distrib]
lemma sum_collapse (h𝒜 : 𝒜 ⊆ (insert a u).powerset) (hu : a ∉ u) :
    ∑ s in u.powerset, collapse 𝒜 a f s = ∑ s in 𝒜, f s := by
  calc
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in u.powerset.image (insert a) ∩ 𝒜, f s := ?_
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in ((insert a u).powerset \ u.powerset) ∩ 𝒜, f s := ?_
    _ = ∑ s in 𝒜, f s := ?_
  · rw [← sum_ite_mem, ← sum_ite_mem, sum_image, ← sum_add_distrib]
    · 

Proof state:
case calc_1
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜 ℬ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s t u : Finset α
h𝒜 : 𝒜 ⊆ powerset (insert a u)
hu : a ∉ u
⊢ ∑ s in powerset u, collapse 𝒜 a f s =
    ∑ x in powerset u, ((if x ∈ 𝒜 then f x else 0) + if insert a x ∈ 𝒜 then f (insert a x) else 0)

Next tactic:
exact sum_congr rfl fun s hs ↦ collapse_eq (not_mem_mono (mem_powerset.1 hs) hu) _ _
lemma sum_collapse (h𝒜 : 𝒜 ⊆ (insert a u).powerset) (hu : a ∉ u) :
    ∑ s in u.powerset, collapse 𝒜 a f s = ∑ s in 𝒜, f s := by
  calc
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in u.powerset.image (insert a) ∩ 𝒜, f s := ?_
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in ((insert a u).powerset \ u.powerset) ∩ 𝒜, f s := ?_
    _ = ∑ s in 𝒜, f s := ?_
  · rw [← sum_ite_mem, ← sum_ite_mem, sum_image, ← sum_add_distrib]
    · exact sum_congr rfl fun s hs ↦ collapse_eq (not_mem_mono (mem_powerset.1 hs) hu) _ _
    · 

Proof state:
case calc_1
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜 ℬ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s t u : Finset α
h𝒜 : 𝒜 ⊆ powerset (insert a u)
hu : a ∉ u
⊢ ∀ x ∈ powerset u, ∀ y ∈ powerset u, insert a x = insert a y → x = y

Next tactic:
exact (insert_erase_invOn.2.injOn).mono fun s hs ↦ not_mem_mono (mem_powerset.1 hs) hu
lemma sum_collapse (h𝒜 : 𝒜 ⊆ (insert a u).powerset) (hu : a ∉ u) :
    ∑ s in u.powerset, collapse 𝒜 a f s = ∑ s in 𝒜, f s := by
  calc
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in u.powerset.image (insert a) ∩ 𝒜, f s := ?_
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in ((insert a u).powerset \ u.powerset) ∩ 𝒜, f s := ?_
    _ = ∑ s in 𝒜, f s := ?_
  · rw [← sum_ite_mem, ← sum_ite_mem, sum_image, ← sum_add_distrib]
    · exact sum_congr rfl fun s hs ↦ collapse_eq (not_mem_mono (mem_powerset.1 hs) hu) _ _
    · exact (insert_erase_invOn.2.injOn).mono fun s hs ↦ not_mem_mono (mem_powerset.1 hs) hu
  · 

Proof state:
case calc_2
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜 ℬ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s t u : Finset α
h𝒜 : 𝒜 ⊆ powerset (insert a u)
hu : a ∉ u
⊢ ∑ s in powerset u ∩ 𝒜, f s + ∑ s in image (insert a) (powerset u) ∩ 𝒜, f s =
    ∑ s in powerset u ∩ 𝒜, f s + ∑ s in powerset (insert a u) \ powerset u ∩ 𝒜, f s

Next tactic:
congr with s
lemma sum_collapse (h𝒜 : 𝒜 ⊆ (insert a u).powerset) (hu : a ∉ u) :
    ∑ s in u.powerset, collapse 𝒜 a f s = ∑ s in 𝒜, f s := by
  calc
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in u.powerset.image (insert a) ∩ 𝒜, f s := ?_
    _ = ∑ s in u.powerset ∩ 𝒜, f s + ∑ s in ((insert a u).powerset \ u.powerset) ∩ 𝒜, f s := ?_
    _ = ∑ s in 𝒜, f s := ?_
  · rw [← sum_ite_mem, ← sum_ite_mem, sum_image, ← sum_add_distrib]
    · exact sum_congr rfl fun s hs ↦ collapse_eq (not_mem_mono (mem_powerset.1 hs) hu) _ _
    · exact (insert_erase_invOn.2.injOn).mono fun s hs ↦ not_mem_mono (mem_powerset.1 hs) hu
  · congr with s
    

Proof state:
case calc_2.e_a.e_s.e_a.a
α : Type u_1
β : Type u_2
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
𝒜 ℬ : Finset (Finset α)
a : α
f f₁ f₂ f₃ f₄ g μ : Finset α → β
s✝ t u : Finset α
h𝒜 : 𝒜 ⊆ powerset (insert a u)
hu : a ∉ u
s : Finset α
⊢ s ∈ image (insert a) (powerset u) ↔ s ∈ powerset (insert a u) \ powerset u

Next tactic:
simp only [mem_image, mem_powerset, mem_sdiff, subset_insert_iff]