l3lab/ntp-mathlib huggingface dataset:
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    

Proof state:
α : Type u_1
β : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t))) }
this : Finite ↥L
s' : Finset ↥L := preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s))
t' : Finset ↥L := preimage t Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑t))
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
⊢ map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t

Next tactic:
simp [map_eq_image, image_preimage, filter_eq_self]
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    

Proof state:
α : Type u_1
β : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t))) }
this : Finite ↥L
s' : Finset ↥L := preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s))
t' : Finset ↥L := preimage t Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑t))
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
⊢ ∀ x ∈ t, x ∈ latticeClosure (↑s ∪ ↑t)

Next tactic:
exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  

Proof state:
α : Type u_1
β : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t))) }
this : Finite ↥L
s' : Finset ↥L := preimage s Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑s))
t' : Finset ↥L := preimage t Subtype.val (_ : Set.InjOn (fun a => ↑a) (Subtype.val ⁻¹' ↑t))
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t
⊢ (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a

Next tactic:
clear_value s' t'
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  clear_value s' t'
  

Proof state:
α : Type u_1
β : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t))) }
this : Finite ↥L
t' : Finset ↥L
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t
s' : Finset ↥L
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
⊢ (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a

Next tactic:
obtain ⟨β, _, _, g, hg⟩ := exists_birkhoff_representation L
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  clear_value s' t'
  obtain ⟨β, _, _, g, hg⟩ := exists_birkhoff_representation L
  

Proof state:
case intro.intro.intro.intro
α : Type u_1
β✝ : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β✝
inst✝ : ExistsAddOfLE β✝
f f₁ f₂ f₃ f₄ g✝ μ : α → β✝
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t))) }
this : Finite ↥L
t' : Finset ↥L
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t
s' : Finset ↥L
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
β : Type u_1
w✝¹ : DecidableEq β
w✝ : Fintype β
g : LatticeHom (↥L) (Finset β)
hg : Injective ⇑g
⊢ (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a

Next tactic:
have := four_functions_theorem_aux (extend g (f₁ ∘ (↑)) 0) (extend g (f₂ ∘ (↑)) 0)
    (extend g (f₃ ∘ (↑)) 0) (extend g (f₄ ∘ (↑)) 0) (extend_nonneg (fun _ ↦ h₁ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₂ _) le_rfl) (extend_nonneg (fun _ ↦ h₃ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₄ _) le_rfl) ?_ (s'.map ⟨g, hg⟩) (t'.map ⟨g, hg⟩)
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  clear_value s' t'
  obtain ⟨β, _, _, g, hg⟩ := exists_birkhoff_representation L
  have := four_functions_theorem_aux (extend g (f₁ ∘ (↑)) 0) (extend g (f₂ ∘ (↑)) 0)
    (extend g (f₃ ∘ (↑)) 0) (extend g (f₄ ∘ (↑)) 0) (extend_nonneg (fun _ ↦ h₁ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₂ _) le_rfl) (extend_nonneg (fun _ ↦ h₃ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₄ _) le_rfl) ?_ (s'.map ⟨g, hg⟩) (t'.map ⟨g, hg⟩)
  simpa only [← hs', ← ht', ← map_sups, ← map_infs, sum_map, Embedding.coeFn_mk, hg.extend_apply]
    using this
  

Proof state:
case intro.intro.intro.intro.refine_1
α : Type u_1
β✝ : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β✝
inst✝ : ExistsAddOfLE β✝
f f₁ f₂ f₃ f₄ g✝ μ : α → β✝
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t))) }
this : Finite ↥L
t' : Finset ↥L
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t
s' : Finset ↥L
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
β : Type u_1
w✝¹ : DecidableEq β
w✝ : Fintype β
g : LatticeHom (↥L) (Finset β)
hg : Injective ⇑g
⊢ ∀ (s t : Finset β),
    extend (⇑g) (f₁ ∘ Subtype.val) 0 s * extend (⇑g) (f₂ ∘ Subtype.val) 0 t ≤
      extend (⇑g) (f₃ ∘ Subtype.val) 0 (s ∩ t) * extend (⇑g) (f₄ ∘ Subtype.val) 0 (s ∪ t)

Next tactic:
rintro s t
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  clear_value s' t'
  obtain ⟨β, _, _, g, hg⟩ := exists_birkhoff_representation L
  have := four_functions_theorem_aux (extend g (f₁ ∘ (↑)) 0) (extend g (f₂ ∘ (↑)) 0)
    (extend g (f₃ ∘ (↑)) 0) (extend g (f₄ ∘ (↑)) 0) (extend_nonneg (fun _ ↦ h₁ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₂ _) le_rfl) (extend_nonneg (fun _ ↦ h₃ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₄ _) le_rfl) ?_ (s'.map ⟨g, hg⟩) (t'.map ⟨g, hg⟩)
  simpa only [← hs', ← ht', ← map_sups, ← map_infs, sum_map, Embedding.coeFn_mk, hg.extend_apply]
    using this
  rintro s t
  

Proof state:
case intro.intro.intro.intro.refine_1
α : Type u_1
β✝ : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β✝
inst✝ : ExistsAddOfLE β✝
f f₁ f₂ f₃ f₄ g✝ μ : α → β✝
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s✝ t✝ : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s✝ ∪ ↑t✝), supClosed' := (_ : SupClosed (latticeClosure (↑s✝ ∪ ↑t✝))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s✝ ∪ ↑t✝))) }
this : Finite ↥L
t' : Finset ↥L
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t✝
s' : Finset ↥L
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s✝
β : Type u_1
w✝¹ : DecidableEq β
w✝ : Fintype β
g : LatticeHom (↥L) (Finset β)
hg : Injective ⇑g
s t : Finset β
⊢ extend (⇑g) (f₁ ∘ Subtype.val) 0 s * extend (⇑g) (f₂ ∘ Subtype.val) 0 t ≤
    extend (⇑g) (f₃ ∘ Subtype.val) 0 (s ∩ t) * extend (⇑g) (f₄ ∘ Subtype.val) 0 (s ∪ t)

Next tactic:
classical
  obtain ⟨a, rfl⟩ | hs := em (∃ a, g a = s)
  · obtain ⟨b, rfl⟩ | ht := em (∃ b, g b = t)
    · simp_rw [← sup_eq_union, ← inf_eq_inter, ← map_sup, ← map_inf, hg.extend_apply]
      exact h _ _
    · simpa [extend_apply' _ _ _ ht] using mul_nonneg
        (extend_nonneg (fun a : L ↦ h₃ a) le_rfl _) (extend_nonneg (fun a : L ↦ h₄ a) le_rfl _)
  · simpa [extend_apply' _ _ _ hs] using mul_nonneg
      (extend_nonneg (fun a : L ↦ h₃ a) le_rfl _) (extend_nonneg (fun a : L ↦ h₄ a) le_rfl _)
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  clear_value s' t'
  obtain ⟨β, _, _, g, hg⟩ := exists_birkhoff_representation L
  have := four_functions_theorem_aux (extend g (f₁ ∘ (↑)) 0) (extend g (f₂ ∘ (↑)) 0)
    (extend g (f₃ ∘ (↑)) 0) (extend g (f₄ ∘ (↑)) 0) (extend_nonneg (fun _ ↦ h₁ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₂ _) le_rfl) (extend_nonneg (fun _ ↦ h₃ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₄ _) le_rfl) ?_ (s'.map ⟨g, hg⟩) (t'.map ⟨g, hg⟩)
  simpa only [← hs', ← ht', ← map_sups, ← map_infs, sum_map, Embedding.coeFn_mk, hg.extend_apply]
    using this
  rintro s t
  classical
  

Proof state:
case intro.intro.intro.intro.refine_1
α : Type u_1
β✝ : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β✝
inst✝ : ExistsAddOfLE β✝
f f₁ f₂ f₃ f₄ g✝ μ : α → β✝
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s✝ t✝ : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s✝ ∪ ↑t✝), supClosed' := (_ : SupClosed (latticeClosure (↑s✝ ∪ ↑t✝))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s✝ ∪ ↑t✝))) }
this : Finite ↥L
t' : Finset ↥L
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t✝
s' : Finset ↥L
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s✝
β : Type u_1
w✝¹ : DecidableEq β
w✝ : Fintype β
g : LatticeHom (↥L) (Finset β)
hg : Injective ⇑g
s t : Finset β
⊢ extend (⇑g) (f₁ ∘ Subtype.val) 0 s * extend (⇑g) (f₂ ∘ Subtype.val) 0 t ≤
    extend (⇑g) (f₃ ∘ Subtype.val) 0 (s ∩ t) * extend (⇑g) (f₄ ∘ Subtype.val) 0 (s ∪ t)

Next tactic:
obtain ⟨a, rfl⟩ | hs := em (∃ a, g a = s)
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  clear_value s' t'
  obtain ⟨β, _, _, g, hg⟩ := exists_birkhoff_representation L
  have := four_functions_theorem_aux (extend g (f₁ ∘ (↑)) 0) (extend g (f₂ ∘ (↑)) 0)
    (extend g (f₃ ∘ (↑)) 0) (extend g (f₄ ∘ (↑)) 0) (extend_nonneg (fun _ ↦ h₁ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₂ _) le_rfl) (extend_nonneg (fun _ ↦ h₃ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₄ _) le_rfl) ?_ (s'.map ⟨g, hg⟩) (t'.map ⟨g, hg⟩)
  simpa only [← hs', ← ht', ← map_sups, ← map_infs, sum_map, Embedding.coeFn_mk, hg.extend_apply]
    using this
  rintro s t
  classical
  obtain ⟨a, rfl⟩ | hs := em (∃ a, g a = s)
  · 

Proof state:
case intro.intro.intro.intro.refine_1.inl.intro
α : Type u_1
β✝ : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β✝
inst✝ : ExistsAddOfLE β✝
f f₁ f₂ f₃ f₄ g✝ μ : α → β✝
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t✝ : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t✝), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t✝))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t✝))) }
this : Finite ↥L
t' : Finset ↥L
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t✝
s' : Finset ↥L
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
β : Type u_1
w✝¹ : DecidableEq β
w✝ : Fintype β
g : LatticeHom (↥L) (Finset β)
hg : Injective ⇑g
t : Finset β
a : ↥L
⊢ extend (⇑g) (f₁ ∘ Subtype.val) 0 (g a) * extend (⇑g) (f₂ ∘ Subtype.val) 0 t ≤
    extend (⇑g) (f₃ ∘ Subtype.val) 0 (g a ∩ t) * extend (⇑g) (f₄ ∘ Subtype.val) 0 (g a ∪ t)

Next tactic:
obtain ⟨b, rfl⟩ | ht := em (∃ b, g b = t)
/-- The **Four Functions Theorem**, aka **Ahlswede-Daykin Inequality**. -/
lemma four_functions_theorem (h₁ : 0 ≤ f₁) (h₂ : 0 ≤ f₂) (h₃ : 0 ≤ f₃) (h₄ : 0 ≤ f₄)
    (h : ∀ a b, f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)) (s t : Finset α) :
    (∑ a in s, f₁ a) * ∑ a in t, f₂ a ≤ (∑ a in s ⊼ t, f₃ a) * ∑ a in s ⊻ t, f₄ a := by
  classical
  set L : Sublattice α := ⟨latticeClosure (s ∪ t), isSublattice_latticeClosure.1,
    isSublattice_latticeClosure.2⟩
  have : Finite L := (s.finite_toSet.union t.finite_toSet).latticeClosure.to_subtype
  set s' : Finset L := s.preimage (↑) $ Subtype.coe_injective.injOn _
  set t' : Finset L := t.preimage (↑) $ Subtype.coe_injective.injOn _
  have hs' : s'.map ⟨L.subtype, Subtype.coe_injective⟩ = s := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_left _ _ ha
  have ht' : t'.map ⟨L.subtype, Subtype.coe_injective⟩ = t := by
    simp [map_eq_image, image_preimage, filter_eq_self]
    exact fun a ha ↦ subset_latticeClosure $ Set.subset_union_right _ _ ha
  clear_value s' t'
  obtain ⟨β, _, _, g, hg⟩ := exists_birkhoff_representation L
  have := four_functions_theorem_aux (extend g (f₁ ∘ (↑)) 0) (extend g (f₂ ∘ (↑)) 0)
    (extend g (f₃ ∘ (↑)) 0) (extend g (f₄ ∘ (↑)) 0) (extend_nonneg (fun _ ↦ h₁ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₂ _) le_rfl) (extend_nonneg (fun _ ↦ h₃ _) le_rfl)
    (extend_nonneg (fun _ ↦ h₄ _) le_rfl) ?_ (s'.map ⟨g, hg⟩) (t'.map ⟨g, hg⟩)
  simpa only [← hs', ← ht', ← map_sups, ← map_infs, sum_map, Embedding.coeFn_mk, hg.extend_apply]
    using this
  rintro s t
  classical
  obtain ⟨a, rfl⟩ | hs := em (∃ a, g a = s)
  · obtain ⟨b, rfl⟩ | ht := em (∃ b, g b = t)
    · 

Proof state:
case intro.intro.intro.intro.refine_1.inl.intro.inl.intro
α : Type u_1
β✝ : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β✝
inst✝ : ExistsAddOfLE β✝
f f₁ f₂ f₃ f₄ g✝ μ : α → β✝
h₁ : 0 ≤ f₁
h₂ : 0 ≤ f₂
h₃ : 0 ≤ f₃
h₄ : 0 ≤ f₄
h : ∀ (a b : α), f₁ a * f₂ b ≤ f₃ (a ⊓ b) * f₄ (a ⊔ b)
s t : Finset α
L : Sublattice α :=
  { carrier := latticeClosure (↑s ∪ ↑t), supClosed' := (_ : SupClosed (latticeClosure (↑s ∪ ↑t))),
    infClosed' := (_ : InfClosed (latticeClosure (↑s ∪ ↑t))) }
this : Finite ↥L
t' : Finset ↥L
ht' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } t' = t
s' : Finset ↥L
hs' : map { toFun := ⇑(Sublattice.subtype L), inj' := (_ : Injective fun a => ↑a) } s' = s
β : Type u_1
w✝¹ : DecidableEq β
w✝ : Fintype β
g : LatticeHom (↥L) (Finset β)
hg : Injective ⇑g
a b : ↥L
⊢ extend (⇑g) (f₁ ∘ Subtype.val) 0 (g a) * extend (⇑g) (f₂ ∘ Subtype.val) 0 (g b) ≤
    extend (⇑g) (f₃ ∘ Subtype.val) 0 (g a ∩ g b) * extend (⇑g) (f₄ ∘ Subtype.val) 0 (g a ∪ g b)

Next tactic:
simp_rw [← sup_eq_union, ← inf_eq_inter, ← map_sup, ← map_inf, hg.extend_apply]