Module docstring
{"# Successor and predecessor
This file defines successor and predecessor orders. succ a, the successor of an element a : α is
the least element greater than a. pred a is the greatest element less than a. Typical examples
include ℕ, ℤ, ℕ+, Fin n, but also ENat, the lexicographic order of a successor/predecessor
order...
Typeclasses
SuccOrder: Order equipped with a sensible successor function.PredOrder: Order equipped with a sensible predecessor function.
Implementation notes
Maximal elements don't have a sensible successor. Thus the naïve typeclass
lean
class NaiveSuccOrder (α : Type*) [Preorder α] where
(succ : α → α)
(succ_le_iff : ∀ {a b}, succ a ≤ b ↔ a < b)
(lt_succ_iff : ∀ {a b}, a < succ b ↔ a ≤ b)
can't apply to an OrderTop because plugging in a = b = ⊤ into either of succ_le_iff and
lt_succ_iff yields ⊤ < ⊤ (or more generally m < m for a maximal element m).
The solution taken here is to remove the implications ≤ → < and instead require that a < succ a
for all non maximal elements (enforced by the combination of le_succ and the contrapositive of
max_of_succ_le).
The stricter condition of every element having a sensible successor can be obtained through the
combination of SuccOrder α and NoMaxOrder α.
","### Successor order ","### Predecessor order ","### Successor-predecessor orders ","### WithBot, WithTop
Adding a greatest/least element to a SuccOrder or to a PredOrder.
As far as successors and predecessors are concerned, there are four ways to add a bottom or top
element to an order:
* Adding a ⊤ to an OrderTop: Preserves succ and pred.
* Adding a ⊤ to a NoMaxOrder: Preserves succ. Never preserves pred.
* Adding a ⊥ to an OrderBot: Preserves succ and pred.
* Adding a ⊥ to a NoMinOrder: Preserves pred. Never preserves succ.
where \"preserves (succ/pred)\" means
(Succ/Pred)Order α → (Succ/Pred)Order ((WithTop/WithBot) α).
","#### Adding a ⊤ to an OrderTop ","#### Adding a ⊥ to an OrderBot ","#### Adding a ⊥ to a NoMinOrder "}