Documentation

Init.Data.List.Nat.Basic

Miscellaneous List lemmas, that require more Nat lemmas than are available in Init.Data.List.Lemmas. #

In particular, omega is available here.

dropLast #

theorem List.tail_dropLast {α : Type u_1} (l : List α) :
@[simp]
theorem List.dropLast_reverse {α : Type u_1} (l : List α) :

filter #

@[simp]
theorem List.length_filter_pos_iff {α : Type u_1} {l : List α} {p : αBool} :
0 < (filter p l).length (x : α), x l p x = true
@[simp]
theorem List.length_filter_lt_length_iff_exists {α✝ : Type u_1} {p : α✝Bool} {l : List α✝} :
(filter p l).length < l.length (x : α✝), x l ¬p x = true

filterMap #

@[simp]
theorem List.length_filterMap_pos_iff {α : Type u_1} {β : Type u_2} {xs : List α} {f : αOption β} :
0 < (filterMap f xs).length (x : α), (x_1 : x xs), (b : β), f x = some b
@[simp]
theorem List.length_filterMap_lt_length_iff_exists {α : Type u_1} {β : Type u_2} {xs : List α} {f : αOption β} :
(filterMap f xs).length < xs.length (x : α), (x_1 : x xs), f x = none

reverse #

theorem List.getElem_eq_getElem_reverse {α : Type u_1} {l : List α} {i : Nat} (h : i < l.length) :
l[i] = l.reverse[l.length - 1 - i]

leftpad #

theorem List.length_leftpad {α : Type u_1} (n : Nat) (a : α) (l : List α) :
(leftpad n a l).length = max n l.length

The length of the List returned by List.leftpad n a l is equal to the larger of n and l.length

@[reducible, inline, deprecated List.length_leftpad (since := "2025-02-24")]
abbrev List.leftpad_length {α : Type u_1} (n : Nat) (a : α) (l : List α) :
(leftpad n a l).length = max n l.length
Equations
Instances For
    theorem List.length_rightpad {α : Type u_1} (n : Nat) (a : α) (l : List α) :
    (rightpad n a l).length = max n l.length

    eraseIdx #

    theorem List.mem_eraseIdx_iff_getElem {α : Type u_1} {x : α} {l : List α} {k : Nat} :
    x l.eraseIdx k (i : Nat), (h : i < l.length), i k l[i] = x
    theorem List.mem_eraseIdx_iff_getElem? {α : Type u_1} {x : α} {l : List α} {k : Nat} :
    x l.eraseIdx k (i : Nat), i k l[i]? = some x

    min? #

    theorem List.min?_eq_some_iff' {a : Nat} {xs : List Nat} :
    xs.min? = some a a xs ∀ (b : Nat), b xsa b
    theorem List.min?_get_le_of_mem {l : List Nat} {a : Nat} (h : a l) :
    l.min?.get a
    theorem List.min?_getD_le_of_mem {l : List Nat} {a k : Nat} (h : a l) :
    l.min?.getD k a

    max? #

    theorem List.max?_eq_some_iff' {a : Nat} {xs : List Nat} :
    xs.max? = some a a xs ∀ (b : Nat), b xsb a
    theorem List.le_max?_get_of_mem {l : List Nat} {a : Nat} (h : a l) :
    a l.max?.get
    theorem List.le_max?_getD_of_mem {l : List Nat} {a k : Nat} (h : a l) :
    a l.max?.getD k
    @[reducible, inline, deprecated List.min?_eq_some_iff' (since := "2024-09-29")]
    abbrev List.minimum?_eq_some_iff' {a : Nat} {xs : List Nat} :
    xs.min? = some a a xs ∀ (b : Nat), b xsa b
    Equations
    Instances For
      @[reducible, inline, deprecated List.min?_cons' (since := "2024-09-29")]
      abbrev List.minimum?_cons' {α : Type u_1} {x : α} [Min α] {xs : List α} :
      (x :: xs).min? = some (foldl min x xs)
      Equations
      Instances For
        @[reducible, inline, deprecated List.min?_getD_le_of_mem (since := "2024-09-29")]
        abbrev List.minimum?_getD_le_of_mem {l : List Nat} {a k : Nat} (h : a l) :
        l.min?.getD k a
        Equations
        Instances For
          @[reducible, inline, deprecated List.max?_eq_some_iff' (since := "2024-09-29")]
          abbrev List.maximum?_eq_some_iff' {a : Nat} {xs : List Nat} :
          xs.max? = some a a xs ∀ (b : Nat), b xsb a
          Equations
          Instances For
            @[reducible, inline, deprecated List.max?_cons' (since := "2024-09-29")]
            abbrev List.maximum?_cons' {α : Type u_1} {x : α} [Max α] {xs : List α} :
            (x :: xs).max? = some (foldl max x xs)
            Equations
            Instances For
              @[reducible, inline, deprecated List.le_max?_getD_of_mem (since := "2024-09-29")]
              abbrev List.le_maximum?_getD_of_mem {l : List Nat} {a k : Nat} (h : a l) :
              a l.max?.getD k
              Equations
              Instances For