Zulip Chat Archive
Stream: Is there code for X?
Topic: Fixed point
Patrick Johnson (Jun 13 2022 at 10:32):
Do we have these?
def get_some {α : Type} [inhabited α] (P : α → Prop) : α :=
if h : ∃ (x : α), P x then h.some else default
def fixed {α : Type} [inhabited α] (f : α → α) (z : α) : α :=
get_some (λ (x : α), ∃ (n : ℕ), (f^[n]) z = x ∧ (f^[n + 1]) z = x)
Floris van Doorn (Jun 13 2022 at 18:29):
get_some
is basically docs#classical.epsilon.
Floris van Doorn (Jun 13 2022 at 18:33):
I don't think the second definition exists, but there are some related notions in file#dynamics/fixed_points/basic.
Patrick Johnson (Jun 16 2022 at 14:20):
Ok then, I'd like to add the following two defs to function.iterate
def function.iterate_tendsto {α : Type*} (f : α → α) (z x : α) : Prop :=
∃ (n : ℕ), (f^[n]) z = x ∧ (f^[n + 1]) z = x
def function.iterate_limit {α : Type*} [inhabited α] (f : α → α) (z : α) : α :=
classical.epsilon (function.iterate_tendsto f z)
because I feel like they are useful, but apparently missing in mathlib. I would also prove few lemmas about them. Should I rename them to something else (or put them in dynamics/fixed_points
instead)? Or is there any reason we don't want them in mathlib?
Patrick Johnson (Jun 16 2022 at 14:21):
An example usage is the digital root of a natural number.
Eric Wieser (Jun 16 2022 at 22:19):
For the digital root I would assume you could just use well-founded recursion
Last updated: Dec 20 2023 at 11:08 UTC