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

Commit c416a48

Browse files
Julian-KuelshammerRuben-VandeVeldejcommelin
committed
feat(algebra/gcd_monoid): move the gcd_monoid nat instance (#7180)
moves `gcd_monoid nat` instance, removes corresponding todos. removes: * `nat.normalize_eq` -- use `normalize_eq` instead renames: * `nat.gcd_eq_gcd` to `gcd_eq_nat_gcd` * `nat.lcm_eq_lcm` to `lcm_eq_nat_lcm` Co-authored-by: Julian-Kuelshammer <68201724+Julian-Kuelshammer@users.noreply.github.com> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Johan Commelin <johan@commelin.net>
1 parent 2b43587 commit c416a48

File tree

3 files changed

+27
-37
lines changed

3 files changed

+27
-37
lines changed

src/algebra/gcd_monoid.lean

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Jens Wagemaker
5-
6-
TODO: Provide a GCD monoid instance for `ℕ`, port GCD facts about nats
7-
TODO: Generalize normalization monoids commutative (cancellative) monoids with or without zero
8-
TODO: Generalize GCD monoid to not require normalization in all cases
95
-/
6+
107
import algebra.associated
118
import data.nat.gcd
129
import algebra.group_power.lemmas
1310

1411
/-!
15-
1612
# Monoids with normalization functions, `gcd`, and `lcm`
1713
1814
This file defines extra structures on `comm_cancel_monoid_with_zero`s, including `integral_domain`s.
@@ -24,6 +20,8 @@ This file defines extra structures on `comm_cancel_monoid_with_zero`s, including
2420
* `gcd_monoid_of_exists_gcd`
2521
* `gcd_monoid_of_exists_lcm`
2622
23+
For the `gcd_monoid` instances on `ℕ` and `Z`, see `ring_theory.int.basic`.
24+
2725
## Implementation Notes
2826
2927
* `normalization_monoid` is defined by assigning to each element a `norm_unit` such that multiplying
@@ -48,15 +46,13 @@ without zero.
4846
4947
## TODO
5048
51-
* Provide a GCD monoid instance for `ℕ`, port GCD facts about nats, definition of coprime
49+
* Port GCD facts about nats, definition of coprime
5250
* Generalize normalization monoids to commutative (cancellative) monoids with or without zero
5351
* Generalize GCD monoid to not require normalization in all cases
5452
55-
5653
## Tags
5754
5855
divisibility, gcd, lcm, normalize
59-
6056
-/
6157

6258
variables {α : Type*}
@@ -822,27 +818,4 @@ gcd_monoid_of_lcm
822818
(λ a b c ac ab, normalize_dvd_iff.2 ((classical.some_spec (h c b) a).1 ⟨ac, ab⟩))
823819
(λ a b, normalize_idem _)
824820

825-
/-- `ℕ` is a `gcd_monoid` -/
826-
instance : gcd_monoid ℕ :=
827-
{ gcd := nat.gcd,
828-
lcm := nat.lcm,
829-
gcd_dvd_left := nat.gcd_dvd_left,
830-
gcd_dvd_right := nat.gcd_dvd_right,
831-
dvd_gcd := λ _ _ _, nat.dvd_gcd,
832-
normalize_gcd := λ a b, nat.mul_one (a.gcd b),
833-
gcd_mul_lcm := λ a b, (a.gcd_mul_lcm b).trans (mul_one (a * b)).symm,
834-
lcm_zero_left := nat.lcm_zero_left,
835-
lcm_zero_right := nat.lcm_zero_right,
836-
norm_unit := λ _, 1,
837-
norm_unit_zero := rfl,
838-
norm_unit_mul := λ _ _ _ _, rfl,
839-
norm_unit_coe_units := λ u, eq_inv_of_eq_inv
840-
(by rw [one_inv, units.ext_iff, units.coe_one, nat.is_unit_iff.mp u.is_unit]) }
841-
842-
@[simp] lemma nat.normalize_eq (n : ℕ) : normalize n = n := n.mul_one
843-
844-
lemma nat.gcd_eq_gcd (m n : ℕ) : gcd m n = nat.gcd m n := rfl
845-
846-
lemma nat.lcm_eq_lcm (m n : ℕ) : lcm m n = nat.lcm m n := rfl
847-
848821
end constructors

src/group_theory/perm/cycle_type.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Thomas Browning
55
-/
66

7-
import combinatorics.partition
87
import algebra.gcd_monoid.multiset
9-
import tactic.linarith
8+
import combinatorics.partition
109
import group_theory.perm.cycles
1110
import group_theory.sylow
11+
import ring_theory.int.basic
12+
import tactic.linarith
1213

1314
/-!
1415
# Cycle Types
@@ -154,9 +155,8 @@ cycle_induction_on (λ τ : perm α, sign τ = (τ.cycle_type.map (λ n, -(-1 :
154155
lemma lcm_cycle_type (σ : perm α) : σ.cycle_type.lcm = order_of σ :=
155156
cycle_induction_on (λ τ : perm α, τ.cycle_type.lcm = order_of τ) σ
156157
(by rw [cycle_type_one, lcm_zero, order_of_one])
157-
(λ σ hσ, by rw [hσ.cycle_type, ←singleton_coe, lcm_singleton, order_of_is_cycle hσ,
158-
nat.normalize_eq])
159-
(λ σ τ hστ hc hσ hτ, by rw [hστ.cycle_type, lcm_add, nat.lcm_eq_lcm, hστ.order_of, hσ, hτ])
158+
(λ σ hσ, by rw [hσ.cycle_type, ←singleton_coe, lcm_singleton, order_of_is_cycle hσ, normalize_eq])
159+
(λ σ τ hστ hc hσ hτ, by rw [hστ.cycle_type, lcm_add, lcm_eq_nat_lcm, hστ.order_of, hσ, hτ])
160160

161161
lemma dvd_of_mem_cycle_type {σ : perm α} {n : ℕ} (h : n ∈ σ.cycle_type) : n ∣ order_of σ :=
162162
begin
@@ -437,7 +437,7 @@ by rwa [is_three_cycle, cycle_type_inv]
437437
lemma order_of {g : perm α} (ht : is_three_cycle g) :
438438
order_of g = 3 :=
439439
by rw [←lcm_cycle_type, ht.cycle_type, multiset.singleton_eq_singleton,
440-
multiset.lcm_singleton, nat.normalize_eq]
440+
multiset.lcm_singleton, normalize_eq]
441441

442442
lemma is_three_cycle_sq {g : perm α} (ht : is_three_cycle g) :
443443
is_three_cycle (g * g) :=

src/ring_theory/int/basic.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ instance : unique_factorization_monoid ℕ :=
8585

8686
end nat
8787

88+
/-- `ℕ` is a gcd_monoid. -/
89+
instance : gcd_monoid ℕ :=
90+
{ gcd := nat.gcd,
91+
lcm := nat.lcm,
92+
gcd_dvd_left := nat.gcd_dvd_left ,
93+
gcd_dvd_right := nat.gcd_dvd_right,
94+
dvd_gcd := λ a b c, nat.dvd_gcd,
95+
normalize_gcd := λ a b, normalize_eq _,
96+
gcd_mul_lcm := λ a b, by rw [normalize_eq _, nat.gcd_mul_lcm],
97+
lcm_zero_left := nat.lcm_zero_left,
98+
lcm_zero_right := nat.lcm_zero_right,
99+
.. (infer_instance : normalization_monoid ℕ) }
100+
101+
lemma gcd_eq_nat_gcd (m n : ℕ) : gcd m n = nat.gcd m n := rfl
102+
103+
lemma lcm_eq_nat_lcm (m n : ℕ) : lcm m n = nat.lcm m n := rfl
104+
88105
namespace int
89106

90107
section normalization_monoid

0 commit comments

Comments
 (0)