Zulip Chat Archive
Stream: mathlib4
Topic: Nat.repeat vs Nat.iterate
Yuyang Zhao (Jul 09 2023 at 12:49):
Why do we have both docs#Nat.repeat and docs#Nat.iterate ?
Eric Wieser (Jul 09 2023 at 12:53):
It looks like Mathlib/Init/Data/Nat/Lemmas.lean
is an ad-hoc port, which is probably why it has left this mess behind
Ruben Van de Velde (Jul 09 2023 at 12:53):
No, we already had both in lean 3 core
Ruben Van de Velde (Jul 09 2023 at 12:55):
Oh, but docs3#nat.repeat and docs#Nat.repeat don't match
Ruben Van de Velde (Jul 09 2023 at 12:58):
The new repeat was probably added with no concern for what existed in mathlib 3. Maybe it's worth filling an issue about
Eric Wieser (Jul 09 2023 at 14:02):
Eric Wieser said:
It looks like
Mathlib/Init/Data/Nat/Lemmas.lean
is an ad-hoc port
I've started a re-port at #5782
Eric Wieser (Jul 09 2023 at 16:51):
This now gives a panic‽
Eric Wieser (Jan 02 2024 at 11:59):
Ran into this again today. Should we delete docs#Nat.iterate, or should we file a bug against core to restore the old meaning of repeat
?
Yaël Dillies (Jan 02 2024 at 12:17):
I have a slight preference for Nat.repeat
since it means repeat f n.succ a
is defeq to f _
.
Mario Carneiro (Jan 02 2024 at 12:19):
The other definition is tail recursive though, which is important
Mario Carneiro (Jan 02 2024 at 12:19):
we can fix that using a csimp lemma though
Eric Rodriguez (Jan 02 2024 at 12:21):
does Lean have TCO?
Yury G. Kudryashov (Jan 02 2024 at 16:58):
There is a @[csimp]
for Nat.repeat
in the core.
Yury G. Kudryashov (Jan 02 2024 at 17:01):
And repeatTR
is defined the same way as Nat.iterate
.
Yury G. Kudryashov (Jan 02 2024 at 17:02):
I like the name iterate
but I'm OK with migrating to repeat
.
Yaël Dillies (Jan 02 2024 at 17:10):
I think iterate
is a better name mathematically.
Yury G. Kudryashov (Jan 02 2024 at 17:11):
OTOH, we can redefine Nat.iterate
to be as Nat.repeat
.
Yury G. Kudryashov (Jan 02 2024 at 17:12):
And move some lemmas about it (in the Nat.repeat
spelling) to Std4
.
Jz Pan (Jan 09 2025 at 12:56):
Sorry to ping this thread again...
Yury G. Kudryashov said:
OTOH, we can redefine
Nat.iterate
to be asNat.repeat
.
msybe just abbrev Nat.iterate
to Nat.repeat
.
There is only one difference of them: Nat.iterate
also works for Prop
. Do we have such use case?
Last updated: May 02 2025 at 03:31 UTC