Lemmas about List.rtake and List.rdrop #
Mathlib/Data/List/DropRight.lean defines List.rtake l n and List.rdrop l n, the last n
elements of l and l without them, and proves only their nil, zero, concat, and reverse
characterizations, plus a few rdrop-of-append facts. This file supplies the tail mirrors of the
List.take and List.drop API in Init/Data/List/Nat/TakeDrop.lean, each proved by reducing to
its front counterpart through List.rtake_eq_reverse_take_reverse or
List.rdrop_eq_reverse_drop_reverse. [UPSTREAM] candidates for Mathlib/Data/List/DropRight.lean.
Main results #
List.length_rtake,List.length_rtake_le,List.rtake_of_length_le, and theirrdroptwinsList.length_rdropandList.rdrop_of_length_le: lengths and saturation on a short list, mirroringList.length_take,List.length_take_le,List.take_of_length_le,List.length_drop, andList.drop_of_length_le.List.getElem?_rtake,List.getElem?_rdrop,List.getLast?_rtake: indexing into a tail-take or tail-drop, mirroringList.getElem?_drop,List.getElem?_take, andList.head?_take.List.rtake_rtake,List.rtake_append,List.rdrop_append: nested tail-takes and the tail-take or tail-drop of an append, mirroringList.take_take,List.take_append, andList.drop_append.List.rtake_append_of_le_length,List.rtake_append_length, andList.rtake_append_length_addare the corollaries mirroringList.take_append_of_le_lengthand mathlib'sList.rdrop_append_lengthandList.rdrop_append_length_add.List.rdrop_prefix,List.rtake_suffix,List.rdrop_append_rtake: a tail-drop is a prefix, a tail-take a suffix, and together they recover the list, mirroringList.take_prefix,List.drop_suffix, andList.take_append_drop.List.rtake_append_rtakeandList.rtake_append_append_of_le_length: the lastnelements are a sufficient state, so truncating before appending, or prepending anything to a block of length at leastn, leaves the tail-take unchanged.
Truncating to the last n elements before appending is the same as truncating after: the
last n elements are enough state to compute the next window.
A middle block of length at least n screens off everything to its left: the last n
elements of a ++ u ++ y do not depend on a.