l3lab/ntp-mathlib huggingface dataset:
/-- Let `s` be a closed set in a separable normal space. If the induced topology on `s` is discrete,
then `s` has cardinality less than continuum.

The proof follows
https://en.wikipedia.org/wiki/Moore_plane#Proof_that_the_Moore_plane_is_not_normal -/
theorem IsClosed.mk_lt_continuum [NormalSpace X] {s : Set X} (hs : IsClosed s)
    [DiscreteTopology s] : #s < 𝔠 := by
  -- Proof by contradiction: assume `𝔠 ≤ #s`
  by_contra! h
  -- Choose a countable dense set `t : Set X`
  rcases exists_countable_dense X with ⟨t, htc, htd⟩
  haveI := htc.to_subtype
  -- To obtain a contradiction, we will prove `2 ^ 𝔠 ≤ 𝔠`.
  refine (Cardinal.cantor 𝔠).not_le ?_
  calc
    -- Any function `s → ℝ` is continuous, hence `2 ^ 𝔠 ≤ #C(s, ℝ)`
    2 ^ 𝔠 ≤ #C(s, ℝ) := by
      rw [(ContinuousMap.equivFnOfDiscrete _ _).cardinal_eq, mk_arrow, mk_real, lift_continuum,
        lift_uzero]
      exact (power_le_power_left two_ne_zero h).trans (power_le_power_right (nat_lt_continuum 2).le)
    -- By the Tietze Extension Theorem, any function `f : C(s, ℝ)` can be extended to `C(X, ℝ)`,
    -- hence `#C(s, ℝ) ≤ #C(X, ℝ)`
    _ ≤ #C(X, ℝ) := by
      choose f hf using (ContinuousMap.exists_restrict_eq_of_closed · hs)
      

Proof state:
X : Type u
inst✝³ : TopologicalSpace X
inst✝² : SeparableSpace X
inst✝¹ : NormalSpace X
s : Set X
hs : IsClosed s
inst✝ : DiscreteTopology ↑s
h : 𝔠 ≤ #↑s
t : Set X
htc : Set.Countable t
htd : Dense t
this : Countable ↑t
f : C(↑s, ℝ) → C(X, ℝ)
hf : ∀ (x : C(↑s, ℝ)), ContinuousMap.restrict s (f x) = x
⊢ #C(↑s, ℝ) ≤ #C(X, ℝ)

Next tactic:
have hfi : Injective f := LeftInverse.injective hf
/-- Let `s` be a closed set in a separable normal space. If the induced topology on `s` is discrete,
then `s` has cardinality less than continuum.

The proof follows
https://en.wikipedia.org/wiki/Moore_plane#Proof_that_the_Moore_plane_is_not_normal -/
theorem IsClosed.mk_lt_continuum [NormalSpace X] {s : Set X} (hs : IsClosed s)
    [DiscreteTopology s] : #s < 𝔠 := by
  -- Proof by contradiction: assume `𝔠 ≤ #s`
  by_contra! h
  -- Choose a countable dense set `t : Set X`
  rcases exists_countable_dense X with ⟨t, htc, htd⟩
  haveI := htc.to_subtype
  -- To obtain a contradiction, we will prove `2 ^ 𝔠 ≤ 𝔠`.
  refine (Cardinal.cantor 𝔠).not_le ?_
  calc
    -- Any function `s → ℝ` is continuous, hence `2 ^ 𝔠 ≤ #C(s, ℝ)`
    2 ^ 𝔠 ≤ #C(s, ℝ) := by
      rw [(ContinuousMap.equivFnOfDiscrete _ _).cardinal_eq, mk_arrow, mk_real, lift_continuum,
        lift_uzero]
      exact (power_le_power_left two_ne_zero h).trans (power_le_power_right (nat_lt_continuum 2).le)
    -- By the Tietze Extension Theorem, any function `f : C(s, ℝ)` can be extended to `C(X, ℝ)`,
    -- hence `#C(s, ℝ) ≤ #C(X, ℝ)`
    _ ≤ #C(X, ℝ) := by
      choose f hf using (ContinuousMap.exists_restrict_eq_of_closed · hs)
      have hfi : Injective f := LeftInverse.injective hf
      

Proof state:
X : Type u
inst✝³ : TopologicalSpace X
inst✝² : SeparableSpace X
inst✝¹ : NormalSpace X
s : Set X
hs : IsClosed s
inst✝ : DiscreteTopology ↑s
h : 𝔠 ≤ #↑s
t : Set X
htc : Set.Countable t
htd : Dense t
this : Countable ↑t
f : C(↑s, ℝ) → C(X, ℝ)
hf : ∀ (x : C(↑s, ℝ)), ContinuousMap.restrict s (f x) = x
hfi : Injective f
⊢ #C(↑s, ℝ) ≤ #C(X, ℝ)

Next tactic:
exact mk_le_of_injective hfi
/-- Let `s` be a closed set in a separable normal space. If the induced topology on `s` is discrete,
then `s` has cardinality less than continuum.

The proof follows
https://en.wikipedia.org/wiki/Moore_plane#Proof_that_the_Moore_plane_is_not_normal -/
theorem IsClosed.mk_lt_continuum [NormalSpace X] {s : Set X} (hs : IsClosed s)
    [DiscreteTopology s] : #s < 𝔠 := by
  -- Proof by contradiction: assume `𝔠 ≤ #s`
  by_contra! h
  -- Choose a countable dense set `t : Set X`
  rcases exists_countable_dense X with ⟨t, htc, htd⟩
  haveI := htc.to_subtype
  -- To obtain a contradiction, we will prove `2 ^ 𝔠 ≤ 𝔠`.
  refine (Cardinal.cantor 𝔠).not_le ?_
  calc
    -- Any function `s → ℝ` is continuous, hence `2 ^ 𝔠 ≤ #C(s, ℝ)`
    2 ^ 𝔠 ≤ #C(s, ℝ) := by
      rw [(ContinuousMap.equivFnOfDiscrete _ _).cardinal_eq, mk_arrow, mk_real, lift_continuum,
        lift_uzero]
      exact (power_le_power_left two_ne_zero h).trans (power_le_power_right (nat_lt_continuum 2).le)
    -- By the Tietze Extension Theorem, any function `f : C(s, ℝ)` can be extended to `C(X, ℝ)`,
    -- hence `#C(s, ℝ) ≤ #C(X, ℝ)`
    _ ≤ #C(X, ℝ) := by
      choose f hf using (ContinuousMap.exists_restrict_eq_of_closed · hs)
      have hfi : Injective f := LeftInverse.injective hf
      exact mk_le_of_injective hfi
    -- Since `t` is dense, restriction `C(X, ℝ) → C(t, ℝ)` is injective, hence `#C(X, ℝ) ≤ #C(t, ℝ)`
    _ ≤ #C(t, ℝ) := mk_le_of_injective <| ContinuousMap.injective_restrict htd
    _ ≤ #(t → ℝ) := mk_le_of_injective FunLike.coe_injective
    -- Since `t` is countable, we have `#(t → ℝ) ≤ 𝔠`
    _ ≤ 𝔠 := by
      

Proof state:
X : Type u
inst✝³ : TopologicalSpace X
inst✝² : SeparableSpace X
inst✝¹ : NormalSpace X
s : Set X
hs : IsClosed s
inst✝ : DiscreteTopology ↑s
h : 𝔠 ≤ #↑s
t : Set X
htc : Set.Countable t
htd : Dense t
this : Countable ↑t
⊢ #(↑t → ℝ) ≤ 𝔠

Next tactic:
rw [mk_arrow, mk_real, lift_uzero, lift_continuum, continuum, ← power_mul]
/-- Let `s` be a closed set in a separable normal space. If the induced topology on `s` is discrete,
then `s` has cardinality less than continuum.

The proof follows
https://en.wikipedia.org/wiki/Moore_plane#Proof_that_the_Moore_plane_is_not_normal -/
theorem IsClosed.mk_lt_continuum [NormalSpace X] {s : Set X} (hs : IsClosed s)
    [DiscreteTopology s] : #s < 𝔠 := by
  -- Proof by contradiction: assume `𝔠 ≤ #s`
  by_contra! h
  -- Choose a countable dense set `t : Set X`
  rcases exists_countable_dense X with ⟨t, htc, htd⟩
  haveI := htc.to_subtype
  -- To obtain a contradiction, we will prove `2 ^ 𝔠 ≤ 𝔠`.
  refine (Cardinal.cantor 𝔠).not_le ?_
  calc
    -- Any function `s → ℝ` is continuous, hence `2 ^ 𝔠 ≤ #C(s, ℝ)`
    2 ^ 𝔠 ≤ #C(s, ℝ) := by
      rw [(ContinuousMap.equivFnOfDiscrete _ _).cardinal_eq, mk_arrow, mk_real, lift_continuum,
        lift_uzero]
      exact (power_le_power_left two_ne_zero h).trans (power_le_power_right (nat_lt_continuum 2).le)
    -- By the Tietze Extension Theorem, any function `f : C(s, ℝ)` can be extended to `C(X, ℝ)`,
    -- hence `#C(s, ℝ) ≤ #C(X, ℝ)`
    _ ≤ #C(X, ℝ) := by
      choose f hf using (ContinuousMap.exists_restrict_eq_of_closed · hs)
      have hfi : Injective f := LeftInverse.injective hf
      exact mk_le_of_injective hfi
    -- Since `t` is dense, restriction `C(X, ℝ) → C(t, ℝ)` is injective, hence `#C(X, ℝ) ≤ #C(t, ℝ)`
    _ ≤ #C(t, ℝ) := mk_le_of_injective <| ContinuousMap.injective_restrict htd
    _ ≤ #(t → ℝ) := mk_le_of_injective FunLike.coe_injective
    -- Since `t` is countable, we have `#(t → ℝ) ≤ 𝔠`
    _ ≤ 𝔠 := by
      rw [mk_arrow, mk_real, lift_uzero, lift_continuum, continuum, ← power_mul]
      

Proof state:
X : Type u
inst✝³ : TopologicalSpace X
inst✝² : SeparableSpace X
inst✝¹ : NormalSpace X
s : Set X
hs : IsClosed s
inst✝ : DiscreteTopology ↑s
h : 𝔠 ≤ #↑s
t : Set X
htc : Set.Countable t
htd : Dense t
this : Countable ↑t
⊢ 2 ^ (ℵ₀ * #↑t) ≤ 2 ^ ℵ₀

Next tactic:
exact power_le_power_left two_ne_zero mk_le_aleph0
theorem iInf_iSup_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨅ a, ⨆ b, f a b) = ⨆ g : ∀ a, κ a, ⨅ a, f a (g a) :=
  (le_antisymm · le_iInf_iSup) <| calc
    _ = ⨅ a : range (range <| f ·), ⨆ b : a.1, b.1 := by
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
⊢ ⨅ a, ⨆ b, f a b = ⨅ a, ⨆ b, ↑b

Next tactic:
simp_rw [iInf_subtype, iInf_range, iSup_subtype, iSup_range]
theorem iInf_iSup_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨅ a, ⨆ b, f a b) = ⨆ g : ∀ a, κ a, ⨅ a, f a (g a) :=
  (le_antisymm · le_iInf_iSup) <| calc
    _ = ⨅ a : range (range <| f ·), ⨆ b : a.1, b.1 := by
      simp_rw [iInf_subtype, iInf_range, iSup_subtype, iSup_range]
    _ = _ := CompletelyDistribLattice.iInf_iSup_eq _
    _ ≤ _ := iSup_le fun g => by
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : (a : ↑(range fun x => range (f x))) → ↑↑a
⊢ ⨅ a, ↑(g a) ≤ ⨆ g, ⨅ a, f a (g a)

Next tactic:
refine le_trans ?_ <| le_iSup _ fun a => Classical.choose (g ⟨_, a, rfl⟩).2
theorem iInf_iSup_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨅ a, ⨆ b, f a b) = ⨆ g : ∀ a, κ a, ⨅ a, f a (g a) :=
  (le_antisymm · le_iInf_iSup) <| calc
    _ = ⨅ a : range (range <| f ·), ⨆ b : a.1, b.1 := by
      simp_rw [iInf_subtype, iInf_range, iSup_subtype, iSup_range]
    _ = _ := CompletelyDistribLattice.iInf_iSup_eq _
    _ ≤ _ := iSup_le fun g => by
      refine le_trans ?_ <| le_iSup _ fun a => Classical.choose (g ⟨_, a, rfl⟩).2
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : (a : ↑(range fun x => range (f x))) → ↑↑a
⊢ ⨅ a, ↑(g a) ≤
    ⨅ a,
      f a
        ((fun a =>
            Classical.choose
              (_ :
                ↑(g
                      { val := (fun x => range (f x)) a,
                        property := (_ : ∃ y, (fun x => range (f x)) y = (fun x => range (f x)) a) }) ∈
                  ↑{ val := (fun x => range (f x)) a,
                      property := (_ : ∃ y, (fun x => range (f x)) y = (fun x => range (f x)) a) }))
          a)

Next tactic:
refine le_iInf fun a => le_trans (iInf_le _ ⟨range (f a), a, rfl⟩) ?_
theorem iInf_iSup_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨅ a, ⨆ b, f a b) = ⨆ g : ∀ a, κ a, ⨅ a, f a (g a) :=
  (le_antisymm · le_iInf_iSup) <| calc
    _ = ⨅ a : range (range <| f ·), ⨆ b : a.1, b.1 := by
      simp_rw [iInf_subtype, iInf_range, iSup_subtype, iSup_range]
    _ = _ := CompletelyDistribLattice.iInf_iSup_eq _
    _ ≤ _ := iSup_le fun g => by
      refine le_trans ?_ <| le_iSup _ fun a => Classical.choose (g ⟨_, a, rfl⟩).2
      refine le_iInf fun a => le_trans (iInf_le _ ⟨range (f a), a, rfl⟩) ?_
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : (a : ↑(range fun x => range (f x))) → ↑↑a
a : ι
⊢ ↑(g { val := range (f a), property := (_ : ∃ y, (fun x => range (f x)) y = range (f a)) }) ≤
    f a
      ((fun a =>
          Classical.choose
            (_ :
              ↑(g
                    { val := (fun x => range (f x)) a,
                      property := (_ : ∃ y, (fun x => range (f x)) y = (fun x => range (f x)) a) }) ∈
                ↑{ val := (fun x => range (f x)) a,
                    property := (_ : ∃ y, (fun x => range (f x)) y = (fun x => range (f x)) a) }))
        a)

Next tactic:
rw [← Classical.choose_spec (g ⟨_, a, rfl⟩).2]
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
⊢ ⨆ a, ⨅ b, f a b = ⨅ g, ⨆ a, f a (g a)

Next tactic:
refine le_antisymm iSup_iInf_le ?_
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
⊢ ⨅ g, ⨆ a, f a (g a) ≤ ⨆ a, ⨅ b, f a b

Next tactic:
rw [iInf_iSup_eq]
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
⊢ ⨆ g, ⨅ a, f (g a) (a (g a)) ≤ ⨆ a, ⨅ b, f a b

Next tactic:
refine iSup_le fun g => ?_
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
⊢ ⨅ a, f (g a) (a (g a)) ≤ ⨆ a, ⨅ b, f a b

Next tactic:
have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    choose h hh using h
    have := hh _ h rfl
    contradiction
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
h : ¬∃ a, ∀ (b : κ a), ∃ f, ∃ (h : a = g f), h ▸ b = f (g f)
⊢ False

Next tactic:
push_neg at h
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
h : ∀ (a : ι), ∃ b, ∀ (f : (a : ι) → κ a) (h : a = g f), h ▸ b ≠ f (g f)
⊢ False

Next tactic:
choose h hh using h
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    choose h hh using h
    

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
h : (a : ι) → κ a
hh : ∀ (a : ι) (f : (a : ι) → κ a) (h_1 : a = g f), h_1 ▸ h a ≠ f (g f)
⊢ False

Next tactic:
have := hh _ h rfl
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    choose h hh using h
    have := hh _ h rfl
    

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
h : (a : ι) → κ a
hh : ∀ (a : ι) (f : (a : ι) → κ a) (h_1 : a = g f), h_1 ▸ h a ≠ f (g f)
this : (_ : g h = g h) ▸ h (g h) ≠ h (g h)
⊢ False

Next tactic:
contradiction
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    choose h hh using h
    have := hh _ h rfl
    contradiction
  

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
a : ι
ha : ∀ (b : κ a), ∃ f, ∃ (h : a = g f), h ▸ b = f (g f)
⊢ ⨅ a, f (g a) (a (g a)) ≤ ⨆ a, ⨅ b, f a b

Next tactic:
refine le_trans ?_ (le_iSup _ a)
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    choose h hh using h
    have := hh _ h rfl
    contradiction
  refine le_trans ?_ (le_iSup _ a)
  

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
a : ι
ha : ∀ (b : κ a), ∃ f, ∃ (h : a = g f), h ▸ b = f (g f)
⊢ ⨅ a, f (g a) (a (g a)) ≤ ⨅ b, f a b

Next tactic:
refine le_iInf fun b => ?_
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    choose h hh using h
    have := hh _ h rfl
    contradiction
  refine le_trans ?_ (le_iSup _ a)
  refine le_iInf fun b => ?_
  

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
a : ι
ha : ∀ (b : κ a), ∃ f, ∃ (h : a = g f), h ▸ b = f (g f)
b : κ a
⊢ ⨅ a, f (g a) (a (g a)) ≤ f a b

Next tactic:
obtain ⟨h, rfl, rfl⟩ := ha b
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
    (⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
  refine le_antisymm iSup_iInf_le ?_
  rw [iInf_iSup_eq]
  refine iSup_le fun g => ?_
  have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
    push_neg at h
    choose h hh using h
    have := hh _ h rfl
    contradiction
  refine le_trans ?_ (le_iSup _ a)
  refine le_iInf fun b => ?_
  obtain ⟨h, rfl, rfl⟩ := ha b
  

Proof state:
case intro.intro
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
f : (a : ι) → κ a → α
g : ((a : ι) → κ a) → ι
h : (a : ι) → κ a
ha : ∀ (b : κ (g h)), ∃ f, ∃ (h_1 : g h = g f), h_1 ▸ b = f (g f)
⊢ ⨅ a, f (g a) (a (g a)) ≤ f (g h) (h (g h))

Next tactic:
exact iInf_le _ _
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
    [CompletelyDistribLattice α] : CompleteDistribLattice α where
  iInf_sup_le_sup_sInf a s := calc
    _ = ⨅ b : s, ⨆ x : Bool, cond x a b := by simp_rw [iInf_subtype, iSup_bool_eq, cond]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := iSup_le fun f => by
      by_cases h : ∀ i, f i = false
      case pos => simp [h, iInf_subtype, ← sInf_eq_iInf]
      case neg =>
        have ⟨i, h⟩ : ∃ i, f i = true := by simpa using h
        refine le_trans (iInf_le _ i) ?_
        simp [h]
  inf_sSup_le_iSup_inf a s := calc
    _ = ⨅ x : Bool, ⨆ y : cond x PUnit s, match x with | true => a | false => y.1 := by
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
a : α
s : Set α
⊢ a ⊓ sSup s =
    ⨅ x,
      ⨆ y,
        match x, y with
        | true, y => a
        | false, y => ↑y

Next tactic:
simp_rw [iInf_bool_eq, cond, iSup_const, iSup_subtype, sSup_eq_iSup]
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
    [CompletelyDistribLattice α] : CompleteDistribLattice α where
  iInf_sup_le_sup_sInf a s := calc
    _ = ⨅ b : s, ⨆ x : Bool, cond x a b := by simp_rw [iInf_subtype, iSup_bool_eq, cond]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := iSup_le fun f => by
      by_cases h : ∀ i, f i = false
      case pos => simp [h, iInf_subtype, ← sInf_eq_iInf]
      case neg =>
        have ⟨i, h⟩ : ∃ i, f i = true := by simpa using h
        refine le_trans (iInf_le _ i) ?_
        simp [h]
  inf_sSup_le_iSup_inf a s := calc
    _ = ⨅ x : Bool, ⨆ y : cond x PUnit s, match x with | true => a | false => y.1 := by
      simp_rw [iInf_bool_eq, cond, iSup_const, iSup_subtype, sSup_eq_iSup]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := by
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
a : α
s : Set α
⊢ (⨆ g,
      ⨅ a_1,
        match a_1, g a_1 with
        | true, y => a
        | false, y => ↑y) ≤
    ⨆ b ∈ s, a ⊓ b

Next tactic:
simp_rw [iInf_bool_eq]
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
    [CompletelyDistribLattice α] : CompleteDistribLattice α where
  iInf_sup_le_sup_sInf a s := calc
    _ = ⨅ b : s, ⨆ x : Bool, cond x a b := by simp_rw [iInf_subtype, iSup_bool_eq, cond]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := iSup_le fun f => by
      by_cases h : ∀ i, f i = false
      case pos => simp [h, iInf_subtype, ← sInf_eq_iInf]
      case neg =>
        have ⟨i, h⟩ : ∃ i, f i = true := by simpa using h
        refine le_trans (iInf_le _ i) ?_
        simp [h]
  inf_sSup_le_iSup_inf a s := calc
    _ = ⨅ x : Bool, ⨆ y : cond x PUnit s, match x with | true => a | false => y.1 := by
      simp_rw [iInf_bool_eq, cond, iSup_const, iSup_subtype, sSup_eq_iSup]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := by
      simp_rw [iInf_bool_eq]
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
a : α
s : Set α
⊢ ⨆ g, a ⊓ ↑(g false) ≤ ⨆ b ∈ s, a ⊓ b

Next tactic:
refine iSup_le fun g => le_trans ?_ (le_iSup _ (g false).1)
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
    [CompletelyDistribLattice α] : CompleteDistribLattice α where
  iInf_sup_le_sup_sInf a s := calc
    _ = ⨅ b : s, ⨆ x : Bool, cond x a b := by simp_rw [iInf_subtype, iSup_bool_eq, cond]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := iSup_le fun f => by
      by_cases h : ∀ i, f i = false
      case pos => simp [h, iInf_subtype, ← sInf_eq_iInf]
      case neg =>
        have ⟨i, h⟩ : ∃ i, f i = true := by simpa using h
        refine le_trans (iInf_le _ i) ?_
        simp [h]
  inf_sSup_le_iSup_inf a s := calc
    _ = ⨅ x : Bool, ⨆ y : cond x PUnit s, match x with | true => a | false => y.1 := by
      simp_rw [iInf_bool_eq, cond, iSup_const, iSup_subtype, sSup_eq_iSup]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := by
      simp_rw [iInf_bool_eq]
      refine iSup_le fun g => le_trans ?_ (le_iSup _ (g false).1)
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
a : α
s : Set α
g : (a : Bool) → bif a then PUnit.{u + 1} else ↑s
⊢ a ⊓ ↑(g false) ≤ ⨆ (_ : ↑(g false) ∈ s), a ⊓ ↑(g false)

Next tactic:
refine le_trans ?_ (le_iSup _ (g false).2)
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
    [CompletelyDistribLattice α] : CompleteDistribLattice α where
  iInf_sup_le_sup_sInf a s := calc
    _ = ⨅ b : s, ⨆ x : Bool, cond x a b := by simp_rw [iInf_subtype, iSup_bool_eq, cond]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := iSup_le fun f => by
      by_cases h : ∀ i, f i = false
      case pos => simp [h, iInf_subtype, ← sInf_eq_iInf]
      case neg =>
        have ⟨i, h⟩ : ∃ i, f i = true := by simpa using h
        refine le_trans (iInf_le _ i) ?_
        simp [h]
  inf_sSup_le_iSup_inf a s := calc
    _ = ⨅ x : Bool, ⨆ y : cond x PUnit s, match x with | true => a | false => y.1 := by
      simp_rw [iInf_bool_eq, cond, iSup_const, iSup_subtype, sSup_eq_iSup]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := by
      simp_rw [iInf_bool_eq]
      refine iSup_le fun g => le_trans ?_ (le_iSup _ (g false).1)
      refine le_trans ?_ (le_iSup _ (g false).2)
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
a : α
s : Set α
g : (a : Bool) → bif a then PUnit.{u + 1} else ↑s
⊢ a ⊓ ↑(g false) ≤ a ⊓ ↑(g false)

Next tactic:
rfl
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
    [CompletelyDistribLattice α] : CompleteDistribLattice α where
  iInf_sup_le_sup_sInf a s := calc
    _ = ⨅ b : s, ⨆ x : Bool, cond x a b := by 

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
a : α
s : Set α
⊢ ⨅ b ∈ s, a ⊔ b = ⨅ b, ⨆ x, bif x then a else ↑b

Next tactic:
simp_rw [iInf_subtype, iSup_bool_eq, cond]
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
    [CompletelyDistribLattice α] : CompleteDistribLattice α where
  iInf_sup_le_sup_sInf a s := calc
    _ = ⨅ b : s, ⨆ x : Bool, cond x a b := by simp_rw [iInf_subtype, iSup_bool_eq, cond]
    _ = _ := iInf_iSup_eq
    _ ≤ _ := iSup_le fun f => by
      

Proof state:
α : Type u
β : Type v
ι : Sort w
κ : ι → Sort w'
inst✝ : CompletelyDistribLattice α
a : α
s : Set α
f : ↑s → Bool
⊢ (⨅ a_1, bif f a_1 then a else ↑a_1) ≤ a ⊔ sInf s

Next tactic:
by_cases h : ∀ i, f i = false