Skip to content

Commit 92f24cb

Browse files
feat: GCDMonoid (Associates α) instance (#11618)
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent 68a8628 commit 92f24cb

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Mathlib/Algebra/Associated.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ theorem quot_out [Monoid α] (a : Associates α) : Associates.mk (Quot.out a) =
819819
rw [← quot_mk_eq_mk, Quot.out_eq]
820820
#align associates.quot_out Associates.quot_outₓ
821821

822+
theorem mk_quot_out [Monoid α] (a : α) : Quot.out (Associates.mk a) ~ᵤ a := by
823+
rw [← Associates.mk_eq_mk_iff_associated, Associates.quot_out]
824+
822825
theorem forall_associated [Monoid α] {p : Associates α → Prop} :
823826
(∀ a, p a) ↔ ∀ a, p (Associates.mk a) :=
824827
Iff.intro (fun h _ => h _) fun h a => Quotient.inductionOn a h

Mathlib/Algebra/GCDMonoid/Basic.lean

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,3 +1420,39 @@ theorem normalize_eq_one {a : G₀} (h0 : a ≠ 0) : normalize a = 1 := by simp
14201420
#align comm_group_with_zero.normalize_eq_one CommGroupWithZero.normalize_eq_one
14211421

14221422
end CommGroupWithZero
1423+
1424+
theorem Associated.gcd [CancelCommMonoidWithZero α] [GCDMonoid α]
1425+
{a₁ a₂ b₁ b₂ : α} (ha : Associated a₁ a₂) (hb : Associated b₁ b₂) :
1426+
Associated (gcd a₁ b₁) (gcd a₂ b₂) :=
1427+
associated_of_dvd_dvd (gcd_dvd_gcd ha.dvd hb.dvd) (gcd_dvd_gcd ha.symm.dvd hb.symm.dvd)
1428+
1429+
theorem Associated.lcm [CancelCommMonoidWithZero α] [GCDMonoid α]
1430+
{a₁ a₂ b₁ b₂ : α} (ha : Associated a₁ a₂) (hb : Associated b₁ b₂) :
1431+
Associated (lcm a₁ b₁) (lcm a₂ b₂) :=
1432+
associated_of_dvd_dvd (lcm_dvd_lcm ha.dvd hb.dvd) (lcm_dvd_lcm ha.symm.dvd hb.symm.dvd)
1433+
1434+
namespace Associates
1435+
1436+
variable [CancelCommMonoidWithZero α] [GCDMonoid α]
1437+
1438+
instance instGCDMonoid : GCDMonoid (Associates α) where
1439+
gcd := Quotient.map₂' gcd fun a₁ a₂ (ha : Associated _ _) b₁ b₂ (hb : Associated _ _) => ha.gcd hb
1440+
lcm := Quotient.map₂' lcm fun a₁ a₂ (ha : Associated _ _) b₁ b₂ (hb : Associated _ _) => ha.lcm hb
1441+
gcd_dvd_left := by rintro ⟨a⟩ ⟨b⟩; exact mk_le_mk_of_dvd (gcd_dvd_left _ _)
1442+
gcd_dvd_right := by rintro ⟨a⟩ ⟨b⟩; exact mk_le_mk_of_dvd (gcd_dvd_right _ _)
1443+
dvd_gcd := by
1444+
rintro ⟨a⟩ ⟨b⟩ ⟨c⟩ hac hbc
1445+
exact mk_le_mk_of_dvd (dvd_gcd (dvd_of_mk_le_mk hac) (dvd_of_mk_le_mk hbc))
1446+
gcd_mul_lcm := by
1447+
rintro ⟨a⟩ ⟨b⟩
1448+
rw [associated_iff_eq]
1449+
exact Quotient.sound <| gcd_mul_lcm _ _
1450+
lcm_zero_left := by rintro ⟨a⟩; exact congr_arg Associates.mk <| lcm_zero_left _
1451+
lcm_zero_right := by rintro ⟨a⟩; exact congr_arg Associates.mk <| lcm_zero_right _
1452+
1453+
theorem gcd_mk_mk {a b : α} : gcd (Associates.mk a) (Associates.mk b) = Associates.mk (gcd a b) :=
1454+
rfl
1455+
theorem lcm_mk_mk {a b : α} : lcm (Associates.mk a) (Associates.mk b) = Associates.mk (lcm a b) :=
1456+
rfl
1457+
1458+
end Associates

0 commit comments

Comments
 (0)