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: ZMod-module lemmas #17693

Closed
wants to merge 8 commits into from
Closed
Changes from 4 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
46 changes: 43 additions & 3 deletions Mathlib/Data/ZMod/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This is a ring hom if the ring has characteristic dividing `n`

assert_not_exists Submodule

open Function
open Function ZMod

namespace ZMod

Expand Down Expand Up @@ -1433,8 +1433,10 @@ end lift
end ZMod

section Module
variable {S G : Type*} [AddCommGroup G] {n : ℕ} [Module (ZMod n) G] [SetLike S G]
[AddSubgroupClass S G] {K : S} {x : G}
variable {n : ℕ} {S G : Type*} [AddCommGroup G] [SetLike S G] [AddSubgroupClass S G] {K : S} {x : G}

section general
YaelDillies marked this conversation as resolved.
Show resolved Hide resolved
variable [Module (ZMod n) G] {x : G}

lemma zmod_smul_mem (hx : x ∈ K) : ∀ a : ZMod n, a • x ∈ K := by
simpa [ZMod.forall, Int.cast_smul_eq_zsmul] using zsmul_mem hx
Expand All @@ -1453,6 +1455,44 @@ instance instZModModule : Module (ZMod n) K :=
Subtype.coe_injective.module _ (AddSubmonoidClass.subtype K) coe_zmod_smul

end AddSubgroupClass

variable (n)

lemma ZModModule.char_nsmul_eq_zero (x : G) : n • x = 0 := by
YaelDillies marked this conversation as resolved.
Show resolved Hide resolved
simp [← Nat.cast_smul_eq_nsmul (ZMod n)]

variable (G) in
lemma ZModModule.char_ne_one [Nontrivial G] : n ≠ 1 := by
rintro rfl
obtain ⟨x, hx⟩ := exists_ne (0 : G)
exact hx <| by simpa using char_nsmul_eq_zero 1 x

variable (G) in
lemma ZModModule.two_le_char [NeZero n] [Nontrivial G] : 2 ≤ n := by
have := NeZero.ne n
have := char_ne_one n G
omega

lemma ZModModule.periodicPts_add_left [NeZero n] (x : G) : periodicPts (x + ·) = .univ :=
Set.eq_univ_of_forall fun y ↦ ⟨n, NeZero.pos n, by
simpa [char_nsmul_eq_zero, IsPeriodicPt] using isFixedPt_id _⟩

end general

section two
variable [Module (ZMod 2) G]

lemma ZModModule.add_self (x : G) : x + x = 0 := by
simpa [two_nsmul] using char_nsmul_eq_zero 2 x

lemma ZModModule.neg_eq_self (x : G) : -x = x := by simp [add_self, eq_comm, ← sub_eq_zero]

lemma ZModModule.sub_eq_add (x y : G) : x - y = x + y := by simp [neg_eq_self, sub_eq_add_neg]

lemma ZModModule.add_add_add_cancel (x y z : G) : (x + y) + (y + z) = x + z := by
simpa [sub_eq_add] using sub_add_sub_cancel x y z

end two
end Module

section AddGroup
Expand Down
Loading