Skip to content

Commit e0a6278

Browse files
astrainfinitaAuthor Name
andcommitted
chore(Algebra/CharP/Two): reduce dependencies (leanprover-community#34663)
--- <!-- Your PR title will become the first line of the commit message. In this box, the text above the `---` (if not empty) will be appended to the commit message, and can be used to give additional context or details. Please leave a blank newline before the `---`, otherwise GitHub will format the text above it as a title. For details on the "pull request lifecycle" in mathlib, please see: https://leanprover-community.github.io/contribute/index.html In particular, note that most reviewers will only notice your PR if it passes the continuous integration checks. Please ask for help on https://leanprover.zulipchat.com if needed. When merging, all the commits will be squashed into a single commit listing all co-authors. Co-authors in the squash commit are gathered from two sources: First, all authors of commits to this PR branch are included. Thus, one way to add co-authors is to include at least one commit authored by each co-author among the commits in the pull request. If necessary, you may create empty commits to indicate co-authorship, using commands like so: git commit --author="Author Name <author@email.com>" --allow-empty -m "add Author Name as coauthor" Second, co-authors can also be listed in lines at the very bottom of the commit message (that is, directly before the `---`) using the following format: If you are moving or deleting declarations, please include these lines at the bottom of the commit message (before the `---`, and also before any "Co-authored-by" lines) using the following format: Moves: - Vector.* -> List.Vector.* - ... Deletions: - Nat.bit1_add_bit1 - ... Any other comments you want to keep out of the PR commit should go below the `---`, and placed outside this HTML comment, or else they will be invisible to reviewers. If this PR depends on other PRs, please list them below this comment, using the following format: - [ ] depends on: #abc [optional extra text] - [ ] depends on: #xyz [optional extra text] --> [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/from-referrer/) Co-authored-by: Author Name <author@email.com>
1 parent fd928cd commit e0a6278

8 files changed

Lines changed: 44 additions & 36 deletions

File tree

Mathlib/Algebra/CharP/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ end CharP
310310
/-
311311
Preliminary definitions and results for the Frobenius map.
312312
Necessary here for simple results about sums of `p`-powers that are used in files forbidding
313-
to import algebra-related definitions (see `Mathlib/Algebra/CharP/Two.lean`).
313+
to import algebra-related definitions.
314314
-/
315315
section Frobenius
316316

Mathlib/Algebra/CharP/Two.lean

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Authors: Eric Wieser
55
-/
66
module
77

8-
public import Mathlib.Algebra.CharP.Lemmas
9-
public import Mathlib.GroupTheory.OrderOfElement
8+
public import Mathlib.Algebra.BigOperators.Group.Finset.Defs
9+
public import Mathlib.Algebra.CharP.Defs
10+
public import Mathlib.Algebra.Ring.Parity
1011

1112
/-!
1213
# Lemmas about rings of characteristic two
@@ -19,7 +20,10 @@ elsewhere, with a shorter name for ease of discovery, and no need for a `[Fact (
1920

2021
public section
2122

22-
assert_not_exists Algebra LinearMap
23+
-- TODO: `assert_not_exists Field` is added because of `Mathlib.GroupTheory.OrderOfElement`.
24+
-- If you want to import fields here, please refactor the import hierarchy for
25+
-- `Mathlib.GroupTheory.OrderOfElement`.
26+
assert_not_exists Algebra LinearMap Field
2327

2428
variable {R ι : Type*}
2529

@@ -48,10 +52,10 @@ section Semiring
4852
variable [Semiring R] [CharP R 2]
4953

5054
@[scoped simp]
51-
theorem add_self_eq_zero (x : R) : x + x = 0 := by rw [← two_smul R x, two_eq_zero, zero_smul]
55+
theorem add_self_eq_zero (x : R) : x + x = 0 := by rw [← two_mul x, two_eq_zero, zero_mul]
5256

5357
@[scoped simp]
54-
protected theorem two_nsmul (x : R) : 2 • x = 0 := by rw [two_smul, add_self_eq_zero]
58+
protected theorem two_nsmul (x : R) : 2 • x = 0 := by rw [two_nsmul, add_self_eq_zero]
5559

5660
@[scoped simp]
5761
protected theorem add_cancel_left (a b : R) : a + (a + b) = b := by
@@ -96,26 +100,32 @@ section CommSemiring
96100

97101
variable [CommSemiring R] [CharP R 2]
98102

99-
theorem add_sq (x y : R) : (x + y) ^ 2 = x ^ 2 + y ^ 2 :=
100-
add_pow_char _ _ _
103+
theorem add_sq (x y : R) : (x + y) ^ 2 = x ^ 2 + y ^ 2 := by
104+
simp [add_pow_two, two_eq_zero (R := R)]
101105

102106
theorem add_mul_self (x y : R) : (x + y) * (x + y) = x * x + y * y := by
103107
rw [← pow_two, ← pow_two, ← pow_two, add_sq]
104108

109+
/-- See `frobenius` for the Frobenius map. -/
110+
private def sqAddMonoidHom : R →+ R where
111+
toFun := (· ^ 2)
112+
map_zero' := zero_pow two_ne_zero
113+
map_add' := add_sq
114+
105115
theorem list_sum_sq (l : List R) : l.sum ^ 2 = (l.map (· ^ 2)).sum :=
106-
list_sum_pow_char _ _
116+
map_list_sum sqAddMonoidHom _
107117

108118
theorem list_sum_mul_self (l : List R) : l.sum * l.sum = (List.map (fun x => x * x) l).sum := by
109119
simp_rw [← pow_two, list_sum_sq]
110120

111121
theorem multiset_sum_sq (l : Multiset R) : l.sum ^ 2 = (l.map (· ^ 2)).sum :=
112-
multiset_sum_pow_char _ _
122+
map_multiset_sum sqAddMonoidHom _
113123

114124
theorem multiset_sum_mul_self (l : Multiset R) :
115125
l.sum * l.sum = (Multiset.map (fun x => x * x) l).sum := by simp_rw [← pow_two, multiset_sum_sq]
116126

117127
theorem sum_sq (s : Finset ι) (f : ι → R) : (∑ i ∈ s, f i) ^ 2 = ∑ i ∈ s, f i ^ 2 :=
118-
sum_pow_char _ _ _
128+
map_sum sqAddMonoidHom _ _
119129

120130
theorem sum_mul_self (s : Finset ι) (f : ι → R) :
121131
((∑ i ∈ s, f i) * ∑ i ∈ s, f i) = ∑ i ∈ s, f i * f i := by simp_rw [← pow_two, sum_sq]
@@ -147,25 +157,4 @@ theorem neg_one_eq_one_iff [Nontrivial R] : (-1 : R) = 1 ↔ ringChar R = 2 := b
147157
rw [eq_comm, ← sub_eq_zero, sub_neg_eq_add, ← Nat.cast_one, ← Nat.cast_add] at h
148158
exact ((Nat.dvd_prime Nat.prime_two).mp (ringChar.dvd h)).resolve_left CharP.ringChar_ne_one
149159

150-
@[simp]
151-
theorem orderOf_neg_one [Nontrivial R] : orderOf (-1 : R) = if ringChar R = 2 then 1 else 2 := by
152-
split_ifs with h
153-
· rw [neg_one_eq_one_iff.2 h, orderOf_one]
154-
apply orderOf_eq_prime
155-
· simp
156-
simpa [neg_one_eq_one_iff] using h
157-
158160
end ringChar
159-
160-
section CharP
161-
162-
variable [Ring R]
163-
164-
lemma CharP.orderOf_eq_two_iff [Nontrivial R] [NoZeroDivisors R] (p : ℕ)
165-
(hp : p ≠ 2) [CharP R p] {x : R} : orderOf x = 2 ↔ x = -1 := by
166-
simp only [orderOf_eq_prime_iff, sq_eq_one_iff, ne_eq, or_and_right, and_not_self, false_or,
167-
and_iff_left_iff_imp]
168-
rintro rfl
169-
exact fun h ↦ hp ((ringChar.eq R p) ▸ (neg_one_eq_one_iff.1 h))
170-
171-
end CharP

Mathlib/Data/Nat/Totient.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Chris Hughes
66
module
77

88
public import Mathlib.Algebra.CharP.Two
9+
public import Mathlib.Algebra.Order.BigOperators.Group.LocallyFinite
910
public import Mathlib.Algebra.Order.BigOperators.Ring.Finset
1011
public import Mathlib.Data.Nat.Cast.Field
1112
public import Mathlib.Data.Nat.Factorization.Basic

Mathlib/GroupTheory/OrderOfElement.lean

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Johannes Hölzl, Julian Kuelshammer
55
-/
66
module
77

8-
public import Mathlib.Algebra.CharP.Defs
8+
public import Mathlib.Algebra.CharP.Two
99
public import Mathlib.Algebra.Group.Commute.Basic
1010
public import Mathlib.Algebra.Group.Pointwise.Set.Finite
1111
public import Mathlib.Algebra.Group.Subgroup.Finite
@@ -520,6 +520,22 @@ theorem exists_orderOf_eq_prime_pow_iff :
520520
obtain ⟨k, _, hk⟩ := (Nat.dvd_prime_pow hp.elim).mp (orderOf_dvd_of_pow_eq_one hm)
521521
exact ⟨k, hk⟩⟩
522522

523+
@[simp]
524+
theorem orderOf_neg_one {R} [Ring R] [Nontrivial R] :
525+
orderOf (-1 : R) = if ringChar R = 2 then 1 else 2 := by
526+
split_ifs with h
527+
· rw [neg_one_eq_one_iff.2 h, orderOf_one]
528+
apply orderOf_eq_prime
529+
· simp
530+
simpa [neg_one_eq_one_iff] using h
531+
532+
lemma CharP.orderOf_eq_two_iff {R} [Ring R] [Nontrivial R] [NoZeroDivisors R] (p : ℕ)
533+
(hp : p ≠ 2) [CharP R p] {x : R} : orderOf x = 2 ↔ x = -1 := by
534+
simp only [orderOf_eq_prime_iff, sq_eq_one_iff, ne_eq, or_and_right, and_not_self, false_or,
535+
and_iff_left_iff_imp]
536+
rintro rfl
537+
exact fun h ↦ hp ((ringChar.eq R p) ▸ (neg_one_eq_one_iff.1 h))
538+
523539
end PPrime
524540

525541
/-- The equivalence between `Fin (orderOf x)` and `Submonoid.powers x`, sending `i` to `x ^ i` -/

Mathlib/GroupTheory/Perm/MaximalSubgroups.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ theorem isCoatom_stabilizer_of_ncard_lt_ncard_compl
375375
apply hB.eq_univ_of_card_lt
376376
have : sᶜ.ncard ≤ B.ncard := ncard_le_ncard this
377377
rw [← Set.ncard_add_ncard_compl s]
378-
linarith
378+
lia
379379
-- The proof needs 4 steps
380380
/- Step 1 : `sᶜ` is not a block.
381381
This uses that `Nat.card s < Nat.card sᶜ`.

Mathlib/GroupTheory/RegularWreathProduct.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Authors: Francisco Silva
55
-/
66
module
77

8-
public import Mathlib.GroupTheory.Sylow
98
public import Mathlib.Algebra.Group.PUnit
109
public import Mathlib.Data.Finite.Perm
11-
public import Mathlib.Algebra.Group.End
10+
public import Mathlib.Data.Nat.Multiplicity
11+
public import Mathlib.GroupTheory.Sylow
1212

1313
/-!
1414
# Regular wreath product

Mathlib/GroupTheory/SpecificGroups/Cyclic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public import Mathlib.Data.ZMod.QuotientGroup
1313
public import Mathlib.GroupTheory.Exponent
1414
public import Mathlib.GroupTheory.Subgroup.Simple
1515
public import Mathlib.Tactic.Group
16+
public import Mathlib.Tactic.IntervalCases
1617

1718
/-!
1819
# Cyclic groups

Mathlib/RingTheory/IntegralDomain.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Johan Commelin, Chris Hughes
66
module
77

88
public import Mathlib.Algebra.Polynomial.Roots
9+
public import Mathlib.Algebra.Ring.GeomSum
910
public import Mathlib.Data.Fintype.Inv
1011
public import Mathlib.GroupTheory.SpecificGroups.Cyclic
1112
public import Mathlib.Tactic.FieldSimp

0 commit comments

Comments
 (0)