introvoyz041/TaoAnalysisBench huggingface dataset:
import Mathlib.Tactic
import Mathlib.Data.Real.Basic

/-!
# Analysis I, Section 9.3: Limiting values of functions (extracted slice)

This file extracts the minimal context needed to state and typecheck the target theorem
`Chapter9.Convergesto.smul` from Section 9.3, together with the supporting definitions.
We copy the relevant declarations verbatim from the textbook source files.
-/

/-- Definition 9.3.1 -/
abbrev Real.CloseFn (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) : Prop :=
  ∀ x ∈ X, |f x - L| < ε

/-- Definition 9.3.3 -/
abbrev Real.CloseNear (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop :=
  ∃ δ > 0, ε.CloseFn (X ∩ .Ioo (x₀-δ) (x₀+δ)) f L

/-- Definition 9.1.5.  Note that a slightly different `Real.adherent` was defined in Chapter 6.4 -/
abbrev Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

namespace Chapter9

/-- Definition 9.1.-/
abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

/-- Definition 9.3.6 (Convergence of functions at a point)-/
abbrev Convergesto (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop := ∀ ε > (0:ℝ), ε.CloseNear X f L x₀

/-- Proposition 9.3.14 (Limit laws for functions) / Exercise 9.3.2 -/
theorem Convergesto.smul {E:Set ℝ} {f: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (c:ℝ) :
  Convergesto E (c • f) (c * L) x₀ := by
end Chapter9
import Mathlib
import Analysis.Section_9_1
import Analysis.Tags.Section_9_1

-- <CONTEXT>
abbrev Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

abbrev Real.CloseFn (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) : Prop :=
  ∀ x ∈ X, |f x - L| < ε

abbrev Real.CloseNear (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop :=
  ∃ δ > 0, ε.CloseFn (X ∩ .Ioo (x₀-δ) (x₀+δ)) f L

namespace Chapter9

abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

abbrev Convergesto (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop := ∀ ε > (0:ℝ), ε.CloseNear X f L x₀

theorem Convergesto.iff (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) :
  Convergesto X f L x₀ ↔ (nhdsWithin x₀ X).Tendsto f (nhds L) := by
  sorry

theorem Convergesto.comp {E:Set ℝ} {f: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E) (hf: Convergesto E f L x₀) {a:ℕ → ℝ} (ha: ∀ n:ℕ, a n ∈ E) (hconv: Filter.atTop.Tendsto a (nhds x₀)) :
  Filter.atTop.Tendsto (fun n ↦ f (a n)) (nhds L) := by
  sorry

theorem Convergesto.uniq {E:Set ℝ} {f: ℝ → ℝ} {L L':ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hf': Convergesto E f L' x₀) : L = L' := by
  sorry

theorem Convergesto.add {E:Set ℝ} {f g: ℝ → ℝ} {L M:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hg: Convergesto E g M x₀) :
  Convergesto E (f + g) (L + M) x₀ := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Convergesto.smul {E:Set ℝ} {f: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (c:ℝ) :
  Convergesto E (c • f) (c * L) x₀ := by
-- </TARGET_THEOREM>

end Chapter9
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter9
theorem Convergesto.smul
  {E : Set ℝ} {f : ℝ → ℝ} {L x₀ : ℝ}
  (h : x₀ ∈ closure E)
  (hf : Tendsto f (𝓝[E] x₀) (𝓝 L))
  (c : ℝ) :
  Tendsto (fun x => c * f x) (𝓝[E] x₀) (𝓝 (c * L)) := by
end Chapter9

end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Data.Set.Lattice

/-- Definition 9.1.5.  Note that a slightly different `Real.adherent` was defined in Chapter 6.4 -/
abbrev Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

namespace Chapter9

/-- Definition 9.1.-/ 
abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

end Chapter9

/-- Definition 9.3.1 -/
abbrev Real.CloseFn (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) : Prop :=
  ∀ x ∈ X, |f x - L| < ε

/-- Definition 9.3.3 -/
abbrev Real.CloseNear (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop :=
  ∃ δ > 0, ε.CloseFn (X ∩ .Ioo (x₀-δ) (x₀+δ)) f L

namespace Chapter9

/-- Definition 9.3.6 (Convergence of functions at a point)-/
abbrev Convergesto (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop := ∀ ε > (0:ℝ), ε.CloseNear X f L x₀

/-- Exercise 9.3.5 (Continuous version of squeeze test) -/
theorem Convergesto.squeeze {E:Set ℝ} {f g h: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (had: AdherentPt x₀ E)
  (hfg: ∀ x ∈ E, f x ≤ g x) (hgh: ∀ x ∈ E, g x ≤ h x)
  (hf: Convergesto E f L x₀) (hh: Convergesto E h L x₀) :
  Convergesto E g L x₀ := by
end Chapter9
import Mathlib
import Analysis.Section_9_1
import Analysis.Tags.Section_9_1

namespace Chapter9

-- <CONTEXT>
abbrev _root_.Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

abbrev _root_.Real.CloseFn (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) : Prop :=
  ∀ x ∈ X, |f x - L| < ε

abbrev _root_.Real.CloseNear (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop :=
  ∃ δ > 0, ε.CloseFn (X ∩ .Ioo (x₀-δ) (x₀+δ)) f L

abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

abbrev Convergesto (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop := ∀ ε > (0:ℝ), ε.CloseNear X f L x₀

theorem Convergesto.iff (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) :
  Convergesto X f L x₀ ↔ (nhdsWithin x₀ X).Tendsto f (nhds L) := by
  sorry

theorem Convergesto.comp {E:Set ℝ} {f: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E) (hf: Convergesto E f L x₀) {a:ℕ → ℝ} (ha: ∀ n:ℕ, a n ∈ E) (hconv: Filter.atTop.Tendsto a (nhds x₀)) :
  Filter.atTop.Tendsto (fun n ↦ f (a n)) (nhds L) := by
  sorry

theorem Convergesto.uniq {E:Set ℝ} {f: ℝ → ℝ} {L L':ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hf': Convergesto E f L' x₀) : L = L' := by
  sorry

theorem Convergesto.add {E:Set ℝ} {f g: ℝ → ℝ} {L M:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hg: Convergesto E g M x₀) :
  Convergesto E (f + g) (L + M) x₀ := by
  sorry

theorem Convergesto.const {E:Set ℝ} {x₀:ℝ} (h: AdherentPt x₀ E) (c:ℝ)
  : Convergesto E (fun x ↦ c) c x₀ := by
  sorry

theorem Convergesto.id {E:Set ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  : Convergesto E (fun x ↦ x) x₀ x₀ := by
  sorry

theorem Convergesto.sq {E:Set ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  : Convergesto E (fun x ↦ x^2) x₀ (x₀^2) := by
  sorry

theorem Convergesto.linear {E:Set ℝ} {x₀:ℝ} (h: AdherentPt x₀ E) (c:ℝ)
  : Convergesto E (fun x ↦ c * x) x₀ (c * x₀) := by
  sorry

theorem Convergesto.quadratic {E:Set ℝ} {x₀:ℝ} (h: AdherentPt x₀ E) (c d:ℝ)
  : Convergesto E (fun x ↦ x^2 + c * x + d) x₀ (x₀^2 + c * x₀ + d) := by
  sorry

theorem Convergesto.restrict {X Y:Set ℝ} {f: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (h: AdherentPt x₀ X) (hf: Convergesto X f L x₀) (hY: Y ⊆ X) : Convergesto Y f L x₀ := by
  sorry

theorem Real.sign_def (x:ℝ) : Real.sign x = if x < 0 then -1 else if x > 0 then 1 else 0 := by
  sorry

theorem Convergesto.sign_right : Convergesto (.Ioi 0) Real.sign 1 0 := by
  sorry

theorem Convergesto.sign_left : Convergesto (.Iio 0) Real.sign (-1) 0 := by
  sorry

theorem Convergesto.sign_all : ¬ ∃ L, Convergesto (.univ) Real.sign L 0 := by
  sorry

noncomputable abbrev f_9_3_17 : ℝ → ℝ := fun x ↦ if x = 0 then 1 else 0

theorem Convergesto.f_9_3_17_remove : Convergesto (.univ \ {0}) f_9_3_17 0 0 := by
  sorry

theorem Convergesto.f_9_3_17_all : ¬ ∃ L, Convergesto .univ f_9_3_17 L 0 := by
  sorry

open Classical in
noncomputable abbrev f_9_3_21 : ℝ → ℝ := fun x ↦ if x ∈ (fun q:ℚ ↦ (q:ℝ)) '' .univ then 1 else 0
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Convergesto.squeeze {E:Set ℝ} {f g h: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (had: AdherentPt x₀ E)
  (hfg: ∀ x ∈ E, f x ≤ g x) (hgh: ∀ x ∈ E, g x ≤ h x)
  (hf: Convergesto E f L x₀) (hh: Convergesto E h L x₀) :
  Convergesto E g L x₀ := by
-- </TARGET_THEOREM>

end Chapter9
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter9

/-- Exercise 9.3.5 (Continuous version of squeeze test), Mathlib formulation -/
theorem Convergesto.squeeze
    {E : Set ℝ} {f g h : ℝ → ℝ} {L x₀ : ℝ}
    (had : x₀ ∈ closure E)
    (hfg : ∀ x ∈ E, f x ≤ g x)
    (hgh : ∀ x ∈ E, g x ≤ h x)
    (hf : Tendsto f (nhdsWithin x₀ E) (𝓝 L))
    (hh : Tendsto h (nhdsWithin x₀ E) (𝓝 L)) :
    Tendsto g (nhdsWithin x₀ E) (𝓝 L) :=
  by
end Chapter9

end TaoBench
import Mathlib.Tactic
import Mathlib.Data.Real.Basic

/-- Definition 9.3.1 -/
abbrev Real.CloseFn (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) : Prop :=
  ∀ x ∈ X, |f x - L| < ε

/-- Definition 9.3.3 -/
abbrev Real.CloseNear (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop :=
  ∃ δ > 0, ε.CloseFn (X ∩ .Ioo (x₀-δ) (x₀+δ)) f L

/-- From Section 9.1: auxiliary notion used by `AdherentPt`. -/
abbrev Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

namespace Chapter9

/-- Definition 9.1.-/
abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

/-- Definition 9.3.6 (Convergence of functions at a point)-/
abbrev Convergesto (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop := ∀ ε > (0:ℝ), ε.CloseNear X f L x₀

/-- Proposition 9.3.14 (Limit laws for functions) / Exercise 9.3.2 -/
theorem Convergesto.sub {E:Set ℝ} {f g: ℝ → ℝ} {L M:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hg: Convergesto E g M x₀) :
  Convergesto E (f - g) (L - M) x₀ := by
end Chapter9
import Mathlib
import Analysis.Section_9_1
import Analysis.Tags.Section_9_1

namespace Chapter9

-- <CONTEXT>
abbrev _root_.Real.CloseFn (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) : Prop :=
  ∀ x ∈ X, |f x - L| < ε

abbrev _root_.Real.CloseNear (ε:ℝ) (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop :=
  ∃ δ > 0, ε.CloseFn (X ∩ .Ioo (x₀-δ) (x₀+δ)) f L

abbrev _root_.Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

abbrev Convergesto (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) : Prop := ∀ ε > (0:ℝ), ε.CloseNear X f L x₀

theorem Convergesto.iff (X:Set ℝ) (f: ℝ → ℝ) (L:ℝ) (x₀:ℝ) :
  Convergesto X f L x₀ ↔ (nhdsWithin x₀ X).Tendsto f (nhds L) := by
  sorry

theorem Convergesto.comp {E:Set ℝ} {f: ℝ → ℝ} {L:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E) (hf: Convergesto E f L x₀) {a:ℕ → ℝ} (ha: ∀ n:ℕ, a n ∈ E) (hconv: Filter.atTop.Tendsto a (nhds x₀)) :
  Filter.atTop.Tendsto (fun n ↦ f (a n)) (nhds L) := by
  sorry

theorem Convergesto.uniq {E:Set ℝ} {f: ℝ → ℝ} {L L':ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hf': Convergesto E f L' x₀) : L = L' := by
  sorry

theorem Convergesto.add {E:Set ℝ} {f g: ℝ → ℝ} {L M:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hg: Convergesto E g M x₀) :
  Convergesto E (f + g) (L + M) x₀ := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Convergesto.sub {E:Set ℝ} {f g: ℝ → ℝ} {L M:ℝ} {x₀:ℝ} (h: AdherentPt x₀ E)
  (hf: Convergesto E f L x₀) (hg: Convergesto E g M x₀) :
  Convergesto E (f - g) (L - M) x₀ := by
-- </TARGET_THEOREM>

end Chapter9
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter9

/-- Proposition 9.3.14 (Limit laws for functions) / Exercise 9.3.2 -/
theorem Convergesto.sub {E : Set ℝ} {f g : ℝ → ℝ} {L M x₀ : ℝ}
    (h : x₀ ∈ closure E)
    (hf : Tendsto f (nhdsWithin x₀ E) (nhds L))
    (hg : Tendsto g (nhdsWithin x₀ E) (nhds M)) :
    Tendsto (fun x => f x - g x) (nhdsWithin x₀ E) (nhds (L - M)) := by
end Chapter9

end TaoBench
import Mathlib.Tactic
import Mathlib.Topology.Instances.Real
import Mathlib.Order.Filter.AtTopBot

namespace Chapter9

open Classical in
/-- Exercise 9.10.1 -/
theorem Exercise_9_10_1 (a:ℕ → ℝ) (L:ℝ) :
    Filter.Tendsto
      (fun x:ℝ ↦ (if h:(∃ n:ℕ, x = n) then a h.choose else 0))
      (.atTop ⊓ .principal ((fun n:ℕ ↦ (n:ℝ)) '' .univ))
      (nhds L)
    ↔
    Filter.atTop.Tendsto a (nhds L) := by
end Chapter9
import Mathlib

namespace Chapter9

-- <CONTEXT>
theorem BddAbove.unbounded_iff (X:Set ℝ) : ¬ BddAbove X ↔ ∀ M, ∃ x ∈ X, x > M := by
  sorry

theorem BddAbove.unbounded_iff' (X:Set ℝ) : ¬ BddAbove X ↔ sSup ((fun x:ℝ ↦ (x:EReal)) '' X) = ⊤ := by
  sorry

theorem BddBelow.unbounded_iff (X:Set ℝ) : ¬ BddBelow X ↔ ∀ M, ∃ x ∈ X, x < M := by
  sorry

theorem BddBelow.unbounded_iff' (X:Set ℝ) : ¬ BddBelow X ↔ sInf ((fun x:ℝ ↦ (x:EReal)) '' X) = ⊥ := by
  sorry

theorem Filter.Tendsto.AtTop.iff {X: Set ℝ} (f:ℝ → ℝ) (L:ℝ) : Filter.Tendsto f (.atTop ⊓ .principal X) (nhds L) ↔ ∀ ε > (0:ℝ), ∃ M, ∀ x ∈ X ∩ .Ici M, |f x - L| < ε := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
open Classical in
theorem Exercise_9_10_1 (a:ℕ → ℝ) (L:ℝ) :
    Filter.Tendsto
      (fun x:ℝ ↦ (if h:(∃ n:ℕ, x = n) then a h.choose else 0))
      (.atTop ⊓ .principal ((fun n:ℕ ↦ (n:ℝ)) '' .univ))
      (nhds L)
    ↔
    Filter.atTop.Tendsto a (nhds L) := by
-- </TARGET_THEOREM>

end Chapter9
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter
open scoped Classical

namespace TaoBench
theorem Exercise_9_10_1 (a : ℕ → ℝ) (L : ℝ) :
    Filter.Tendsto
      (fun x : ℝ =>
        (if h : ∃ n : ℕ, x = n then a (Classical.choose h) else 0))
      (Filter.atTop ⊓
        Filter.principal ((fun n : ℕ => (n : ℕ) • (1 : ℝ)) '' Set.univ))
      (nhds L)
    ↔
    Filter.Tendsto a Filter.atTop (nhds L) := by
end TaoBench
import Mathlib

namespace Chapter9

-- <CONTEXT>
theorem BddAbove.unbounded_iff (X : Set ℝ) : ¬ BddAbove X ↔ ∀ M, ∃ x ∈ X, x > M := by
  sorry

theorem BddAbove.unbounded_iff' (X : Set ℝ) : ¬ BddAbove X ↔ sSup ((fun x : ℝ ↦ (x : EReal)) '' X) = ⊤ := by
  sorry

theorem BddBelow.unbounded_iff (X : Set ℝ) : ¬ BddBelow X ↔ ∀ M, ∃ x ∈ X, x < M := by
  sorry

theorem BddBelow.unbounded_iff' (X : Set ℝ) : ¬ BddBelow X ↔ sInf ((fun x : ℝ ↦ (x : EReal)) '' X) = ⊥ := by
  sorry

theorem Filter.Tendsto.AtTop.iff {X : Set ℝ} (f : ℝ → ℝ) (L : ℝ) : Filter.Tendsto f (.atTop ⊓ .principal X) (nhds L) ↔ ∀ ε > (0 : ℝ), ∃ M, ∀ x ∈ X ∩ .Ici M, |f x - L| < ε := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Exercise_9_10_4 :
    Filter.Tendsto (fun x : ℝ ↦ 1 / x) (.atTop ⊓ .principal (.Ioi 0)) (nhds 0) := by
-- </TARGET_THEOREM>

end Chapter9
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.10.4.
Mathematically: the function `x ↦ 1 / x` tends to `0` as `x → +∞` along the positive reals,
i.e. along the filter `atTop ⊓ principal (Ioi 0)`. -/
theorem Exercise_9_10_4 :
  Filter.Tendsto (fun x : ℝ => 1 / x)
    (Filter.atTop ⊓ Filter.principal (Set.Ioi (0 : ℝ)))
    (nhds (0 : ℝ)) := by
end TaoBench
import Mathlib.Data.Real.EReal
import Mathlib.Topology.Instances.Real
import Mathlib.Topology.Bornology

/-- Exercise 9.1.10 -/
theorem Exercise_9_1_10 {X:Set ℝ} (hX: X ≠ ∅) : Bornology.IsBounded X ↔
  sSup ((fun x:ℝ ↦ (x:EReal)) '' X) < ⊤ ∧
  sInf ((fun x:ℝ ↦ (x:EReal)) '' X) > ⊥ := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.10 -/
theorem Exercise_9_1_10 {X : Set ℝ} (hX : X ≠ ∅) :
    Bornology.IsBounded X ↔
      sSup ((fun x : ℝ ↦ (x : EReal)) '' X) < ⊤ ∧
      sInf ((fun x : ℝ ↦ (x : EReal)) '' X) > ⊥ := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/--
Exercise 9.1.11 (Tao, *Analysis I*).

Mathematically: in ℝ with its usual topology and bornology, if a set `X` is
bounded (in the sense of `Bornology.IsBounded`), then its topological closure
`closure X` is also bounded.
-/
theorem Exercise_9_1_11 {X : Set ℝ} (hX : Bornology.IsBounded X) :
    Bornology.IsBounded (closure X) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Topology.Bornology.Basic
import Mathlib.Topology.Instances.Real

open Set

/-- Exercise 9.1.12.  As a followup: prove or disprove this exercise with `[Fintype I]` removed. -/
theorem Exercise_9_1_12 {I:Type} [Fintype I] (X: I → Set ℝ) (hX: ∀ i, Bornology.IsBounded (X i)) :
  Bornology.IsBounded (⋃ i, X i) := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.12 (Tao, Analysis I, §9.1).
If `I` is a finite index type, a family of bounded subsets `X i ⊆ ℝ`
has bounded union `⋃ i, X i`. -/
theorem Exercise_9_1_12 {I : Type} [Fintype I]
    (X : I → Set ℝ) (hX : ∀ i, Bornology.IsBounded (X i)) :
    Bornology.IsBounded (⋃ i, X i) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Topology.Instances.Real
import Mathlib.Topology.Bornology.Basic

open Classical
noncomputable section

/-- Exercise 9.1.14 -/
theorem Exercise_9_1_14 (I: Finset ℝ) :
    IsClosed (I : Set ℝ) ∧ Bornology.IsBounded (I : Set ℝ) := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.14 -/
theorem Exercise_9_1_14 (I : Finset ℝ) :
    IsClosed (I : Set ℝ) ∧ Bornology.IsBounded (I : Set ℝ) := by
end TaoBench
import Mathlib.Tactic
import Mathlib.Analysis.SpecificLimits.Basic

/-- Definition 9.1.5.  Note that a slightly different `Real.adherent` was defined in Chapter 6.4 -/
abbrev Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

namespace Chapter9

/-- Definition 9.1.-/
abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

end Chapter9

open Chapter9

/-- Exercise 9.1.15 -/
theorem Exercise_9_1_15 {E:Set ℝ} (hE: Bornology.IsBounded E) (hnon: E.Nonempty):
    AdherentPt (sSup E) E ∧ AdherentPt (sSup E) Eᶜ := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Exercise_9_1_15 {E : Set ℝ} (hE : Bornology.IsBounded E) (hnon : E.Nonempty) :
    (∀ ε > (0 : ℝ), ∃ y ∈ E, |sSup E - y| ≤ ε) ∧
      (∀ ε > (0 : ℝ), ∃ y ∈ Eᶜ, |sSup E - y| ≤ ε) := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.3 -/
theorem Exercise_9_1_3 :
    ∃ (X Y : Set ℝ), closure (X ∩ Y) ≠ closure X ∩ closure Y := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.6 -/
theorem Exercise_9_1_6 {X Y : Set ℝ} (hY : IsClosed Y) (hXY : X ⊆ Y) :
    closure X ⊆ Y := by
end TaoBench
import Mathlib/Topology/Instances/Real
import Mathlib/Data/Set/Lattice

/-- Exercise 9.1.7 -/
theorem Exercise_9_1_7 {n:ℕ} (X: Fin n → Set ℝ) (hX: ∀ i, IsClosed (X i)) :
  IsClosed (⋃ i, X i) := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.7 -/
theorem Exercise_9_1_7 {n : ℕ} (X : Fin n → Set ℝ) (hX : ∀ i, IsClosed (X i)) :
  IsClosed (⋃ i, X i) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Data.Set.Lattice
import Mathlib.Topology.Basic
import Mathlib.Topology.Instances.Real

/-- Exercise 9.1.8 -/
theorem Exercise_9_1_8 {I:Type} (X: I → Set ℝ) (hX: ∀ i, IsClosed (X i)) :
  IsClosed (⋂ i, X i) := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.8 -/
theorem Exercise_9_1_8 {I : Type} (X : I → Set ℝ) (hX : ∀ i, IsClosed (X i)) :
  IsClosed (⋂ i, X i) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Data.Set.Basic

/-- Definition 9.1.5.  Note that a slightly different `Real.adherent` was defined in Chapter 6.4 -/
abbrev Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

namespace Chapter9

/-- Definition 9.1.-/
abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

/-- Definition 9.1.18 (Limit points) -/
abbrev LimitPt (x:ℝ) (X: Set ℝ) := AdherentPt x (X \ {x})

/-- Definition 9.1.18 (Isolated points) -/
abbrev IsolatedPt (x:ℝ) (X: Set ℝ) := x ∈ X ∧ ∃ ε>0, ∀ y ∈ X \ {x}, |x-y| > ε

end Chapter9

open Chapter9

/-- Exercise 9.1.9 -/
theorem Exercise_9_1_9a {X:Set ℝ} {x:ℝ} (hx: AdherentPt x X) : LimitPt x X ∨ IsolatedPt x X := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 9.1.9 (translation of `Chapter9.Exercise_9_1_9a`). -/
theorem Exercise_9_1_9a
  {X : Set ℝ} {x : ℝ}
  (hx : ∀ ε > (0 : ℝ), ∃ y ∈ X, |x - y| ≤ ε) :
  (∀ ε > (0 : ℝ), ∃ y ∈ X \ {x}, |x - y| ≤ ε) ∨
  (x ∈ X ∧ ∃ ε > (0 : ℝ), ∀ y ∈ X \ {x}, |x - y| > ε) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Data.Set.Basic

/-- Definition 9.1.5.  Note that a slightly different `Real.adherent` was defined in Chapter 6.4 -/
abbrev Real.adherent' (ε:ℝ) (x:ℝ) (X: Set ℝ) := ∃ y ∈ X, |x - y| ≤ ε

namespace Chapter9

/-- Definition 9.1.-/
abbrev AdherentPt (x:ℝ) (X:Set ℝ) := ∀ ε > (0:ℝ), ε.adherent' x X

/-- Definition 9.1.18 (Limit points) -/
abbrev LimitPt (x:ℝ) (X: Set ℝ) := AdherentPt x (X \ {x})

/-- Definition 9.1.18 (Isolated points) -/
abbrev IsolatedPt (x:ℝ) (X: Set ℝ) := x ∈ X ∧ ∃ ε>0, ∀ y ∈ X \ {x}, |x-y| > ε

end Chapter9

open Chapter9

/-- Exercise 9.1.9 -/
theorem Exercise_9_1_9b {X:Set ℝ} {x:ℝ} : ¬ (LimitPt x X ∧ IsolatedPt x X) := by
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Exercise_9_1_9b {X : Set ℝ} {x : ℝ} :
  ¬ (x ∈ closure (X \ {x}) ∧ x ∈ X ∧ ∃ ε > 0, ∀ y ∈ X \ {x}, |x - y| > ε) := by
end TaoBench
import Mathlib

namespace Chapter9

-- <CONTEXT>
open Classical in
noncomputable abbrev function_example : ℝ → ℝ := fun x ↦ if x ∈ ((fun y:ℚ ↦ (y:ℝ)) '' .univ) then 1 else 0

theorem add_func_eval (f g: ℝ → ℝ) (x: ℝ) : (f + g) x = f x + g x := by sorry

theorem sub_func_eval (f g: ℝ → ℝ) (x: ℝ) : (f - g) x = f x - g x := by sorry

theorem max_func_eval (f g: ℝ → ℝ) (x: ℝ) : max f g x = max (f x) (g x) := by sorry

theorem min_func_eval (f g: ℝ → ℝ) (x: ℝ) : min f g x = min (f x) (g x) := by sorry

theorem mul_func_eval (f g: ℝ → ℝ) (x: ℝ) : (f * g) x = f x * g x := by sorry

theorem div_func_eval (f g: ℝ → ℝ) (x: ℝ) : (f / g) x = f x / g x := by sorry

theorem smul_func_eval (c: ℝ) (f: ℝ → ℝ) (x: ℝ) : (c • f) x = c * f x := by sorry

abbrev f_9_2_2 : ℝ → ℝ := fun x ↦ x^2

abbrev g_9_2_2 : ℝ → ℝ := fun x ↦ 2*x

def Exercise_9_2_1b : Decidable (∀ (f g h : ℝ → ℝ), f ∘ (g + h) = f ∘ g + f ∘ h) := by
  sorry

def Exercise_9_2_1c : Decidable (∀ (f g h : ℝ → ℝ), (f+g) * h = f * h + g * h) := by
  sorry

def Exercise_9_2_1d : Decidable (∀ (f g h : ℝ → ℝ), f * (g+h) = f * g + f * h) := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
def Exercise_9_2_1a : Decidable (∀ (f g h : ℝ → ℝ), (f+g) ∘ h = f ∘ h + g ∘ h) := by
-- </TARGET_THEOREM>

end Chapter9
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
def Exercise_9_2_1a :
    Decidable (∀ (f g h : ℝ → ℝ), (f + g) ∘ h = f ∘ h + g ∘ h) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Topology.Basic
import Mathlib.Topology.Instances.Real

open Set

namespace Chapter9

/-- Definition 9.6.1 -/
abbrev BddAboveOn (f:ℝ → ℝ) (X:Set ℝ) : Prop := ∃ M, ∀ x ∈ X, f x ≤ M

abbrev BddBelowOn (f:ℝ → ℝ) (X:Set ℝ) : Prop := ∃ M, ∀ x ∈ X, -M ≤ f x

abbrev BddOn (f:ℝ → ℝ) (X:Set ℝ) : Prop := ∃ M, ∀ x ∈ X, |f x| ≤ M

/-- Exercise 9.6.1 a) -/
theorem Exercise_9_6_1a : ∃ f: ℝ → ℝ, ContinuousOn f (.Ioo 1 2) ∧ BddOn f (.Ioo 1 2) ∧
  ∃ x₀ ∈ Set.Ioo 1 2, IsMinOn f (.Ioo 1 2) x₀ ∧
  ¬ ∃ x₀ ∈ Set.Ioo 1 2, IsMaxOn f (.Ioo 1 2) x₀
  := by
end Chapter9