Skip to content
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

Closed
wants to merge 9 commits into from

Conversation

Ruben-VandeVelde
Copy link
Collaborator

Co-authored-by: Alex J. Best alex.j.best@gmail.com


Extracted from #1822.

Co-authored-by: Alex J. Best <alex.j.best@gmail.com>
variables [semimodule R M] (f : M →ₗ[R] M)

/-- Iteration of a linear map is a linear map -/
def iterate : ℕ → (M →ₗ[R] M)
Copy link
Member

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]?

Copy link
Collaborator Author

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.

Copy link
Member

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

Copy link
Member

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

Copy link
Collaborator Author

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

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@[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]

Copy link
Collaborator Author

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.

Ruben-VandeVelde and others added 2 commits February 23, 2021 17:54
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@semorrison
Copy link
Collaborator

semorrison commented Feb 24, 2021

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

@bryangingechen bryangingechen added the awaiting-author A reviewer has asked the author a question or requested changes label Feb 25, 2021
@semorrison
Copy link
Collaborator

semorrison commented Feb 27, 2021

I've realised that we already have a instance : monoid (M →ₗ[R] M) in src/linear_algebra/basic.lean.

Perhaps we don't actually need this PR?

iterate_surj and friends are worth saving, however.

@Ruben-VandeVelde Ruben-VandeVelde added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Mar 17, 2021
@semorrison
Copy link
Collaborator

I changed some names: lemmas that conclude injective should actually have _injective in the name.

@semorrison
Copy link
Collaborator

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Mar 20, 2021
@eric-wieser
Copy link
Member

bors r-, there's a line length issue

@bors
Copy link

bors bot commented Mar 20, 2021

Canceled.

@bryangingechen bryangingechen added awaiting-author A reviewer has asked the author a question or requested changes and removed ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) labels Mar 20, 2021
@bors
Copy link

bors bot commented Mar 20, 2021

✌️ Ruben-VandeVelde can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@bryangingechen bryangingechen added the delegated The PR author may merge after reviewing final suggestions. label Mar 20, 2021
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
@bryangingechen
Copy link
Collaborator

bors r+

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-author A reviewer has asked the author a question or requested changes labels Mar 21, 2021
bors bot pushed a commit that referenced this pull request Mar 21, 2021
Co-authored-by: Alex J. Best <alex.j.best@gmail.com>





Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Mar 21, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(algebra/module/linear_map): Add linear_map.iterate [Merged by Bors] - feat(algebra/module/linear_map): Add linear_map.iterate Mar 21, 2021
@bors bors bot closed this Mar 21, 2021
@bors bors bot deleted the iterate-linear-map branch March 21, 2021 06:39
b-mehta pushed a commit that referenced this pull request Apr 2, 2021
Co-authored-by: Alex J. Best <alex.j.best@gmail.com>





Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions. ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants