Zulip Chat Archive

Stream: new members

Topic: Rewrite "within" in Tendsto nhdsWithin


Adomas Baliuka (Nov 27 2023 at 20:47):

I want to prove

import Mathlib

open Real Filter Classical Set Topology

lemma tendsto_abs_logx_rpow {r : โ„} (hr: 0 < r)
: Tendsto (fun x => |log x| * |x| ^ r) (๐“[>] 0) (๐“ 0) := by
    sorry

I want to "rewrite" using the fact that I only care about x > 0. So I want to do something like rw and reduce the goal to Tendsto (fun x => |log x| * x ^ r) (๐“[>] 0) (๐“ 0). Then, I want to do a by-cases analysis of x < 1 or x > 1, which removes the absolute value around log. Then the rest follows from tendsto_log_mul_rpow_nhds_zero.

I didn't find a way to do this "rewrite". Is the following theorem true? I was looking for something like that. I also didn't find anything looking for "eventually equal" (a lemma that might be called "tendsto_nhdsWithin_of_eventuallyEqual").

lemma tendstoNhdsWithin_of_eq_within
    {f g : โ„ โ†’ โ„} {l : โ„} {S : Set โ„} {x : โ„}
    (eq_within : โˆ€xโˆˆS, f x = g x)
    (tenF : Tendsto g (๐“[S] x) (๐“ l))
    : Tendsto f (๐“[S] x) (๐“ l) := by
    sorry

Maybe this isn't the idiomatic approach?

Patrick Massot (Nov 27 2023 at 21:21):

That second lemma isn't true. The eq_within assumption isn't strong enough.

Eric Wieser (Nov 27 2023 at 21:29):

docs#Filter.Tendsto.congr' might be what you're looking for?

Patrick Massot (Nov 27 2023 at 21:31):

Sorry, I got interrupted by a student question. Yes, the lemma that Eric pointed out is the main relevant lemma.

Eric Wieser (Nov 27 2023 at 21:31):

This works:

lemma tendstoNhdsWithin_of_eq_within
    {f g : โ„ โ†’ โ„} {l : โ„} {S : Set โ„} {x : โ„}
    (eq_within : โˆ€xโˆˆS, f x = g x)
    (tenF : Tendsto g (๐“[S] x) (๐“ l)) :
    Tendsto f (๐“[S] x) (๐“ l) :=
  tenF.congr' (Set.EqOn.symm eq_within).eventuallyEq_nhdsWithin

Adomas Baliuka (Nov 27 2023 at 21:35):

Patrick Massot said:

That second lemma isn't true. The eq_within assumption isn't strong enough.

Which lemma isn't true? Eric Wieser proved what I would have called "the second lemma" from my post.

Eric Wieser (Nov 27 2023 at 21:39):

Which seems to contradict Patrick's claim that it's false: perhaps this was fixed in an edit that Zulip is not loading for me; or maybe there's a junk value coming into play somewhere

Patrick Massot (Nov 27 2023 at 21:40):

Sorry, I read your lemma too quickly. I shouldn't try to answer questions on Zulip and questions from students in parallel.

Patrick Massot (Nov 27 2023 at 21:42):

I think I was misled by the surrounding text and this influenced my reading of the Lean code. Why did you discuss splitting depending on x < 1?

Adomas Baliuka (Nov 27 2023 at 21:43):

It's not really splitting I guess, it's just saying "wlog x < 1". I want to use it to remove the absolute value around the log. (Will post solution later if I manage to get it)

Jireh Loreaux (Nov 27 2023 at 21:45):

I think you just want to apply docs#squeeze_zero_norm'

Jireh Loreaux (Nov 27 2023 at 21:47):

oh, or even just docs#Filter.Tendsto.norm, which makes more sense

Adomas Baliuka (Nov 27 2023 at 21:53):

Thanks! As an aside, I just saw squeeze_one_norm' (and squeeze_zero_norm', which have the same docstring, which might be a typo?). I'm really confused why squeeze_one_norm' is true (must be misunderstanding it). Maybe I'll have to learn filters properly after all

Jireh Loreaux (Nov 27 2023 at 21:54):

Yes, the docstring should be fixed. Note the difference between SeminormedGroup and SeminormedAddGroup.

Adomas Baliuka (Nov 27 2023 at 21:55):

Can/should one PR individual small doc typos like this?

Jireh Loreaux (Nov 27 2023 at 21:59):

Yes, definitely. You can mark it as easy.

Jireh Loreaux (Nov 27 2023 at 21:59):

import Mathlib

open Real Filter Classical Set Topology

lemma tendsto_abs_logx_rpow {r : โ„} (hr: 0 < r) :
    Tendsto (fun x => |log x| * |x| ^ r) (๐“[>] 0) (๐“ 0) := by
  convert (tendsto_log_mul_rpow_nhds_zero hr).norm.congr' ?_
  ยท simp
  ยท filter_upwards [self_mem_nhdsWithin] with x hx
    simp_rw [norm_mul, norm_rpow_of_nonneg (mem_Ioi.mp hx).le, norm_eq_abs]

Patrick Massot (Nov 27 2023 at 22:00):

I'm sorry I keep being interrupted, but I'm in office hours. Closer to the intended proof is:

import Mathlib

open Real Filter Classical Set Topology

lemma tendsto_abs_logx_rpow {r : โ„} (hr: 0 < r) :
    Tendsto (fun x โ†ฆ |log x| * |x| ^ r) (๐“[>] 0) (๐“ 0) := by
  suffices Tendsto (fun x โ†ฆ -log x * x ^ r) (๐“[>] 0) (๐“ 0) by
    apply this.congr'
    rw [eventuallyEq_nhdsWithin_iff]
    have : Ioo (-1) 1 โˆˆ  ๐“ (0 : โ„) := by
      apply Ioo_mem_nhds <;> norm_num
    apply mem_of_superset this
    rintro x โŸจ-, hxโŸฉ (hx' : 0 < x)
    rw [abs_of_pos hx', abs_of_neg (log_neg hx' hx)]
  convert (tendsto_log_mul_rpow_nhds_zero hr).neg using 1
  simp

I hope this will be useful for future proofs.

Adomas Baliuka (Nov 27 2023 at 22:01):

Wow, thanks a lot! I didn't even ask for the proof of this :)

Adomas Baliuka (Nov 27 2023 at 22:11):

Oh, the reason for that "typo" is actually that squeeze_zero_norm' is auto-generated by to_additive. I guess it's fine then

Riccardo Brasca (Nov 27 2023 at 22:21):

You can still fix the docstring!

Adomas Baliuka (Nov 27 2023 at 22:22):

You mean write it so it matches both cases? Or is there some trick to customize to_additive?

Riccardo Brasca (Nov 27 2023 at 22:23):

@[to_additive "blah blah"]

Patrick Massot (Nov 27 2023 at 22:31):

There is already a hand-written docstring there, but it's wrong.

Adomas Baliuka (Nov 27 2023 at 22:33):

I made a PR


Last updated: Dec 20 2023 at 11:08 UTC