@@ -3,93 +3,23 @@ Copyright (c) 2016 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, Mario Carneiro, Johannes Hölzl, Damiano Testa
5
5
-/
6
- import algebra.group.defs
7
- import order.basic
8
- /-!
9
- This file begins the splitting of the ordering assumptions from the algebraic assumptions on the
10
- operations in the `ordered_[...]` hierarchy.
11
-
12
- The strategy is to introduce two more flexible typeclasses, covariant_class and contravariant_class.
13
-
14
- * covariant_class models the implication a ≤ b → c * a ≤ c * b (multiplication is monotone),
15
- * contravariant_class models the implication a * b < a * c → b < c.
16
-
17
- Since `co(ntra)variant_class` takes as input the operation (typically `(+)` or `(*)`) and the order
18
- relation (typically `(≤)` or `(<)`), these are the only two typeclasses that I have used.
19
-
20
- The general approach is to formulate the lemma that you are interested and prove it, with the
21
- `ordered_[...]` typeclass of your liking. After that, you convert the single typeclass,
22
- say `[ordered_cancel_monoid M]`, with three typeclasses, e.g.
23
- `[partial_order M] [left_cancel_semigroup M] [covariant_class M M (function.swap (*)) (≤)]`
24
- and have a go at seeing if the proof still works!
25
-
26
- Note that it is possible to combine several co(ntra)variant_class assumptions together.
27
- Indeed, the usual ordered typeclasses arise from assuming the pair
28
- `[covariant_class M M (*) (≤)] [contravariant_class M M (*) (<)]`
29
- on top of order/algebraic assumptions.
30
-
31
- A formal remark is that normally covariant_class uses the `(≤)`-relation, while contravariant_class
32
- uses the `(<)`-relation. This need not be the case in general, but seems to be the most common
33
- usage. In the opposite direction, the implication
34
-
35
- ```lean
36
- [semigroup α] [partial_order α] [contravariant_class α α (*) (≤)] => left_cancel_semigroup α
37
- ```
38
- holds (note the `co*ntra*` assumption and the `(≤)`-relation).
39
- -/
40
- -- TODO: convert `has_exists_mul_of_le`, `has_exists_add_of_le`?
41
- -- TODO: relationship with add_con
42
- -- include equivalence of `left_cancel_semigroup` with
43
- -- `semigroup partial_order contravariant_class α α (*) (≤)`?
44
- -- use ⇒, as per Eric's suggestion?
45
- section variants
46
-
47
- variables {M N : Type *} (μ : M → N → N) (r s : N → N → Prop ) (m : M) {a b c : N}
48
6
7
+ import algebra.covariant_and_contravariant
8
+ import order.basic
49
9
50
- variables (M N)
51
- /-- `covariant` is useful to formulate succintly statements about the interactions between an
52
- action of a Type on another one and a relation on the acted-upon Type.
53
-
54
- See the `covariant_class` doc-string for its meaning. -/
55
- def covariant : Prop := ∀ (m) {n₁ n₂}, r n₁ n₂ → r (μ m n₁) (μ m n₂)
56
-
57
- /-- `contravariant` is useful to formulate succintly statements about the interactions between an
58
- action of a Type on another one and a relation on the acted-upon Type.
59
-
60
- See the `contravariant_class` doc-string for its meaning. -/
61
- def contravariant : Prop := ∀ (m) {n₁ n₂}, s (μ m n₁) (μ m n₂) → s n₁ n₂
62
-
63
- /-- Given an action `μ` of a Type `M` on a Type `N` and a relation `r` on `N`, informally, the
64
- `covariant_class` says that "the action `μ` preserves the relation `r`.
65
-
66
- More precisely, the `covariant_class` is a class taking two Types `M N`, together with an "action"
67
- `μ : M → N → N` and a relation `r : N → N`. Its unique field `covc` is the assertion that
68
- for all `m ∈ M` and all elements `n₁, n₂ ∈ N`, if the relation `r` holds for the pair
69
- `(n₁, n₂)`, then, the relation `r` also holds for the pair `(μ m n₁, μ m n₂)`,
70
- obtained from `(n₁, n₂)` by "acting upon it by `m`".
71
-
72
- If `m : M` and `h : r n₁ n₂`, then `covariant_class.covc m h : r (μ m n₁) (μ m n₂)`.
73
- -/
74
- class covariant_class :=
75
- (covc : covariant M N μ r)
76
-
77
- /-- Given an action `μ` of a Type `M` on a Type `N` and a relation `r` on `N`, informally, the
78
- `contravariant_class` says that "if the result of the action `μ` on a pair satisfies the
79
- relation `r`, then the initial pair satisfied the relation `r`.
10
+ /-!
11
+ # Ordered monoids
12
+ This file develops the basics of ordered monoids.
80
13
81
- More precisely, the `contravariant_class` is a class taking two Types `M N`, together with an
82
- "action" `μ : M → N → N` and a relation `r : N → N`. Its unique field `covtc` is the assertion that
83
- for all `m ∈ M` and all elements `n₁, n₂ ∈ N`, if the relation `r` holds for the pair
84
- `(μ m n₁, μ m n₂)` obtained from `(n₁, n₂)` by "acting upon it by `m`"", then, the relation `r`
85
- also holds for the pair `(n₁, n₂)`.
14
+ ## Implementation details
15
+ Unfortunately, the number of `'` appended to lemmas in this file
16
+ may differ between the multiplicative and the additive version of a lemma.
17
+ The reason is that we did not want to change existing names in the library.
86
18
87
- If `m : M` and `h : r (μ m n₁) (μ m n₂)`, then `covariant_class.covc m h : r n₁ n₂`.
19
+ ## Remark
20
+ No monoid is actually present in this file: all assumptions have been generalized to `has_mul` or
21
+ `mul_one_class`.
88
22
-/
89
- class contravariant_class :=
90
- (covtc : contravariant M N μ s)
91
-
92
- end variants
93
23
94
24
variables {α : Type *} {a b c d : α}
95
25
0 commit comments