Documentation

Mathlib.Init.Data.List.Basic

Note about Mathlib/Init/ #

The files in Mathlib/Init are leftovers from the port from Mathlib3. (They contain content moved from lean3 itself that Mathlib needed but was not moved to lean4.)

We intend to move all the content of these files out into the main Mathlib directory structure. Contributions assisting with this are appreciated.

#align statements without corresponding declarations (i.e. because the declaration is in Batteries or Lean) can be left here. These will be deleted soon so will not significantly delay deleting otherwise empty Init files.

Definitions for List not (yet) in Batteries #

def List.headI {α : Type u} [Inhabited α] :
List αα

The head of a list, or the default element of the type is the list is nil.

Equations
  • x.headI = match x with | [] => default | a :: tail => a
Instances For
    @[simp]
    theorem List.headI_nil {α : Type u} [Inhabited α] :
    [].headI = default
    @[simp]
    theorem List.headI_cons {α : Type u} [Inhabited α] {h : α} {t : List α} :
    (h :: t).headI = h
    def List.getLastI {α : Type u} [Inhabited α] :
    List αα

    The last element of a list, with the default if list empty

    Equations
    • [].getLastI = default
    • [a].getLastI = a
    • [head, b].getLastI = b
    • (head :: head_1 :: l).getLastI = l.getLastI
    Instances For
      @[inline, deprecated List.pure]
      def List.ret {α : Type u} (a : α) :
      List α

      List with a single given element.

      Equations
      Instances For
        theorem List.le_eq_not_gt {α : Type u} [LT α] (l₁ : List α) (l₂ : List α) :
        (l₁ l₂) = ¬l₂ < l₁

        implies not > for lists.

        @[deprecated Array.data_toArray]
        theorem List.toArray_data {α : Type u_1} (as : List α) :
        (List.toArray as).data = as

        Alias of Array.data_toArray.