introvoyz041/TaoAnalysisBench huggingface dataset:
import Mathlib
import Analysis.Section_5_epilogue
import Analysis.Tags.Section_5_epilogue
import Analysis.Section_6_6
import Analysis.Tags.Section_6_6

abbrev Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

namespace Chapter6

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

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

@[coe]
abbrev Sequence.ofNatFun (a:ℕ → ℝ) : Sequence :=
 {
    m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all
 }

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

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

abbrev Sequence.from (a:Sequence) (m₁:ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)

end Chapter6

abbrev Real.CloseSeq (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop := ∀ n ≥ a.m, ε.Close (a n) L

abbrev Real.EventuallyClose (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

namespace Chapter6

abbrev Sequence.TendsTo (a:Sequence) (L:ℝ) : Prop :=
  ∀ ε > (0:ℝ), ε.EventuallyClose a L

abbrev Sequence.Convergent (a:Sequence) : Prop := ∃ L, a.TendsTo L

open Classical in
noncomputable abbrev lim (a:Sequence) : ℝ := if h: a.Convergent then h.choose else 0

open Sequence Real

-- <CONTEXT>
lemma ratPow_continuous {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).Convergent := by
  sorry

lemma ratPow_lim_uniq {x α:ℝ} (hx: x > 0) {q q': ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α)
 (hq': ((fun n ↦ (q' n:ℝ)):Sequence).TendsTo α) :
 lim ((fun n ↦ x^(q n:ℝ)):Sequence) = lim ((fun n ↦ x^(q' n:ℝ)):Sequence) := by
  sorry

theorem Real.eq_lim_of_rat (α:ℝ) : ∃ q: ℕ → ℚ, ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α := by
  sorry

noncomputable abbrev Real.rpow (x:ℝ) (α:ℝ) :ℝ := lim ((fun n ↦ x^((eq_lim_of_rat α).choose n:ℝ)):Sequence)

lemma Real.rpow_eq_lim_ratPow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 rpow x α = lim ((fun n ↦ x^(q n:ℝ)):Sequence) := by
  sorry

lemma Real.ratPow_tendsto_rpow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).TendsTo (rpow x α) := by
  sorry

lemma Real.rpow_of_rat_eq_ratPow {x:ℝ} (hx: x > 0) {q: ℚ} :
  rpow x (q:ℝ) = x^(q:ℝ) := by
  sorry

theorem Real.ratPow_add {x:ℝ} (hx: x > 0) (q r:ℝ) : rpow x (q+r) = rpow x q * rpow x r := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Real.ratPow_mono {x y:ℝ} (hx: x > 0) (hy: y > 0) {q:ℝ} (h: q > 0) : x > y ↔ rpow x q > rpow y q := by
-- </TARGET_THEOREM>

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

namespace TaoBench
theorem ratPow_mono {x y : ℝ} (hx : x > 0) (hy : y > 0) {q : ℝ} (h : q > 0) :
    x > y ↔ Real.rpow x q > Real.rpow y q := by
end TaoBench
import Mathlib
import Aesop
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat Set Filter

namespace TaoBench

/-- Proposition 6.7.3(e) / Exercise 6.7.1 (Tao).
For a base `x > 1`, the function `q ↦ x^q` is strictly increasing. -/
theorem ratPow_mono_of_gt_one {x : ℝ} (hx : x > 1) {q r : ℝ} :
  x ^ q > x ^ r ↔ q > r := by
end TaoBench
import Mathlib.Tactic
import Mathlib.Data.Real.Basic

/-- Definition 6.1.1 (Distance-based closeness). -/
abbrev Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

/-- Definition 6.1.2 (ε-close). -/
lemma Real.close_def (ε x y : ℝ) : ε.Close x y ↔ dist x y ≤ ε := by rfl

namespace Chapter6

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

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

@[coe]
abbrev Sequence.ofNatFun (a:ℕ → ℝ) : Sequence :=
 {
    m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all
 }

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

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

lemma Sequence.eval_mk {n m:ℤ} (a: { n // n ≥ m } → ℝ) (h: n ≥ m) :
    (Sequence.mk' m a) n = a ⟨ n, h ⟩ := by simp [h]

@[simp]
lemma Sequence.eval_coe (n:ℕ) (a: ℕ → ℝ) : (a:Sequence) n = a n := by simp

abbrev Sequence.from (a:Sequence) (m₁:ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)

lemma Sequence.from_eval (a:Sequence) {m₁ n:ℤ} (hn: n ≥ m₁) :
  (a.from m₁) n = a n := by
  simp [hn]; intros; symm; solve_by_elim [a.vanish]

end Chapter6

/-- Definition 6.1.3 (ε-steady) -/
abbrev Real.Steady (ε: ℝ) (a: Chapter6.Sequence) : Prop :=
  ∀ n ≥ a.m, ∀ m ≥ a.m, ε.Close (a n) (a m)

/-- Definition 6.1.3 (Eventually ε-steady) -/
abbrev Real.EventuallySteady (ε: ℝ) (a: Chapter6.Sequence) : Prop :=
  ∃ N ≥ a.m, ε.Steady (a.from N)

/-- Definition 6.1.5 (ε-close to a limit) -/
abbrev Real.CloseSeq (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop := ∀ n ≥ a.m, ε.Close (a n) L

/-- Definition 6.1.5 (Eventually ε-close) -/
abbrev Real.EventuallyClose (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

namespace Chapter6

/-- Definition 6.1.8 (Tends to a limit) -/
abbrev Sequence.TendsTo (a:Sequence) (L:ℝ) : Prop :=
  ∀ ε > (0:ℝ), ε.EventuallyClose a L

/-- Definition 6.1.8 (Convergent sequence) -/
abbrev Sequence.Convergent (a:Sequence) : Prop := ∃ L, a.TendsTo L

open Classical in
/-- Definition 6.1.8 (limit, junk value 0 if not convergent) -/
noncomputable abbrev lim (a:Sequence) : ℝ := if h: a.Convergent then h.choose else 0

namespace Real

/-- From Section 6.7: existence of a rational approximating sequence for any real. -/
-- This matches the declaration in the textbook (Chapter6.Real.eq_lim_of_rat).
theorem eq_lim_of_rat (α : ℝ) : ∃ q : ℕ → ℚ, ((fun n ↦ (q n : ℝ)) : Sequence).TendsTo α := by
  sorry

/-- From Section 6.7: definition of real exponentiation via limits of rational powers. -/
noncomputable abbrev rpow (x : ℝ) (α : ℝ) : ℝ :=
  lim ((fun n ↦ x ^ ((eq_lim_of_rat α).choose n : ℝ)) : Sequence)

end Real

/-- Proposition 6.7.3(e) / Exercise 6.7.1 -/
 theorem Real.ratPow_mono_of_lt_one {x:ℝ} (hx0: 0 < x) (hx: x < 1) {q r:ℝ} :
    rpow x q > rpow x r ↔ q < r := by
end Chapter6
import Mathlib
import Analysis.Section_5_epilogue
import Analysis.Tags.Section_5_epilogue
import Analysis.Section_6_6
import Analysis.Tags.Section_6_6

namespace Chapter6

-- <CONTEXT>
abbrev _root_.Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

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

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

@[coe]
abbrev Sequence.ofNatFun (a:ℕ → ℝ) : Sequence :=
 {
    m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all
 }

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

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

abbrev Sequence.from (a:Sequence) (m₁:ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)

abbrev _root_.Real.CloseSeq (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop := ∀ n ≥ a.m, ε.Close (a n) L

abbrev _root_.Real.EventuallyClose (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

abbrev Sequence.TendsTo (a:Sequence) (L:ℝ) : Prop :=
  ∀ ε > (0:ℝ), ε.EventuallyClose a L

abbrev Sequence.Convergent (a:Sequence) : Prop := ∃ L, a.TendsTo L

open Classical in
noncomputable abbrev lim (a:Sequence) : ℝ := if h: a.Convergent then h.choose else 0

open Sequence Real

lemma ratPow_continuous {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).Convergent := by
  sorry

lemma ratPow_lim_uniq {x α:ℝ} (hx: x > 0) {q q': ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α)
 (hq': ((fun n ↦ (q' n:ℝ)):Sequence).TendsTo α) :
 lim ((fun n ↦ x^(q n:ℝ)):Sequence) = lim ((fun n ↦ x^(q' n:ℝ)):Sequence) := by
  sorry

theorem Real.eq_lim_of_rat (α:ℝ) : ∃ q: ℕ → ℚ, ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α := by
  sorry

noncomputable abbrev Real.rpow (x:ℝ) (α:ℝ) :ℝ := lim ((fun n ↦ x^((eq_lim_of_rat α).choose n:ℝ)):Sequence)

lemma Real.rpow_eq_lim_ratPow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 rpow x α = lim ((fun n ↦ x^(q n:ℝ)):Sequence) := by
  sorry

lemma Real.ratPow_tendsto_rpow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).TendsTo (rpow x α) := by
  sorry

lemma Real.rpow_of_rat_eq_ratPow {x:ℝ} (hx: x > 0) {q: ℚ} :
  rpow x (q:ℝ) = x^(q:ℝ) := by
  sorry

theorem Real.ratPow_add {x:ℝ} (hx: x > 0) (q r:ℝ) : rpow x (q+r) = rpow x q * rpow x r := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Real.ratPow_mono_of_lt_one {x:ℝ} (hx0: 0 < x) (hx: x < 1) {q r:ℝ} : rpow x q > rpow x r ↔ q < r := by
-- </TARGET_THEOREM>

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

namespace TaoBench

namespace Real

/-- Proposition 6.7.3(e) / Exercise 6.7.1 (Mathlib version).
For a real base `x` with `0 < x < 1`, the real power function is strictly decreasing
in the exponent: larger exponents give smaller values. -/
theorem ratPow_mono_of_lt_one {x : ℝ} (hx0 : 0 < x) (hx : x < 1) {q r : ℝ} :
    _root_.Real.rpow x q > _root_.Real.rpow x r ↔ q < r := by
end Real

end TaoBench
import Mathlib.Tactic
import Mathlib/Topology/Instances/Real
import Mathlib/Analysis/SpecialFunctions/Pow/Real

/-!
Self-contained slice for Chapter 6.7 target theorem.
-/


/-- Definition 6.1.1 (Distance). We use Mathlib's distance. -/
abbrev Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

namespace Chapter6

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

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

namespace Sequence

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

/-- a.from n₁ starts `a` from `n₁`. -/
abbrev «from» (a : Sequence) (m₁ : ℤ) : Sequence := mk' (max a.m m₁) (fun n ↦ a (n : ℤ))

end Sequence

end Chapter6

/-- Definition 6.1.5 -/ 
abbrev Real.CloseSeq (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∀ n ≥ a.m, ε.Close (a n) L

/-- Definition 6.1.5 -/ 
theorem Real.closeSeq_def (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) :
  ε.CloseSeq a L ↔ ∀ n ≥ a.m, dist (a n) L ≤ ε := by rfl

/-- Definition 6.1.5 -/ 
abbrev Real.EventuallyClose (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

namespace Chapter6

namespace Sequence

/-- Definition 6.7: TendsTo (copied from Section 6.7). -/
abbrev TendsTo (a : Sequence) (L : ℝ) : Prop :=
  ∀ ε > (0 : ℝ), ε.EventuallyClose a L

/-- Definition 6.7: Convergent (copied from Section 6.7). -/
abbrev Convergent (a : Sequence) : Prop :=
  ∃ L, a.TendsTo L

@[coe]
abbrev ofNatFun (a : ℕ → ℝ) : Sequence :=
  { m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all }

end Sequence

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

open Classical in
/-- Definition 6.1.8.  The limit of a sequence (junk value 0 if not convergent). -/
noncomputable abbrev lim (a : Sequence) : ℝ :=
  if h : a.Convergent then h.choose else 0

namespace Real

/-- Theorem: every real is a limit of a rational sequence (from Section 6.7). -/
-- We keep the proof as `sorry` per extraction rules.
theorem eq_lim_of_rat (α : ℝ) : ∃ q : ℕ → ℚ, ((fun n ↦ (q n : ℝ)) : Sequence).TendsTo α := by
  sorry

/-- Definition 6.7.2 (Exponentiation to a real exponent) -/
noncomputable abbrev rpow (x : ℝ) (α : ℝ) : ℝ :=
  lim ((fun n ↦ x ^ ((eq_lim_of_rat α).choose n : ℝ)) : Sequence)

/-- Proposition 6.7.3(f) / Exercise 6.7.1 -/
lemma ratPow_mul {x y : ℝ} (hx : x > 0) (hy : y > 0) (q : ℝ) :
    rpow (x * y) q = rpow x q * rpow y q := by
end Real

end Chapter6
import Mathlib
import Analysis.Section_5_epilogue
import Analysis.Tags.Section_5_epilogue
import Analysis.Section_6_6
import Analysis.Tags.Section_6_6

namespace Chapter6

-- <CONTEXT>
abbrev _root_.Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

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

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

@[coe]
abbrev Sequence.ofNatFun (a : ℕ → ℝ) : Sequence :=
  { m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all }

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

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

abbrev Sequence.from (a : Sequence) (m₁ : ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)

abbrev _root_.Real.CloseSeq (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∀ n ≥ a.m, ε.Close (a n) L

theorem _root_.Real.closeSeq_def (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) :
    ε.CloseSeq a L ↔ ∀ n ≥ a.m, dist (a n) L ≤ ε := by
  sorry

abbrev _root_.Real.EventuallyClose (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

abbrev Sequence.TendsTo (a : Sequence) (L : ℝ) : Prop :=
  ∀ ε > (0 : ℝ), ε.EventuallyClose a L

abbrev Sequence.Convergent (a : Sequence) : Prop :=
  ∃ L, a.TendsTo L

open Classical in
noncomputable abbrev lim (a : Sequence) : ℝ :=
  if h : a.Convergent then h.choose else 0

open Sequence Real

lemma ratPow_continuous {x α : ℝ} (hx : x > 0) {q : ℕ → ℚ}
    (hq : ((fun n ↦ (q n : ℝ)) : Sequence).TendsTo α) :
    ((fun n ↦ x ^ (q n : ℝ)) : Sequence).Convergent := by
  sorry

lemma ratPow_lim_uniq {x α : ℝ} (hx : x > 0) {q q' : ℕ → ℚ}
    (hq : ((fun n ↦ (q n : ℝ)) : Sequence).TendsTo α)
    (hq' : ((fun n ↦ (q' n : ℝ)) : Sequence).TendsTo α) :
    lim ((fun n ↦ x ^ (q n : ℝ)) : Sequence) = lim ((fun n ↦ x ^ (q' n : ℝ)) : Sequence) := by
  sorry

theorem Real.eq_lim_of_rat (α : ℝ) : ∃ q : ℕ → ℚ, ((fun n ↦ (q n : ℝ)) : Sequence).TendsTo α := by
  sorry

noncomputable abbrev Real.rpow (x : ℝ) (α : ℝ) : ℝ :=
  lim ((fun n ↦ x ^ ((eq_lim_of_rat α).choose n : ℝ)) : Sequence)

lemma Real.rpow_eq_lim_ratPow {x α : ℝ} (hx : x > 0) {q : ℕ → ℚ}
    (hq : ((fun n ↦ (q n : ℝ)) : Sequence).TendsTo α) :
    rpow x α = lim ((fun n ↦ x ^ (q n : ℝ)) : Sequence) := by
  sorry

lemma Real.ratPow_tendsto_rpow {x α : ℝ} (hx : x > 0) {q : ℕ → ℚ}
    (hq : ((fun n ↦ (q n : ℝ)) : Sequence).TendsTo α) :
    ((fun n ↦ x ^ (q n : ℝ)) : Sequence).TendsTo (rpow x α) := by
  sorry

lemma Real.rpow_of_rat_eq_ratPow {x : ℝ} (hx : x > 0) {q : ℚ} :
    rpow x (q : ℝ) = x ^ (q : ℝ) := by
  sorry

theorem Real.ratPow_add {x : ℝ} (hx : x > 0) (q r : ℝ) : rpow x (q + r) = rpow x q * rpow x r := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Real.ratPow_mul {x y : ℝ} (hx : x > 0) (hy : y > 0) (q : ℝ) : rpow (x * y) q = rpow x q * rpow y q := by
-- </TARGET_THEOREM>

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

namespace TaoBench
theorem ratPow_mul {x y : ℝ} (hx : x > 0) (hy : y > 0) (q : ℝ) :
    Real.rpow (x * y) q = Real.rpow x q * Real.rpow y q := by
end TaoBench
import Mathlib
import Analysis.Section_5_epilogue
import Analysis.Tags.Section_5_epilogue
import Analysis.Section_6_6
import Analysis.Tags.Section_6_6

noncomputable section
open Classical

abbrev Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

namespace Chapter6

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

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

@[coe]
abbrev Sequence.ofNatFun (a:ℕ → ℝ) : Sequence :=
 {
    m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all
 }

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

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

abbrev Sequence.from (a:Sequence) (m₁:ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)

end Chapter6

abbrev Real.CloseSeq (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop := ∀ n ≥ a.m, ε.Close (a n) L

abbrev Real.EventuallyClose (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

namespace Chapter6

abbrev Sequence.TendsTo (a:Sequence) (L:ℝ) : Prop :=
  ∀ ε > (0:ℝ), ε.EventuallyClose a L

abbrev Sequence.Convergent (a:Sequence) : Prop := ∃ L, a.TendsTo L

noncomputable abbrev lim (a:Sequence) : ℝ := if h: a.Convergent then h.choose else 0

-- <CONTEXT>
open Sequence Real

lemma ratPow_continuous {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).Convergent := by
  sorry

lemma ratPow_lim_uniq {x α:ℝ} (hx: x > 0) {q q': ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α)
 (hq': ((fun n ↦ (q' n:ℝ)):Sequence).TendsTo α) :
 lim ((fun n ↦ x^(q n:ℝ)):Sequence) = lim ((fun n ↦ x^(q' n:ℝ)):Sequence) := by
  sorry

theorem Real.eq_lim_of_rat (α:ℝ) : ∃ q: ℕ → ℚ, ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α := by
  sorry

noncomputable abbrev Real.rpow (x:ℝ) (α:ℝ) :ℝ := lim ((fun n ↦ x^((eq_lim_of_rat α).choose n:ℝ)):Sequence)

lemma Real.rpow_eq_lim_ratPow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 rpow x α = lim ((fun n ↦ x^(q n:ℝ)):Sequence) := by
  sorry

lemma Real.ratPow_tendsto_rpow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).TendsTo (rpow x α) := by
  sorry

lemma Real.rpow_of_rat_eq_ratPow {x:ℝ} (hx: x > 0) {q: ℚ} :
  rpow x (q:ℝ) = x^(q:ℝ) := by
  sorry

theorem Real.ratPow_add {x:ℝ} (hx: x > 0) (q r:ℝ) : rpow x (q+r) = rpow x q * rpow x r := by
  sorry

-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Real.ratPow_neg {x:ℝ} (hx: x > 0) (q:ℝ) : rpow x (-q) = 1 / rpow x q := by
-- </TARGET_THEOREM>

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

namespace TaoBench

namespace Chapter6
namespace Real

/-- Proposition 6.7.3(c) / Exercise 6.7.1 (negative real exponents) -/
theorem ratPow_neg {x : ℝ} (hx : x > 0) (q : ℝ) :
    _root_.Real.rpow x (-q) = 1 / _root_.Real.rpow x q := by
end Real
end Chapter6

end TaoBench
import Mathlib.Tactic
import Mathlib.Data.Real.Basic
import Mathlib.Analysis.SpecialFunctions.Pow

/-- We use Mathlib's real distance. -/
abbrev Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

namespace Chapter6

/-- Definition 6.1.3 (Sequence of reals). -/
@[ext]
structure Sequence where
  m : ℤ
  seq : ℤ → ℝ
  vanish : ∀ n < m, seq n = 0

/-- Sequences can be evaluated as functions ℤ → ℝ. -/
instance Sequence.instCoeFun : CoeFun Sequence (fun _ ↦ ℤ → ℝ) where
  coe a := a.seq

@[coe]
abbrev Sequence.ofNatFun (a : ℕ → ℝ) : Sequence :=
  { m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all }

/-- Functions from ℕ → ℝ coerce to sequences. -/
instance Sequence.instCoe : Coe (ℕ → ℝ) Sequence where
  coe := ofNatFun

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

lemma Sequence.eval_mk {n m : ℤ} (a : { n // n ≥ m } → ℝ) (h : n ≥ m) :
    (Sequence.mk' m a) n = a ⟨ n, h ⟩ := by simp [h]

@[simp]
lemma Sequence.eval_coe (n : ℕ) (a : ℕ → ℝ) : (a : Sequence) n = a n := by simp

/-- Start a sequence from a later index. -/
abbrev Sequence.from (a : Sequence) (m₁ : ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)

lemma Sequence.from_eval (a : Sequence) {m₁ n : ℤ} (hn : n ≥ m₁) :
  (a.from m₁) n = a n := by
  simp [hn]; intros; symm; solve_by_elim [a.vanish]

end Chapter6

/-- Definition 6.1.3 (ε-steady, eventually steady) helpers for limits. -/
abbrev Real.CloseSeq (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∀ n ≥ a.m, ε.Close (a n) L

abbrev Real.EventuallyClose (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

namespace Chapter6

/-- Definition 6.1.3 (TendsTo). -/
abbrev Sequence.TendsTo (a : Sequence) (L : ℝ) : Prop :=
  ∀ ε > (0 : ℝ), ε.EventuallyClose a L

/-- Convergent sequence. -/
abbrev Sequence.Convergent (a : Sequence) : Prop := ∃ L, a.TendsTo L

open Classical in
/-- Limit of a sequence (junk value 0 if divergent). -/
noncomputable abbrev lim (a : Sequence) : ℝ :=
  if h : a.Convergent then h.choose else 0

end Chapter6

namespace Chapter6
open Sequence Real

namespace Real

/-- From Mathlib reals, every real is a limit of rationals (as a sequence). -/
-- We use the exact statement from the textbook; the proof is omitted here.
theorem eq_lim_of_rat (α : ℝ) : ∃ q : ℕ → ℚ, ((fun n ↦ (q n : ℝ)) : Chapter6.Sequence).TendsTo α := by
  sorry

/-- Definition 6.7.2 (Exponentiation to a real exponent). -/
noncomputable abbrev rpow (x : ℝ) (α : ℝ) : ℝ :=
  Chapter6.lim ((fun n ↦ x ^ ((eq_lim_of_rat α).choose n : ℝ)) : Chapter6.Sequence)

end Real

/-- Proposition 6.7.3(a) / Exercise 6.7.1. -/
-- We keep the exact statement; the proof is omitted.
theorem Real.ratPow_nonneg {x : ℝ} (hx : x > 0) (q : ℝ) : rpow x q ≥ 0 := by
end Chapter6
import Mathlib
import Analysis.Section_5_epilogue
import Analysis.Tags.Section_5_epilogue
import Analysis.Section_6_6
import Analysis.Tags.Section_6_6

abbrev Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε

namespace Chapter6

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

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

@[coe]
abbrev Sequence.ofNatFun (a : ℕ → ℝ) : Sequence :=
  { m := 0
    seq n := if n ≥ 0 then a n.toNat else 0
    vanish := by simp_all }

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

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

abbrev Sequence.from (a : Sequence) (m₁ : ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)

end Chapter6

abbrev Real.CloseSeq (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∀ n ≥ a.m, ε.Close (a n) L

abbrev Real.EventuallyClose (ε : ℝ) (a : Chapter6.Sequence) (L : ℝ) : Prop :=
  ∃ N ≥ a.m, ε.CloseSeq (a.from N) L

namespace Chapter6

abbrev Sequence.TendsTo (a : Sequence) (L : ℝ) : Prop :=
  ∀ ε > (0 : ℝ), ε.EventuallyClose a L

abbrev Sequence.Convergent (a : Sequence) : Prop := ∃ L, a.TendsTo L

open Classical in
noncomputable abbrev lim (a : Sequence) : ℝ :=
  if h : a.Convergent then h.choose else 0

end Chapter6

namespace Chapter6

open Sequence Real

-- <CONTEXT>
lemma ratPow_continuous {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).Convergent := by
  sorry

lemma ratPow_lim_uniq {x α:ℝ} (hx: x > 0) {q q': ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α)
 (hq': ((fun n ↦ (q' n:ℝ)):Sequence).TendsTo α) :
 lim ((fun n ↦ x^(q n:ℝ)):Sequence) = lim ((fun n ↦ x^(q' n:ℝ)):Sequence) := by
  sorry

theorem Real.eq_lim_of_rat (α:ℝ) : ∃ q: ℕ → ℚ, ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α := by
  sorry

noncomputable abbrev Real.rpow (x:ℝ) (α:ℝ) :ℝ := lim ((fun n ↦ x^((eq_lim_of_rat α).choose n:ℝ)):Sequence)

lemma Real.rpow_eq_lim_ratPow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 rpow x α = lim ((fun n ↦ x^(q n:ℝ)):Sequence) := by
  sorry

lemma Real.ratPow_tendsto_rpow {x α:ℝ} (hx: x > 0) {q: ℕ → ℚ}
 (hq: ((fun n ↦ (q n:ℝ)):Sequence).TendsTo α) :
 ((fun n ↦ x^(q n:ℝ)):Sequence).TendsTo (rpow x α) := by
  sorry

lemma Real.rpow_of_rat_eq_ratPow {x:ℝ} (hx: x > 0) {q: ℚ} :
  rpow x (q:ℝ) = x^(q:ℝ) := by
  sorry
-- </CONTEXT>
-- <TARGET_THEOREM>
theorem Real.ratPow_nonneg {x:ℝ} (hx: x > 0) (q:ℝ) : rpow x q ≥ 0 := by
-- </TARGET_THEOREM>

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

namespace TaoBench

namespace Chapter6
namespace Real

/-- Proposition 6.7.3(a) / Exercise 6.7.1, using Mathlib's `Real.rpow`. -/
theorem ratPow_nonneg {x : ℝ} (hx : x > 0) (q : ℝ) :
    Real.rpow x q ≥ 0 := by
end Real
end Chapter6

end TaoBench