l3lab/ntp-mathlib huggingface dataset:
/-- Yet another metric characterization of Cauchy sequences on integers. This one is often the
most efficient. -/
theorem EMetric.cauchySeq_iff_le_tendsto_0 [Nonempty β] [SemilatticeSup β] {s : β → α} :
    CauchySeq s ↔ ∃ b : β → ℝ≥0∞, (∀ n m N : β, N ≤ n → N ≤ m → edist (s n) (s m) ≤ b N) ∧
      Tendsto b atTop (𝓝 0) := EMetric.cauchySeq_iff.trans <| by
  constructor
  · intro hs
    /- `s` is Cauchy sequence. Let `b n` be the diameter of the set `s '' Set.Ici n`. -/
    refine ⟨fun N => EMetric.diam (s '' Ici N), fun n m N hn hm => ?_, ?_⟩
    -- Prove that it bounds the distances of points in the Cauchy sequence
    · exact EMetric.edist_le_diam_of_mem (mem_image_of_mem _ hn) (mem_image_of_mem _ hm)
    -- Prove that it tends to `0`, by using the Cauchy property of `s`
    · refine ENNReal.tendsto_nhds_zero.2 fun ε ε0 => ?_
      rcases hs ε ε0 with ⟨N, hN⟩
      refine (eventually_ge_atTop N).mono fun n hn => EMetric.diam_le ?_
      rintro _ ⟨k, hk, rfl⟩ _ ⟨l, hl, rfl⟩
      exact (hN _ (hn.trans hk) _ (hn.trans hl)).le
  · rintro ⟨b, ⟨b_bound, b_lim⟩⟩ ε εpos
    have : ∀ᶠ n in atTop, b n < ε := b_lim.eventually (gt_mem_nhds εpos)
    rcases this.exists with ⟨N, hN⟩
    refine ⟨N, fun m hm n hn => ?_⟩
    

Proof state:
case mpr.intro.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝² : PseudoEMetricSpace α
inst✝¹ : Nonempty β
inst✝ : SemilatticeSup β
s : β → α
b : β → ℝ≥0∞
b_bound : ∀ (n m N : β), N ≤ n → N ≤ m → edist (s n) (s m) ≤ b N
b_lim : Tendsto b atTop (𝓝 0)
ε : ℝ≥0∞
εpos : ε > 0
this : ∀ᶠ (n : β) in atTop, b n < ε
N : β
hN : b N < ε
m : β
hm : N ≤ m
n : β
hn : N ≤ n
⊢ edist (s m) (s n) < ε

Next tactic:
calc edist (s m) (s n) ≤ b N := b_bound m n N hm hn
    _ < ε := hN
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
⊢ Continuous f

Next tactic:
refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
⊢ ∀ᶠ (x_1 : α) in 𝓝 x, f x_1 ∈ Icc (f x - ε) (f x + ε)

Next tactic:
rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
  rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
δ : ℝ≥0
δ0 : δ > 0
hδ : ↑δ * C < ε
⊢ ∀ᶠ (x_1 : α) in 𝓝 x, f x_1 ∈ Icc (f x - ε) (f x + ε)

Next tactic:
rw [mul_comm] at hδ
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
  rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩
  rw [mul_comm] at hδ
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
δ : ℝ≥0
δ0 : δ > 0
hδ : C * ↑δ < ε
⊢ ∀ᶠ (x_1 : α) in 𝓝 x, f x_1 ∈ Icc (f x - ε) (f x + ε)

Next tactic:
filter_upwards [EMetric.closedBall_mem_nhds x (ENNReal.coe_pos.2 δ0)] with y hy
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
  rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩
  rw [mul_comm] at hδ
  filter_upwards [EMetric.closedBall_mem_nhds x (ENNReal.coe_pos.2 δ0)] with y hy
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
δ : ℝ≥0
δ0 : δ > 0
hδ : C * ↑δ < ε
y : α
hy : y ∈ EMetric.closedBall x ↑δ
⊢ f y ∈ Icc (f x - ε) (f x + ε)

Next tactic:
refine ⟨tsub_le_iff_right.2 <| (h x y).trans ?_, (h y x).trans ?_⟩
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
  rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩
  rw [mul_comm] at hδ
  filter_upwards [EMetric.closedBall_mem_nhds x (ENNReal.coe_pos.2 δ0)] with y hy
  refine ⟨tsub_le_iff_right.2 <| (h x y).trans ?_, (h y x).trans ?_⟩ <;>
    

Proof state:
case h.refine_1
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
δ : ℝ≥0
δ0 : δ > 0
hδ : C * ↑δ < ε
y : α
hy : y ∈ EMetric.closedBall x ↑δ
⊢ f y + C * edist x y ≤ f y + ε

Next tactic:
refine add_le_add_left (le_trans (mul_le_mul_left' ?_ _) hδ.le) _
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
  rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩
  rw [mul_comm] at hδ
  filter_upwards [EMetric.closedBall_mem_nhds x (ENNReal.coe_pos.2 δ0)] with y hy
  refine ⟨tsub_le_iff_right.2 <| (h x y).trans ?_, (h y x).trans ?_⟩ <;>
    

Proof state:
case h.refine_2
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
δ : ℝ≥0
δ0 : δ > 0
hδ : C * ↑δ < ε
y : α
hy : y ∈ EMetric.closedBall x ↑δ
⊢ f x + C * edist y x ≤ f x + ε

Next tactic:
refine add_le_add_left (le_trans (mul_le_mul_left' ?_ _) hδ.le) _
theorem continuous_of_le_add_edist {f : α → ℝ≥0∞} (C : ℝ≥0∞) (hC : C ≠ ⊤)
    (h : ∀ x y, f x ≤ f y + C * edist x y) : Continuous f := by
  refine continuous_iff_continuousAt.2 fun x => ENNReal.tendsto_nhds_of_Icc fun ε ε0 => ?_
  rcases ENNReal.exists_nnreal_pos_mul_lt hC ε0.ne' with ⟨δ, δ0, hδ⟩
  rw [mul_comm] at hδ
  filter_upwards [EMetric.closedBall_mem_nhds x (ENNReal.coe_pos.2 δ0)] with y hy
  refine ⟨tsub_le_iff_right.2 <| (h x y).trans ?_, (h y x).trans ?_⟩ <;>
    refine add_le_add_left (le_trans (mul_le_mul_left' ?_ _) hδ.le) _
  

Proof state:
case h.refine_1
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
δ : ℝ≥0
δ0 : δ > 0
hδ : C * ↑δ < ε
y : α
hy : y ∈ EMetric.closedBall x ↑δ
⊢ edist x y ≤ ↑δ
case h.refine_2
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : α → ℝ≥0∞
C : ℝ≥0∞
hC : C ≠ ⊤
h : ∀ (x y : α), f x ≤ f y + C * edist x y
x : α
ε : ℝ≥0∞
ε0 : ε > 0
δ : ℝ≥0
δ0 : δ > 0
hδ : C * ↑δ < ε
y : α
hy : y ∈ EMetric.closedBall x ↑δ
⊢ edist y x ≤ ↑δ

Next tactic:
exacts [EMetric.mem_closedBall'.1 hy, EMetric.mem_closedBall.1 hy]
theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
⊢ Continuous fun p => edist p.1 p.2

Next tactic:
apply continuous_of_le_add_edist 2 (by decide)
theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by
  apply continuous_of_le_add_edist 2 (by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
⊢ 2 ≠ ⊤

Next tactic:
decide
theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by
  apply continuous_of_le_add_edist 2 (by decide)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
⊢ ∀ (x y : α × α), edist x.1 x.2 ≤ edist y.1 y.2 + 2 * edist x y

Next tactic:
rintro ⟨x, y⟩ ⟨x', y'⟩
theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by
  apply continuous_of_le_add_edist 2 (by decide)
  rintro ⟨x, y⟩ ⟨x', y'⟩
  

Proof state:
case mk.mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
x y x' y' : α
⊢ edist (x, y).1 (x, y).2 ≤ edist (x', y').1 (x', y').2 + 2 * edist (x, y) (x', y')

Next tactic:
calc
    edist x y ≤ edist x x' + edist x' y' + edist y' y := edist_triangle4 _ _ _ _
    _ = edist x' y' + (edist x x' + edist y y') := by simp only [edist_comm]; ac_rfl
    _ ≤ edist x' y' + (edist (x, y) (x', y') + edist (x, y) (x', y')) :=
      (add_le_add_left (add_le_add (le_max_left _ _) (le_max_right _ _)) _)
    _ = edist x' y' + 2 * edist (x, y) (x', y') := by rw [← mul_two, mul_comm]
theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by
  apply continuous_of_le_add_edist 2 (by decide)
  rintro ⟨x, y⟩ ⟨x', y'⟩
  calc
    edist x y ≤ edist x x' + edist x' y' + edist y' y := edist_triangle4 _ _ _ _
    _ = edist x' y' + (edist x x' + edist y y') := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
x y x' y' : α
⊢ edist x x' + edist x' y' + edist y' y = edist x' y' + (edist x x' + edist y y')

Next tactic:
simp only [edist_comm]
theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by
  apply continuous_of_le_add_edist 2 (by decide)
  rintro ⟨x, y⟩ ⟨x', y'⟩
  calc
    edist x y ≤ edist x x' + edist x' y' + edist y' y := edist_triangle4 _ _ _ _
    _ = edist x' y' + (edist x x' + edist y y') := by simp only [edist_comm]; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
x y x' y' : α
⊢ edist x x' + edist x' y' + edist y y' = edist x' y' + (edist x x' + edist y y')

Next tactic:
ac_rfl
theorem continuous_edist : Continuous fun p : α × α => edist p.1 p.2 := by
  apply continuous_of_le_add_edist 2 (by decide)
  rintro ⟨x, y⟩ ⟨x', y'⟩
  calc
    edist x y ≤ edist x x' + edist x' y' + edist y' y := edist_triangle4 _ _ _ _
    _ = edist x' y' + (edist x x' + edist y y') := by simp only [edist_comm]; ac_rfl
    _ ≤ edist x' y' + (edist (x, y) (x', y') + edist (x, y) (x', y')) :=
      (add_le_add_left (add_le_add (le_max_left _ _) (le_max_right _ _)) _)
    _ = edist x' y' + 2 * edist (x, y) (x', y') := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
x y x' y' : α
⊢ edist x' y' + (edist (x, y) (x', y') + edist (x, y) (x', y')) = edist x' y' + 2 * edist (x, y) (x', y')

Next tactic:
rw [← mul_two, mul_comm]
theorem cauchySeq_of_edist_le_of_tsum_ne_top {f : ℕ → α} (d : ℕ → ℝ≥0∞)
    (hf : ∀ n, edist (f n) (f n.succ) ≤ d n) (hd : tsum d ≠ ∞) : CauchySeq f := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : ℕ → α
d : ℕ → ℝ≥0∞
hf : ∀ (n : ℕ), edist (f n) (f (Nat.succ n)) ≤ d n
hd : tsum d ≠ ⊤
⊢ CauchySeq f

Next tactic:
lift d to ℕ → NNReal using fun i => ENNReal.ne_top_of_tsum_ne_top hd i
theorem cauchySeq_of_edist_le_of_tsum_ne_top {f : ℕ → α} (d : ℕ → ℝ≥0∞)
    (hf : ∀ n, edist (f n) (f n.succ) ≤ d n) (hd : tsum d ≠ ∞) : CauchySeq f := by
  lift d to ℕ → NNReal using fun i => ENNReal.ne_top_of_tsum_ne_top hd i
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : ℕ → α
d : ℕ → ℝ≥0
hf : ∀ (n : ℕ), edist (f n) (f (Nat.succ n)) ≤ (fun i => ↑(d i)) n
hd : ∑' (i : ℕ), ↑(d i) ≠ ⊤
⊢ CauchySeq f

Next tactic:
rw [ENNReal.tsum_coe_ne_top_iff_summable] at hd
theorem cauchySeq_of_edist_le_of_tsum_ne_top {f : ℕ → α} (d : ℕ → ℝ≥0∞)
    (hf : ∀ n, edist (f n) (f n.succ) ≤ d n) (hd : tsum d ≠ ∞) : CauchySeq f := by
  lift d to ℕ → NNReal using fun i => ENNReal.ne_top_of_tsum_ne_top hd i
  rw [ENNReal.tsum_coe_ne_top_iff_summable] at hd
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
f : ℕ → α
d : ℕ → ℝ≥0
hf : ∀ (n : ℕ), edist (f n) (f (Nat.succ n)) ≤ (fun i => ↑(d i)) n
hd : Summable fun i => d i
⊢ CauchySeq f

Next tactic:
exact cauchySeq_of_edist_le_of_summable d hf hd
@[simp]
theorem EMetric.diam_closure (s : Set α) : diam (closure s) = diam s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set α
⊢ diam (closure s) = diam s

Next tactic:
refine' le_antisymm (diam_le fun x hx y hy => _) (diam_mono subset_closure)
@[simp]
theorem EMetric.diam_closure (s : Set α) : diam (closure s) = diam s := by
  refine' le_antisymm (diam_le fun x hx y hy => _) (diam_mono subset_closure)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set α
x : α
hx : x ∈ closure s
y : α
hy : y ∈ closure s
⊢ edist x y ≤ diam s

Next tactic:
have : edist x y ∈ closure (Iic (diam s)) :=
    map_mem_closure₂ continuous_edist hx hy fun x hx y hy => edist_le_diam_of_mem hx hy
@[simp]
theorem EMetric.diam_closure (s : Set α) : diam (closure s) = diam s := by
  refine' le_antisymm (diam_le fun x hx y hy => _) (diam_mono subset_closure)
  have : edist x y ∈ closure (Iic (diam s)) :=
    map_mem_closure₂ continuous_edist hx hy fun x hx y hy => edist_le_diam_of_mem hx hy
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set α
x : α
hx : x ∈ closure s
y : α
hy : y ∈ closure s
this : edist x y ∈ closure (Iic (diam s))
⊢ edist x y ≤ diam s

Next tactic:
rwa [closure_Iic] at this
@[simp]
theorem Metric.diam_closure {α : Type*} [PseudoMetricSpace α] (s : Set α) :
    Metric.diam (closure s) = diam s := by 

Proof state:
α✝ : Type u_1
β : Type u_2
γ : Type u_3
inst✝¹ : PseudoEMetricSpace α✝
α : Type u_4
inst✝ : PseudoMetricSpace α
s : Set α
⊢ diam (closure s) = diam s

Next tactic:
simp only [Metric.diam, EMetric.diam_closure]
theorem isClosed_setOf_lipschitzOnWith {α β} [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0)
    (s : Set α) : IsClosed { f : α → β | LipschitzOnWith K f s } := by
  

Proof state:
α✝ : Type u_1
β✝ : Type u_2
γ : Type u_3
inst✝² : PseudoEMetricSpace α✝
α : Type u_4
β : Type u_5
inst✝¹ : PseudoEMetricSpace α
inst✝ : PseudoEMetricSpace β
K : ℝ≥0
s : Set α
⊢ IsClosed {f | LipschitzOnWith K f s}

Next tactic:
simp only [LipschitzOnWith, setOf_forall]
theorem isClosed_setOf_lipschitzOnWith {α β} [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0)
    (s : Set α) : IsClosed { f : α → β | LipschitzOnWith K f s } := by
  simp only [LipschitzOnWith, setOf_forall]
  

Proof state:
α✝ : Type u_1
β✝ : Type u_2
γ : Type u_3
inst✝² : PseudoEMetricSpace α✝
α : Type u_4
β : Type u_5
inst✝¹ : PseudoEMetricSpace α
inst✝ : PseudoEMetricSpace β
K : ℝ≥0
s : Set α
⊢ IsClosed (⋂ i ∈ s, ⋂ i_1 ∈ s, {x | edist (x i) (x i_1) ≤ ↑K * edist i i_1})

Next tactic:
refine' isClosed_biInter fun x _ => isClosed_biInter fun y _ => isClosed_le _ _
theorem isClosed_setOf_lipschitzOnWith {α β} [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0)
    (s : Set α) : IsClosed { f : α → β | LipschitzOnWith K f s } := by
  simp only [LipschitzOnWith, setOf_forall]
  refine' isClosed_biInter fun x _ => isClosed_biInter fun y _ => isClosed_le _ _
  

Proof state:
case refine'_1
α✝ : Type u_1
β✝ : Type u_2
γ : Type u_3
inst✝² : PseudoEMetricSpace α✝
α : Type u_4
β : Type u_5
inst✝¹ : PseudoEMetricSpace α
inst✝ : PseudoEMetricSpace β
K : ℝ≥0
s : Set α
x : α
x✝¹ : x ∈ s
y : α
x✝ : y ∈ s
⊢ Continuous fun x_1 => edist (x_1 x) (x_1 y)
case refine'_2
α✝ : Type u_1
β✝ : Type u_2
γ : Type u_3
inst✝² : PseudoEMetricSpace α✝
α : Type u_4
β : Type u_5
inst✝¹ : PseudoEMetricSpace α
inst✝ : PseudoEMetricSpace β
K : ℝ≥0
s : Set α
x : α
x✝¹ : x ∈ s
y : α
x✝ : y ∈ s
⊢ Continuous fun x_1 => ↑K * edist x y

Next tactic:
exacts [.edist (continuous_apply x) (continuous_apply y), continuous_const]
theorem isClosed_setOf_lipschitzWith {α β} [PseudoEMetricSpace α] [PseudoEMetricSpace β] (K : ℝ≥0) :
    IsClosed { f : α → β | LipschitzWith K f } := by
  

Proof state:
α✝ : Type u_1
β✝ : Type u_2
γ : Type u_3
inst✝² : PseudoEMetricSpace α✝
α : Type u_4
β : Type u_5
inst✝¹ : PseudoEMetricSpace α
inst✝ : PseudoEMetricSpace β
K : ℝ≥0
⊢ IsClosed {f | LipschitzWith K f}

Next tactic:
simp only [← lipschitzOn_univ, isClosed_setOf_lipschitzOnWith]
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
⊢ EMetric.diam s = ENNReal.ofReal (sSup s - sInf s)

Next tactic:
rcases eq_empty_or_nonempty s with (rfl | hne)
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
h : Bornology.IsBounded ∅
⊢ EMetric.diam ∅ = ENNReal.ofReal (sSup ∅ - sInf ∅)

Next tactic:
simp
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · simp
  

Proof state:
case inr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
hne : Set.Nonempty s
⊢ EMetric.diam s = ENNReal.ofReal (sSup s - sInf s)

Next tactic:
refine' le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => _) _
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · simp
  refine' le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => _) _
  · 

Proof state:
case inr.refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
hne : Set.Nonempty s
x : ℝ
hx : x ∈ s
y : ℝ
hy : y ∈ s
⊢ dist x y ≤ sSup s - sInf s

Next tactic:
have := Real.subset_Icc_sInf_sSup_of_isBounded h
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · simp
  refine' le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => _) _
  · have := Real.subset_Icc_sInf_sSup_of_isBounded h
    

Proof state:
case inr.refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
hne : Set.Nonempty s
x : ℝ
hx : x ∈ s
y : ℝ
hy : y ∈ s
this : s ⊆ Icc (sInf s) (sSup s)
⊢ dist x y ≤ sSup s - sInf s

Next tactic:
exact Real.dist_le_of_mem_Icc (this hx) (this hy)
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · simp
  refine' le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => _) _
  · have := Real.subset_Icc_sInf_sSup_of_isBounded h
    exact Real.dist_le_of_mem_Icc (this hx) (this hy)
  · 

Proof state:
case inr.refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
hne : Set.Nonempty s
⊢ ENNReal.ofReal (sSup s - sInf s) ≤ EMetric.diam s

Next tactic:
apply ENNReal.ofReal_le_of_le_toReal
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · simp
  refine' le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => _) _
  · have := Real.subset_Icc_sInf_sSup_of_isBounded h
    exact Real.dist_le_of_mem_Icc (this hx) (this hy)
  · apply ENNReal.ofReal_le_of_le_toReal
    

Proof state:
case inr.refine'_2.h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
hne : Set.Nonempty s
⊢ sSup s - sInf s ≤ ENNReal.toReal (EMetric.diam s)

Next tactic:
rw [← Metric.diam, ← Metric.diam_closure]
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · simp
  refine' le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => _) _
  · have := Real.subset_Icc_sInf_sSup_of_isBounded h
    exact Real.dist_le_of_mem_Icc (this hx) (this hy)
  · apply ENNReal.ofReal_le_of_le_toReal
    rw [← Metric.diam, ← Metric.diam_closure]
    

Proof state:
case inr.refine'_2.h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
hne : Set.Nonempty s
⊢ sSup s - sInf s ≤ Metric.diam (closure s)

Next tactic:
have h' := Real.isBounded_iff_bddBelow_bddAbove.1 h
/-- For a bounded set `s : Set ℝ`, its `EMetric.diam` is equal to `sSup s - sInf s` reinterpreted as
`ℝ≥0∞`. -/
theorem ediam_eq {s : Set ℝ} (h : Bornology.IsBounded s) :
    EMetric.diam s = ENNReal.ofReal (sSup s - sInf s) := by
  rcases eq_empty_or_nonempty s with (rfl | hne)
  · simp
  refine' le_antisymm (Metric.ediam_le_of_forall_dist_le fun x hx y hy => _) _
  · have := Real.subset_Icc_sInf_sSup_of_isBounded h
    exact Real.dist_le_of_mem_Icc (this hx) (this hy)
  · apply ENNReal.ofReal_le_of_le_toReal
    rw [← Metric.diam, ← Metric.diam_closure]
    have h' := Real.isBounded_iff_bddBelow_bddAbove.1 h
    

Proof state:
case inr.refine'_2.h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
hne : Set.Nonempty s
h' : BddBelow s ∧ BddAbove s
⊢ sSup s - sInf s ≤ Metric.diam (closure s)

Next tactic:
calc sSup s - sInf s ≤ dist (sSup s) (sInf s) := le_abs_self _
    _ ≤ Metric.diam (closure s) := dist_le_diam_of_mem h.closure (csSup_mem_closure hne h'.2)
        (csInf_mem_closure hne h'.1)
/-- For a bounded set `s : Set ℝ`, its `Metric.diam` is equal to `sSup s - sInf s`. -/
theorem diam_eq {s : Set ℝ} (h : Bornology.IsBounded s) : Metric.diam s = sSup s - sInf s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
⊢ Metric.diam s = sSup s - sInf s

Next tactic:
rw [Metric.diam, Real.ediam_eq h, ENNReal.toReal_ofReal]
/-- For a bounded set `s : Set ℝ`, its `Metric.diam` is equal to `sSup s - sInf s`. -/
theorem diam_eq {s : Set ℝ} (h : Bornology.IsBounded s) : Metric.diam s = sSup s - sInf s := by
  rw [Metric.diam, Real.ediam_eq h, ENNReal.toReal_ofReal]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : Bornology.IsBounded s
⊢ 0 ≤ sSup s - sInf s

Next tactic:
rw [Real.isBounded_iff_bddBelow_bddAbove] at h
/-- For a bounded set `s : Set ℝ`, its `Metric.diam` is equal to `sSup s - sInf s`. -/
theorem diam_eq {s : Set ℝ} (h : Bornology.IsBounded s) : Metric.diam s = sSup s - sInf s := by
  rw [Metric.diam, Real.ediam_eq h, ENNReal.toReal_ofReal]
  rw [Real.isBounded_iff_bddBelow_bddAbove] at h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : PseudoEMetricSpace α
s : Set ℝ
h : BddBelow s ∧ BddAbove s
⊢ 0 ≤ sSup s - sInf s

Next tactic:
exact sub_nonneg.2 (Real.sInf_le_sSup s h.1 h.2)