Module docstring
{"# Basic operations on List.
We define
* basic operations on List,
* simp lemmas for applying the operations on .nil and .cons arguments
(in the cases where the right hand side is simple to state; otherwise these are deferred to Init.Data.List.Lemmas),
* the minimal lemmas which are required for setting up Init.Data.Array.Basic.
In Init.Data.List.Impl we give tail-recursive versions of these operations
along with @[csimp] lemmas,
In Init.Data.List.Lemmas we develop the full API for these functions.
Recall that length, get, set, foldl, and concat have already been defined in Init.Prelude.
The operations are organized as follow:
* Equality: beq, isEqv.
* Lexicographic ordering: lt, le, and instances.
* Head and tail operators: head, head?, headD?, tail, tail?, tailD.
* Basic operations:
map, filter, filterMap, foldr, append, flatten, pure, flatMap, replicate, and
reverse.
* Additional functions defined in terms of these: leftpad, rightPad, and reduceOption.
* Operations using indexes: mapIdx.
* List membership: isEmpty, elem, contains, mem (and the ∈ notation),
and decidability for predicates quantifying over membership in a List.
* Sublists: take, drop, takeWhile, dropWhile, partition, dropLast,
isPrefixOf, isPrefixOf?, isSuffixOf, isSuffixOf?, Subset, Sublist,
rotateLeft and rotateRight.
* Manipulating elements: replace, modify, insert, insertIdx, erase, eraseP, eraseIdx.
* Finding elements: find?, findSome?, findIdx, indexOf, findIdx?, indexOf?,
countP, count, and lookup.
* Logic: any, all, or, and and.
* Zippers: zipWith, zip, zipWithAll, and unzip.
* Ranges and enumeration: range, zipIdx.
* Minima and maxima: min? and max?.
* Other functions: intersperse, intercalate, eraseDups, eraseReps, span, splitBy,
removeAll
(currently these functions are mostly only used in meta code,
and do not have API suitable for verification).
Further operations are defined in Init.Data.List.BasicAux
(because they use Array in their implementations), namely:
* Variant getters: get!, get?, getD, getLast, getLast!, getLast?, and getLastD.
* Head and tail: head!, tail!.
* Other operations on sublists: partitionMap, rotateLeft, and rotateRight.
","## Preliminaries from Init.Prelude ","### length ","### set ","### foldl ","### concat ","## Equality ","## Lexicographic ordering ","## Alternative getters ","### getLast ","### getLast? ","### getLastD ","## Head and tail ","### head ","### head? ","### headD ","### tail ","### tail? ","### tailD ","## Basic List operations.
We define the basic functional programming operations on List:
map, filter, filterMap, foldr, append, flatten, pure, bind, replicate, and reverse.
","### map ","### filter ","### filterMap ","### foldr ","### reverse ","### append ","### flatten ","### singleton ","### flatMap ","### replicate ","## Additional functions ","### leftpad and rightpad ","### reduceOption ","## List membership
L.contains a : Booldetermines, using a[BEq α]instance, whetherLcontains an element· == a.a ∈ L : Propis the proposition (only decidable ifαhas decidable equality) thatLcontains an element· = a. ","### EmptyCollection ","### isEmpty ","### elem ","### contains ","### Mem ","## Sublists ","### take ","### drop ","### extract ","### takeWhile ","### dropWhile ","### partition ","### dropLast ","### Subset ","### Sublist and isSublist ","### IsPrefix / isPrefixOf / isPrefixOf? ","### IsSuffix / isSuffixOf / isSuffixOf? ","### IsInfix ","### splitAt ","### rotateLeft ","### rotateRight ","## Pairwise, Nodup ","## Manipulating elements ","### replace ","### modify ","### insert ","### erase ","### eraseIdx ","Finding elements ","### find? ","### findSome? ","### findIdx ","### idxOf ","### findIdx? ","### idxOf? ","### findFinIdx? ","### finIdxOf? ","### countP ","### count ","### lookup ","## Permutations ","### Perm ","### isPerm ","## Logical operations ","### any ","### all ","### or ","### and ","## Zippers ","### zipWith ","### zip ","### zipWithAll ","### unzip ","## Ranges and enumeration ","### range ","### range' ","### iota ","### zipIdx ","### enumFrom ","### enum ","## Minima and maxima ","### min? ","### max? ","## Other list operations
The functions are currently mostly used in meta code,
and do not have sufficient API developed for verification work.
","### intersperse ","### intercalate ","### eraseDups ","### eraseReps ","### span ","### splitBy ","### removeAll ","# Runtime re-implementations using @[csimp]
More of these re-implementations are provided in Init/Data/List/Impl.lean.
They can not be here, because the remaining ones required Array for their implementation.
This leaves a dangerous situation: if you import this file, but not Init/Data/List/Impl.lean,
then at runtime you will get non tail-recursive versions.
","### length ","### map ","### filter ","### replicate ","## Additional functions ","### leftpad ","## Zippers ","### unzip ","## Ranges and enumeration ","### range' ","### iota ","## Other list operations ","### intersperse "}