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

Commit 64ad902

Browse files
committed
refactor(algebra/order/{smul,module}): Turn lemmas around (#16696)
Match the `mul` lemmas by having the `⁻¹` on the LHS in `inv_smul_le_iff`, `inv_smul_lt_iff`, etc... Also generalize for free to `ordered_add_comm_monoid`.
1 parent a52be2a commit 64ad902

File tree

3 files changed

+25
-38
lines changed

3 files changed

+25
-38
lines changed

src/algebra/order/module.lean

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,17 @@ begin
160160
exact smul_le_smul_iff_of_pos (neg_pos_of_neg hc),
161161
end
162162

163-
lemma smul_lt_iff_of_neg (hc : c < 0) : c • a < b ↔ c⁻¹ • b < a :=
164-
begin
165-
rw [←neg_neg c, ←neg_neg a, neg_smul_neg, inv_neg, neg_smul _ b, neg_lt_neg_iff],
166-
exact smul_lt_iff_of_pos (neg_pos_of_neg hc),
167-
end
163+
lemma inv_smul_le_iff_of_neg (h : c < 0) : c⁻¹ • a ≤ b ↔ c • b ≤ a :=
164+
by { rw [←smul_le_smul_iff_of_neg h, smul_inv_smul₀ h.ne], apply_instance }
168165

169-
lemma lt_smul_iff_of_neg (hc : c < 0) : a < c • b ↔ b < c⁻¹ • a :=
170-
begin
171-
rw [←neg_neg c, ←neg_neg b, neg_smul_neg, inv_neg, neg_smul _ a, neg_lt_neg_iff],
172-
exact lt_smul_iff_of_pos (neg_pos_of_neg hc),
173-
end
166+
lemma inv_smul_lt_iff_of_neg (h : c < 0) : c⁻¹ • a < b ↔ c • b < a :=
167+
by { rw [←smul_lt_smul_iff_of_neg h, smul_inv_smul₀ h.ne], apply_instance }
168+
169+
lemma smul_inv_le_iff_of_neg (h : c < 0) : a ≤ c⁻¹ • b ↔ b ≤ c • a :=
170+
by { rw [←smul_le_smul_iff_of_neg h, smul_inv_smul₀ h.ne], apply_instance }
171+
172+
lemma smul_inv_lt_iff_of_neg (h : c < 0) : a < c⁻¹ • b ↔ b < c • a :=
173+
by { rw [←smul_lt_smul_iff_of_neg h, smul_inv_smul₀ h.ne], apply_instance }
174174

175175
variables (M)
176176

src/algebra/order/smul.lean

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,8 @@ instance linear_ordered_semiring.to_ordered_smul {R : Type*} [linear_ordered_sem
174174
ordered_smul.mk'' $ λ c, strict_mono_mul_left_of_pos
175175

176176
section linear_ordered_semifield
177-
variables [linear_ordered_semifield 𝕜]
178-
179-
section ordered_add_comm_monoid
180-
variables [ordered_add_comm_monoid M] [ordered_add_comm_monoid N] [mul_action_with_zero 𝕜 M]
181-
[mul_action_with_zero 𝕜 N]
177+
variables [linear_ordered_semifield 𝕜] [ordered_add_comm_monoid M] [ordered_add_comm_monoid N]
178+
[mul_action_with_zero 𝕜 M] [mul_action_with_zero 𝕜 N]
182179

183180
/-- To prove that a vector space over a linear ordered field is ordered, it suffices to verify only
184181
the first axiom of `ordered_smul`. -/
@@ -213,32 +210,24 @@ instance pi.ordered_smul' [ordered_smul 𝕜 M] : ordered_smul 𝕜 (ι → M) :
213210
/- Sometimes Lean fails to unify the module with the scalars, so we define another instance. -/
214211
instance pi.ordered_smul'' : ordered_smul 𝕜 (ι → 𝕜) := @pi.ordered_smul' ι 𝕜 𝕜 _ _ _ _
215212

216-
end ordered_add_comm_monoid
217-
218-
section ordered_add_comm_group
219-
variables [ordered_add_comm_group M] [mul_action_with_zero 𝕜 M] [ordered_smul 𝕜 M] {s : set M}
220-
{a b : M} {c : 𝕜}
213+
variables [ordered_smul 𝕜 M] {s : set M} {a b : M} {c : 𝕜}
221214

222215
lemma smul_le_smul_iff_of_pos (hc : 0 < c) : c • a ≤ c • b ↔ a ≤ b :=
223216
⟨λ h, inv_smul_smul₀ hc.ne' a ▸ inv_smul_smul₀ hc.ne' b ▸
224217
smul_le_smul_of_nonneg h (inv_nonneg.2 hc.le),
225218
λ h, smul_le_smul_of_nonneg h hc.le⟩
226219

227-
lemma smul_lt_iff_of_pos (hc : 0 < c) : c • a < b ↔ a < c⁻¹ • b :=
228-
calc c • a < b ↔ c • a < c • c⁻¹ • b : by rw [smul_inv_smul₀ hc.ne']
229-
... ↔ a < c⁻¹ • b : smul_lt_smul_iff_of_pos hc
220+
lemma inv_smul_le_iff (h : 0 < c) : c⁻¹ • a ≤ b ↔ a ≤ c • b :=
221+
by { rw [←smul_le_smul_iff_of_pos h, smul_inv_smul₀ h.ne'], apply_instance }
230222

231-
lemma lt_smul_iff_of_pos (hc : 0 < c) : a < c • b ↔ c⁻¹ • a < b :=
232-
calc a < c • b ↔ c • c⁻¹ • a < c • b : by rw [smul_inv_smul₀ hc.ne']
233-
... ↔ c⁻¹ • a < b : smul_lt_smul_iff_of_pos hc
223+
lemma inv_smul_lt_iff (h : 0 < c) : c⁻¹ • a < b ↔ a < c • b :=
224+
by { rw [←smul_lt_smul_iff_of_pos h, smul_inv_smul₀ h.ne'], apply_instance }
234225

235-
lemma smul_le_iff_of_pos (hc : 0 < c) : c • a ≤ b ↔ a ≤ c⁻¹ • b :=
236-
calc c • a ≤ b ↔ c • a ≤ c • c⁻¹ • b : by rw [smul_inv_smul₀ hc.ne']
237-
... ↔ a ≤ c⁻¹ • b : smul_le_smul_iff_of_pos hc
226+
lemma le_inv_smul_iff (h : 0 < c) : a ≤ c⁻¹ • b ↔ c • a ≤ b :=
227+
by { rw [←smul_le_smul_iff_of_pos h, smul_inv_smul₀ h.ne'], apply_instance }
238228

239-
lemma le_smul_iff_of_pos (hc : 0 < c) : a ≤ c • b ↔ c⁻¹ • a ≤ b :=
240-
calc a ≤ c • b ↔ c • c⁻¹ • a ≤ c • b : by rw [smul_inv_smul₀ hc.ne']
241-
... ↔ c⁻¹ • a ≤ b : smul_le_smul_iff_of_pos hc
229+
lemma lt_inv_smul_iff (h : 0 < c) : a < c⁻¹ • b ↔ c • a < b :=
230+
by { rw [←smul_lt_smul_iff_of_pos h, smul_inv_smul₀ h.ne'], apply_instance }
242231

243232
variables (M)
244233

@@ -264,7 +253,6 @@ variables {M}
264253
@[simp] lemma bdd_above_smul_iff_of_pos (hc : 0 < c) : bdd_above (c • s) ↔ bdd_above s :=
265254
(order_iso.smul_left _ hc).bdd_above_image
266255

267-
end ordered_add_comm_group
268256
end linear_ordered_semifield
269257

270258
namespace tactic

src/linear_algebra/affine_space/ordered.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ begin
203203
vsub_eq_sub, vsub_eq_sub, vsub_eq_sub, vadd_eq_add, vadd_eq_add,
204204
smul_eq_mul, add_sub_cancel, smul_sub, smul_sub, smul_sub,
205205
sub_le_iff_le_add, mul_inv_rev, mul_smul, mul_smul, ←smul_sub, ←smul_sub, ←smul_add, smul_smul,
206-
← mul_inv_rev, smul_le_iff_of_pos (inv_pos.2 h), inv_inv, smul_smul,
206+
← mul_inv_rev, inv_smul_le_iff h, smul_smul,
207207
mul_inv_cancel_right₀ (right_ne_zero_of_mul h.ne'), smul_add,
208208
smul_inv_smul₀ (left_ne_zero_of_mul h.ne')],
209209
apply_instance
@@ -236,11 +236,10 @@ begin
236236
rw [← line_map_apply_one_sub, ← line_map_apply_one_sub _ _ r],
237237
revert h, generalize : 1 - r = r', clear r, intro h,
238238
simp_rw [line_map_apply, slope, vsub_eq_sub, vadd_eq_add, smul_eq_mul],
239-
rw [sub_add_eq_sub_sub_swap, sub_self, zero_sub, le_smul_iff_of_pos, inv_inv, smul_smul,
240-
neg_mul_eq_mul_neg, neg_sub, mul_inv_cancel_right₀, le_sub, ← neg_sub (f b), smul_neg,
241-
neg_add_eq_sub],
239+
rw [sub_add_eq_sub_sub_swap, sub_self, zero_sub, neg_mul_eq_mul_neg, neg_sub, le_inv_smul_iff h,
240+
smul_smul, mul_inv_cancel_right₀, le_sub, ← neg_sub (f b), smul_neg, neg_add_eq_sub],
242241
{ exact right_ne_zero_of_mul h.ne' },
243-
{ simpa [mul_sub] using h }
242+
{ apply_instance }
244243
end
245244

246245
/-- Given `c = line_map a b r`, `c < b`, the point `(c, f c)` is non-strictly above the

0 commit comments

Comments
 (0)