Documentation

Linglib.Core.Data.List.DropRight

Length, saturation, and decomposition for List.rtake #

A handful of facts about List.rtake (take from the tail) and List.rdrop (drop from the tail) that mathlib's Mathlib/Data/List/DropRight.lean defines but leaves without an API: the length of a tail-take, when it saturates to the whole list, how it absorbs a left append, and the rdrop/rtake decomposition. Each is the tail mirror of a front-end take lemma and is proved by reducing to it through List.rtake_eq_reverse_take_reverse — reverse, then take. These flesh out an under-developed corner of mathlib and are candidates for Mathlib/Data/List/DropRight.lean.

Main results #

@[simp]
theorem List.length_rtake {α : Type u_1} (l : List α) (n : ) :
(l.rtake n).length = min n l.length

A tail-take has length min n l.length — the tail analog of List.length_take.

theorem List.length_rtake_le {α : Type u_1} (l : List α) (n : ) :
(l.rtake n).length n

A tail-take has length at most n — the tail analog of List.length_take_le.

theorem List.rtake_of_length_le {α : Type u_1} {l : List α} {n : } (h : l.length n) :
l.rtake n = l

A list no longer than n is its own tail-take — the tail analog of List.take_of_length_le.

theorem List.rtake_append_of_le_length {α : Type u_1} {n : } (l₁ l₂ : List α) (h : n l₂.length) :
(l₁ ++ l₂).rtake n = l₂.rtake n

A tail-take that fits inside the right summand ignores the left one — the tail analog of List.take_append_of_le_length.

@[simp]
theorem List.rdrop_append_rtake {α : Type u_1} (l : List α) (n : ) :
l.rdrop n ++ l.rtake n = l

Splitting a list at its last n symbols — the tail analog of List.take_append_drop.