-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - feat(algebra/module/linear_map): Add linear_map.iterate #6377
Conversation
Co-authored-by: Alex J. Best <alex.j.best@gmail.com>
src/algebra/module/linear_map.lean
Outdated
variables [semimodule R M] (f : M →ₗ[R] M) | ||
|
||
/-- Iteration of a linear map is a linear map -/ | ||
def iterate : ℕ → (M →ₗ[R] M) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How reasonable is it to define this as (\lam g, g.comp f)^[n]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed what I think you meant; I don't feel strongly either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being unclear, I meant
def iterate (n : ℕ) (f : M →ₗ[R] M) : M →ₗ[R] M :=
(λ g, linear_map.comp g f)^[n] linear_map.id
or perhaps
def iterate (n : ℕ) (f : M →ₗ[R] M) : M →ₗ[R] M :=
f.comp^[n] linear_map.id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But your new version has the nice benefit of making iterate_to_fun
a rfl lemma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. I have no preference
src/algebra/module/linear_map.lean
Outdated
lemma iterate_succ' (n) : (iterate f (n + 1)) = comp f (iterate f n) := | ||
by rw [add_comm, iterate_add, iterate_one] | ||
|
||
@[simp] lemma iterate_to_fun : ∀ n, (iterate f n).to_fun = nat.iterate f.to_fun n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@[simp] lemma iterate_to_fun : ∀ n, (iterate f n).to_fun = nat.iterate f.to_fun n | |
@[simp] lemma iterate_to_fun : ∀ n, iterate f n = (⇑f)^[n] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have needed more changes; reverted until I can look more closely.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
This reverts commit c55dd4c.
For comparison, this is what I had written in a branch: namespace linear_map
universes u v
def iterate {R : Type u} [semiring R]
{M : Type v} [add_comm_monoid M] [semimodule R M] (f : M →ₗ[R] M) : ℕ → (M →ₗ[R] M)
| 0 := linear_map.id
| (n+1) := (iterate n).comp f
@[simp] lemma iterate_apply {R : Type u} [semiring R]
{M : Type v} [add_comm_monoid M] [semimodule R M] (f : M →ₗ[R] M) (n : ℕ) (m : M) :
f.iterate n m = ((f : M → M)^[n] m) :=
begin
induction n with n ih generalizing m,
{ refl, },
{ apply ih, },
end
instance {R : Type u} [semiring R] {M : Type v} [add_comm_monoid M] [semimodule R M] :
has_pow (M →ₗ[R] M) ℕ :=
{ pow := λ f n, f.iterate n, }
@[simp] lemma pow_apply {R : Type u} [semiring R]
{M : Type v} [add_comm_monoid M] [semimodule R M] (f : M →ₗ[R] M) (n : ℕ) (m : M) :
(f^n) m = ((f : M → M)^[n] m) :=
iterate_apply f n m
end linear_map |
I've realised that we already have a Perhaps we don't actually need this PR?
|
I changed some names: lemmas that conclude |
bors merge |
bors r-, there's a line length issue |
Canceled. |
✌️ Ruben-VandeVelde can now approve this pull request. To approve and merge a pull request, simply reply with |
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
bors r+ |
Co-authored-by: Alex J. Best <alex.j.best@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Pull request successfully merged into master. Build succeeded: |
Co-authored-by: Alex J. Best <alex.j.best@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Alex J. Best alex.j.best@gmail.com
Extracted from #1822.