@@ -6,6 +6,7 @@ Authors: Mario Carneiro
6
6
import Mathlib.Data.Fintype.Prod
7
7
import Mathlib.Data.Fintype.Sum
8
8
import Mathlib.Data.Int.Units
9
+ import Mathlib.SetTheory.Cardinal.Finite
9
10
10
11
#align_import data.fintype.units from "leanprover-community/mathlib" @"509de852e1de55e1efa8eacfa11df0823f26f226"
11
12
@@ -33,11 +34,19 @@ instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
33
34
34
35
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
35
36
36
- theorem Fintype.card_units [GroupWithZero α] [Fintype α] [Fintype αˣ] :
37
- Fintype.card αˣ = Fintype.card α - 1 := by
37
+ theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
38
+ Fintype.card α = Fintype.card αˣ + 1 := by
39
+ rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
40
+ have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
41
+ rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
42
+
43
+ theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
44
+ Nat.card α = Nat.card αˣ + 1 := by
45
+ have : Fintype α := Fintype.ofFinite α
38
46
classical
39
- rw [eq_comm, Nat.sub_eq_iff_eq_add (Fintype.card_pos_iff.2 ⟨(0 : α)⟩),
40
- Fintype.card_congr (unitsEquivNeZero α)]
41
- have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α))).symm
42
- rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
47
+ rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card, Fintype.card_eq_card_units_add_one]
48
+
49
+ theorem Fintype.card_units [GroupWithZero α] [Fintype α] [DecidableEq α] :
50
+ Fintype.card αˣ = Fintype.card α - 1 := by
51
+ rw [@Fintype.card_eq_card_units_add_one α, Nat.add_sub_cancel]
43
52
#align fintype.card_units Fintype.card_units
0 commit comments