Documentation

LeanPool.FormalizationOfBoundedArithmetic.IsEnum

LeanPool.FormalizationOfBoundedArithmetic.IsEnum #

class IsEnum (α : Type u) :

A finite type equipped with explicit encodings to and from a finite index type.

  • size :

    The number of elements in the enumeration.

  • toIdx : αFin (size α)

    Encode an element as an index.

  • fromIdx : Fin (size α)α

    Decode an index as an element.

  • to_from_id (i : Fin (size α)) : toIdx (fromIdx i) = i

    Decoding and then encoding gives back the same index.

  • from_to_id (x : α) : fromIdx (toIdx x) = x

    Encoding and then decoding gives back the same element.

Instances

    Deriving handler for IsEnum on finite inductive types.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The index decoder is a left inverse of the encoder.

      The index decoder is a right inverse of the encoder.

      def IsEnum.equiv {α : Type u_1} {enum : IsEnum α} :
      α Fin (size α)

      The equivalence between an enumerated type and its finite index type.

      Equations
      Instances For
        theorem IsEnum.finite {α : Type u_1} (enum : IsEnum α) :

        An enumerated type is finite.

        The decoder from indices is injective.

        The encoder to indices is injective.

        def IsEnum.toList {α : Type u_1} {enum : IsEnum α} :
        List α

        List all elements of an enumerated type in index order.

        Equations
        Instances For
          theorem IsEnum.nodup_toList {α : Type u_1} {enum : IsEnum α} :