Some lemmas about lists involving sets #
Split out from Data.List.Basic to reduce its dependencies.
@[simp]
MapAccumr and Foldr #
Some lemmas relation mapAccumr and foldr
theorem
List.mapAccumr_eq_foldr
{α : Type u_1}
{β : Type u_2}
{σ : Type u_4}
(f : α → σ → σ × β)
(as : List α)
(s : σ)
:
mapAccumr f as s = foldr
(fun (a : α) (s : σ × List β) =>
have r := f a s.1;
(r.1, r.2 :: s.2))
(s, []) as
theorem
List.mapAccumr₂_eq_foldr
{α : Type u_1}
{β : Type u_2}
{σ : Type u_4}
{φ : Type u_5}
(f : α → β → σ → σ × φ)
(as : List α)
(bs : List β)
(s : σ)
:
mapAccumr₂ f as bs s = foldr
(fun (ab : α × β) (s : σ × List φ) =>
have r := f ab.1 ab.2 s.1;
(r.1, r.2 :: s.2))
(s, []) (as.zip bs)