Documentation

Init.Data.Range.Polymorphic.Basic

class Std.PRange.RangeSize (shape : BoundShape) (α : Type u) :

This typeclass provides support for the PRange.size function.

The returned size should be equal to the number of elements returned by toList. This condition is captured by the typeclass LawfulRangeSize.

  • size (upperBound : Bound shape α) (init : α) : Nat

    Returns the number of elements starting from init that satisfy the given upper bound.

Instances

    This typeclass ensures that a RangeSize instance returns the correct size for all ranges.

    Instances
      @[inline]
      def Std.PRange.isEmpty {sl su : BoundShape} {α : Type u_1} [UpwardEnumerable α] [BoundedUpwardEnumerable sl α] [SupportsUpperBound su α] (r : PRange { lower := sl, upper := su } α) :

      Checks whether the range contains any value.

      This function returns a meaningful value for all range types defined by the standard library and for all range types that satisfy the properties encoded in the LawfulUpwardEnumerable, LawfulUpwardEnumerableLowerBound and LawfulUpwardEnumerableUpperBound typeclasses.

      Equations
      Instances For
        theorem Std.PRange.le_upper_of_mem {sl : BoundShape} {α : Type u_1} [LE α] [DecidableLE α] [SupportsLowerBound sl α] {a : α} {r : PRange { lower := sl, upper := BoundShape.closed } α} (h : a r) :
        theorem Std.PRange.lt_upper_of_mem {sl : BoundShape} {α : Type u_1} [LT α] [DecidableLT α] [SupportsLowerBound sl α] {a : α} {r : PRange { lower := sl, upper := BoundShape.open } α} (h : a r) :
        a < r.upper
        theorem Std.PRange.lower_le_of_mem {su : BoundShape} {α : Type u_1} [LE α] [DecidableLE α] [SupportsUpperBound su α] {a : α} {r : PRange { lower := BoundShape.closed, upper := su } α} (h : a r) :
        theorem Std.PRange.lower_lt_of_mem {su : BoundShape} {α : Type u_1} [LT α] [DecidableLT α] [SupportsUpperBound su α] {a : α} {r : PRange { lower := BoundShape.open, upper := su } α} (h : a r) :
        r.lower < a
        theorem Std.PRange.Internal.get_elem_helper_upper_open {sl : BoundShape} {α : Type u_1} [SupportsLowerBound sl α] [LT α] [DecidableLT α] {a n : α} {r : PRange { lower := sl, upper := BoundShape.open } α} (h₁ : a r) (h₂ : r.upper = n) :
        a < n