-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Data/ZMod/Basic): don't import
Field
- Loading branch information
1 parent
2238540
commit 3092e6a
Showing
12 changed files
with
72 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/- | ||
Copyright (c) 2023 Joël Riou. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Joël Riou, Johan Commelin | ||
-/ | ||
import Mathlib.Algebra.Field.Defs | ||
import Mathlib.Algebra.Ring.NegOnePow | ||
import Mathlib.Tactic.NormNum | ||
|
||
/-! # Integer powers of `-1` in a field -/ | ||
|
||
namespace Int | ||
|
||
lemma cast_negOnePow (K : Type*) (n : ℤ) [Field K] : n.negOnePow = (-1 : K) ^ n := by | ||
rcases even_or_odd' n with ⟨k, rfl | rfl⟩ | ||
· simp [zpow_mul, zpow_ofNat] | ||
· rw [zpow_add_one₀ (by norm_num), zpow_mul, zpow_ofNat] | ||
simp | ||
|
||
@[deprecated (since := "2024-10-20")] alias coe_negOnePow := cast_negOnePow | ||
|
||
end Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/- | ||
Copyright (c) 2018 Chris Hughes. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Chris Hughes | ||
-/ | ||
import Mathlib.Algebra.Field.Basic | ||
import Mathlib.Data.ZMod.Basic | ||
|
||
/-! | ||
# `ZMod p` is a field | ||
-/ | ||
|
||
namespace ZMod | ||
variable (p : ℕ) [hp : Fact p.Prime] | ||
|
||
private theorem mul_inv_cancel_aux (a : ZMod p) (h : a ≠ 0) : a * a⁻¹ = 1 := by | ||
obtain ⟨k, rfl⟩ := natCast_zmod_surjective a | ||
apply coe_mul_inv_eq_one | ||
apply Nat.Coprime.symm | ||
rwa [Nat.Prime.coprime_iff_not_dvd Fact.out, ← CharP.cast_eq_zero_iff (ZMod p)] | ||
|
||
/-- Field structure on `ZMod p` if `p` is prime. -/ | ||
instance : Field (ZMod p) where | ||
mul_inv_cancel := mul_inv_cancel_aux p | ||
inv_zero := inv_zero p | ||
nnqsmul := _ | ||
nnqsmul_def := fun _ _ => rfl | ||
qsmul := _ | ||
qsmul_def := fun _ _ => rfl | ||
|
||
/-- `ZMod p` is an integral domain when `p` is prime. -/ | ||
instance : IsDomain (ZMod p) := by | ||
-- We need `cases p` here in order to resolve which `CommRing` instance is being used. | ||
cases p | ||
· exact (Nat.not_prime_zero hp.out).elim | ||
exact @Field.isDomain (ZMod _) (inferInstanceAs (Field (ZMod _))) | ||
|
||
end ZMod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters