Note about Mathlib/Init/
#
The files in Mathlib/Init
are leftovers from the port from Mathlib3.
(They contain content moved from lean3 itself that Mathlib needed but was not moved to lean4.)
We intend to move all the content of these files out into the main Mathlib
directory structure.
Contributions assisting with this are appreciated.
Lemmas for List
not (yet) in Batteries
#
mem
Alias of the forward direction of List.mem_cons
.
@[deprecated List.not_exists_mem_nil]
Alias of List.not_exists_mem_nil
.
sublists
Alias of List.Sublist.length_le
.
map_accumr
Runs a function over a list returning the intermediate results and a final result.
Equations
- List.mapAccumr f [] x = (x, [])
- List.mapAccumr f (y :: yr) x = let r := List.mapAccumr f yr x; let z := f y r.fst; (z.fst, z.snd :: r.snd)
Instances For
@[simp]
theorem
List.length_mapAccumr
{α : Type u}
{β : Type v}
{σ : Type w₂}
(f : α → σ → σ × β)
(x : List α)
(s : σ)
:
(List.mapAccumr f x s).snd.length = x.length
Length of the list obtained by mapAccumr
.
Runs a function over two lists returning the intermediate results and a final result.
Equations
- List.mapAccumr₂ f [] x✝ x = (x, [])
- List.mapAccumr₂ f x✝ [] x = (x, [])
- List.mapAccumr₂ f (x_3 :: xr) (y :: yr) x = let r := List.mapAccumr₂ f xr yr x; let q := f x_3 y r.fst; (q.fst, q.snd :: r.snd)
Instances For
@[simp]
theorem
List.length_mapAccumr₂
{α : Type u}
{β : Type v}
{φ : Type w₁}
{σ : Type w₂}
(f : α → β → σ → σ × φ)
(x : List α)
(y : List β)
(c : σ)
:
(List.mapAccumr₂ f x y c).snd.length = min x.length y.length
Length of a list obtained using mapAccumr₂
.