Properties of Lists #
This file contains useful lemmas about standard list functions and our custom variations on these.
any #
all #
map, map₁, map₂, map₃, and attach variants #
Similar to the standard library's map_eq_singleton_iff, but for doubleton.
We could probably make this an iff but currently don't need to.
Not actually a special case of map_pmap_subtype -- you can use this in
places you can't use map_pmap_subtype because the LHS function (being
mapped) doesn't fit the map_pmap_subtype form but does fit this form (where
the application of f is not the outermost AST node of the function,
basically)
Not actually a special case of map₂_eq_map -- you can use this in places you
can't use map₂_eq_map because the LHS function (being mapped) doesn't fit
the map₂_eq_map form but does fit this form (where the application of f is
not the outermost AST node of the function, basically)
same as map₂_eq_map_snd but for map₃
flatMap #
As of this writing, the standard-library lemma List.exists_of_mem_flatMap is a
→, but it's trivial to extend it to ↔ and makes some things easier, so we do
that here
Forall₂ #
Applying mapM on the RHS list of Forall₂
leads to new Forall₂ relation if certain
conditions are met.
kind of a transitivity property, if you squint
mapM, mapM', mapM₁, and mapM₂ #
See notes on map₂_eq_map_snd. This has a similar relationship to mapM₂_eq_mapM
as map₂_eq_map_snd does to map₂_eq_map.
Introduces forall₂ through the input output relation
of a f through List.mapM. This is slightly stronger
than the forward direction of mapM_ok_iff_forall₂
since it allowed an extra x ∈ xs condition in h.
Note that the converse is not true:
counterexample xs is [1], ys is [1, 2], f is Except.ok
But for a limited converse, see all_ok_implies_mapM'_ok
Note that the converse is not true:
counterexample ys is [1], xs is [1, 2], f is Except.ok
But for a limited converse, see all_from_ok_implies_mapM'_ok
The converse is not true:
counterexample xs is [1, 2] and f is Except.error.
In that case, f 2 = .error 2 but xs.mapM' f = .error 1.
But for a limited converse, see element_error_implies_mapM_error
If applying f to any of xs produces an error, then xs.mapM' f must also
produce an error (not necessarily the same error)
Limited converse of mapM'_error_implies_exists_error
Note that the converse is not true:
counterexample xs is [1], ys is [1, 2], f is Option.some
But for a limited converse, see all_some_implies_mapM'_some
Note that the converse is not true:
counterexample ys is [1], xs is [1, 2], f is Option.some
But for a limited converse, see all_from_some_implies_mapM'_some
foldl #
foldlM #
find? #
filterMap #
forM and mapM #
removeAll #
mapM preserves SortedBy if the keys are preserved