This file contains a collection definitions and theorems about lists that are not part of Lean's standard library. At least when initially writing some of these, suitable variants did not exist or I simply did not find them.
Some cleanup is certainly needed here.
We can convert a list to a set by defining membership in the set through membership in the list.
Equations
- CustomBasicDatastructures.List.toSet l e = (e ∈ l)
Instances For
Converting a list to a set and then applying a function to each element is the same as first applyign the function and then converting to the set.
If two lists resulting from append calls are equal and the second components have the same length, then the first components also have the same length.
An element is in a list if and only if the list is composable such the element has its first occurrence in this composition.
Mapping over list produces the same list if the mapping function maps each list member to itself. Note that this is very close to List.map_id''
but that List.map_id'' has a stronger assumption. Namely it requires the function to be the id not only on list elements but on every representant of the element type.
Filtering a list based on two predicates yields the same list if the predicates behave the same on all elements.
A list that is longer than a list without duplicates but only contains the same elements must have a duplicate.
For two equal lists, filter does the same.
The index of an element that we get from given index is exactly this index. Note that this uses DecidableEq.