@@ -311,6 +311,15 @@ instance [ordered_comm_monoid α] : ordered_comm_monoid (with_zero α) :=
311
311
..with_zero.partial_order
312
312
}
313
313
314
+ /-
315
+ Note 1 : the below is not an instance because it requires `zero_le`. It seems
316
+ like a rather pathological definition because α already has a zero.
317
+
318
+ Note 2 : there is no multiplicative analogue because it does not seem necessary.
319
+ Mathematicians might be more likely to use the order-dual version, where all
320
+ elements are ≤ 1 and then 1 is the top element.
321
+ -/
322
+
314
323
/--
315
324
If `0` is the least element in `α`, then `with_zero α` is an `ordered_add_comm_monoid`.
316
325
-/
@@ -520,55 +529,74 @@ by norm_cast
520
529
end with_bot
521
530
522
531
/-- A canonically ordered additive monoid is an ordered commutative additive monoid
523
- in which the ordering coincides with the divisibility relation,
532
+ in which the ordering coincides with the subtractibility relation,
524
533
which is to say, `a ≤ b` iff there exists `c` with `b = a + c`.
525
534
This is satisfied by the natural numbers, for example, but not
526
- the integers or other ordered groups . -/
527
- @[protect_proj]
535
+ the integers or other nontrivial `ordered_add_comm_group`s . -/
536
+ @[protect_proj, ancestor ordered_add_comm_monoid order_bot ]
528
537
class canonically_ordered_add_monoid (α : Type *) extends ordered_add_comm_monoid α, order_bot α :=
529
- (le_iff_exists_add : ∀a b:α, a ≤ b ↔ ∃c, b = a + c)
538
+ (le_iff_exists_add : ∀ a b : α, a ≤ b ↔ ∃ c, b = a + c)
539
+
540
+ /-- A canonically ordered monoid is an ordered commutative monoid
541
+ in which the ordering coincides with the divisibility relation,
542
+ which is to say, `a ≤ b` iff there exists `c` with `b = a * c`.
543
+ Example seem rare; it seems more likely that the `order_dual`
544
+ of a naturally-occurring lattice satisfies this than the lattice
545
+ itself (for example, dual of the lattice of ideals of a PID or
546
+ Dedekind domain satisfy this; collections of all things ≤ 1 seem to
547
+ be more natural that collections of all things ≥ 1).
548
+ -/
549
+ @[protect_proj, ancestor ordered_comm_monoid order_bot, to_additive]
550
+ class canonically_ordered_monoid (α : Type *) extends ordered_comm_monoid α, order_bot α :=
551
+ (le_iff_exists_mul : ∀ a b : α, a ≤ b ↔ ∃ c, b = a * c)
530
552
531
- section canonically_ordered_add_monoid
532
- variables [canonically_ordered_add_monoid α] {a b c d : α}
553
+ section canonically_ordered_monoid
533
554
534
- lemma le_iff_exists_add : a ≤ b ↔ ∃c, b = a + c :=
535
- canonically_ordered_add_monoid.le_iff_exists_add a b
555
+ variables [canonically_ordered_monoid α] {a b c d : α}
536
556
537
- @[simp] lemma zero_le (a : α) : 0 ≤ a := le_iff_exists_add.mpr ⟨a, by simp⟩
557
+ @[to_additive]
558
+ lemma le_iff_exists_mul : a ≤ b ↔ ∃c, b = a * c :=
559
+ canonically_ordered_monoid.le_iff_exists_mul a b
560
+
561
+ @[simp, to_additive zero_le] lemma one_le (a : α) : 1 ≤ a := le_iff_exists_mul.mpr ⟨a, by simp⟩
538
562
539
- @[simp] lemma bot_eq_zero : (⊥ : α) = 0 :=
540
- le_antisymm bot_le (zero_le ⊥)
563
+ @[simp, to_additive ] lemma bot_eq_one : (⊥ : α) = 1 :=
564
+ le_antisymm bot_le (one_le ⊥)
541
565
542
- @[simp] lemma add_eq_zero_iff : a + b = 0 ↔ a = 0 ∧ b = 0 :=
543
- add_eq_zero_iff ' (zero_le _) (zero_le _)
566
+ @[simp, to_additive ] lemma mul_eq_one_iff : a * b = 1 ↔ a = 1 ∧ b = 1 :=
567
+ mul_eq_one_iff ' (one_le _) (one_le _)
544
568
545
- @[simp] lemma le_zero_iff_eq : a ≤ 0 ↔ a = 0 :=
569
+ -- TODO -- global replace le_zero_iff_eq by n nonpos_iff_eq_zero?
570
+ @[simp, to_additive le_zero_iff_eq] lemma le_one_iff_eq : a ≤ 1 ↔ a = 1 :=
546
571
iff.intro
547
- (assume h, le_antisymm h (zero_le a))
572
+ (assume h, le_antisymm h (one_le a))
548
573
(assume h, h ▸ le_refl a)
549
574
550
- lemma zero_lt_iff_ne_zero : 0 < a ↔ a ≠ 0 :=
551
- iff.intro ne_of_gt $ assume hne, lt_of_le_of_ne (zero_le _) hne.symm
575
+ -- TODO -- global replace zero_lt_iff_ne_zero by pos_iff_ne_zero?
576
+ @[to_additive zero_lt_iff_ne_zero] lemma one_lt_iff_ne_one : 1 < a ↔ a ≠ 1 :=
577
+ iff.intro ne_of_gt $ assume hne, lt_of_le_of_ne (one_le _) hne.symm
552
578
553
- lemma exists_pos_add_of_lt (h : a < b) : ∃ c > 0 , a + c = b :=
579
+ @[to_additive] lemma exists_pos_mul_of_lt (h : a < b) : ∃ c > 1 , a * c = b :=
554
580
begin
555
- obtain ⟨c, hc⟩ := le_iff_exists_add .1 h.le,
556
- refine ⟨c, zero_lt_iff_ne_zero .2 _, hc.symm⟩,
581
+ obtain ⟨c, hc⟩ := le_iff_exists_mul .1 h.le,
582
+ refine ⟨c, one_lt_iff_ne_one .2 _, hc.symm⟩,
557
583
rintro rfl,
558
584
simpa [hc, lt_irrefl] using h
559
585
end
560
586
561
- lemma le_add_left (h : a ≤ c) : a ≤ b + c :=
562
- calc a = 0 + a : by simp
563
- ... ≤ b + c : add_le_add (zero_le _) h
587
+ @[to_additive] lemma le_mul_left (h : a ≤ c) : a ≤ b * c :=
588
+ calc a = 1 * a : by simp
589
+ ... ≤ b * c : mul_le_mul' (one_le _) h
564
590
565
- lemma le_add_right (h : a ≤ b) : a ≤ b + c :=
566
- calc a = a + 0 : by simp
567
- ... ≤ b + c : add_le_add h (zero_le _)
591
+ @[to_additive] lemma le_mul_right (h : a ≤ b) : a ≤ b * c :=
592
+ calc a = a * 1 : by simp
593
+ ... ≤ b * c : mul_le_mul' h (one_le _)
568
594
569
595
local attribute [semireducible] with_zero
570
596
571
- instance with_zero.canonically_ordered_add_monoid :
597
+ -- This instance looks absurd: a monoid already has a zero
598
+ /-- Adding a new zero to a canonically ordered additive monoid produces another one. -/
599
+ instance with_zero.canonically_ordered_add_monoid {α : Type u} [canonically_ordered_add_monoid α] :
572
600
canonically_ordered_add_monoid (with_zero α) :=
573
601
{ le_iff_exists_add := λ a b, begin
574
602
cases a with a,
@@ -588,7 +616,8 @@ instance with_zero.canonically_ordered_add_monoid :
588
616
bot_le := assume a a' h, option.no_confusion h,
589
617
.. with_zero.ordered_add_comm_monoid zero_le }
590
618
591
- instance with_top.canonically_ordered_add_monoid : canonically_ordered_add_monoid (with_top α) :=
619
+ instance with_top.canonically_ordered_add_monoid {α : Type u} [canonically_ordered_add_monoid α] :
620
+ canonically_ordered_add_monoid (with_top α) :=
592
621
{ le_iff_exists_add := assume a b,
593
622
match a, b with
594
623
| a, none := show a ≤ ⊤ ↔ ∃c, ⊤ = a + c, by simp; refine ⟨⊤, _⟩; cases a; refl
@@ -604,26 +633,39 @@ instance with_top.canonically_ordered_add_monoid : canonically_ordered_add_monoi
604
633
.. with_top.order_bot,
605
634
.. with_top.ordered_add_comm_monoid }
606
635
607
- end canonically_ordered_add_monoid
636
+ end canonically_ordered_monoid
608
637
609
638
/-- A canonically linear-ordered additive monoid is a canonically ordered additive monoid
610
- whose ordering is a decidable linear order. -/
611
- @[protect_proj]
639
+ whose ordering is a linear order. -/
640
+ @[protect_proj, ancestor canonically_ordered_add_monoid linear_order ]
612
641
class canonically_linear_ordered_add_monoid (α : Type *)
613
642
extends canonically_ordered_add_monoid α, linear_order α
614
643
615
- section canonically_linear_ordered_add_monoid
616
- variables [canonically_linear_ordered_add_monoid α]
644
+ /-- A canonically linear-ordered monoid is a canonically ordered monoid
645
+ whose ordering is a linear order. -/
646
+ @[protect_proj, ancestor canonically_ordered_monoid linear_order]
647
+ class canonically_linear_ordered_monoid (α : Type *)
648
+ extends canonically_ordered_monoid α, linear_order α
649
+
650
+ section canonically_linear_ordered_monoid
651
+ variables
617
652
618
653
@[priority 100 ] -- see Note [lower instance priority]
619
- instance canonically_linear_ordered_add_monoid.semilattice_sup_bot : semilattice_sup_bot α :=
654
+ instance canonically_linear_ordered_add_monoid.semilattice_sup_bot
655
+ [canonically_linear_ordered_add_monoid α] : semilattice_sup_bot α :=
620
656
{ ..lattice_of_linear_order, ..canonically_ordered_add_monoid.to_order_bot α }
621
657
622
- end canonically_linear_ordered_add_monoid
658
+ @[priority 100 , to_additive canonically_linear_ordered_add_monoid.semilattice_sup_bot]
659
+ -- see Note [lower instance priority]
660
+ instance canonically_linear_ordered_monoid.semilattice_sup_bot
661
+ [canonically_linear_ordered_monoid α] : semilattice_sup_bot α :=
662
+ { ..lattice_of_linear_order, ..canonically_ordered_monoid.to_order_bot α }
663
+
664
+ end canonically_linear_ordered_monoid
623
665
624
666
/-- An ordered cancellative additive commutative monoid
625
667
is an additive commutative monoid with a partial order,
626
- in which addition is cancellative and strictly monotone. -/
668
+ in which addition is cancellative and monotone. -/
627
669
@[protect_proj, ancestor add_comm_monoid add_left_cancel_semigroup
628
670
add_right_cancel_semigroup partial_order]
629
671
class ordered_cancel_add_comm_monoid (α : Type u)
@@ -634,16 +676,15 @@ class ordered_cancel_add_comm_monoid (α : Type u)
634
676
635
677
/-- An ordered cancellative commutative monoid
636
678
is a commutative monoid with a partial order,
637
- in which multiplication is cancellative and strictly monotone. -/
638
- @[protect_proj, ancestor comm_monoid left_cancel_semigroup right_cancel_semigroup partial_order]
679
+ in which multiplication is cancellative and monotone. -/
680
+ @[protect_proj, ancestor comm_monoid left_cancel_semigroup right_cancel_semigroup partial_order,
681
+ to_additive]
639
682
class ordered_cancel_comm_monoid (α : Type u)
640
683
extends comm_monoid α, left_cancel_semigroup α,
641
684
right_cancel_semigroup α, partial_order α :=
642
685
(mul_le_mul_left : ∀ a b : α, a ≤ b → ∀ c : α, c * a ≤ c * b)
643
686
(le_of_mul_le_mul_left : ∀ a b c : α, a * b ≤ a * c → b ≤ c)
644
687
645
- attribute [to_additive] ordered_cancel_comm_monoid
646
-
647
688
section ordered_cancel_comm_monoid
648
689
variables [ordered_cancel_comm_monoid α] {a b c d : α}
649
690
@@ -894,12 +935,6 @@ by simpa [add_comm] using @with_bot.add_lt_add_iff_left _ _ a b c
894
935
895
936
end ordered_cancel_add_comm_monoid
896
937
897
- /-- A decidable linearly ordered cancellative additive commutative monoid
898
- is an additive commutative monoid with a decidable linear order
899
- in which addition is cancellative and strictly monotone. -/
900
- @[protect_proj] class linear_ordered_cancel_add_comm_monoid (α : Type u)
901
- extends ordered_cancel_add_comm_monoid α, linear_order α
902
-
903
938
/-! Some lemmas about types that have an ordering and a binary operation, with no
904
939
rules relating them. -/
905
940
@[to_additive]
@@ -912,50 +947,75 @@ lemma min_mul_max [linear_order α] [comm_semigroup α] (n m : α) :
912
947
min n m * max n m = n * m :=
913
948
fn_min_mul_fn_max id n m
914
949
915
- section linear_ordered_cancel_add_comm_monoid
916
- variables [linear_ordered_cancel_add_comm_monoid α]
950
+ /-- A linearly ordered cancellative additive commutative monoid
951
+ is an additive commutative monoid with a decidable linear order
952
+ in which addition is cancellative and monotone. -/
953
+ @[protect_proj, ancestor ordered_cancel_add_comm_monoid linear_order]
954
+ class linear_ordered_cancel_add_comm_monoid (α : Type u)
955
+ extends ordered_cancel_add_comm_monoid α, linear_order α
917
956
918
- lemma min_add_add_left (a b c : α) : min (a + b) (a + c) = a + min b c :=
919
- (monotone_id.const_add a).map_min.symm
957
+ /-- A linearly ordered cancellative commutative monoid
958
+ is a commutative monoid with a linear order
959
+ in which multiplication is cancellative and monotone. -/
960
+ @[protect_proj, ancestor ordered_cancel_comm_monoid linear_order, to_additive]
961
+ class linear_ordered_cancel_comm_monoid (α : Type u)
962
+ extends ordered_cancel_comm_monoid α, linear_order α
920
963
921
- lemma min_add_add_right (a b c : α) : min (a + c) (b + c) = min a b + c :=
922
- (monotone_id.add_const c).map_min.symm
964
+ section linear_ordered_cancel_comm_monoid
923
965
924
- lemma max_add_add_left (a b c : α) : max (a + b) (a + c) = a + max b c :=
925
- (monotone_id.const_add a).map_max.symm
966
+ variables [linear_ordered_cancel_comm_monoid α]
926
967
927
- lemma max_add_add_right (a b c : α) : max (a + c) (b + c) = max a b + c :=
928
- (monotone_id.add_const c).map_max.symm
968
+ @[to_additive] lemma min_mul_mul_left (a b c : α) : min (a * b) (a * c) = a * min b c :=
969
+ (monotone_id.const_mul' a).map_min.symm
970
+
971
+ @[to_additive]
972
+ lemma min_mul_mul_right (a b c : α) : min (a * c) (b * c) = min a b * c :=
973
+ (monotone_id.mul_const' c).map_min.symm
929
974
930
- lemma min_le_add_of_nonneg_right {a b : α} (hb : 0 ≤ b) : min a b ≤ a + b :=
931
- min_le_iff.2 $ or.inl $ le_add_of_nonneg_right hb
975
+ @[to_additive]
976
+ lemma max_mul_mul_left (a b c : α) : max (a * b) (a * c) = a * max b c :=
977
+ (monotone_id.const_mul' a).map_max.symm
932
978
933
- lemma min_le_add_of_nonneg_left {a b : α} (ha : 0 ≤ a) : min a b ≤ a + b :=
934
- min_le_iff.2 $ or.inr $ le_add_of_nonneg_left ha
979
+ @[to_additive]
980
+ lemma max_mul_mul_right (a b c : α) : max (a * c) (b * c) = max a b * c :=
981
+ (monotone_id.mul_const' c).map_max.symm
935
982
936
- lemma max_le_add_of_nonneg {a b : α} (ha : 0 ≤ a) (hb : 0 ≤ b) : max a b ≤ a + b :=
937
- max_le_iff.2 ⟨le_add_of_nonneg_right hb, le_add_of_nonneg_left ha⟩
983
+ @[to_additive]
984
+ lemma min_le_mul_of_one_le_right {a b : α} (hb : 1 ≤ b) : min a b ≤ a * b :=
985
+ min_le_iff.2 $ or.inl $ le_mul_of_one_le_right' hb
938
986
939
- end linear_ordered_cancel_add_comm_monoid
987
+ @[to_additive]
988
+ lemma min_le_mul_of_one_le_left {a b : α} (ha : 1 ≤ a) : min a b ≤ a * b :=
989
+ min_le_iff.2 $ or.inr $ le_mul_of_one_le_left' ha
990
+
991
+ @[to_additive]
992
+ lemma max_le_mul_of_one_le {a b : α} (ha : 1 ≤ a) (hb : 1 ≤ b) : max a b ≤ a * b :=
993
+ max_le_iff.2 ⟨le_mul_of_one_le_right' hb, le_mul_of_one_le_left' ha⟩
994
+
995
+ end linear_ordered_cancel_comm_monoid
940
996
941
997
namespace order_dual
942
998
943
- instance [ordered_add_comm_monoid α] : ordered_add_comm_monoid (order_dual α) :=
944
- { add_le_add_left := λ a b h c, @add_le_add_left α _ b a h _,
945
- lt_of_add_lt_add_left := λ a b c h, @lt_of_add_lt_add_left α _ a c b h,
999
+ @[to_additive]
1000
+ instance [ordered_comm_monoid α] : ordered_comm_monoid (order_dual α) :=
1001
+ { mul_le_mul_left := λ a b h c, @mul_le_mul_left' α _ b a h _,
1002
+ lt_of_mul_lt_mul_left := λ a b c h, @lt_of_mul_lt_mul_left' α _ a c b h,
946
1003
..order_dual.partial_order α,
947
- ..show add_comm_monoid α, by apply_instance }
1004
+ ..show comm_monoid α, by apply_instance }
948
1005
949
- instance [ordered_cancel_add_comm_monoid α] : ordered_cancel_add_comm_monoid (order_dual α) :=
950
- { le_of_add_le_add_left := λ a b c : α, le_of_add_le_add_left,
951
- add_left_cancel := @add_left_cancel α _,
952
- add_right_cancel := @add_right_cancel α _,
953
- ..order_dual.ordered_add_comm_monoid }
954
1006
955
- instance [linear_ordered_cancel_add_comm_monoid α] :
956
- linear_ordered_cancel_add_comm_monoid (order_dual α) :=
1007
+ @[to_additive]
1008
+ instance [ordered_cancel_comm_monoid α] : ordered_cancel_comm_monoid (order_dual α) :=
1009
+ { le_of_mul_le_mul_left := λ a b c : α, le_of_mul_le_mul_left',
1010
+ mul_left_cancel := @mul_left_cancel α _,
1011
+ mul_right_cancel := @mul_right_cancel α _,
1012
+ ..order_dual.ordered_comm_monoid }
1013
+
1014
+ @[to_additive]
1015
+ instance [linear_ordered_cancel_comm_monoid α] :
1016
+ linear_ordered_cancel_comm_monoid (order_dual α) :=
957
1017
{ .. order_dual.linear_order α,
958
- .. order_dual.ordered_cancel_add_comm_monoid }
1018
+ .. order_dual.ordered_cancel_comm_monoid }
959
1019
960
1020
end order_dual
961
1021
0 commit comments