Zulip Chat Archive

Stream: new members

Topic: how to name a theorem about real number


Wenrong Zou (Jan 08 2024 at 14:09):

Hi, everyone!
I am new in lean. I have written a proof of theorem (this is one of sub-theorem of my main theorem). However, I don't know whether it is exist in the library and I don't know how to name one of theorems. If there is not a theorem in library, where should I put this theorem. Thanks in advance!!

import Mathlib.Data.Rat.NNRat
import Mathlib.Tactic
import Mathlib.Topology.Order.Basic

open Filter

/- For any given real number, there exist a number sequence of rational number converge to that real number from above.-/
theorem Real.rat_seq_above_tendsto (b : ) :  a :   , ( n, (b : ) < a n)  Tendsto (fun n  (a n : )) atTop (nhds b) := by
  have :  a :   , ( n, (b : ) < a n)  Tendsto a atTop (nhds b)
  · have h :  a, StrictAnti a  ( (n : ), b < a n)  Filter.Tendsto a Filter.atTop (nhds b) := exists_seq_strictAnti_tendsto b
    rcases h with a, _, h₁, h₂
    use a
  choose a hab ha using this
  choose r hr hr' using fun n  exists_rat_btwn (hab n)
  refine r, hr, tendsto_of_tendsto_of_tendsto_of_le_of_le (g := fun _  b) ?_ ha ?_ ?_
  · simp
  · exact fun n  (hr n).le
  · exact fun n  (hr' n).le

/- For any given real number, there exist a number sequence of rational number converge to that real number from below.-/
theorem Real.rat_seq_below_tendsto (b : ) :  a :   , ( n, (b : ) > a n)  Tendsto (fun n  (a n : )) atTop (nhds b) := by
  have :  a :   , ( n, (b : ) > a n)  Tendsto a atTop (nhds b)
  · have h :  a, StrictMono a  ( (n : ), a n < b)  Filter.Tendsto a Filter.atTop (nhds b) := exists_seq_strictMono_tendsto b
    rcases h with a, _, h₁, h₂
    use a
  choose a hab ha using this
  choose r hr hr' using fun n  exists_rat_btwn (hab n)
  refine r, hr', tendsto_of_tendsto_of_tendsto_of_le_of_le (h := fun _  b) ha ?_ ?_ ?_
  · simp
  · exact fun n  (hr n).le
  · exact fun n  (hr' n).le

Yakov Pechersky (Jan 08 2024 at 15:02):

Likely this can be generalized to a statement about dense sets


Last updated: May 02 2025 at 03:31 UTC