Zulip Chat Archive
Stream: mathlib4
Topic: Changing `Stream.Seq` to use `GetElem`
Eric Wieser (Sep 10 2025 at 00:03):
Would this be a desirable change? docs#Stream' describes itself as an infinite list, so presumably it shoudl present s[i] notation to match lsits?
Eric Wieser (Sep 10 2025 at 00:08):
(I guess this is a question for @Mario Carneiro)
Jakub Nowak (Sep 10 2025 at 01:41):
You mean to add GetElem to Stream' or Stream'.Seq?
Mario Carneiro (Sep 10 2025 at 06:37):
I think it's fine to offer that. I don't like it as the default because it will have bad defeqs in the latter case
Eric Wieser (Sep 10 2025 at 08:06):
What would be bad about the defeq?
Eric Wieser (Sep 11 2025 at 23:03):
Does #29484 look like a viable direction?
Eric Wieser (Sep 11 2025 at 23:03):
This also switches it to a one-field structure to prevent accidentally mixing s i and s[i]
Eric Wieser (Sep 11 2025 at 23:06):
Unfortunately this gets quite annoying for recursive stream definitions, since the termination checker doesn't like
def Fix.approx : Stream' (∀ a, Part (β a)) where
get'
| 0 => ⊥
| Nat.succ i => f approx[i] -- `(approx i)` was no problem before
Aaron Liu (Sep 11 2025 at 23:06):
uhoh
Aaron Liu (Sep 11 2025 at 23:07):
can we rewrite that as a function Nat -> ∀ a, Part (β a)
Eric Wieser (Sep 11 2025 at 23:07):
Sure, I can write
def Fix.approx : Stream' (∀ a, Part (β a)) where
get'
where
get'
| 0 => ⊥
| Nat.succ i => f (get' i)
@[simp] theorem Fix.get_succ_approx (n : ℕ) : (Fix.approx f)[n + 1] = f ((Fix.approx f)[n]) :=
rfl
but I have to write the equation lemma manually
Eric Wieser (Sep 11 2025 at 23:08):
Or a slightly more cursed spelling,
def Fix.approx : Stream' (∀ a, Part (β a)) where get' where
get'
| 0 => ⊥
| Nat.succ i => f (get' i)
-- still need the simp lemma
Aaron Liu (Sep 11 2025 at 23:08):
I like the cursed version
Aaron Liu (Sep 11 2025 at 23:09):
can we get @[simps] to do these equations for us
Eric Wieser (Sep 11 2025 at 23:09):
It would have to know to replace the inner get' with the high-level notation operator
Eric Wieser (Sep 11 2025 at 23:09):
I'd rather the equation compiler could do it for me
Aaron Liu (Sep 11 2025 at 23:09):
which one
Aaron Liu (Sep 11 2025 at 23:10):
the structural recursion or the well-founded recursion
Eric Wieser (Sep 11 2025 at 23:11):
Let's move this to
Last updated: Dec 20 2025 at 21:32 UTC