|
2 | 2 | Copyright (c) 2014 Jeremy Avigad. All rights reserved. |
3 | 3 | Released under Apache 2.0 license as described in the file LICENSE. |
4 | 4 | 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 |
6 | 6 | -/ |
7 | 7 | module |
8 | 8 |
|
9 | | -public import Mathlib.Algebra.Group.Basic |
| 9 | +public import Mathlib.Algebra.Group.Opposite |
10 | 10 | public import Mathlib.Tactic.Common |
11 | 11 | public import Batteries.Tactic.SeqFocus |
12 | 12 |
|
@@ -110,8 +110,58 @@ theorem mul_dvd_mul_left (a : α) (h : b ∣ c) : a * b ∣ a * c := by |
110 | 110 | theorem IsLeftRegular.dvd_cancel_left (h : IsLeftRegular a) : a * b ∣ a * c ↔ b ∣ c := |
111 | 111 | ⟨fun dvd ↦ have ⟨d, eq⟩ := dvd; ⟨d, h (eq.trans <| mul_assoc ..)⟩, mul_dvd_mul_left a⟩ |
112 | 112 |
|
| 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 | + |
113 | 153 | end Semigroup |
114 | 154 |
|
| 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 | + |
115 | 165 | section Monoid |
116 | 166 | variable [Monoid α] {a b c : α} {m n : ℕ} |
117 | 167 |
|
@@ -143,6 +193,19 @@ alias Dvd.dvd.pow := dvd_pow |
143 | 193 |
|
144 | 194 | lemma dvd_pow_self (a : α) {n : ℕ} (hn : n ≠ 0) : a ∣ a ^ n := dvd_rfl.pow hn |
145 | 195 |
|
| 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 | + |
146 | 209 | end Monoid |
147 | 210 |
|
148 | 211 | section CommSemigroup |
@@ -189,6 +252,10 @@ theorem dvd_mul [DecompositionMonoid α] {k m n : α} : |
189 | 252 | rintro ⟨d₁, d₂, hy, hz, rfl⟩ |
190 | 253 | gcongr |
191 | 254 |
|
| 255 | +@[simp] |
| 256 | +theorem rightDvd_iff_dvd : a ∣ᵣ b ↔ a ∣ b := |
| 257 | + exists_congr fun c ↦ by rw [mul_comm] |
| 258 | + |
192 | 259 | end CommSemigroup |
193 | 260 |
|
194 | 261 | section CommMonoid |
|
0 commit comments