introvoyz041/TaoAnalysisBench huggingface dataset:
import Mathlib
import Analysis.Section_5_2
import Analysis.Tags.Section_5_2

namespace Chapter5

-- <CONTEXT>
def _root_.Rat.Close (ε : ℚ) (x y:ℚ) := |x-y| ≤ ε

@[ext]
structure Sequence where
  n₀ : ℤ
  seq : ℤ → ℚ
  vanish : ∀ n < n₀, seq n = 0

instance Sequence.instCoeFun : CoeFun Sequence (fun _ ↦ ℤ → ℚ) where
  coe := fun a ↦ a.seq

@[coe]
def Sequence.ofNatFun (a : ℕ → ℚ) : Sequence where
    n₀ := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by grind

instance : Coe (ℕ → ℚ) Sequence where
  coe := Sequence.ofNatFun

@[simp]
lemma Sequence.eval_coe_at_int (n:ℤ) (a: ℕ → ℚ) : (a:Sequence) n = if n ≥ 0 then a n.toNat else 0 := by
  sorry

abbrev Sequence.mk' (n₀:ℤ) (a: { n // n ≥ n₀ } → ℚ) : Sequence where
  n₀ := n₀
  seq n := if h : n ≥ n₀ then a ⟨n, h⟩ else 0
  vanish := by grind

abbrev Sequence.from (a:Sequence) (n₁:ℤ) : Sequence :=
  mk' (max a.n₀ n₁) (fun n ↦ a (n:ℤ))

abbrev _root_.Rat.Steady (ε: ℚ) (a: Chapter5.Sequence) : Prop :=
  ∀ n ≥ a.n₀, ∀ m ≥ a.n₀, ε.Close (a n) (a m)

abbrev _root_.Rat.EventuallySteady (ε: ℚ) (a: Chapter5.Sequence) : Prop := ∃ N ≥ a.n₀, ε.Steady (a.from N)

abbrev _root_.Rat.CloseSeq (ε: ℚ) (a b: Chapter5.Sequence) : Prop :=
  ∀ n, n ≥ a.n₀ → n ≥ b.n₀ → ε.Close (a n) (b n)

abbrev _root_.Rat.EventuallyClose (ε: ℚ) (a b: Chapter5.Sequence) : Prop :=
  ∃ N, ε.CloseSeq (a.from N) (b.from N)

abbrev Sequence.Equiv (a b: ℕ → ℚ) : Prop :=
  ∀ ε > (0:ℚ), ε.EventuallyClose (a:Sequence) (b:Sequence)

abbrev Sequence.IsCauchy (a:Sequence) : Prop := ∀ ε > (0:ℚ), ε.EventuallySteady a

@[ext]
class CauchySequence extends Sequence where
  zero : n₀ = 0
  cauchy : toSequence.IsCauchy

theorem CauchySequence.ext' {a b: CauchySequence} (h: a.seq = b.seq) : a = b := by
  sorry

abbrev CauchySequence.mk' {a:ℕ → ℚ} (ha: (a:Sequence).IsCauchy) : CauchySequence where
  n₀ := 0
  seq := (a:Sequence).seq
  vanish := by aesop
  zero := rfl
  cauchy := ha

@[simp]
theorem CauchySequence.coe_eq {a:ℕ → ℚ} (ha: (a:Sequence).IsCauchy) :
    (mk' ha).toSequence = (a:Sequence) := by
  sorry

instance CauchySequence.instCoeFun : CoeFun CauchySequence (fun _ ↦ ℕ → ℚ) where
  coe a n := a.toSequence (n:ℤ)

@[simp]
theorem CauchySequence.coe_to_sequence (a: CauchySequence) :
    ((a:ℕ → ℚ):Sequence) = a.toSequence := by
  sorry

@[simp]
theorem CauchySequence.coe_coe {a:ℕ → ℚ} (ha: (a:Sequence).IsCauchy) : mk' ha = a := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
instance CauchySequence.instSetoid : Setoid CauchySequence := by
-- </TARGET_THEOREM>

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

namespace TaoBench

namespace Chapter5

/--
Mathlib version of Tao's Proposition 5.3.3 / Exercise 5.3.1.

We consider Cauchy sequences of rationals simply as functions `ℕ → ℚ`
equipped with Mathlib's standard notion `CauchySeq`.  The exercise is
to show that the usual “eventual closeness” relation between such
Cauchy sequences defines a setoid on the type
`{ f : ℕ → ℚ // CauchySeq f }`.
-/
instance CauchySequence.instSetoid :
    Setoid { f : ℕ → ℚ // CauchySeq f } := by
end Chapter5

end TaoBench
import Mathlib.Tactic

/-!
Self-contained slice for Chapter 5 target: Real.IsBounded.equiv
-/

namespace Chapter5

/--
  Definition 5.1.1 (Sequence). To avoid some technicalities involving dependent types, we extend
  sequences by zero to the left of the starting point `n₀`.
-/
@[ext]
structure Sequence where
  n₀ : ℤ
  seq : ℤ → ℚ
  vanish : ∀ n < n₀, seq n = 0

/-- Sequences can be thought of as functions from ℤ to ℚ. -/
instance Sequence.instCoeFun : CoeFun Sequence (fun _ ↦ ℤ → ℚ) where
  coe := fun a ↦ a.seq

/--
Functions from ℕ to ℚ can be thought of as sequences starting from 0; `ofNatFun` performs this conversion.

The `coe` attribute allows the delaborator to print `Sequence.ofNatFun f` as `↑f`, which is more concise; you may safely remove this if you prefer the more explicit notation.
-/
@[coe]
def Sequence.ofNatFun (a : ℕ → ℚ) : Sequence where
    n₀ := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by grind

/--
If `a : ℕ → ℚ` is used in a context where a `Sequence` is expected, automatically coerce `a` to `Sequence.ofNatFun a` (which will be pretty-printed as `↑a`)
-/
instance : Coe (ℕ → ℚ) Sequence where
  coe := Sequence.ofNatFun

abbrev Sequence.mk' (n₀:ℤ) (a: { n // n ≥ n₀ } → ℚ) : Sequence where
  n₀ := n₀
  seq n := if h : n ≥ n₀ then a ⟨n, h⟩ else 0
  vanish := by grind

lemma Sequence.eval_mk {n n₀:ℤ} (a: { n // n ≥ n₀ } → ℚ) (h: n ≥ n₀) :
    (Sequence.mk' n₀ a) n = a ⟨ n, h ⟩ := by grind

@[simp]
lemma Sequence.n0_coe (a: ℕ → ℚ) : (a:Sequence).n₀ = 0 := by norm_cast

/--
  a.from n₁ starts `a:Sequence` from `n₁`.  It is intended for use when `n₁ ≥ n₀`, but returns
  the "junk" value of the original sequence `a` otherwise.
-/
abbrev Sequence.from (a:Sequence) (n₁:ℤ) : Sequence :=
  mk' (max a.n₀ n₁) (fun n ↦ a (n:ℤ))

/-- Definition 5.1.12 (bounded sequences) -/
abbrev Sequence.BoundedBy (a:Sequence) (M:ℚ) : Prop := ∀ n, |a n| ≤ M

/-- Definition 5.1.12 (bounded sequences) -/
lemma Sequence.boundedBy_def (a:Sequence) (M:ℚ) : a.BoundedBy M ↔ ∀ n, |a n| ≤ M := by rfl

abbrev Sequence.IsBounded (a:Sequence) : Prop := ∃ M ≥ 0, a.BoundedBy M

/-- Definition 5.1.12 (bounded sequences) -/
lemma Sequence.isBounded_def (a:Sequence) : a.IsBounded ↔ ∃ M ≥ 0, a.BoundedBy M := by rfl

end Chapter5

/--
  This definition needs to be made outside of the Section 4.3 namespace for technical reasons.
-/
def Rat.Close (ε : ℚ) (x y:ℚ) := |x-y| ≤ ε

abbrev Rat.CloseSeq (ε: ℚ) (a b: Chapter5.Sequence) : Prop :=
  ∀ n, n ≥ a.n₀ → n ≥ b.n₀ → ε.Close (a n) (b n)

abbrev Rat.EventuallyClose (ε: ℚ) (a b: Chapter5.Sequence) : Prop :=
  ∃ N, ε.CloseSeq (a.from N) (b.from N)

namespace Chapter5

/-- Definition 5.2.6 (Equivalent sequences) -/
abbrev Sequence.Equiv (a b: ℕ → ℚ) : Prop :=
  ∀ ε > (0:ℚ), ε.EventuallyClose (a:Sequence) (b:Sequence)

/-- Exercise 5.3.4 -/
theorem Real.IsBounded.equiv {a b:ℕ → ℚ} (ha: (a:Sequence).IsBounded) (hab: Sequence.Equiv a b) :
    (b:Sequence).IsBounded := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Real.IsBounded.equiv
    {a b : ℕ → ℚ}
    (ha : ∃ M : ℚ, 0 ≤ M ∧ ∀ n : ℕ, |a n| ≤ M)
    (hab : ∀ ε : ℚ, 0 < ε → ∃ N : ℕ, ∀ n ≥ N, |a n - b n| ≤ ε) :
    ∃ M : ℚ, 0 ≤ M ∧ ∀ n : ℕ, |b n| ≤ M := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/--
In Tao's construction, `Real` is defined as a quotient of Cauchy sequences of rationals
and `LIM` picks out the real number represented by a (Cauchy) rational sequence,
defaulting to `0` if the sequence is not Cauchy. The exercise

`Real.LIM.harmonic : LIM (fun n ↦ 1/((n:ℚ)+1)) = 0`

says that the rational sequence `a n = 1 / (n + 1)` converges to `0` in the
constructed real numbers.

In Mathlib, limits of sequences are expressed via `Tendsto` and filters.
The following theorem is the corresponding statement in standard Mathlib terms:
the real sequence `n ↦ 1 / (n + 1)` tends to `0` as `n → ∞`.
-/
theorem Real.LIM.harmonic :
    Tendsto (fun n : ℕ => (1 : ℝ) / ((n : ℝ) + 1)) atTop (𝓝 0) := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter5
theorem Real.LIM_of_Cauchy {q : ℕ → ℚ}
    (hq : ∀ M : ℕ, ∀ n ≥ M, ∀ n' ≥ M,
      |(q n - q n' : ℚ)| ≤ 1 / (M+1 : ℚ)) :
    CauchySeq q ∧
    ∃ L : ℝ, ∀ M : ℕ,
      |((q M : ℚ) : ℝ) - L|
        ≤ (1 : ℝ) / (M+1 : ℝ) := by
end Chapter5

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

namespace TaoBench

/-- Mathlib version of Chapter5.Real.LIM_of_ge.

If `(a n)` is a Cauchy sequence of rationals, viewed in `ℝ`, and every term is
greater than or equal to a real number `x`, then the limit of the sequence is
also greater than or equal to `x`. -/
theorem Real.LIM_of_ge {x : ℝ} {a : ℕ → ℚ}
    (hcauchy : CauchySeq fun n => (a n : ℝ))
    (h : ∀ n, x ≤ (a n : ℝ)) :
    x ≤ lim (map (fun n => (a n : ℝ)) (atTop : Filter ℕ)) := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter5

/-- Proposition 5.4.7(d) (addition preserves order) / Exercise 5.4.2 -/
theorem Real.add_lt_add_right {x y : Real} (z : Real) (hxy : x < y) :
  x + z < y + z := by
end Chapter5

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

namespace TaoBench

namespace Chapter5

/--
Tao’s Proposition 5.4.7(b) says that, with the usual convention that `x > y`
means `y < x`, the statement “`x < y`” is equivalent to “`y > x`”.
In Mathlib’s `ℝ` with its standard order, this is definitionally true.
-/
theorem Real.antisymm (x y : ℝ) : x < y ↔ y > x := by
end Chapter5

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

namespace TaoBench

/-- Exercise 5.4.6:
For real numbers `ε`, `x`, `y`, the inequality `|x - y| ≤ ε`
is equivalent to `y - ε ≤ x ∧ x ≤ y + ε`. -/
theorem Chapter5.Real.dist_le_iff (ε x y : ℝ) :
    |x - y| ≤ ε ↔ y - ε ≤ x ∧ x ≤ y + ε := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Real.dist_lt_iff (ε x y : ℝ) :
    |x - y| < ε ↔ y - ε < x ∧ x < y + ε := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Topology.Instances.Real

noncomputable section

namespace Chapter5

-- In this extracted snippet, we use Mathlib's `Real` as the chapter's real numbers.
abbrev Real := _root_.Real

namespace Real

-- Definition 5.6.2 (nth root via sSup of the set {y ≥ 0 ∧ y^n ≤ x})
noncomputable abbrev root (x : Real) (n : ℕ) : Real :=
  sSup {y : Real | y ≥ 0 ∧ y ^ n ≤ x}

end Real

/-- Lemma 5.6.6 (ab) / Exercise 5.6.1 -/
theorem Real.eq_root_iff_pow_eq {x y : Real} (hx : x ≥ 0) (hy : y ≥ 0) {n : ℕ} (hn : n ≥ 1) :
  y = x.root n ↔ y ^ n = x := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter5

/-- Lemma 5.6.6 (ab) / Exercise 5.6.1, using only Mathlib's standard `sSup` definition
for the nth root (as the supremum of `{y ≥ 0 | y^n ≤ x}`). -/
theorem Real.eq_root_iff_pow_eq {x y : ℝ}
    (hx : x ≥ 0) (hy : y ≥ 0) {n : ℕ} (hn : n ≥ 1) :
    y = sSup {z : ℝ | z ≥ 0 ∧ z ^ n ≤ x} ↔ y ^ n = x := by
end Chapter5

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

namespace TaoBench
theorem Real.exist_inv_nat_le {x : ℝ} (hx : 0 < x) :
    ∃ N : ℤ, 0 < N ∧ (N : ℝ)⁻¹ < x := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 5.5.1 -/
theorem Real.inf_neg {E : Set Real} {M : Real} (h : IsLUB E M) :
    IsGLB (-E) (-M) := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Real.inv_max {x y : ℝ} (hx : 0 < x) (hy : 0 < y) :
    (max x y)⁻¹ = min x⁻¹ y⁻¹ := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Real.inv_min {x y : ℝ} (hx : 0 < x) (hy : 0 < y) :
    (min x y)⁻¹ = max x⁻¹ y⁻¹ := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 5.5.5 -/
theorem Real.irrat_between {x y : ℝ} (hxy : x < y) :
    ∃ z, x < z ∧ z < y ∧ ¬ ∃ q : ℚ, z = (q : ℝ) := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Real.le_add_eps_iff (x y : ℝ) :
    ∀ ε > 0, x ≤ y + ε ↔ x ≤ y := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Exercise 5.4.9 (Tao, Analysis I, §5.4).

If `z` is a positive real number, then multiplication by `z` preserves the
ordering of real numbers, so the maximum of `x*z` and `y*z` is `max x y * z`. -/
theorem Real.max_mul (x y : ℝ) {z : ℝ} (hz : 0 < z) :
    max (x * z) (y * z) = max x y * z := by
end TaoBench
import Mathlib/Analysis/SpecialFunctions/Pow
import Mathlib/Data/Real/Basic

-- Provide a Pow instance for real numbers with rational exponents by reusing Real.rpow.
noncomputable instance instPowRealRat : Pow Real ℚ where
  pow x q := Real.rpow x (q : ℝ)

namespace Chapter5

-- Target theorem (statement copied verbatim from the textbook; proof elided).
theorem Real.max_ratPow {x y:Real} (hx: x > 0) (hy: y > 0) {q:ℚ} (hq: q > 0) :
  max (x^q) (y^q) = (max x y)^q := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Real.max_ratPow {x y : Real} (hx : x > 0) (hy : y > 0) {q : ℚ} (hq : q > 0) :
    max (x ^ (q : ℝ)) (y ^ (q : ℝ)) = (max x y) ^ (q : ℝ) := by
end TaoBench
import Mathlib
import Analysis.Section_5_3
import Analysis.Tags.Section_5_3

namespace Chapter5

-- <CONTEXT>
abbrev BoundedAwayPos (a:ℕ → ℚ) : Prop :=
  ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≥ c

abbrev BoundedAwayNeg (a:ℕ → ℚ) : Prop :=
  ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≤ -c

theorem boundedAwayPos_def (a:ℕ → ℚ) : BoundedAwayPos a ↔ ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≥ c := by
  sorry

theorem boundedAwayNeg_def (a:ℕ → ℚ) : BoundedAwayNeg a ↔ ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≤ -c := by
  sorry

theorem not_boundedAwayPos_boundedAwayNeg {a:ℕ → ℚ} : ¬ (BoundedAwayPos a ∧ BoundedAwayNeg a) := by
  sorry

theorem Real.le_iff (x y:Real) : x ≤ y ↔ (x < y) ∨ (x = y) := by
  sorry

theorem Real.ge_iff (x y:Real) : x ≥ y ↔ (x > y) ∨ (x = y) := by
  sorry

theorem Real.lt_of_coe (q q':ℚ): q < q' ↔ (q:Real) < (q':Real) := by
  sorry

theorem Real.gt_of_coe (q q':ℚ): q > q' ↔ (q:Real) > (q':Real) := by
  sorry

theorem Real.abs_eq_abs (x:Real) : |x| = abs x := by
  sorry

theorem Real.max_eq (x y:Real) : max x y = if x ≥ y then x else y := by
  sorry

theorem Real.min_eq (x y:Real) : min x y = if x ≤ y then x else y := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Real.max_self (x:Real) : max x x = x := by
-- </TARGET_THEOREM>

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

namespace TaoBench

namespace Chapter5

/-- Exercise 5.4.9: For any real `x`, the maximum of `x` with itself is `x`, i.e. `max x x = x`. -/
theorem Real.max_self (x : Real) : max x x = x := by
end Chapter5

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

namespace TaoBench
theorem Real.min_mul (x y : ℝ) {z : ℝ} (hz : 0 < z) :
  min (x * z) (y * z) = min x y * z := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Order.CompleteLattice

namespace Chapter5

noncomputable abbrev Real.root (x : Real) (n : ℕ) : Real := sSup { y : Real | y ≥ 0 ∧ y ^ n ≤ x }

noncomputable abbrev Real.sqrt (x : Real) := Real.root x 2

noncomputable abbrev Real.ratPow (x : Real) (q : ℚ) : Real := (Real.root x q.den) ^ (q.num)

noncomputable instance Real.instRatPow : Pow Real ℚ where
  pow x q := Real.ratPow x q

/-- Exercise 5.6.5 -/
theorem Real.min_ratPow {x y:Real} (hx: x > 0) (hy: y > 0) {q:ℚ} (hq: q > 0) :
  min (x^q) (y^q) = (min x y)^q := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench
theorem Real.min_ratPow {x y : ℝ} (hx : x > 0) (hy : y > 0) {q : ℚ} (hq : q > 0) :
  min (x ^ (q : ℝ)) (y ^ (q : ℝ)) = (min x y) ^ (q : ℝ) := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter5
theorem Real.mul_le_mul_left {x y z : ℝ} (hxy : x ≤ y) (hz : 0 < z) :
    z * x ≤ z * y := by
end Chapter5

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

namespace TaoBench

namespace Chapter5
@[simp]
theorem Real.neg_iff_pos_of_neg (x : ℝ) : x < 0 ↔ 0 < -x := by
end Chapter5

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

namespace TaoBench

/-- Exercise 5.4.9 (Tao): For all real numbers `x` and `y`,
`max x y = - min (-x) (-y)`. -/
theorem Real.neg_max (x y : ℝ) : max x y = - min (-x) (-y) := by
end TaoBench
import Mathlib
import Analysis.Section_5_3
import Analysis.Tags.Section_5_3

namespace Chapter5

-- <CONTEXT>
abbrev BoundedAwayPos (a:ℕ → ℚ) : Prop :=
  ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≥ c

abbrev BoundedAwayNeg (a:ℕ → ℚ) : Prop :=
  ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≤ -c

theorem boundedAwayPos_def (a:ℕ → ℚ) : BoundedAwayPos a ↔ ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≥ c := by
  sorry

theorem boundedAwayNeg_def (a:ℕ → ℚ) : BoundedAwayNeg a ↔ ∃ (c:ℚ), c > 0 ∧ ∀ n, a n ≤ -c := by
  sorry

theorem not_boundedAwayPos_boundedAwayNeg {a:ℕ → ℚ} : ¬ (BoundedAwayPos a ∧ BoundedAwayNeg a) := by
  sorry

theorem Real.le_iff (x y:Real) : x ≤ y ↔ (x < y) ∨ (x = y) := by
  sorry

theorem Real.ge_iff (x y:Real) : x ≥ y ↔ (x > y) ∨ (x = y) := by
  sorry

theorem Real.lt_of_coe (q q':ℚ): q < q' ↔ (q:Real) < (q':Real) := by
  sorry

theorem Real.gt_of_coe (q q':ℚ): q > q' ↔ (q:Real) > (q':Real) := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Real.not_gt_and_eq (x y:Real) : ¬ (x > y ∧ x = y):= by
-- </TARGET_THEOREM>

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

namespace TaoBench
namespace Chapter5

/-- Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1 -/
theorem Real.not_pos_neg (x : ℝ) : ¬ (0 < x ∧ x < 0) := by
end Chapter5
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

namespace Chapter5

/-- Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1,
translated to Mathlib: if two real numbers are positive, then their sum is positive. -/
theorem Real.pos_add {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : 0 < x + y := by
end Chapter5

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

namespace TaoBench

namespace Chapter5

/-- Exercise 5.6.3 -/
theorem Real.pow_even (x : ℝ) {n : ℕ} (hn : Even n) : x ^ n ≥ 0 := by
end Chapter5

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

namespace TaoBench

namespace Chapter5
@[simp]
theorem Real.ratCast_inj (q r : ℚ) :
    (q : ℝ) = (r : ℝ) ↔ q = r := by
end Chapter5

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

namespace Chapter5

namespace Real

noncomputable abbrev root (x : Real) (n : ℕ) : Real :=
  sSup {y : Real | y ≥ 0 ∧ y ^ n ≤ x}

noncomputable abbrev ratPow (x : Real) (q : ℚ) : Real :=
  (root x q.den) ^ (q.num)

noncomputable instance instRatPow : Pow Real ℚ where
  pow x q := ratPow x q

end Real

/-- Lemma 5.6.9(b) / Exercise 5.6.2 -/
theorem Real.ratPow_add {x:Real} (hx: x > 0) (q r:ℚ) : x^(q+r) = x^q * x^r := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Lemma 5.6.9(b) / Exercise 5.6.2 -/
theorem Real.ratPow_add {x : ℝ} (hx : x > 0) (q r : ℚ) :
    x ^ ((q + r : ℚ) : ℝ) = x ^ (q : ℝ) * x ^ (r : ℝ) := by
end TaoBench
import Mathlib.Tactic
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Data.Rat.Basic

namespace Chapter5

-- For this isolated snippet, we alias the textbook's `Real` to mathlib's real numbers.
abbrev Real := _root_.Real

-- Rational exponentiation on reals, used only to parse/typecheck the target theorem.
noncomputable abbrev Real.ratPow (x : Real) (q : ℚ) : Real := Real.rpow x (q : ℝ)

noncomputable instance Real.instRatPow : Pow Real ℚ where
  pow x q := Real.ratPow x q

/-- Lemma 5.6.9(d) / Exercise 5.6.2 -/
theorem Real.ratPow_mono {x y:Real} (hx: x > 0) (hy: y > 0) {q:ℚ} (h: q > 0) : x > y ↔ x^q > y^q := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Lemma 5.6.9(d) / Exercise 5.6.2 -/
theorem Real.ratPow_mono
  {x y : ℝ} (hx : x > 0) (hy : y > 0) {q : ℚ} (hq : q > 0) :
  x > y ↔ x ^ (q : ℝ) > y ^ (q : ℝ) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Topology.Algebra.Order

namespace Chapter5

abbrev Real := _root_.Real

noncomputable abbrev Real.root (x : Real) (n : ℕ) : Real :=
  sSup { y : Real | y ≥ 0 ∧ y ^ n ≤ x }

noncomputable abbrev Real.ratPow (x : Real) (q : ℚ) : Real :=
  (x.root q.den) ^ (q.num)

noncomputable instance Real.instRatPow : Pow Real ℚ where
  pow x q := x.ratPow q

/-- Lemma 5.6.9(e) / Exercise 5.6.2 -/
theorem Real.ratPow_mono_of_gt_one {x:Real} (hx: x > 1) {q r:ℚ} : x^q > x^r ↔ q > r := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Lemma 5.6.9(e) / Exercise 5.6.2 -/
theorem Real.ratPow_mono_of_gt_one {x : Real} (hx : x > 1) {q r : ℚ} :
    Real.rpow x (q : ℝ) > Real.rpow x (r : ℝ) ↔ q > r := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Data.Rat.Basic
import Mathlib.Topology.Algebra.Order

namespace Chapter5

abbrev Real := _root_.Real

noncomputable abbrev Real.root (x:Real) (n:ℕ) : Real := sSup { y:Real | y ≥ 0 ∧ y^n ≤ x }

noncomputable abbrev Real.ratPow (x:Real) (q:ℚ) : Real := (Real.root x q.den)^(q.num)

noncomputable instance Real.instRatPow : Pow Real ℚ where
  pow x q := x.ratPow q

/-- Lemma 5.6.9(e) / Exercise 5.6.2 -/
theorem Real.ratPow_mono_of_lt_one {x:Real} (hx0: 0 < x) (hx: x < 1) {q r:ℚ} : x^q > x^r ↔ q < r := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Lemma 5.6.9(e) / Exercise 5.6.2 (Tao) in Mathlib form:
for `0 < x < 1`, the map `q ↦ x^q` (with rational exponents interpreted as real
exponents via the canonical embedding `ℚ → ℝ`) is strictly decreasing. -/
theorem Real.ratPow_mono_of_lt_one
    {x : ℝ} (hx0 : 0 < x) (hx : x < 1) {q r : ℚ} :
    x ^ (q : ℝ) > x ^ (r : ℝ) ↔ q < r := by
end TaoBench
import Mathlib.Tactic
import Mathlib.Data.Real.Basic
import Mathlib.Algebra.GroupPower

namespace Chapter5

noncomputable abbrev Real.root (x : Real) (n : ℕ) : Real :=
  sSup { y : Real | y ≥ 0 ∧ y ^ n ≤ x }

noncomputable abbrev Real.ratPow (x : Real) (q : ℚ) : Real :=
  (Real.root x q.den) ^ (q.num)

noncomputable instance Real.instRatPow : Pow Real ℚ where
  pow x q := Real.ratPow x q

/-- Lemma 5.6.9(f) / Exercise 5.6.2 -/
theorem Real.ratPow_mul {x y:Real} (hx: x > 0) (hy: y > 0) (q:ℚ) : (x*y)^q = x^q * y^q := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Lemma 5.6.9(f) / Exercise 5.6.2 -/
theorem Real.ratPow_mul {x y : ℝ} (hx : x > 0) (hy : y > 0) (q : ℚ) :
    (x * y) ^ (q : ℝ) = x ^ (q : ℝ) * y ^ (q : ℝ) := by
end TaoBench
import Mathlib.Data.Real.Basic
import Mathlib.Data.Rat.Basic
import Mathlib.Algebra.GroupPower
import Mathlib.Topology.Instances.Real

namespace Chapter5

noncomputable abbrev Real.root (x : Real) (n : ℕ) : Real :=
  sSup { y : Real | y ≥ 0 ∧ y ^ n ≤ x }

noncomputable abbrev Real.ratPow (x : Real) (q : ℚ) : Real :=
  (Real.root x q.den) ^ (q.num)

noncomputable instance Real.instRatPow : Pow Real ℚ where
  pow x q := Real.ratPow x q

/-- Lemma 5.6.9(c) / Exercise 5.6.2 -/
theorem Real.ratPow_neg {x:Real} (hx: x > 0) (q:ℚ) : x^(-q) = 1 / x^q := by
end Chapter5
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Lemma 5.6.9(c) / Exercise 5.6.2 -/
theorem Real.ratPow_neg {x : ℝ} (hx : x > 0) (q : ℚ) :
    x ^ (-(q : ℝ)) = 1 / x ^ (q : ℝ) := by
end TaoBench