Lemmas about List.*Idx functions. #
Some specification lemmas for List.mapIdx
, List.mapIdxM
, List.foldlIdx
and List.foldrIdx
.
As of 2025-01-29, these are not used anywhere in Mathlib. Moreover, with
List.enum
and List.enumFrom
being replaced by List.zipIdx
in Lean's nightly-2025-01-29
release, they now use deprecated functions and theorems.
Rather than updating this unused material, we are deprecating it.
Anyone wanting to restore this material is welcome to do so, but will need to update uses of
List.enum
and List.enumFrom
to use List.zipIdx
instead.
However, note that this material will later be implemented in the Lean standard library.
Lean3 map_with_index
helper function
Equations
- List.oldMapIdxCore f x✝ [] = []
- List.oldMapIdxCore f x✝ (a :: as) = f x✝ a :: List.oldMapIdxCore f (x✝ + 1) as
Instances For
Given a function f : ℕ → α → β
and as : List α
, as = [a₀, a₁, ...]
, returns the list
[f 0 a₀, f 1 a₁, ...]
.
Equations
- List.oldMapIdx f as = List.oldMapIdxCore f 0 as
Instances For
Specification of foldrIdx
.
Equations
- List.foldrIdxSpec f b as start = List.foldr (Function.uncurry f) b (List.enumFrom start as)
Instances For
Specification of foldlIdx
.
Equations
- List.foldlIdxSpec f a bs start = List.foldl (fun (a : α) (p : ℕ × β) => f p.fst a p.snd) a (List.enumFrom start bs)
Instances For
Specification of mapIdxMAux
.
Equations
- List.mapIdxMAuxSpec f start as = List.traverse (Function.uncurry f) (List.enumFrom start as)