Zulip Chat Archive
Stream: new members
Topic: How to introduce a list of numbers or a list of functions?
Yagub Aliyev (Feb 17 2024 at 17:20):
What is the best way to introduce a list (or a finite sequence) of rationals a[i] b[i]: ℚ
and functions f[i](x) =a[i]*x+b[i]
from ℚ
to ℚ
?
Eric Wieser (Feb 17 2024 at 17:33):
a b : Fin n -> ℚ
might be a good choice for the sequence
Yagub Aliyev (Feb 17 2024 at 17:48):
Should n
be introduced before? What about functions?
import Mathlib
lemma formula1 (n : ℕ) (x : ℚ) (a b : Fin n -> ℚ)
Eric Wieser (Feb 17 2024 at 17:49):
Do you want to "introduce" a function, or "define" a function?
Eric Wieser (Feb 17 2024 at 17:49):
Your =
suggests the latter
Yagub Aliyev (Feb 17 2024 at 17:51):
Sorry, I am still learning the terminology. Yes, define. I have a formula for it f[i](x) =a[i]*x+b[i]
.
Eric Wieser (Feb 17 2024 at 17:52):
def f {n : ℕ} (a b : Fin n -> ℚ) (i : Fin n) (x : ℚ) : ℚ := a i * x + b i
should work
Eric Wieser (Feb 17 2024 at 17:52):
Here, your is f a b i x
Yagub Aliyev (Feb 17 2024 at 17:54):
Thank you! I have plans to work with indices modulo n
so I want them be between 0
and n-1
. Is there a way to make Lean to start i
from 0
?
Eric Wieser (Feb 17 2024 at 17:54):
It already does :)
Eric Wieser (Feb 17 2024 at 17:54):
Yagub Aliyev (Feb 17 2024 at 17:55):
Oh! I am so lucky! :-)
Last updated: May 02 2025 at 03:31 UTC