Zulip Chat Archive

Stream: general

Topic: define a recursive function inside a proof


Miguel Marco (Dec 14 2023 at 17:08):

I am trying to prove that in a first countable space, for every cluster point x of a sequence, there is a subsequence for which x is a limit.

I have managed to construct a decreasing sequence of neighborhoods that form a a basis, so i can use it to construct the subsequence using the axiom of choice... but my problem is how to make sure that the indices in the subsequence are increasing.

So I basically have the following:

X: Type
s:   X
x: X
f:   set X
hf:  (n : ), f n  ⋂₀ {_x : set X |  (j : ) (H : j < n), f j = _x}
haux:  (n : ),  (n0 : ), n < n0  s n0  f n

and I need to construct a sequence k : ℕ → ℕ as follows:

  • k 0 should be the n0 that is ensured to exists by haux with n = 0
  • k (succ n1) should be the n0 that exists because of haux with n = k n1

I am trying to define such a sequence, but apparently Lean doesn't like to define recursive functions inside a tactic proof.

What is the right way to do this?

Yaël Dillies (Dec 14 2023 at 17:09):

Why do you care about it being increasing in the first place?

Miguel Marco (Dec 14 2023 at 17:21):

It is part of the definition of subsequence.

Kyle Miller (Dec 14 2023 at 17:23):

The choose tactic might be useful, since it can take haux and give you a function Nat -> Nat, but you might need to transform it more.

Miguel Marco (Dec 14 2023 at 18:05):

Yes, that was my idea, but as you said, it doesn't work right away. Somehow I need the previous values of the chosing function to define the next one.

Kevin Buzzard (Dec 14 2023 at 18:19):

You could just use the recursor Nat.rec directly in the proof, or make an auxiliary definition outside the proof which takes f and haux as inputs and spits out the function.

Patrick Massot (Dec 14 2023 at 19:11):

@Miguel Marco this is almost surely in Mathlib already. Are you doing that as an exercise or would you be happy to get it from Mathlib?

Miguel Marco (Dec 14 2023 at 19:36):

I am happy to get it from mathlib, but didn't find it.

I mean, I am happy to get the subsequence from mathlib. The fact that cluster points are limit points of a subsquence is the exercise I want to do.

Patrick Massot (Dec 14 2023 at 19:42):

You probably want to play with docs#Filter.extraction_forall_of_frequently and surrounding lemmas then.

Patrick Massot (Dec 14 2023 at 19:44):

Maybe docs@Filter.extraction_forall_of_eventually'

Patrick Massot (Dec 14 2023 at 19:44):

There are tons of variations in that file.

Miguel Marco (Dec 14 2023 at 20:29):

I see... It looks like the exact variation I need is missing: docs#Filter.extraction_forall_of_eventually' requires a stronger hypothesis, and docs#Filter.extraction_forall_of_frequently , which would be the one I need (I think), has the hypothesis written in terms of filters instead of sequences.

I guess I will need to do some work translating from filter language to sequences.

Patrick Massot (Dec 14 2023 at 20:40):

There should be a lemma doing the translation already. Something like Filter.frequently_atTop (only guessing the name).

Miguel Marco (Dec 14 2023 at 21:24):

It did work, thank you!

Do you think it would be worth adding the version with sequences to mathlib?


Last updated: Dec 20 2023 at 11:08 UTC