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] - refactor: Redefine pow in terms of iterate #1388

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ import Mathlib.Algebra.Ring.Ext
import Mathlib.Algebra.Ring.Fin
import Mathlib.Algebra.Ring.Hom.Basic
import Mathlib.Algebra.Ring.Hom.Defs
import Mathlib.Algebra.Ring.Hom.IterateHom
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.Algebra.Ring.Identities
import Mathlib.Algebra.Ring.InjSurj
Expand Down
3 changes: 3 additions & 0 deletions Mathlib/Algebra/Group/Action/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Mathlib.Algebra.Group.Commute.Defs
import Mathlib.Algebra.Group.TypeTags
import Mathlib.Algebra.Opposites
import Mathlib.Logic.Embedding.Basic
import Mathlib.Logic.Function.Iterate
import Mathlib.Tactic.Common

#align_import group_theory.group_action.defs from "leanprover-community/mathlib"@"dad7ecf9a1feae63e6e49f07619b7087403fb8d4"
Expand Down Expand Up @@ -706,6 +707,8 @@ instance : Monoid (Function.End α) where
mul_assoc f g h := rfl
mul_one f := rfl
one_mul f := rfl
npow n f := f^[n]
npow_succ n f := Function.iterate_succ _ _

instance : Inhabited (Function.End α) := ⟨1⟩

Expand Down
48 changes: 30 additions & 18 deletions Mathlib/Algebra/Group/Hom/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Authors: Patrick Massot, Kevin Buzzard, Scott Morrison, Johan Commelin, Chris Hu
-/
import Mathlib.Algebra.Group.Pi.Basic
import Mathlib.Data.FunLike.Basic
import Mathlib.Logic.Function.Iterate

#align_import algebra.hom.group from "leanprover-community/mathlib"@"a148d797a1094ab554ad4183a4ad6f130358ef64"

Expand Down Expand Up @@ -1097,18 +1098,26 @@ protected def End := M →* M

namespace End

instance instFunLike : FunLike (Monoid.End M) M M := MonoidHom.instFunLike
instance instMonoidHomClass : MonoidHomClass (Monoid.End M) M M := MonoidHom.instMonoidHomClass

instance instOne : One (Monoid.End M) where one := .id _
instance instMul : Mul (Monoid.End M) where mul := .comp

instance : Monoid (Monoid.End M) where
mul := MonoidHom.comp
one := MonoidHom.id M
mul_assoc _ _ _ := MonoidHom.comp_assoc _ _ _
mul_one := MonoidHom.comp_id
one_mul := MonoidHom.id_comp
npow n f := (npowRec n f).copy f^[n] $ by induction n <;> simp [npowRec, *] <;> rfl
npow_succ n f := DFunLike.coe_injective $ Function.iterate_succ _ _

instance : Inhabited (Monoid.End M) := ⟨1⟩

instance : FunLike (Monoid.End M) M M := MonoidHom.instFunLike

instance : MonoidHomClass (Monoid.End M) M M := MonoidHom.instMonoidHomClass
@[simp, norm_cast] lemma coe_pow (f : Monoid.End M) (n : ℕ) : (↑(f ^ n) : M → M) = f^[n] := rfl
#align monoid_hom.coe_pow Monoid.End.coe_pow
#align monoid.End.coe_pow Monoid.End.coe_pow

end End

Expand All @@ -1132,29 +1141,32 @@ protected def End := A →+ A

namespace End

instance instFunLike : FunLike (AddMonoid.End A) A A := AddMonoidHom.instFunLike
instance instAddMonoidHomClass : AddMonoidHomClass (AddMonoid.End A) A A :=
AddMonoidHom.instAddMonoidHomClass

instance instOne : One (AddMonoid.End A) where one := .id _
instance instMul : Mul (AddMonoid.End A) where mul := .comp

@[simp, norm_cast] lemma coe_one : ((1 : AddMonoid.End A) : A → A) = id := rfl
#align add_monoid.coe_one AddMonoid.End.coe_one

@[simp, norm_cast] lemma coe_mul (f g : AddMonoid.End A) : (f * g : A → A) = f ∘ g := rfl
#align add_monoid.coe_mul AddMonoid.End.coe_mul

instance monoid : Monoid (AddMonoid.End A) where
mul := AddMonoidHom.comp
one := AddMonoidHom.id A
mul_assoc _ _ _ := AddMonoidHom.comp_assoc _ _ _
mul_one := AddMonoidHom.comp_id
one_mul := AddMonoidHom.id_comp
npow n f := (npowRec n f).copy (Nat.iterate f n) $ by induction n <;> simp [npowRec, *] <;> rfl
npow_succ n f := DFunLike.coe_injective $ Function.iterate_succ _ _

instance : Inhabited (AddMonoid.End A) := ⟨1⟩
@[simp, norm_cast] lemma coe_pow (f : AddMonoid.End A) (n : ℕ) : (↑(f ^ n) : A → A) = f^[n] := rfl
#align add_monoid.End.coe_pow AddMonoid.End.coe_pow

instance : FunLike (AddMonoid.End A) A A := AddMonoidHom.instFunLike

instance : AddMonoidHomClass (AddMonoid.End A) A A := AddMonoidHom.instAddMonoidHomClass
instance : Inhabited (AddMonoid.End A) := ⟨1⟩

end End

@[simp]
theorem coe_one : ((1 : AddMonoid.End A) : A → A) = id := rfl
#align add_monoid.coe_one AddMonoid.coe_one

@[simp]
theorem coe_mul (f g) : ((f * g : AddMonoid.End A) : A → A) = f ∘ g := rfl
#align add_monoid.coe_mul AddMonoid.coe_mul

end AddMonoid

end End
Expand Down
18 changes: 0 additions & 18 deletions Mathlib/Algebra/GroupPower/IterateHom.lean
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,6 @@ theorem iterate_map_zpow {M F : Type*} [Group M] [FunLike F M M] [MonoidHomClass
f^[n] (x ^ k) = f^[n] x ^ k :=
Commute.iterate_left (map_zpow f · k) n x

namespace MonoidHom

variable [Monoid M] [Monoid N] [Group G] [Group H]

theorem coe_pow {M} [CommMonoid M] (f : Monoid.End M) (n : ℕ) : ⇑(f ^ n) = f^[n] :=
hom_coe_pow _ rfl (fun _ _ => rfl) _ _
#align monoid_hom.coe_pow MonoidHom.coe_pow

end MonoidHom

theorem Monoid.End.coe_pow {M} [Monoid M] (f : Monoid.End M) (n : ℕ) : ⇑(f ^ n) = f^[n] :=
hom_coe_pow _ rfl (fun _ _ => rfl) _ _
#align monoid.End.coe_pow Monoid.End.coe_pow

theorem AddMonoid.End.coe_pow {A} [AddMonoid A] (f : AddMonoid.End A) (n : ℕ) : ⇑(f ^ n) = f^[n] :=
hom_coe_pow _ rfl (fun _ _ => rfl) _ _
#align add_monoid.End.coe_pow AddMonoid.End.coe_pow

--what should be the namespace for this section?
section Monoid

Expand Down
32 changes: 16 additions & 16 deletions Mathlib/Algebra/Ring/Hom/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -681,31 +681,31 @@ theorem id_comp (f : α →+* β) : (id β).comp f = f :=
ext fun _ => rfl
#align ring_hom.id_comp RingHom.id_comp

instance : Monoid (α →+* α) where
one := id α
mul := comp
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
instance instOne : One (α →+* α) where one := id _
instance instMul : Mul (α →+* α) where mul := comp

theorem one_def : (1 : α →+* α) = id α :=
rfl
lemma one_def : (1 : α →+* α) = id α := rfl
#align ring_hom.one_def RingHom.one_def

theorem mul_def (f g : α →+* α) : f * g = f.comp g :=
rfl
lemma mul_def (f g : α →+* α) : f * g = f.comp g := rfl
#align ring_hom.mul_def RingHom.mul_def

@[simp]
theorem coe_one : ⇑(1 : α →+* α) = _root_.id :=
rfl
@[simp, norm_cast] lemma coe_one : ⇑(1 : α →+* α) = _root_.id := rfl
#align ring_hom.coe_one RingHom.coe_one

@[simp]
theorem coe_mul (f g : α →+* α) : ⇑(f * g) = f ∘ g :=
rfl
@[simp, norm_cast] lemma coe_mul (f g : α →+* α) : ⇑(f * g) = f ∘ g := rfl
#align ring_hom.coe_mul RingHom.coe_mul

instance instMonoid : Monoid (α →+* α) where
mul_one := comp_id
one_mul := id_comp
mul_assoc f g h := comp_assoc _ _ _
npow n f := (npowRec n f).copy f^[n] $ by induction' n <;> simp [npowRec, *]
npow_succ n f := DFunLike.coe_injective $ Function.iterate_succ _ _

@[simp, norm_cast] lemma coe_pow (f : α →+* α) (n : ℕ) : ⇑(f ^ n) = f^[n] := rfl
#align ring_hom.coe_pow RingHom.coe_pow

@[simp]
theorem cancel_right {g₁ g₂ : β →+* γ} {f : α →+* β} (hf : Surjective f) :
g₁.comp f = g₂.comp f ↔ g₁ = g₂ :=
Expand Down
21 changes: 0 additions & 21 deletions Mathlib/Algebra/Ring/Hom/IterateHom.lean

This file was deleted.

4 changes: 1 addition & 3 deletions Mathlib/Dynamics/FixedPoints/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ protected theorem perm_inv (h : IsFixedPt e x) : IsFixedPt (⇑e⁻¹) x :=
h.equiv_symm
#align function.is_fixed_pt.perm_inv Function.IsFixedPt.perm_inv

protected theorem perm_pow (h : IsFixedPt e x) (n : ℕ) : IsFixedPt (⇑(e ^ n)) x := by
rw [Equiv.Perm.coe_pow]
exact h.iterate _
protected theorem perm_pow (h : IsFixedPt e x) (n : ℕ) : IsFixedPt (⇑(e ^ n)) x := h.iterate _
#align function.is_fixed_pt.perm_pow Function.IsFixedPt.perm_pow

protected theorem perm_zpow (h : IsFixedPt e x) : ∀ n : ℤ, IsFixedPt (⇑(e ^ n)) x
Expand Down
18 changes: 12 additions & 6 deletions Mathlib/GroupTheory/Perm/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@ variable {α : Type u} {β : Type v}

namespace Perm

instance instOne : One (Perm α) where one := Equiv.refl _
instance instMul : Mul (Perm α) where mul f g := Equiv.trans g f
instance instInv : Inv (Perm α) where inv := Equiv.symm
instance instPowNat : Pow (Perm α) ℕ where
pow f n := ⟨f^[n], f.symm^[n], f.left_inv.iterate _, f.right_inv.iterate _⟩

instance permGroup : Group (Perm α) where
mul f g := Equiv.trans g f
one := Equiv.refl α
inv := Equiv.symm
mul_assoc f g h := (trans_assoc _ _ _).symm
one_mul := trans_refl
mul_one := refl_trans
mul_left_inv := self_trans_symm
npow n f := f ^ n
npow_succ n f := coe_fn_injective $ Function.iterate_succ _ _
zpow := zpowRec fun n f ↦ f ^ n
zpow_succ' n f := coe_fn_injective $ Function.iterate_succ _ _
#align equiv.perm.perm_group Equiv.Perm.permGroup

@[simp]
Expand Down Expand Up @@ -101,11 +108,10 @@ theorem inv_def (f : Perm α) : f⁻¹ = f.symm :=
@[simp, norm_cast] lemma coe_mul (f g : Perm α) : ⇑(f * g) = f ∘ g := rfl
#align equiv.perm.coe_mul Equiv.Perm.coe_mul

@[norm_cast] lemma coe_pow (f : Perm α) (n : ℕ) : ⇑(f ^ n) = f^[n] :=
hom_coe_pow _ rfl (fun _ _ ↦ rfl) _ _
@[norm_cast] lemma coe_pow (f : Perm α) (n : ℕ) : ⇑(f ^ n) = f^[n] := rfl
#align equiv.perm.coe_pow Equiv.Perm.coe_pow

@[simp] lemma iterate_eq_pow (f : Perm α) (n : ℕ) : f^[n] = ⇑(f ^ n) := (coe_pow _ _).symm
@[simp] lemma iterate_eq_pow (f : Perm α) (n : ℕ) : f^[n] = ⇑(f ^ n) := rfl
#align equiv.perm.iterate_eq_pow Equiv.Perm.iterate_eq_pow

theorem eq_inv_iff_eq {f : Perm α} {x y : α} : x = f⁻¹ y ↔ f x = y :=
Expand Down
Loading