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 #
succ_order: Order equipped with a sensible successor function.pred_order: Order equipped with a sensible predecessor function.is_succ_archimedean:succ_orderwheresucciterated to an element gives all the greater ones.is_pred_archimedean:pred_orderwhereprediterated to an element gives all the greater ones.
Implementation notes #
Maximal elements don't have a sensible successor. Thus the naïve typeclass
class naive_succ_order (α : Type*) [preorder α] :=
(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 order_top 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
maximal_of_succ_le).
The stricter condition of every element having a sensible successor can be obtained through the
combination of succ_order α and no_max_order α.
TODO #
Is galois_connection pred succ always true? If not, we should introduce
class succ_pred_order (α : Type*) [preorder α] extends succ_order α, pred_order α :=
(pred_succ_gc : galois_connection (pred : α → α) succ)
covby should help here.
Successor order #
- succ : α → α
- le_succ : ∀ (a : α), a ≤ succ_order.succ a
- maximal_of_succ_le : ∀ ⦃a : α⦄, succ_order.succ a ≤ a → ∀ ⦃b : α⦄, ¬a < b
- succ_le_of_lt : ∀ {a b : α}, a < b → succ_order.succ a ≤ b
- le_of_lt_succ : ∀ {a b : α}, a < succ_order.succ b → a ≤ b
Order equipped with a sensible successor function.
A constructor for succ_order α usable when α has no maximal element.
Equations
- succ_order.of_succ_le_iff_of_le_lt_succ succ hsucc_le_iff hle_of_lt_succ = {succ := succ, le_succ := _, maximal_of_succ_le := _, succ_le_of_lt := _, le_of_lt_succ := _}
Alias of lt_succ_of_not_maximal.
Alias of succ_le_succ_iff.
Alias of succ_lt_succ_iff.
Alias of succ_lt_succ_iff.
There is at most one way to define the successors in a partial_order.
Alias of succ_ne_succ_iff.
Alias of succ_ne_succ_iff.
A constructor for succ_order α usable when α is a linear order with no maximal element.
Equations
- succ_order.of_succ_le_iff succ hsucc_le_iff = {succ := succ, le_succ := _, maximal_of_succ_le := _, succ_le_of_lt := _, le_of_lt_succ := _}
Predecessor order #
- pred : α → α
- pred_le : ∀ (a : α), pred_order.pred a ≤ a
- minimal_of_le_pred : ∀ ⦃a : α⦄, a ≤ pred_order.pred a → ∀ ⦃b : α⦄, ¬b < a
- le_pred_of_lt : ∀ {a b : α}, a < b → a ≤ pred_order.pred b
- le_of_pred_lt : ∀ {a b : α}, pred_order.pred a < b → a ≤ b
Order equipped with a sensible predecessor function.
A constructor for pred_order α usable when α has no minimal element.
Equations
- pred_order.of_le_pred_iff_of_pred_le_pred pred hle_pred_iff hle_of_pred_lt = {pred := pred, pred_le := _, minimal_of_le_pred := _, le_pred_of_lt := _, le_of_pred_lt := _}
Alias of pred_lt_of_not_minimal.
Alias of pred_le_pred_iff.
Alias of pred_lt_pred_iff.
Alias of pred_lt_pred_iff.
There is at most one way to define the predecessors in a partial_order.
A constructor for pred_order α usable when α is a linear order with no maximal element.
Equations
- pred_order.of_le_pred_iff pred hle_pred_iff = {pred := pred, pred_le := _, minimal_of_le_pred := _, le_pred_of_lt := _, le_of_pred_lt := _}
Successor-predecessor orders #
Dual order #
Equations
- order_dual.succ_order = {succ := pred_order.pred _inst_2, le_succ := _, maximal_of_succ_le := _, succ_le_of_lt := _, le_of_lt_succ := _}
Equations
- order_dual.pred_order = {pred := succ_order.succ _inst_2, pred_le := _, minimal_of_le_pred := _, le_pred_of_lt := _, le_of_pred_lt := _}
with_bot, with_top #
Adding a greatest/least element to a succ_order or to a pred_order.
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 anorder_top: Preservessuccandpred. - Adding a
⊤to ano_max_order: Preservessucc. Never preservespred. - Adding a
⊥to anorder_bot: Preservessuccandpred. - Adding a
⊥to ano_min_order: Preservespred. Never preservessucc. where "preserves(succ/pred)" means(succ/pred)_order α → (succ/pred)_order ((with_top/with_bot) α).
Equations
- with_top.succ_order = {succ := λ (a : with_top α), with_top.succ_order._match_1 a, le_succ := _, maximal_of_succ_le := _, succ_le_of_lt := _, le_of_lt_succ := _}
- with_top.succ_order._match_1 (some a) = ite (a = ⊤) ⊤ (some (succ_order.succ a))
- with_top.succ_order._match_1 ⊤ = ⊤
Equations
- with_top.pred_order = {pred := λ (a : with_top α), with_top.pred_order._match_1 a, pred_le := _, minimal_of_le_pred := _, le_pred_of_lt := _, le_of_pred_lt := _}
- with_top.pred_order._match_1 (some a) = some (pred_order.pred a)
- with_top.pred_order._match_1 ⊤ = some ⊤
Adding a ⊤ to a no_max_order #
Equations
- with_top.succ_order_of_no_max_order = {succ := λ (a : with_top α), with_top.succ_order_of_no_max_order._match_1 a, le_succ := _, maximal_of_succ_le := _, succ_le_of_lt := _, le_of_lt_succ := _}
- with_top.succ_order_of_no_max_order._match_1 (some a) = some (succ_order.succ a)
- with_top.succ_order_of_no_max_order._match_1 ⊤ = ⊤
Adding a ⊥ to a bot_order #
Equations
- with_bot.succ_order = {succ := λ (a : with_bot α), with_bot.succ_order._match_1 a, le_succ := _, maximal_of_succ_le := _, succ_le_of_lt := _, le_of_lt_succ := _}
- with_bot.succ_order._match_1 (some a) = some (succ_order.succ a)
- with_bot.succ_order._match_1 ⊥ = some ⊥
Equations
- with_bot.pred_order = {pred := λ (a : with_bot α), with_bot.pred_order._match_1 a, pred_le := _, minimal_of_le_pred := _, le_pred_of_lt := _, le_of_pred_lt := _}
- with_bot.pred_order._match_1 (some a) = ite (a = ⊥) ⊥ (some (pred_order.pred a))
- with_bot.pred_order._match_1 ⊥ = ⊥
Adding a ⊥ to a no_min_order #
Equations
- with_bot.pred_order_of_no_min_order = {pred := λ (a : with_bot α), with_bot.pred_order_of_no_min_order._match_1 a, pred_le := _, minimal_of_le_pred := _, le_pred_of_lt := _, le_of_pred_lt := _}
- with_bot.pred_order_of_no_min_order._match_1 (some a) = some (pred_order.pred a)
- with_bot.pred_order_of_no_min_order._match_1 ⊥ = ⊥
Archimedeanness #
A succ_order is succ-archimedean if one can go from any two comparable elements by iterating
succ
A pred_order is pred-archimedean if one can go from any two comparable elements by iterating
pred
Induction principle on a type with a succ_order for all elements above a given element m.
Induction principle on a type with a pred_order for all elements below a given element m.