This typeclass provides the function succ? : α → Option α
that computes the successor of
elements of α
, or none if no successor exists.
It also provides the function succMany?
, which computes n
-th successors.
succ?
is expected to be acyclic: No element is its own transitive successor.
If α
is ordered, then every element larger than a : α
should be a transitive successor of a
.
These properties and the compatibility of succ?
with succMany?
are encoded in the typeclasses
LawfulUpwardEnumerable
, LawfulUpwardEnumerableLE
and LawfulUpwardEnumerableLT
.
- succ? : α → Option α
Maps elements of
α
to their successor, or none if no successor exists. Maps elements of
α
to theirn
-th successor, or none if no successor exists. This should semantically behave like repeatedly applyingsucc?
, but it might be more efficient.LawfulUpwardEnumerable
ensures the compatibility withsucc?
.If no other implementation is provided in
UpwardEnumerable
instance,succMany?
repeatedly appliessucc?
.
Instances
According to UpwardEnumerable.LE
, a
is less than or equal to b
if b
is a
or a transitive
successor of a
.
Equations
Instances For
According to UpwardEnumerable.LT
, a
is less than b
if b
is a proper transitive successor of
a
. 'Proper' means that b
is the n
-th successor of a
, where n > 0
.
Given LawfulUpwardEnumerable α
, no element of α
is less than itself.
Equations
Instances For
The typeclass Least? α
optionally provides a smallest element of α
, least? : Option α
.
The main use case of this typeclass is to use it in combination with UpwardEnumerable
to
obtain a (possibly infinite) ascending enumeration of all elements of α
.
- least? : Option α
Instances
This typeclass ensures that an UpwardEnumerable α
instance is well-behaved.
- ne_of_lt (a b : α) : UpwardEnumerable.LT a b → a ≠ b
There is no cyclic chain of successors.
The
0
-th successor ofa
isa
itself.- succMany?_succ (n : Nat) (a : α) : UpwardEnumerable.succMany? (n + 1) a = (UpwardEnumerable.succMany? n a).bind UpwardEnumerable.succ?
The
n + 1
-th successor ofa
is the successor of then
-th successor, given that said successors actualy exist.
Instances
This propositional typeclass ensures that UpwardEnumerable.succ?
will never return none
.
In other words, it ensures that there will always be a successor.
Instances
This propositional typeclass ensures that UpwardEnumerable.succ?
is injective.
- eq_of_succ?_eq (a b : α) : UpwardEnumerable.succ? a = UpwardEnumerable.succ? b → a = b
Instances
Equations
Instances For
Equations
Instances For
This typeclass ensures that an UpwardEnumerable α
instance is compatible with ≤
.
In this case, UpwardEnumerable α
fully characterizes the LE α
instance.
a
is less than or equal tob
if and only ifb
is eithera
or a transitive successor ofa
.
Instances
This typeclass ensures that an UpwardEnumerable α
instance is compatible with <
.
In this case, UpwardEnumerable α
fully characterizes the LT α
instance.
a
is less thanb
if and only ifb
is a proper transitive successor ofa
.
Instances
This typeclass ensures that an UpwardEnumerable α
instance is compatible with a Least? α
instance. For nonempty α
, it ensures that least?
has a value and that every other value is
a transitive successor of it.
For nonempty
α
,least?
has a value and every other value is a transitive successor of it.