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
    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)
    · simp_rw [← sup_eq_union, ← inf_eq_inter, ← map_sup, ← map_inf, hg.extend_apply]
      

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
⊢ (f₁ ∘ Subtype.val) a * (f₂ ∘ Subtype.val) b ≤ (f₃ ∘ Subtype.val) (a ⊓ b) * (f₄ ∘ Subtype.val) (a ⊔ b)

Next tactic:
exact h _ _
/-- 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)
    · simp_rw [← sup_eq_union, ← inf_eq_inter, ← map_sup, ← map_inf, hg.extend_apply]
      exact h _ _
    · 

Proof state:
case intro.intro.intro.intro.refine_1.inl.intro.inr
α : 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
ht : ¬∃ b, g b = t
⊢ 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:
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 _)
/-- 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)
    · 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 _)
  · 

Proof state:
case intro.intro.intro.intro.refine_1.inr
α : 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 β
hs : ¬∃ a, g a = s
⊢ 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:
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 _)
/-- An inequality of Daykin. Interestingly, any lattice in which this inequality holds is
distributive. -/
lemma Finset.le_card_infs_mul_card_sups (s t : Finset α) :
    s.card * t.card ≤ (s ⊼ t).card * (s ⊻ t).card := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝³ : DistribLattice α
inst✝² : DecidableEq α
inst✝¹ : LinearOrderedCommSemiring β
inst✝ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
s t : Finset α
⊢ card s * card t ≤ card (s ⊼ t) * card (s ⊻ t)

Next tactic:
simpa using four_functions_theorem (1 : α → ℕ) 1 1 1 zero_le_one zero_le_one zero_le_one
    zero_le_one (fun _ _ ↦ le_rfl) s t
/-- Special case of the **Four Functions Theorem** when `s = t = univ`. -/
lemma four_functions_theorem_univ (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)) :
    (∑ a, f₁ a) * ∑ a, f₂ a ≤ (∑ a, f₃ a) * ∑ a, f₄ a := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
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)
⊢ (∑ a : α, f₁ a) * ∑ a : α, f₂ a ≤ (∑ a : α, f₃ a) * ∑ a : α, f₄ a

Next tactic:
simpa using four_functions_theorem f₁ f₂ f₃ f₄ h₁ h₂ h₃ h₄ h univ univ
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf : 0 ≤ f
hg : 0 ≤ g
hμ : Monotone μ
hfg : ∑ a : α, f a = ∑ a : α, g a
h : ∀ (a b : α), f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)
⊢ ∑ a : α, μ a * f a ≤ ∑ a : α, μ a * g a

Next tactic:
obtain rfl | hf := hf.eq_or_lt
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hg : 0 ≤ g
hμ : Monotone μ
hf : 0 ≤ 0
hfg : ∑ a : α, OfNat.ofNat 0 a = ∑ a : α, g a
h : ∀ (a b : α), OfNat.ofNat 0 a * g b ≤ OfNat.ofNat 0 (a ⊓ b) * g (a ⊔ b)
⊢ ∑ a : α, μ a * OfNat.ofNat 0 a ≤ ∑ a : α, μ a * g a

Next tactic:
simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    

Proof state:
case inl
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hg : 0 ≤ g
hμ : Monotone μ
hf : 0 ≤ 0
h : ∀ (a b : α), OfNat.ofNat 0 a * g b ≤ OfNat.ofNat 0 (a ⊓ b) * g (a ⊔ b)
hfg : g = 0
⊢ ∑ a : α, μ a * OfNat.ofNat 0 a ≤ ∑ a : α, μ a * g a

Next tactic:
simp [hfg]
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  

Proof state:
case inr
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hg : 0 ≤ g
hμ : Monotone μ
hfg : ∑ a : α, f a = ∑ a : α, g a
h : ∀ (a b : α), f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)
hf : 0 < f
⊢ ∑ a : α, μ a * f a ≤ ∑ a : α, μ a * g a

Next tactic:
obtain rfl | hg := hg.eq_or_lt
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  obtain rfl | hg := hg.eq_or_lt
  · 

Proof state:
case inr.inl
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hμ : Monotone μ
hf : 0 < f
hg : 0 ≤ 0
hfg : ∑ a : α, f a = ∑ a : α, OfNat.ofNat 0 a
h : ∀ (a b : α), f a * OfNat.ofNat 0 b ≤ f (a ⊓ b) * OfNat.ofNat 0 (a ⊔ b)
⊢ ∑ a : α, μ a * f a ≤ ∑ a : α, μ a * OfNat.ofNat 0 a

Next tactic:
simp only [Pi.zero_apply, sum_const_zero, Fintype.sum_eq_zero_iff_of_nonneg hf.le] at hfg
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  obtain rfl | hg := hg.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, Fintype.sum_eq_zero_iff_of_nonneg hf.le] at hfg
    

Proof state:
case inr.inl
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hμ : Monotone μ
hf : 0 < f
hg : 0 ≤ 0
h : ∀ (a b : α), f a * OfNat.ofNat 0 b ≤ f (a ⊓ b) * OfNat.ofNat 0 (a ⊔ b)
hfg : f = 0
⊢ ∑ a : α, μ a * f a ≤ ∑ a : α, μ a * OfNat.ofNat 0 a

Next tactic:
simp [hfg]
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  obtain rfl | hg := hg.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, Fintype.sum_eq_zero_iff_of_nonneg hf.le] at hfg
    simp [hfg]
  

Proof state:
case inr.inr
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hg✝ : 0 ≤ g
hμ : Monotone μ
hfg : ∑ a : α, f a = ∑ a : α, g a
h : ∀ (a b : α), f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)
hf : 0 < f
hg : 0 < g
⊢ ∑ a : α, μ a * f a ≤ ∑ a : α, μ a * g a

Next tactic:
have := four_functions_theorem g (μ * f) f (μ * g) hg.le (mul_nonneg hμ₀ hf.le) hf.le
    (mul_nonneg hμ₀ hg.le) (fun a b ↦ ?_) univ univ
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  obtain rfl | hg := hg.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, Fintype.sum_eq_zero_iff_of_nonneg hf.le] at hfg
    simp [hfg]
  have := four_functions_theorem g (μ * f) f (μ * g) hg.le (mul_nonneg hμ₀ hf.le) hf.le
    (mul_nonneg hμ₀ hg.le) (fun a b ↦ ?_) univ univ
  · 

Proof state:
case inr.inr.refine_2
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hg✝ : 0 ≤ g
hμ : Monotone μ
hfg : ∑ a : α, f a = ∑ a : α, g a
h : ∀ (a b : α), f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)
hf : 0 < f
hg : 0 < g
this : (∑ a : α, g a) * ∑ a : α, (μ * f) a ≤ (∑ a in univ ⊼ univ, f a) * ∑ a in univ ⊻ univ, (μ * g) a
⊢ ∑ a : α, μ a * f a ≤ ∑ a : α, μ a * g a

Next tactic:
simpa [hfg, sum_pos hg] using this
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  obtain rfl | hg := hg.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, Fintype.sum_eq_zero_iff_of_nonneg hf.le] at hfg
    simp [hfg]
  have := four_functions_theorem g (μ * f) f (μ * g) hg.le (mul_nonneg hμ₀ hf.le) hf.le
    (mul_nonneg hμ₀ hg.le) (fun a b ↦ ?_) univ univ
  · simpa [hfg, sum_pos hg] using this
  · 

Proof state:
case inr.inr.refine_1
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hg✝ : 0 ≤ g
hμ : Monotone μ
hfg : ∑ a : α, f a = ∑ a : α, g a
h : ∀ (a b : α), f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)
hf : 0 < f
hg : 0 < g
a b : α
⊢ g a * (μ * f) b ≤ f (a ⊓ b) * (μ * g) (a ⊔ b)

Next tactic:
simp_rw [Pi.mul_apply, mul_left_comm _ (μ _), mul_comm (g _)]
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  obtain rfl | hg := hg.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, Fintype.sum_eq_zero_iff_of_nonneg hf.le] at hfg
    simp [hfg]
  have := four_functions_theorem g (μ * f) f (μ * g) hg.le (mul_nonneg hμ₀ hf.le) hf.le
    (mul_nonneg hμ₀ hg.le) (fun a b ↦ ?_) univ univ
  · simpa [hfg, sum_pos hg] using this
  · simp_rw [Pi.mul_apply, mul_left_comm _ (μ _), mul_comm (g _)]
    

Proof state:
case inr.inr.refine_1
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hg✝ : 0 ≤ g
hμ : Monotone μ
hfg : ∑ a : α, f a = ∑ a : α, g a
h : ∀ (a b : α), f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)
hf : 0 < f
hg : 0 < g
a b : α
⊢ μ b * (f b * g a) ≤ μ (a ⊔ b) * (f (a ⊓ b) * g (a ⊔ b))

Next tactic:
rw [sup_comm, inf_comm]
/-- The **Holley Inequality**. -/
lemma holley (hμ₀ : 0 ≤ μ) (hf : 0 ≤ f) (hg : 0 ≤ g) (hμ : Monotone μ)
    (hfg : ∑ a, f a = ∑ a, g a) (h : ∀ a b, f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)) :
    ∑ a, μ a * f a ≤ ∑ a, μ a * g a := by
  obtain rfl | hf := hf.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, eq_comm, Fintype.sum_eq_zero_iff_of_nonneg hg] at hfg
    simp [hfg]
  obtain rfl | hg := hg.eq_or_lt
  · simp only [Pi.zero_apply, sum_const_zero, Fintype.sum_eq_zero_iff_of_nonneg hf.le] at hfg
    simp [hfg]
  have := four_functions_theorem g (μ * f) f (μ * g) hg.le (mul_nonneg hμ₀ hf.le) hf.le
    (mul_nonneg hμ₀ hg.le) (fun a b ↦ ?_) univ univ
  · simpa [hfg, sum_pos hg] using this
  · simp_rw [Pi.mul_apply, mul_left_comm _ (μ _), mul_comm (g _)]
    rw [sup_comm, inf_comm]
    

Proof state:
case inr.inr.refine_1
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf✝ : 0 ≤ f
hg✝ : 0 ≤ g
hμ : Monotone μ
hfg : ∑ a : α, f a = ∑ a : α, g a
h : ∀ (a b : α), f a * g b ≤ f (a ⊓ b) * g (a ⊔ b)
hf : 0 < f
hg : 0 < g
a b : α
⊢ μ b * (f b * g a) ≤ μ (b ⊔ a) * (f (b ⊓ a) * g (b ⊔ a))

Next tactic:
exact mul_le_mul (hμ le_sup_left) (h _ _) (mul_nonneg (hf.le _) $ hg.le _) $ hμ₀ _
/-- The **Fortuin-Kastelyn-Ginibre Inequality**. -/
lemma fkg (hμ₀ : 0 ≤ μ) (hf₀ : 0 ≤ f) (hg₀ : 0 ≤ g) (hf : Monotone f) (hg : Monotone g)
    (hμ : ∀ a b, μ a * μ b ≤ μ (a ⊓ b) * μ (a ⊔ b)) :
    (∑ a, μ a * f a) * ∑ a, μ a * g a ≤ (∑ a, μ a) * ∑ a, μ a * (f a * g a) := by
  

Proof state:
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf₀ : 0 ≤ f
hg₀ : 0 ≤ g
hf : Monotone f
hg : Monotone g
hμ : ∀ (a b : α), μ a * μ b ≤ μ (a ⊓ b) * μ (a ⊔ b)
⊢ (∑ a : α, μ a * f a) * ∑ a : α, μ a * g a ≤ (∑ a : α, μ a) * ∑ a : α, μ a * (f a * g a)

Next tactic:
refine' four_functions_theorem_univ (μ * f) (μ * g) μ _ (mul_nonneg hμ₀ hf₀) (mul_nonneg hμ₀ hg₀)
    hμ₀ (mul_nonneg hμ₀ $ mul_nonneg hf₀ hg₀) (fun a b ↦ _)
/-- The **Fortuin-Kastelyn-Ginibre Inequality**. -/
lemma fkg (hμ₀ : 0 ≤ μ) (hf₀ : 0 ≤ f) (hg₀ : 0 ≤ g) (hf : Monotone f) (hg : Monotone g)
    (hμ : ∀ a b, μ a * μ b ≤ μ (a ⊓ b) * μ (a ⊔ b)) :
    (∑ a, μ a * f a) * ∑ a, μ a * g a ≤ (∑ a, μ a) * ∑ a, μ a * (f a * g a) := by
  refine' four_functions_theorem_univ (μ * f) (μ * g) μ _ (mul_nonneg hμ₀ hf₀) (mul_nonneg hμ₀ hg₀)
    hμ₀ (mul_nonneg hμ₀ $ mul_nonneg hf₀ hg₀) (fun a b ↦ _)
  

Proof state:
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf₀ : 0 ≤ f
hg₀ : 0 ≤ g
hf : Monotone f
hg : Monotone g
hμ : ∀ (a b : α), μ a * μ b ≤ μ (a ⊓ b) * μ (a ⊔ b)
a b : α
⊢ (μ * f) a * (μ * g) b ≤ μ (a ⊓ b) * (μ (a ⊔ b) * (f (a ⊔ b) * g (a ⊔ b)))

Next tactic:
dsimp
/-- The **Fortuin-Kastelyn-Ginibre Inequality**. -/
lemma fkg (hμ₀ : 0 ≤ μ) (hf₀ : 0 ≤ f) (hg₀ : 0 ≤ g) (hf : Monotone f) (hg : Monotone g)
    (hμ : ∀ a b, μ a * μ b ≤ μ (a ⊓ b) * μ (a ⊔ b)) :
    (∑ a, μ a * f a) * ∑ a, μ a * g a ≤ (∑ a, μ a) * ∑ a, μ a * (f a * g a) := by
  refine' four_functions_theorem_univ (μ * f) (μ * g) μ _ (mul_nonneg hμ₀ hf₀) (mul_nonneg hμ₀ hg₀)
    hμ₀ (mul_nonneg hμ₀ $ mul_nonneg hf₀ hg₀) (fun a b ↦ _)
  dsimp
  

Proof state:
α : Type u_1
β : Type u_2
inst✝⁴ : DistribLattice α
inst✝³ : DecidableEq α
inst✝² : LinearOrderedCommSemiring β
inst✝¹ : ExistsAddOfLE β
f f₁ f₂ f₃ f₄ g μ : α → β
inst✝ : Fintype α
hμ₀ : 0 ≤ μ
hf₀ : 0 ≤ f
hg₀ : 0 ≤ g
hf : Monotone f
hg : Monotone g
hμ : ∀ (a b : α), μ a * μ b ≤ μ (a ⊓ b) * μ (a ⊔ b)
a b : α
⊢ μ a * f a * (μ b * g b) ≤ μ (a ⊓ b) * (μ (a ⊔ b) * (f (a ⊔ b) * g (a ⊔ b)))

Next tactic:
rw [mul_mul_mul_comm, ← mul_assoc (μ (a ⊓ b))]