Documentation

Init.Data.Range.Polymorphic.UpwardEnumerable

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.

  • succMany? (n : Nat) (a : α) : Option α

    Maps elements of α to their n-th successor, or none if no successor exists. This should semantically behave like repeatedly applying succ?, but it might be more efficient.

    LawfulUpwardEnumerable ensures the compatibility with succ?.

    If no other implementation is provided in UpwardEnumerable instance, succMany? repeatedly applies succ?.

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
        theorem Std.PRange.UpwardEnumerable.le_of_lt {α : Type u} [UpwardEnumerable α] {a b : α} (h : LT a b) :
        LE a b
        class Std.PRange.Least? (α : Type u) :

        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 α

          Returns the smallest element of α, or none if α is empty.

          Only empty types are allowed to define least? := none. If α is ordered and nonempty, then the value of least? should be the smallest element according to the order on α.

        Instances

          This typeclass ensures that an UpwardEnumerable α instance is well-behaved.

          Instances
            theorem Std.PRange.UpwardEnumerable.succMany?_add {α : Type u_1} [UpwardEnumerable α] [LawfulUpwardEnumerable α] (m n : Nat) (a : α) :
            succMany? (m + n) a = (succMany? m a).bind fun (x : α) => succMany? n x
            theorem Std.PRange.UpwardEnumerable.le_trans {α : Type u} [UpwardEnumerable α] [LawfulUpwardEnumerable α] {a b c : α} (hab : LE a b) (hbc : LE b c) :
            LE a c
            theorem Std.PRange.UpwardEnumerable.lt_of_lt_of_le {α : Type u} [UpwardEnumerable α] [LawfulUpwardEnumerable α] {a b c : α} (hab : LT a b) (hbc : LE b c) :
            LT a c

            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.

              Instances

                This typeclass ensures that an UpwardEnumerable α instance is compatible with . In this case, UpwardEnumerable α fully characterizes the LE α instance.

                • le_iff (a b : α) : a b UpwardEnumerable.LE a b

                  a is less than or equal to b if and only if b is either a or a transitive successor of a.

                Instances

                  This typeclass ensures that an UpwardEnumerable α instance is compatible with <. In this case, UpwardEnumerable α fully characterizes the LT α instance.

                  • lt_iff (a b : α) : a < b UpwardEnumerable.LT a b

                    a is less than b if and only if b is a proper transitive successor of a.

                  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.

                    Instances