Commit 2021-05-15 16:28 172195bb
View on Github →feat(algebra/{ordered_monoid, ordered_monoid_lemmas}): split the ordered_[...] typeclasses (#7371)
This PR tries to split the ordering assumptions from the algebraic assumptions on the operations in the ordered_[...] hierarchy.
The strategy is to introduce two more flexible typeclasses, covariant_class and contravariant_class.
covariant_classmodels the implicationa ≤ b → c * a ≤ c * b(multiplication is monotone),contravariant_classmodels the implicationa * b < a * c → b < c. Sinceco(ntra)variant_classtakes as input the operation (typically(+)or(*)) and the order relation (typically(≤)or(<)), these are the only two typeclasses that I have used. The general approach is to formulate the lemma that you are interested in and prove it, with theordered_[...]typeclass of your liking. After that, you convert the single typeclass, say[ordered_cancel_monoid M], to three typeclasses, e.g.[partial_order M] [left_cancel_semigroup M] [covariant_class M M (function.swap (*)) (≤)]and have a go at seeing if the proof still works! Note that it is possible (or even expected) to combine severalco(ntra)variant_classassumptions together. Indeed, the usualorderedtypeclasses arise from assuming the pair[covariant_class M M (*) (≤)] [contravariant_class M M (*) (<)]on top of order/algebraic assumptions. A formal remark is that normallycovariant_classuses the(≤)-relation, whilecontravariant_classuses the(<)-relation. This need not be the case in general, but seems to be the most common usage. In the opposite direction, the implication[semigroup α] [partial_order α] [contravariant_class α α (*) (≤)] => left_cancel_semigroup αholds (note theco*ntra*assumption and the(≤)-relation). Zulip: https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/ordered.20stuff