Zulip Chat Archive
Stream: Is there code for X?
Topic: Real as limit of sequence of rationals
Xavier Roblot (Aug 17 2022 at 15:55):
I am having a hard time working with limits in mathlib. For example, how would I write the fact that a real number is a limit of a sequence of rationals?
Adam Topaz (Aug 17 2022 at 16:01):
This is true by definition ;)
import data.real.basic
example (a : ℝ) : ∃ s : cau_seq ℚ abs, real.mk s = a :=
begin
rcases a with ⟨⟨a⟩⟩, use a, refl,
end
Adam Topaz (Aug 17 2022 at 16:01):
I don't know if we have such a lemma though
Adam Topaz (Aug 17 2022 at 16:01):
Besides, one should probably use filters as opposed to sequences
Xavier Roblot (Aug 17 2022 at 16:10):
Yes, I realised that my question was a bit stupid since it is actually how the reals are defined in mathlib...
Ok, so what I have in mind is: how to prove the following lemma using the fact that reals are limits of sequence of rationals?
import topology.metric_space.basic
example (f : ℝ → ℝ) (h1 : continuous f) (h2 : ∀ q : ℚ, f q = q) : ∀ x : ℝ, f x = x := sorry
Junyan Xu (Aug 17 2022 at 16:27):
I found docs#dense_inducing.extend_unique the other day
Junyan Xu (Aug 17 2022 at 16:30):
Oh and we have docs#rational_cau_seq_pkg and docs#abstract_completion.dense_inducing ! See below for a better solution using docs#rat.dense_embedding_coe_real directly.
Jireh Loreaux (Aug 17 2022 at 16:30):
There's also docs#dense_inducing.extend_eq (for the first approach)
Jireh Loreaux (Aug 17 2022 at 16:34):
But was your point that you want to do this explicitly via limits of sequences of rational for pedagogical reasons?
Junyan Xu (Aug 17 2022 at 16:34):
Sorry? extend_eq seems just asserting the constructed extend
is actually an extension. I can't see how it helps...
Xavier Roblot (Aug 17 2022 at 16:36):
These results looks great but still very powerful for the purpose. Surely, there is a way to use docs#continuous.lim_eq and the fact that x
is a limit a sequence of rationals? And, as suggested by @Jireh Loreaux , I certainly need to know more about using limits in mathlib so having a proof using limits would make me even more happy :grinning:
In fact, I don't know even how to simply state the fact that the real x
is the limit of rational numbers using filters.
Jireh Loreaux (Aug 17 2022 at 16:37):
@Junyan Xu If you use docs#dense_inducing.extend_unique you get that extension of some function (in this case, the identity) on the rationals is equal to some other function (in our case, f
), but then you need to know that the extension of the identity on rationals is the identity on the reals. Hence docs#dense_inducing.extend_eq.
Junyan Xu (Aug 17 2022 at 16:39):
The identity function on the reals is also a continuous function that is identity on the rationals. So both it and f
equals extend
, so they're equal.
Jireh Loreaux (Aug 17 2022 at 16:40):
This says the real number x
is the limit of some sequence of rational numbers.
example (x : ℝ) : ∃ (seq : ℕ → ℚ), filter.tendsto (λ n, (seq n : ℝ)) filter.at_top (𝓝 x) := sorry
Junyan Xu (Aug 17 2022 at 16:40):
I admit I didn't think of this argument and thought something is missing when I saw docs#dense_inducing.extend_unique the first time ...
Jireh Loreaux (Aug 17 2022 at 16:43):
But do you need this for pedagogical purposes? That is, are you trying to teach something to students with this? If not, I would encourage going the abstract route; it's frequently the way to go.
Xavier Roblot (Aug 17 2022 at 16:44):
Jireh Loreaux said:
This says the real number
x
is the limit of some sequence of rational numbers.example (x : ℝ) : ∃ (seq : ℕ → ℚ), filter.tendsto (λ n, (seq n : ℝ)) filter.at_top (𝓝 x) := sorry
Thanks. Do you need some special code to make the 𝓝
works? I get unknown identifier '𝓝'
on my side.
Xavier Roblot (Aug 17 2022 at 16:45):
Jireh Loreaux said:
But do you need this for pedagogical purposes? That is, are you trying to teach something to students with this? If not, I would encourage going the abstract route; it's frequently the way to go.
Indeed. Let's say I'll do both :grinning_face_with_smiling_eyes:
Patrick Massot (Aug 17 2022 at 16:45):
Guys, you should stop frightening Xavier now.
Patrick Massot (Aug 17 2022 at 16:45):
import topology.instances.rat
example (f : ℝ → ℝ) (h1 : continuous f) (h2 : ∀ q : ℚ, f q = q) : ∀ x : ℝ, f x = x :=
by simp [rat.dense_embedding_coe_real.dense.equalizer h1 continuous_id (by ext q ; simpa using h2 q)]
Jireh Loreaux (Aug 17 2022 at 16:47):
For 𝓝
, use open_locale topological_space
Xavier Roblot (Aug 17 2022 at 16:47):
Well, I guess that answer the question but I am still going to need a little time to process that answer.
Anyway, thanks everybody. I think I have enough to produce three different proofs of the lemma now.
Adam Topaz (Aug 17 2022 at 16:49):
BTW, this fails for some reason...
import topology.uniform_space.compare_reals
example (f : ℝ → ℝ) (h1 : continuous f) (h2 : ∀ q : ℚ, f q = q) :
∀ x : ℝ, f x = x :=
begin
intros x,
have := rational_cau_seq_pkg.induction_on x,
sorry
end
Adam Topaz (Aug 17 2022 at 16:49):
synthesized type class instance is not definitionally equal to expression inferred by typing rules, synthesized
pseudo_metric_space.to_uniform_space
inferred
is_absolute_value.uniform_space abs
Patrick Massot (Aug 17 2022 at 16:50):
Xavier, you can make it easier to decipher by stating both the assumption and the conclusion in a more convenient way:
example (f : ℝ → ℝ) (h1 : continuous f) (h2 : f ∘ (coe : ℚ → ℝ) = id ∘ coe) : f = id :=
rat.dense_embedding_coe_real.dense.equalizer h1 continuous_id h2
Patrick Massot (Aug 17 2022 at 16:50):
This means that simp
and simpa
in my first snippet are only used to bridge that gap.
Patrick Massot (Aug 17 2022 at 16:51):
Adam, this sounds pretty bad. It means then when we refactored to introduce pseudo_metric_space
we created some bad diamond. But it should move to another thread.
Adam Topaz (Aug 17 2022 at 16:52):
I'll repost in general
Xavier Roblot (Aug 17 2022 at 21:14):
@Patrick Massot, in rat.dense_embedding_coe_real.dense.equalizer
, I think I see where the part rat.dense_embedding_coe_real
comes from, but I cannot find to which function the part dense.equalizer
relates to.
Jireh Loreaux (Aug 17 2022 at 21:21):
It's docs#dense_range.equalizer
Jireh Loreaux (Aug 17 2022 at 21:22):
If you have it open in VS Code, you should be able to hover over the pieces to see what the declaration is.
Jireh Loreaux (Aug 17 2022 at 21:24):
It's also using the fact that docs#dense_embedding extends docs#dense_inducing, which has a field dense
that says the map has docs#dense_range. Do you know about dot notation in Lean, and how that works?
Xavier Roblot (Aug 17 2022 at 21:28):
Thanks for the explanation.
Jireh Loreaux said:
Do you know about dot notation in Lean, and how that works?
Well, I thought I did. Maybe I'll have to think about it a bit more to understand what happens here.
Jireh Loreaux (Aug 17 2022 at 21:35):
This is the dot notation unfolded:
dense_range.equalizer (dense_inducing.dense (dense_embedding.to_dense_inducing rat.dense_embedding_coe_real)) h1 continuous_id h2
Note that with dot notation, the explicit map dense_embedding.to_dense_inducing
can be omitted because the structure dense_embedding
extends dense_inducing
and dense_inducing.dense
is one of the fields of the latter.
Jireh Loreaux (Aug 17 2022 at 21:39):
So, rat.dense_embedding_coe_real
is a dense_embedding
which we can plug into dense_inducing.dense
(because Lean sees this .dense
as a field of dense_embedding
also, as described above). This results in rat.dense_embedding_coe_real.dense : dense_range (coe : ℚ → ℝ)
, which we can then plug into dense_range.equalizer
.
Jireh Loreaux (Aug 17 2022 at 21:39):
Does that make sense?
Xavier Roblot (Aug 17 2022 at 21:40):
It does. Thanks a lot :tada:
Matt Diamond (Aug 19 2022 at 00:00):
FYI you can use docs#rat.dense_range_cast to get your dense_range
proof without needing to go through the embedding
Last updated: Dec 20 2023 at 11:08 UTC