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

Commit 2792c93

Browse files
committed
feat(ring_theory/fintype): in a finite nonzero_semiring, fintype.card (units R) < fintype.card R (#2793)
1 parent 63b8c52 commit 2792c93

File tree

13 files changed

+62
-27
lines changed

13 files changed

+62
-27
lines changed

src/algebra/associated.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
1818
refine ⟨⟨0, 0, _, _⟩, rfl⟩; apply subsingleton.elim
1919
end
2020

21-
@[simp] theorem not_is_unit_zero [nonzero_comm_ring α] : ¬ is_unit (0 : α) :=
21+
@[simp] theorem not_is_unit_zero [nonzero_semiring α] : ¬ is_unit (0 : α) :=
2222
mt is_unit_zero_iff.1 zero_ne_one
2323

2424
lemma is_unit_pow [monoid α] {a : α} (n : ℕ) : is_unit a → is_unit (a ^ n) :=
@@ -50,7 +50,7 @@ theorem is_unit_of_dvd_unit {α} [comm_semiring α] {x y : α}
5050
is_unit_iff_dvd_one.2 $ dvd_trans xy $ is_unit_iff_dvd_one.1 hu
5151

5252
theorem is_unit_int {n : ℤ} : is_unit n ↔ n.nat_abs = 1 :=
53-
λ ⟨u, hu⟩, (int.units_eq_one_or u).elim (by simp *) (by simp *),
53+
begin rintro ⟨u, rfl⟩, exact (int.units_eq_one_or u).elim (by simp) (by simp) end,
5454
λ h, is_unit_iff_dvd_one.2 ⟨n, by rw [← int.nat_abs_mul_self, h]; refl⟩⟩
5555

5656
lemma is_unit_of_dvd_one [comm_semiring α] : ∀a ∣ 1, is_unit (a:α)
@@ -201,7 +201,7 @@ theorem unit_associated_one [monoid α] {u : units α} : (u : α) ~ᵤ 1 := ⟨u
201201

202202
theorem associated_one_iff_is_unit [monoid α] {a : α} : (a : α) ~ᵤ 1 ↔ is_unit a :=
203203
iff.intro
204-
(assume h, let ⟨c, h⟩ := h.symm in h ▸ ⟨c, one_mul _⟩)
204+
(assume h, let ⟨c, h⟩ := h.symm in h ▸ ⟨c, (one_mul _).symm⟩)
205205
(assume ⟨c, h⟩, associated.symm ⟨c, by simp [h]⟩)
206206

207207
theorem associated_zero_iff_eq_zero [comm_semiring α] (a : α) : a ~ᵤ 0 ↔ a = 0 :=
@@ -267,7 +267,7 @@ by haveI := classical.dec; exact not_iff_not.2 (eq_zero_iff_of_associated h)
267267
lemma prime_of_associated [comm_semiring α] {p q : α} (h : p ~ᵤ q) (hp : prime p) : prime q :=
268268
⟨(ne_zero_iff_of_associated h).1 hp.ne_zero,
269269
let ⟨u, hu⟩ := h in
270-
⟨λ ⟨v, hv⟩, hp.not_unit ⟨v * u⁻¹, by simp [hv.symm, hu.symm]⟩,
270+
⟨λ ⟨v, hv⟩, hp.not_unit ⟨v * u⁻¹, by simp [hv, hu.symm]⟩,
271271
hu ▸ by { simp [mul_unit_dvd_iff], intros a b, exact hp.div_or_div }⟩⟩
272272

273273
lemma prime_iff_of_associated [comm_semiring α] {p q : α}
@@ -285,7 +285,7 @@ lemma irreducible_of_associated [comm_semiring α] {p q : α} (h : p ~ᵤ q)
285285
have hpab : p = a * (b * (u⁻¹ : units α)),
286286
from calc p = (p * u) * (u ⁻¹ : units α) : by simp
287287
... = _ : by rw hu; simp [hab, mul_assoc],
288-
(hp.2 _ _ hpab).elim or.inl (λ ⟨v, hv⟩, or.inr ⟨v * u, by simp [hv.symm]⟩)⟩
288+
(hp.2 _ _ hpab).elim or.inl (λ ⟨v, hv⟩, or.inr ⟨v * u, by simp [hv]⟩)⟩
289289

290290
lemma irreducible_iff_of_associated [comm_semiring α] {p q : α} (h : p ~ᵤ q) :
291291
irreducible p ↔ irreducible q :=
@@ -399,7 +399,7 @@ theorem coe_unit_eq_one : ∀u:units (associates α), (u : associates α) = 1
399399

400400
theorem is_unit_iff_eq_one (a : associates α) : is_unit a ↔ a = 1 :=
401401
iff.intro
402-
(assume ⟨u, h⟩, h.symm ▸ coe_unit_eq_one _)
402+
(assume ⟨u, h⟩, h ▸ coe_unit_eq_one _)
403403
(assume h, h.symm ▸ is_unit_one)
404404

405405
theorem is_unit_mk {a : α} : is_unit (associates.mk a) ↔ is_unit a :=

src/algebra/gcd_domain.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ lemma normalize_eq_zero {x : α} : normalize x = 0 ↔ x = 0 :=
6464
⟨λ hx, (associated_zero_iff_eq_zero x).1 $ hx ▸ associated_normalize, by rintro rfl; exact normalize_zero⟩
6565

6666
lemma normalize_eq_one {x : α} : normalize x = 1 ↔ is_unit x :=
67-
⟨λ hx, is_unit_iff_exists_inv.2 ⟨_, hx⟩, λ ⟨u, hu⟩, hu.symm ▸ normalize_coe_units u⟩
67+
⟨λ hx, is_unit_iff_exists_inv.2 ⟨_, hx⟩, λ ⟨u, hu⟩, hu ▸ normalize_coe_units u⟩
6868

6969
theorem norm_unit_mul_norm_unit (a : α) : norm_unit (a * norm_unit a) = 1 :=
7070
classical.by_cases (assume : a = 0, by simp only [this, norm_unit_zero, zero_mul]) $

src/algebra/group/units.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ variables {M : Type*} {N : Type*}
202202
The actual definition says that `a` is equal to some `u : units M`, where
203203
`units M` is a bundled version of `is_unit`. -/
204204
@[to_additive is_add_unit "An element `a : M` of an add_monoid is an `add_unit` if it has a two-sided additive inverse. The actual definition says that `a` is equal to some `u : add_units M`, where `add_units M` is a bundled version of `is_add_unit`."]
205-
def is_unit [monoid M] (a : M) : Prop := ∃ u : units M, a = u
205+
def is_unit [monoid M] (a : M) : Prop := ∃ u : units M, (u : M) = a
206206

207207
@[simp, to_additive is_add_unit_add_unit]
208208
lemma is_unit_unit [monoid M] (u : units M) : is_unit (u : M) := ⟨u, rfl⟩
@@ -229,9 +229,9 @@ theorem units.is_unit_mul_units [monoid M] (a : M) (u : units M) :
229229
is_unit (a * u) ↔ is_unit a :=
230230
iff.intro
231231
(assume ⟨v, hv⟩,
232-
have is_unit (a * ↑u * ↑u⁻¹), by existsi v * u⁻¹; rw [hv, units.coe_mul],
232+
have is_unit (a * ↑u * ↑u⁻¹), by existsi v * u⁻¹; rw [hv, units.coe_mul],
233233
by rwa [mul_assoc, units.mul_inv, mul_one] at this)
234-
(assume ⟨v, hv⟩, hv.symm ▸ ⟨v * u, (units.coe_mul v u).symm⟩)
234+
(assume ⟨v, hv⟩, hv ▸ ⟨v * u, (units.coe_mul v u).symm⟩)
235235

236236
@[to_additive is_add_unit_of_add_is_add_unit_left]
237237
theorem is_unit_of_mul_is_unit_left [comm_monoid M] {x y : M}
@@ -245,10 +245,10 @@ is_unit_iff_exists_inv.2 ⟨y * z, by rwa ← mul_assoc⟩
245245

246246
@[to_additive] theorem is_unit.mul_right_inj [monoid M] {a b c : M} (ha : is_unit a) :
247247
a * b = a * c ↔ b = c :=
248-
by cases ha with a ha; rw [ha, units.mul_right_inj]
248+
by cases ha with a ha; rw [ha, units.mul_right_inj]
249249

250250
@[to_additive] theorem is_unit.mul_left_inj [monoid M] {a b c : M} (ha : is_unit a) :
251251
b * a = c * a ↔ b = c :=
252-
by cases ha with a ha; rw [ha, units.mul_left_inj]
252+
by cases ha with a ha; rw [ha, units.mul_left_inj]
253253

254254
end is_unit

src/algebra/group/units_hom.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ to `f : M →* units N`. See also `units.lift_right` for a computable version. -
9494
@[to_additive "If a homomorphism `f : M →+ N` sends each element to an `is_add_unit`, then it can be lifted to `f : M →+ add_units N`. See also `add_units.lift_right` for a computable version."]
9595
noncomputable def is_unit.lift_right [monoid M] [monoid N] (f : M →* N)
9696
(hf : ∀ x, is_unit (f x)) : M →* units N :=
97-
units.lift_right f (λ x, classical.some (hf x)) $ λ x, (classical.some_spec (hf x)).symm
97+
units.lift_right f (λ x, classical.some (hf x)) $ λ x, classical.some_spec (hf x)
9898

9999
@[to_additive] lemma is_unit.coe_lift_right [monoid M] [monoid N] (f : M →* N)
100100
(hf : ∀ x, is_unit (f x)) (x) :
@@ -103,10 +103,10 @@ units.coe_lift_right _ x
103103

104104
@[simp, to_additive] lemma is_unit.mul_lift_right_inv [monoid M] [monoid N] (f : M →* N)
105105
(h : ∀ x, is_unit (f x)) (x) : f x * ↑(is_unit.lift_right f h x)⁻¹ = 1 :=
106-
units.mul_lift_right_inv (λ y, (classical.some_spec $ h y).symm) x
106+
units.mul_lift_right_inv (λ y, classical.some_spec $ h y) x
107107

108108
@[simp, to_additive] lemma is_unit.lift_right_inv_mul [monoid M] [monoid N] (f : M →* N)
109109
(h : ∀ x, is_unit (f x)) (x) : ↑(is_unit.lift_right f h x)⁻¹ * f x = 1 :=
110-
units.lift_right_inv_mul (λ y, (classical.some_spec $ h y).symm) x
110+
units.lift_right_inv_mul (λ y, classical.some_spec $ h y) x
111111

112112
end is_unit

src/algebra/group_with_zero.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ variables {G₀ : Type*} [group_with_zero G₀]
235235
lemma is_unit.mk0 (x : G₀) (hx : x ≠ 0) : is_unit x := is_unit_unit (units.mk0 x hx)
236236

237237
lemma is_unit_iff_ne_zero {x : G₀} : is_unit x ↔ x ≠ 0 :=
238-
⟨λ ⟨u, hu⟩, hu.symm ▸ λ h : u.1 = 0, by simpa [h, zero_ne_one] using u.3, is_unit.mk0 x⟩
238+
⟨λ ⟨u, hu⟩, hu ▸ λ h : u.1 = 0, by simpa [h, zero_ne_one] using u.3, is_unit.mk0 x⟩
239239

240240
lemma mul_eq_zero' (a b : G₀) (h : a * b = 0) : a = 0 ∨ b = 0 :=
241241
begin

src/algebra/ring.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import algebra.group.hom
77
import algebra.group.units
88
import tactic.norm_cast
99
import tactic.split_ifs
10-
import algebra.group.units
1110

1211
/-!
1312
# Properties and homomorphisms of semirings and rings
@@ -942,11 +941,11 @@ variables [semiring α]
942941

943942
theorem mul_left_eq_zero_iff_eq_zero {r u : α}
944943
(hu : is_unit u) : r * u = 0 ↔ r = 0 :=
945-
by cases hu with u hu; exact hu.symm ▸ units.mul_left_eq_zero_iff_eq_zero u
944+
by cases hu with u hu; exact hu ▸ units.mul_left_eq_zero_iff_eq_zero u
946945

947946
theorem mul_right_eq_zero_iff_eq_zero {r u : α}
948947
(hu : is_unit u) : u * r = 0 ↔ r = 0 :=
949-
by cases hu with u hu; exact hu.symm ▸ units.mul_right_eq_zero_iff_eq_zero u
948+
by cases hu with u hu; exact hu ▸ units.mul_right_eq_zero_iff_eq_zero u
950949

951950
end semiring
952951

src/analysis/asymptotics.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ theorem is_O_with_self_const_mul (c : 𝕜) (hc : c ≠ 0) (f : α → 𝕜) (l
774774

775775
theorem is_O_self_const_mul' {c : R} (hc : is_unit c) (f : α → R) (l : filter α) :
776776
is_O f (λ x, c * f x) l :=
777-
let ⟨u, hu⟩ := hc in hu.symm ▸ (is_O_with_self_const_mul' u f l).is_O
777+
let ⟨u, hu⟩ := hc in hu ▸ (is_O_with_self_const_mul' u f l).is_O
778778

779779
theorem is_O_self_const_mul (c : 𝕜) (hc : c ≠ 0) (f : α → 𝕜) (l : filter α) :
780780
is_O f (λ x, c * f x) l :=

src/data/fintype/basic.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,25 @@ instance pfun_fintype (p : Prop) [decidable p] (α : p → Type*)
661661
if hp : p then fintype.of_equiv (α hp) ⟨λ a _, a, λ f, f hp, λ _, rfl, λ _, rfl⟩
662662
else ⟨singleton (λ h, (hp h).elim), by simp [hp, function.funext_iff]⟩
663663

664+
lemma mem_image_univ_iff_mem_range
665+
{α β : Type*} [fintype α] [decidable_eq β] {f : α → β} {b : β} :
666+
b ∈ univ.image f ↔ b ∈ set.range f :=
667+
by simp
668+
669+
lemma card_lt_card_of_injective_of_not_mem
670+
{α β : Type*} [fintype α] [fintype β] (f : α → β) (h : function.injective f)
671+
{b : β} (w : b ∉ set.range f) : fintype.card α < fintype.card β :=
672+
begin
673+
classical,
674+
calc
675+
fintype.card α = (univ : finset α).card : rfl
676+
... = (image f univ).card : (card_image_of_injective univ h).symm
677+
... < (insert b (image f univ)).card :
678+
card_lt_card (ssubset_insert (mt mem_image_univ_iff_mem_range.mp w))
679+
... ≤ (univ : finset β).card : card_le_of_subset (subset_univ _)
680+
... = fintype.card β : rfl
681+
end
682+
664683
def quotient.fin_choice_aux {ι : Type*} [decidable_eq ι]
665684
{α : ι → Type*} [S : ∀ i, setoid (α i)] :
666685
∀ (l : list ι), (∀ i ∈ l, quotient (S i)) → @quotient (Π i ∈ l, α i) (by apply_instance)

src/group_theory/group_action.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ not_congr u.smul_eq_zero
253253

254254
@[simp] theorem is_unit.smul_eq_zero {u : α} (hu : is_unit u) {x : β} :
255255
u • x = 0 ↔ x = 0 :=
256-
exists.elim hu $ λ u hu, hu.symm ▸ u.smul_eq_zero
256+
exists.elim hu $ λ u hu, hu ▸ u.smul_eq_zero
257257

258258
variable (β)
259259

src/group_theory/monoid_localization.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ variables (f : localization_map S N)
262262
begin
263263
rw [f.to_map.map_mul, f.to_map.map_mul] at h,
264264
cases f.map_units c with u hu,
265-
rw hu at h,
265+
rw hu at h,
266266
exact (units.mul_right_inj u).1 h,
267267
end
268268

@@ -380,7 +380,7 @@ by rw [mul_comm, mk'_mul_cancel_right]
380380
is_unit (j.comp f.to_map y) :=
381381
⟨units.map j $ is_unit.lift_right (f.to_map.restrict S) f.map_units y,
382382
show j _ = j _, from congr_arg j $
383-
(is_unit.coe_lift_right (f.to_map.restrict S) f.map_units _).symm
383+
(is_unit.coe_lift_right (f.to_map.restrict S) f.map_units _)⟩
384384

385385
variables {g : M →* P}
386386

0 commit comments

Comments
 (0)