Skip to content

Commit a687aeb

Browse files
committed
feat(Algebra/Divisibility/Basic): introduce right division (RightDvd) (leanprover-community#40843)
As suggested by @YaelDillies [here](leanprover-community#40050 (comment)) in leanprover-community#40050, this PR introduces the concept of right division (`RightDvd`) as a relation in `Algebra/Divisibility/Basic`. Co-authored-by: ReemMelamed <reem.melamed@campus.technion.ac.il>
1 parent c5f3b98 commit a687aeb

1 file changed

Lines changed: 69 additions & 2 deletions

File tree

Mathlib/Algebra/Divisibility/Basic.lean

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Amelia Livingston, Yury Kudryashov,
5-
Neil Strickland, Aaron Anderson
5+
Neil Strickland, Aaron Anderson, Re'em Melamed-Katz
66
-/
77
module
88

9-
public import Mathlib.Algebra.Group.Basic
9+
public import Mathlib.Algebra.Group.Opposite
1010
public import Mathlib.Tactic.Common
1111
public import Batteries.Tactic.SeqFocus
1212

@@ -110,8 +110,58 @@ theorem mul_dvd_mul_left (a : α) (h : b ∣ c) : a * b ∣ a * c := by
110110
theorem IsLeftRegular.dvd_cancel_left (h : IsLeftRegular a) : a * b ∣ a * c ↔ b ∣ c :=
111111
fun dvd ↦ have ⟨d, eq⟩ := dvd; ⟨d, h (eq.trans <| mul_assoc ..)⟩, mul_dvd_mul_left a⟩
112112

113+
/-- Right divisibility relation. `RightDvd a b` means `a` right-divides `b`,
114+
i.e., `∃ c, b = c * a`. -/
115+
def RightDvd (a b : α) : Prop := ∃ c, b = c * a
116+
117+
@[inherit_doc]
118+
infix:50 " ∣ᵣ " => RightDvd
119+
120+
@[trans]
121+
protected theorem RightDvd.trans : a ∣ᵣ b → b ∣ᵣ c → a ∣ᵣ c
122+
| ⟨d, h₁⟩, ⟨e, h₂⟩ => ⟨e * d, h₁ ▸ h₂.trans <| (mul_assoc e d a).symm⟩
123+
124+
/-- Transitivity of `RightDvd` for use in `calc` blocks. -/
125+
instance : IsTrans α RightDvd :=
126+
fun _ _ _ => RightDvd.trans⟩
127+
128+
@[simp]
129+
theorem RightDvd.mul_self (a b : α) : a ∣ᵣ b * a :=
130+
⟨b, rfl⟩
131+
132+
theorem RightDvd.mul_left (h : a ∣ᵣ b) (c : α) : a ∣ᵣ c * b :=
133+
h.trans (RightDvd.mul_self b c)
134+
135+
theorem RightDvd.of_mul_left (h : b * a ∣ᵣ c) : a ∣ᵣ c :=
136+
(RightDvd.mul_self a b).trans h
137+
138+
@[gcongr]
139+
theorem RightDvd.mul_const (a : α) (h : b ∣ᵣ c) : b * a ∣ᵣ c * a := by
140+
obtain ⟨d, rfl⟩ := h
141+
use d
142+
rw [mul_assoc]
143+
144+
theorem IsRightRegular.rightDvd_cancel_right (h : IsRightRegular a) :
145+
b * a ∣ᵣ c * a ↔ b ∣ᵣ c :=
146+
fun dvd ↦ have ⟨d, eq⟩ := dvd
147+
⟨d, h (eq.trans <| (mul_assoc ..).symm)⟩, RightDvd.mul_const a⟩
148+
149+
theorem rightDvd_iff_op_dvd_op : a ∣ᵣ b ↔ MulOpposite.op a ∣ MulOpposite.op b :=
150+
fun ⟨c, hc⟩ => ⟨MulOpposite.op c, by simp [hc]⟩,
151+
fun ⟨c, hc⟩ => ⟨MulOpposite.unop c, by simpa using congrArg MulOpposite.unop hc⟩⟩
152+
113153
end Semigroup
114154

155+
section RightCancelSemigroup
156+
157+
variable [RightCancelSemigroup α] {a b c : α}
158+
159+
@[simp]
160+
theorem mul_rightDvd_mul_iff_left : b * a ∣ᵣ c * a ↔ b ∣ᵣ c :=
161+
fun ⟨d, eq⟩ ↦ ⟨d, mul_right_cancel (eq.trans (mul_assoc ..).symm)⟩, RightDvd.mul_const a⟩
162+
163+
end RightCancelSemigroup
164+
115165
section Monoid
116166
variable [Monoid α] {a b c : α} {m n : ℕ}
117167

@@ -143,6 +193,19 @@ alias Dvd.dvd.pow := dvd_pow
143193

144194
lemma dvd_pow_self (a : α) {n : ℕ} (hn : n ≠ 0) : a ∣ a ^ n := dvd_rfl.pow hn
145195

196+
@[refl, simp]
197+
protected theorem RightDvd.refl (a : α) : a ∣ᵣ a :=
198+
1, (one_mul a).symm⟩
199+
200+
protected theorem RightDvd.rfl {a : α} : a ∣ᵣ a := .refl _
201+
202+
instance : IsPreorder α RightDvd where
203+
refl := .refl
204+
205+
theorem RightDvd.of_eq (h : a = b) : a ∣ᵣ b := by rw [h]
206+
207+
alias Eq.rightDvd := RightDvd.of_eq
208+
146209
end Monoid
147210

148211
section CommSemigroup
@@ -189,6 +252,10 @@ theorem dvd_mul [DecompositionMonoid α] {k m n : α} :
189252
rintro ⟨d₁, d₂, hy, hz, rfl⟩
190253
gcongr
191254

255+
@[simp]
256+
theorem rightDvd_iff_dvd : a ∣ᵣ b ↔ a ∣ b :=
257+
exists_congr fun c ↦ by rw [mul_comm]
258+
192259
end CommSemigroup
193260

194261
section CommMonoid

0 commit comments

Comments
 (0)