@@ -275,7 +275,7 @@ lemma lt_of_mul_lt_mul_left {α : Type u} [has_mul α] [partial_order α]
275
275
∀ (a b c : with_zero α), a * b < a * c → b < c :=
276
276
begin
277
277
rintro (_ | a) (_ | b) (_ | c) h;
278
- try { exact false.elim (lt_irrefl none h) },
278
+ try { exact false.elim (lt_irrefl _ h) },
279
279
{ exact with_zero.zero_lt_coe c },
280
280
{ exact false.elim (not_le_of_lt h (with_zero.zero_le _)) },
281
281
{ simp_rw [some_eq_coe] at h ⊢,
@@ -340,7 +340,8 @@ end with_zero
340
340
@[protect_proj, ancestor ordered_add_comm_monoid has_bot]
341
341
class canonically_ordered_add_monoid (α : Type *) extends ordered_add_comm_monoid α, has_bot α :=
342
342
(bot_le : ∀ x : α, ⊥ ≤ x)
343
- (le_iff_exists_add : ∀ a b : α, a ≤ b ↔ ∃ c, b = a + c)
343
+ (exists_add_of_le : ∀ {a b : α}, a ≤ b → ∃ c, b = a + c)
344
+ (le_self_add : ∀ a b : α, a ≤ a + b)
344
345
345
346
@[priority 100 ] -- see Note [lower instance priority]
346
347
instance canonically_ordered_add_monoid.to_order_bot (α : Type u)
@@ -359,32 +360,36 @@ instance canonically_ordered_add_monoid.to_order_bot (α : Type u)
359
360
@[protect_proj, ancestor ordered_comm_monoid has_bot, to_additive]
360
361
class canonically_ordered_monoid (α : Type *) extends ordered_comm_monoid α, has_bot α :=
361
362
(bot_le : ∀ x : α, ⊥ ≤ x)
362
- (le_iff_exists_mul : ∀ a b : α, a ≤ b ↔ ∃ c, b = a * c)
363
+ (exists_mul_of_le : ∀ {a b : α}, a ≤ b → ∃ c, b = a * c)
364
+ (le_self_mul : ∀ a b : α, a ≤ a * b)
363
365
364
366
@[priority 100 , to_additive] -- see Note [lower instance priority]
365
367
instance canonically_ordered_monoid.to_order_bot (α : Type u)
366
368
[h : canonically_ordered_monoid α] : order_bot α :=
367
369
{ ..h }
368
370
371
+ @[priority 100 , to_additive] -- see Note [lower instance priority]
372
+ instance canonically_ordered_monoid.has_exists_mul_of_le (α : Type u)
373
+ [h : canonically_ordered_monoid α] : has_exists_mul_of_le α :=
374
+ { ..h }
375
+
369
376
section canonically_ordered_monoid
370
377
371
378
variables [canonically_ordered_monoid α] {a b c d : α}
372
379
373
- @[to_additive]
374
- lemma le_iff_exists_mul : a ≤ b ↔ ∃c, b = a * c :=
375
- canonically_ordered_monoid.le_iff_exists_mul a b
380
+ @[to_additive] lemma le_self_mul : a ≤ a * c := canonically_ordered_monoid.le_self_mul _ _
381
+ @[to_additive] lemma le_mul_self : a ≤ b * a := by { rw mul_comm, exact le_self_mul }
376
382
377
- @[to_additive]
378
- lemma le_iff_exists_mul' : a ≤ b ↔ ∃c, b = c * a :=
379
- by simpa only [mul_comm _ a] using le_iff_exists_mul
383
+ @[to_additive] lemma self_le_mul_right (a b : α) : a ≤ a * b := le_self_mul
384
+ @[to_additive] lemma self_le_mul_left (a b : α) : a ≤ b * a := le_mul_self
380
385
381
386
@[to_additive]
382
- lemma self_le_mul_right (a b : α) : a ≤ a * b :=
383
- le_iff_exists_mul.mpr ⟨b , rfl⟩
387
+ lemma le_iff_exists_mul : a ≤ b ↔ ∃ c, b = a * c :=
388
+ ⟨exists_mul_of_le, by { rintro ⟨c , rfl⟩, exact le_self_mul } ⟩
384
389
385
390
@[to_additive]
386
- lemma self_le_mul_left (a b : α) : a ≤ b * a :=
387
- by { rw [mul_comm], exact self_le_mul_right a b }
391
+ lemma le_iff_exists_mul' : a ≤ b ↔ ∃ c, b = c * a :=
392
+ by simpa only [mul_comm _ a] using le_iff_exists_mul
388
393
389
394
@[simp, to_additive zero_le] lemma one_le (a : α) : 1 ≤ a :=
390
395
le_iff_exists_mul.mpr ⟨a, (one_mul _).symm⟩
@@ -418,16 +423,10 @@ end
418
423
calc a = 1 * a : by simp
419
424
... ≤ b * c : mul_le_mul' (one_le _) h
420
425
421
- @[to_additive] lemma le_mul_self : a ≤ b * a :=
422
- le_mul_left (le_refl a)
423
-
424
426
@[to_additive] lemma le_mul_right (h : a ≤ b) : a ≤ b * c :=
425
427
calc a = a * 1 : by simp
426
428
... ≤ b * c : mul_le_mul' h (one_le _)
427
429
428
- @[to_additive] lemma le_self_mul : a ≤ a * c :=
429
- le_mul_right (le_refl a)
430
-
431
430
@[to_additive]
432
431
lemma lt_iff_exists_mul [covariant_class α α (*) (<)] : a < b ↔ ∃ c > 1 , b = a * c :=
433
432
begin
@@ -439,35 +438,31 @@ begin
439
438
{ rw [← (self_le_mul_right a c).lt_iff_ne], apply lt_mul_of_one_lt_right' }
440
439
end
441
440
441
+ instance with_zero.has_exists_add_of_le {α} [has_add α] [preorder α] [has_exists_add_of_le α] :
442
+ has_exists_add_of_le (with_zero α) :=
443
+ ⟨λ a b, begin
444
+ apply with_zero.cases_on a,
445
+ { exact λ _, ⟨b, (zero_add b).symm⟩ },
446
+ apply with_zero.cases_on b,
447
+ { exact λ b' h, (with_bot.not_coe_le_bot _ h).elim },
448
+ rintro a' b' h,
449
+ obtain ⟨c, rfl⟩ := exists_add_of_le (with_zero.coe_le_coe.1 h),
450
+ exact ⟨c, rfl⟩,
451
+ end ⟩
452
+
442
453
-- This instance looks absurd: a monoid already has a zero
443
454
/-- Adding a new zero to a canonically ordered additive monoid produces another one. -/
444
455
instance with_zero.canonically_ordered_add_monoid {α : Type u} [canonically_ordered_add_monoid α] :
445
456
canonically_ordered_add_monoid (with_zero α) :=
446
- { le_iff_exists_add := λ a b, begin
457
+ { le_self_add := λ a b, begin
447
458
apply with_zero.cases_on a,
448
- { exact iff_of_true bot_le ⟨b, (zero_add b).symm⟩ },
459
+ { exact bot_le },
449
460
apply with_zero.cases_on b,
450
- { intro b',
451
- refine iff_of_false (mt (le_antisymm bot_le) (by simp)) (not_exists.mpr (λ c, _)),
452
- apply with_zero.cases_on c;
453
- simp [←with_zero.coe_add] },
454
- { simp only [le_iff_exists_add, with_zero.coe_le_coe],
455
- intros,
456
- split; rintro ⟨c, h⟩,
457
- { exact ⟨c, congr_arg coe h⟩ },
458
- { induction c using with_zero.cases_on,
459
- { refine ⟨0 , _⟩,
460
- simpa using h },
461
- { refine ⟨c, _⟩,
462
- simpa [←with_zero.coe_add] using h } } }
461
+ { exact λ b', le_rfl },
462
+ { exact λ a' b', with_zero.coe_le_coe.2 le_self_add }
463
463
end ,
464
464
.. with_zero.order_bot,
465
- .. with_zero.ordered_add_comm_monoid zero_le }
466
-
467
- @[priority 100 , to_additive]
468
- instance canonically_ordered_monoid.has_exists_mul_of_le (α : Type u)
469
- [canonically_ordered_monoid α] : has_exists_mul_of_le α :=
470
- { exists_mul_of_le := λ a b hab, le_iff_exists_mul.mp hab }
465
+ .. with_zero.ordered_add_comm_monoid zero_le, ..with_zero.has_exists_add_of_le }
471
466
472
467
end canonically_ordered_monoid
473
468
@@ -817,9 +812,8 @@ instance [ordered_cancel_comm_monoid M] [ordered_cancel_comm_monoid N] :
817
812
818
813
@[to_additive] instance [canonically_ordered_monoid α] [canonically_ordered_monoid β] :
819
814
canonically_ordered_monoid (α × β) :=
820
- { le_iff_exists_mul := λ a b,
821
- ⟨exists_mul_of_le, by { rintro ⟨c, rfl⟩, exact ⟨le_self_mul, le_self_mul⟩ }⟩,
822
- .. prod.ordered_comm_monoid, .. prod.order_bot _ _ }
815
+ { le_self_mul := λ a b, ⟨le_self_mul, le_self_mul⟩,
816
+ ..prod.ordered_comm_monoid, ..prod.order_bot _ _, ..prod.has_exists_mul_of_le }
823
817
824
818
end prod
825
819
@@ -1050,23 +1044,25 @@ instance [linear_ordered_add_comm_monoid α] :
1050
1044
..with_top.ordered_add_comm_monoid,
1051
1045
..option.nontrivial }
1052
1046
1053
- instance [canonically_ordered_add_monoid α] : canonically_ordered_add_monoid (with_top α) :=
1054
- { le_iff_exists_add := assume a b,
1055
- match a, b with
1047
+ instance [has_le α] [has_add α] [has_exists_add_of_le α] : has_exists_add_of_le (with_top α) :=
1048
+ ⟨λ a b, match a, b with
1056
1049
| ⊤, ⊤ := by simp
1057
- | (a : α), ⊤ := by { simp only [true_iff, le_top], refine ⟨⊤, _⟩, refl }
1058
- | (a : α), (b : α) := begin
1059
- rw [with_top.coe_le_coe, le_iff_exists_add],
1060
- split,
1061
- { rintro ⟨c, rfl⟩,
1062
- refine ⟨c, _⟩, norm_cast },
1063
- { intro h,
1064
- exact match b, h with _, ⟨some c, rfl⟩ := ⟨_, rfl⟩ end }
1050
+ | (a : α), ⊤ := λ _, ⟨⊤, rfl⟩
1051
+ | (a : α), (b : α) := λ h, begin
1052
+ obtain ⟨c, rfl⟩ := exists_add_of_le (with_top.coe_le_coe.1 h),
1053
+ exact ⟨c, rfl⟩
1065
1054
end
1066
- | ⊤, (b : α) := by simp
1055
+ | ⊤, (b : α) := λ h, (not_top_le_coe _ h).elim
1056
+ end ⟩
1057
+
1058
+ instance [canonically_ordered_add_monoid α] : canonically_ordered_add_monoid (with_top α) :=
1059
+ { le_self_add := λ a b, match a, b with
1060
+ | ⊤, ⊤ := le_rfl
1061
+ | (a : α), ⊤ := le_top
1062
+ | (a : α), (b : α) := with_top.coe_le_coe.2 le_self_add
1063
+ | ⊤, (b : α) := le_rfl
1067
1064
end ,
1068
- .. with_top.order_bot,
1069
- .. with_top.ordered_add_comm_monoid }
1065
+ ..with_top.order_bot, ..with_top.ordered_add_comm_monoid, ..with_top.has_exists_add_of_le }
1070
1066
1071
1067
instance [canonically_linear_ordered_add_monoid α] :
1072
1068
canonically_linear_ordered_add_monoid (with_top α) :=
@@ -1287,12 +1283,13 @@ instance [has_mul α] [has_le α] [has_exists_mul_of_le α] : has_exists_add_of_
1287
1283
⟨@exists_mul_of_le α _ _ _⟩
1288
1284
1289
1285
instance [canonically_ordered_add_monoid α] : canonically_ordered_monoid (multiplicative α) :=
1290
- { le_iff_exists_mul := @le_iff_exists_add α _,
1291
- ..multiplicative.ordered_comm_monoid, ..multiplicative.order_bot }
1286
+ { le_self_mul := @le_self_add α _,
1287
+ ..multiplicative.ordered_comm_monoid, ..multiplicative.order_bot,
1288
+ ..multiplicative.has_exists_mul_of_le }
1292
1289
1293
1290
instance [canonically_ordered_monoid α] : canonically_ordered_add_monoid (additive α) :=
1294
- { le_iff_exists_add := @le_iff_exists_mul α _,
1295
- ..additive.ordered_add_comm_monoid, ..additive.order_bot }
1291
+ { le_self_add := @le_self_mul α _,
1292
+ ..additive.ordered_add_comm_monoid, ..additive.order_bot, ..additive.has_exists_add_of_le }
1296
1293
1297
1294
instance [canonically_linear_ordered_add_monoid α] :
1298
1295
canonically_linear_ordered_monoid (multiplicative α) :=
0 commit comments