Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 2fae5fd

Browse files
committed
feat(algebra/char_p): use finite instead of fintype (#16002)
* rename `char_ne_zero_of_fintype` to `char_ne_zero_of_finite`, use `[finite _]`; * rename `ring_char_ne_zero_of_fintype` to `ring_char_ne_zero_of_finite`, use `[finite _]`; * split `is_unit_iff_not_dvd_char_of_ring_char_ne_zero` from the proof of `is_unit_iff_not_dvd_char`; * add aliases `is_coprime.nat_coprime` and `nat.coprime.is_coprime`.
1 parent 32a432c commit 2fae5fd

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

src/algebra/char_p/basic.lean

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,16 @@ calc (k : R) = ↑(k % p + p * (k / p)) : by rw [nat.mod_add_div]
349349
... = ↑(k % p) : by simp [cast_eq_zero]
350350

351351
/-- The characteristic of a finite ring cannot be zero. -/
352-
theorem char_ne_zero_of_fintype (p : ℕ) [hc : char_p R p] [fintype R] : p ≠ 0 :=
353-
assume h : p = 0,
354-
have char_zero R := @char_p_to_char_zero R _ (h ▸ hc),
355-
absurd (@nat.cast_injective R _ this) (not_injective_infinite_fintype coe)
352+
theorem char_ne_zero_of_finite (p : ℕ) [char_p R p] [finite R] : p ≠ 0 :=
353+
begin
354+
unfreezingI { rintro rfl },
355+
haveI : char_zero R := char_p_to_char_zero R,
356+
casesI nonempty_fintype R,
357+
exact absurd nat.cast_injective (not_injective_infinite_fintype (coe : ℕ → R))
358+
end
356359

357-
lemma ring_char_ne_zero_of_fintype [fintype R] : ring_char R ≠ 0 :=
358-
char_ne_zero_of_fintype R (ring_char R)
360+
lemma ring_char_ne_zero_of_finite [finite R] : ring_char R ≠ 0 :=
361+
char_ne_zero_of_finite R (ring_char R)
359362

360363
end
361364

@@ -432,11 +435,11 @@ end semiring
432435

433436
section ring
434437

435-
variables (R) [ring R] [no_zero_divisors R] [nontrivial R] [fintype R]
438+
variables (R) [ring R] [no_zero_divisors R] [nontrivial R] [finite R]
436439

437440
theorem char_is_prime (p : ℕ) [char_p R p] :
438441
p.prime :=
439-
or.resolve_right (char_is_prime_or_zero R p) (char_ne_zero_of_fintype R p)
442+
or.resolve_right (char_is_prime_or_zero R p) (char_ne_zero_of_finite R p)
440443

441444
end ring
442445

src/algebra/char_p/char_and_card.lean

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ We prove some results relating characteristic and cardinality of finite rings
1515
characterstic, cardinality, ring
1616
-/
1717

18-
/-- A prime `p` is a unit in a finite commutative ring `R`
19-
iff it does not divide the characteristic. -/
20-
lemma is_unit_iff_not_dvd_char (R : Type*) [comm_ring R] [fintype R] (p : ℕ) [fact p.prime] :
18+
/-- A prime `p` is a unit in a commutative ring `R` of nonzero characterstic iff it does not divide
19+
the characteristic. -/
20+
lemma is_unit_iff_not_dvd_char_of_ring_char_ne_zero (R : Type*) [comm_ring R] (p : ℕ) [fact p.prime]
21+
(hR : ring_char R ≠ 0) :
2122
is_unit (p : R) ↔ ¬ p ∣ ring_char R :=
2223
begin
2324
have hch := char_p.cast_eq_zero R (ring_char R),
25+
have hp : p.prime := fact.out p.prime,
2426
split,
2527
{ rintros h₁ ⟨q, hq⟩,
2628
rcases is_unit.exists_left_inv h₁ with ⟨a, ha⟩,
@@ -29,8 +31,7 @@ begin
2931
rintro ⟨r, hr⟩,
3032
rw [hr, ← mul_assoc, mul_comm p, mul_assoc] at hq,
3133
nth_rewrite 0 ← mul_one (ring_char R) at hq,
32-
exact nat.prime.not_dvd_one (fact.out p.prime)
33-
⟨r, mul_left_cancel₀ (char_p.char_ne_zero_of_fintype R (ring_char R)) hq⟩,
34+
exact nat.prime.not_dvd_one hp ⟨r, mul_left_cancel₀ hR hq⟩,
3435
end,
3536
have h₄ := mt (char_p.int_cast_eq_zero_iff R (ring_char R) q).mp,
3637
apply_fun (coe : ℕ → R) at hq,
@@ -39,14 +40,19 @@ begin
3940
norm_cast at h₄,
4041
exact h₄ h₃ hq.symm, },
4142
{ intro h,
42-
rcases nat.is_coprime_iff_coprime.mpr ((nat.prime.coprime_iff_not_dvd (fact.out _)).mpr h)
43-
with ⟨a, b, hab⟩,
43+
rcases (hp.coprime_iff_not_dvd.mpr h).is_coprime with ⟨a, b, hab⟩,
4444
apply_fun (coe : ℤ → R) at hab,
4545
push_cast at hab,
4646
rw [hch, mul_zero, add_zero, mul_comm] at hab,
4747
exact is_unit_of_mul_eq_one (p : R) a hab, },
4848
end
4949

50+
/-- A prime `p` is a unit in a finite commutative ring `R`
51+
iff it does not divide the characteristic. -/
52+
lemma is_unit_iff_not_dvd_char (R : Type*) [comm_ring R] (p : ℕ) [fact p.prime] [finite R] :
53+
is_unit (p : R) ↔ ¬ p ∣ ring_char R :=
54+
is_unit_iff_not_dvd_char_of_ring_char_ne_zero R p $ char_p.char_ne_zero_of_finite R (ring_char R)
55+
5056
/-- The prime divisors of the characteristic of a finite commutative ring are exactly
5157
the prime divisors of its cardinality. -/
5258
lemma prime_dvd_char_iff_dvd_card {R : Type*} [comm_ring R] [fintype R] (p : ℕ) [fact p.prime] :

src/ring_theory/coprime/lemmas.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ theorem nat.is_coprime_iff_coprime {m n : ℕ} : is_coprime (m : ℤ) n ↔ nat.
3333
λ H, ⟨nat.gcd_a m n, nat.gcd_b m n, by rw [mul_comm _ (m : ℤ), mul_comm _ (n : ℤ),
3434
← nat.gcd_eq_gcd_ab, show _ = _, from H, int.coe_nat_one]⟩⟩
3535

36+
alias nat.is_coprime_iff_coprime ↔ is_coprime.nat_coprime nat.coprime.is_coprime
37+
3638
theorem is_coprime.prod_left : (∀ i ∈ t, is_coprime (s i) x) → is_coprime (∏ i in t, s i) x :=
3739
finset.induction_on t (λ _, is_coprime_one_left) $ λ b t hbt ih H,
3840
by { rw finset.prod_insert hbt, rw finset.forall_mem_insert at H, exact H.1.mul_left (ih H.2) }

0 commit comments

Comments
 (0)