File: Mathlib/Data/List/Indexes.lean

full_name: List.oldMapIdxCore
code: /-- Lean3 `map_with_index` helper function -/
protected def oldMapIdxCore (f : ℕ → α → β) : ℕ → List α → List β
  
goal: ℕ → List α → List β

full_name: List.oldMapIdx
code: /-- Given a function `f : ℕ → α → β` and `as : List α`, `as = [a₀, a₁, ...]`, returns the list
`[f 0 a₀, f 1 a₁, ...]`. -/
protected def oldMapIdx (f : ℕ → α → β) (as : List α) : List β 
goal: List β

full_name: List.mapIdx_nil
code: @[simp]
theorem mapIdx_nil {α β} (f : ℕ → α → β) : mapIdx f [] = [] 
goal: List.mapIdx f [] = []

full_name: List.oldMapIdxCore_eq
code: protected theorem oldMapIdxCore_eq (l : List α) (f : ℕ → α → β) (n : ℕ) :
    l.oldMapIdxCore f n = l.oldMapIdx fun i a ↦ f (i + n) a 
goal: List.oldMapIdxCore f n l = List.oldMapIdx (fun i a => f (i + n) a) l

full_name: List.list_reverse_induction
code: theorem list_reverse_induction (p : List α → Prop) (base : p [])
    (ind : ∀ (l : List α) (e : α), p l → p (l ++ [e])) : (∀ (l : List α), p l) 
goal: p l

full_name: List.oldMapIdxCore_append
code: protected theorem oldMapIdxCore_append : ∀ (f : ℕ → α → β) (n : ℕ) (l₁ l₂ : List α),
    List.oldMapIdxCore f n (l₁ ++ l₂) =
    List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂ 
goal: List.oldMapIdxCore f n (l₁ ++ l₂) = List.oldMapIdxCore f n l₁ ++ List.oldMapIdxCore f (n + l₁.length) l₂

full_name: List.oldMapIdx_append
code: protected theorem oldMapIdx_append : ∀ (f : ℕ → α → β) (l : List α) (e : α),
    List.oldMapIdx f (l ++ [e]) = List.oldMapIdx f l ++ [f l.length e] 
goal: List.oldMapIdx f (l ++ [e]) = List.oldMapIdx f l ++ [f l.length e]

full_name: List.mapIdxGo_append
code: theorem mapIdxGo_append : ∀ (f : ℕ → α → β) (l₁ l₂ : List α) (arr : Array β),
    mapIdx.go f (l₁ ++ l₂) arr = mapIdx.go f l₂ (List.toArray (mapIdx.go f l₁ arr)) 
goal: List.mapIdx.go f (l₁ ++ l₂) arr = List.mapIdx.go f l₂ (List.toArray (List.mapIdx.go f l₁ arr))

full_name: List.mapIdxGo_length
code: theorem mapIdxGo_length : ∀ (f : ℕ → α → β) (l : List α) (arr : Array β),
    length (mapIdx.go f l arr) = length l + arr.size 
goal: (List.mapIdx.go f l arr).length = l.length + arr.size

full_name: List.mapIdx_append_one
code: theorem mapIdx_append_one : ∀ (f : ℕ → α → β) (l : List α) (e : α),
    mapIdx f (l ++ [e]) = mapIdx f l ++ [f l.length e] 
goal: List.mapIdx f (l ++ [e]) = List.mapIdx f l ++ [f l.length e]

full_name: List.new_def_eq_old_def
code: protected theorem new_def_eq_old_def :
    ∀ (f : ℕ → α → β) (l : List α), l.mapIdx f = List.oldMapIdx f l 
goal: List.mapIdx f l = List.oldMapIdx f l

full_name: List.map_enumFrom_eq_zipWith
code: @[local simp]
theorem map_enumFrom_eq_zipWith : ∀ (l : List α) (n : ℕ) (f : ℕ → α → β),
    map (uncurry f) (enumFrom n l) = zipWith (fun i ↦ f (i + n)) (range (length l)) l 
goal: List.map (Function.uncurry f) (List.enumFrom n l) = List.zipWith (fun i => f (i + n)) (List.range l.length) l

full_name: List.mapIdx_eq_enum_map
code: theorem mapIdx_eq_enum_map (l : List α) (f : ℕ → α → β) :
    l.mapIdx f = l.enum.map (Function.uncurry f) 
goal: List.mapIdx f l = List.map (Function.uncurry f) l.enum

full_name: List.mapIdx_cons
code: @[simp]
theorem mapIdx_cons (l : List α) (f : ℕ → α → β) (a : α) :
    mapIdx f (a :: l) = f 0 a :: mapIdx (fun i ↦ f (i + 1)) l 
goal: List.mapIdx f (a :: l) = f 0 a :: List.mapIdx (fun i => f (i + 1)) l

full_name: List.mapIdx_append
code: theorem mapIdx_append (K L : List α) (f : ℕ → α → β) :
    (K ++ L).mapIdx f = K.mapIdx f ++ L.mapIdx fun i a ↦ f (i + K.length) a 
goal: List.mapIdx f (K ++ L) = List.mapIdx f K ++ List.mapIdx (fun i a => f (i + K.length) a) L

full_name: List.length_mapIdx
code: @[simp]
theorem length_mapIdx (l : List α) (f : ℕ → α → β) : (l.mapIdx f).length = l.length 
goal: (List.mapIdx f l).length = l.length

full_name: List.mapIdx_eq_nil
code: @[simp]
theorem mapIdx_eq_nil {f : ℕ → α → β} {l : List α} : List.mapIdx f l = [] ↔ l = [] 
goal: List.mapIdx f l = [] ↔ l = []

full_name: List.nthLe_mapIdx
code: @[simp, deprecated (since := "2023-02-11")]
theorem nthLe_mapIdx (l : List α) (f : ℕ → α → β) (i : ℕ) (h : i < l.length)
    (h' : i < (l.mapIdx f).length := h.trans_le (l.length_mapIdx f).ge) :
    (l.mapIdx f).nthLe i h' = f i (l.nthLe i h) 
goal: (List.mapIdx f l).nthLe i h' = f i (l.nthLe i h)

full_name: List.mapIdx_eq_ofFn
code: theorem mapIdx_eq_ofFn (l : List α) (f : ℕ → α → β) :
    l.mapIdx f = ofFn fun i : Fin l.length ↦ f (i : ℕ) (l.get i) 
goal: List.mapIdx f l = List.ofFn fun i => f (↑i) (l.get i)

full_name: List.foldrIdxSpec
code: /-- Specification of `foldrIdx`. -/
def foldrIdxSpec (f : ℕ → α → β → β) (b : β) (as : List α) (start : ℕ) : β 
goal: β

full_name: List.foldrIdxSpec_cons
code: theorem foldrIdxSpec_cons (f : ℕ → α → β → β) (b a as start) :
    foldrIdxSpec f b (a :: as) start = f start a (foldrIdxSpec f b as (start + 1)) 
goal: List.foldrIdxSpec f b (a :: as) start = f start a (List.foldrIdxSpec f b as (start + 1))

full_name: List.foldrIdx_eq_foldrIdxSpec
code: theorem foldrIdx_eq_foldrIdxSpec (f : ℕ → α → β → β) (b as start) :
    foldrIdx f b as start = foldrIdxSpec f b as start 
goal: List.foldrIdx f b as start = List.foldrIdxSpec f b as start

full_name: List.foldrIdx_eq_foldr_enum
code: theorem foldrIdx_eq_foldr_enum (f : ℕ → α → β → β) (b : β) (as : List α) :
    foldrIdx f b as = foldr (uncurry f) b (enum as) 
goal: List.foldrIdx f b as = List.foldr (Function.uncurry f) b as.enum

full_name: List.indexesValues_eq_filter_enum
code: theorem indexesValues_eq_filter_enum (p : α → Prop) [DecidablePred p] (as : List α) :
    indexesValues p as = filter (p ∘ Prod.snd) (enum as) 
goal: List.indexesValues (fun b => decide (p b)) as = List.filter ((fun b => decide (p b)) ∘ Prod.snd) as.enum

full_name: List.findIdxs_eq_map_indexesValues
code: theorem findIdxs_eq_map_indexesValues (p : α → Prop) [DecidablePred p] (as : List α) :
    findIdxs p as = map Prod.fst (indexesValues p as) 
goal: List.findIdxs (fun b => decide (p b)) as = List.map Prod.fst (List.indexesValues (fun b => decide (p b)) as)

full_name: List.findIdx_eq_length
code: theorem findIdx_eq_length {p : α → Bool} {xs : List α} :
    xs.findIdx p = xs.length ↔ ∀ x ∈ xs, ¬p x 
goal: List.findIdx p xs = xs.length ↔ ∀ x ∈ xs, ¬p x = true

full_name: List.findIdx_le_length
code: theorem findIdx_le_length (p : α → Bool) {xs : List α} : xs.findIdx p ≤ xs.length 
goal: List.findIdx p xs ≤ xs.length

full_name: List.findIdx_lt_length
code: theorem findIdx_lt_length {p : α → Bool} {xs : List α} :
    xs.findIdx p < xs.length ↔ ∃ x ∈ xs, p x 
goal: List.findIdx p xs < xs.length ↔ ∃ x ∈ xs, p x = true

full_name: List.not_of_lt_findIdx
code: /-- `p` does not hold for elements with indices less than `xs.findIdx p`. -/
theorem not_of_lt_findIdx {p : α → Bool} {xs : List α} {i : ℕ} (h : i < xs.findIdx p) :
    ¬p (xs.get ⟨i, h.trans_le (findIdx_le_length p)⟩) 
goal: ¬p (xs.get ⟨i, ⋯⟩) = true

full_name: List.le_findIdx_of_not
code: theorem le_findIdx_of_not {p : α → Bool} {xs : List α} {i : ℕ} (h : i < xs.length)
    (h2 : ∀ j (hji : j < i), ¬p (xs.get ⟨j, hji.trans h⟩)) : i ≤ xs.findIdx p 
goal: i ≤ List.findIdx p xs

full_name: List.lt_findIdx_of_not
code: theorem lt_findIdx_of_not {p : α → Bool} {xs : List α} {i : ℕ} (h : i < xs.length)
    (h2 : ∀ j (hji : j ≤ i), ¬p (xs.get ⟨j, hji.trans_lt h⟩)) : i < xs.findIdx p 
goal: i < List.findIdx p xs

full_name: List.findIdx_eq
code: theorem findIdx_eq {p : α → Bool} {xs : List α} {i : ℕ} (h : i < xs.length) :
    xs.findIdx p = i ↔ p (xs.get ⟨i, h⟩) ∧ ∀ j (hji : j < i), ¬p (xs.get ⟨j, hji.trans h⟩) 
goal: List.findIdx p xs = i ↔ p (xs.get ⟨i, h⟩) = true ∧ ∀ (j : ℕ) (hji : j < i), ¬p (xs.get ⟨j, ⋯⟩) = true

full_name: List.foldlIdxSpec
code: /-- Specification of `foldlIdx`. -/
def foldlIdxSpec (f : ℕ → α → β → α) (a : α) (bs : List β) (start : ℕ) : α 
goal: α

full_name: List.foldlIdxSpec_cons
code: theorem foldlIdxSpec_cons (f : ℕ → α → β → α) (a b bs start) :
    foldlIdxSpec f a (b :: bs) start = foldlIdxSpec f (f start a b) bs (start + 1) 
goal: List.foldlIdxSpec f a (b :: bs) start = List.foldlIdxSpec f (f start a b) bs (start + 1)

full_name: List.foldlIdx_eq_foldlIdxSpec
code: theorem foldlIdx_eq_foldlIdxSpec (f : ℕ → α → β → α) (a bs start) :
    foldlIdx f a bs start = foldlIdxSpec f a bs start 
goal: List.foldlIdx f a bs start = List.foldlIdxSpec f a bs start

full_name: List.foldlIdx_eq_foldl_enum
code: theorem foldlIdx_eq_foldl_enum (f : ℕ → α → β → α) (a : α) (bs : List β) :
    foldlIdx f a bs = foldl (fun a p ↦ f p.fst a p.snd) a (enum bs) 
goal: List.foldlIdx f a bs = List.foldl (fun a p => f p.1 a p.2) a bs.enum

full_name: List.foldrIdxM_eq_foldrM_enum
code: theorem foldrIdxM_eq_foldrM_enum {β} (f : ℕ → α → β → m β) (b : β) (as : List α) [LawfulMonad m] :
    foldrIdxM f b as = foldrM (uncurry f) b (enum as) 
goal: List.foldrIdxM f b as = List.foldrM (Function.uncurry f) b as.enum

full_name: List.foldlIdxM_eq_foldlM_enum
code: theorem foldlIdxM_eq_foldlM_enum [LawfulMonad m] {β} (f : ℕ → β → α → m β) (b : β) (as : List α) :
    foldlIdxM f b as = List.foldlM (fun b p ↦ f p.fst b p.snd) b (enum as) 
goal: List.foldlIdxM f b as = List.foldlM (fun b p => f p.1 b p.2) b as.enum

full_name: List.mapIdxMAuxSpec
code: /-- Specification of `mapIdxMAux`. -/
def mapIdxMAuxSpec {β} (f : ℕ → α → m β) (start : ℕ) (as : List α) : m (List β) 
goal: m (List β)

full_name: List.mapIdxMAuxSpec_cons
code: theorem mapIdxMAuxSpec_cons {β} (f : ℕ → α → m β) (start : ℕ) (a : α) (as : List α) :
    mapIdxMAuxSpec f start (a :: as) = cons <$> f start a <*> mapIdxMAuxSpec f (start + 1) as 
goal: List.mapIdxMAuxSpec f start (a :: as) = Seq.seq (List.cons <$> f start a) fun x => List.mapIdxMAuxSpec f (start + 1) as

full_name: List.mapIdxMGo_eq_mapIdxMAuxSpec
code: theorem mapIdxMGo_eq_mapIdxMAuxSpec
    [LawfulMonad m] {β} (f : ℕ → α → m β) (arr : Array β) (as : List α) :
    mapIdxM.go f as arr = (arr.toList ++ ·) <$> mapIdxMAuxSpec f arr.size as 
goal: List.mapIdxM.go f as arr = (fun x => arr.toList ++ x) <$> List.mapIdxMAuxSpec f arr.size as

full_name: List.mapIdxM_eq_mmap_enum
code: theorem mapIdxM_eq_mmap_enum [LawfulMonad m] {β} (f : ℕ → α → m β) (as : List α) :
    as.mapIdxM f = List.traverse (uncurry f) (enum as) 
goal: as.mapIdxM f = List.traverse (Function.uncurry f) as.enum

full_name: List.mapIdxMAux'_eq_mapIdxMGo
code: theorem mapIdxMAux'_eq_mapIdxMGo {α} (f : ℕ → α → m PUnit) (as : List α) (arr : Array PUnit) :
    mapIdxMAux' f arr.size as = mapIdxM.go f as arr *> pure PUnit.unit 
goal: List.mapIdxMAux' f arr.size as = SeqRight.seqRight (List.mapIdxM.go f as arr) fun x => pure PUnit.unit

full_name: List.mapIdxM'_eq_mapIdxM
code: theorem mapIdxM'_eq_mapIdxM {α} (f : ℕ → α → m PUnit) (as : List α) :
    mapIdxM' f as = mapIdxM as f *> pure PUnit.unit 
goal: List.mapIdxM' f as = SeqRight.seqRight (as.mapIdxM f) fun x => pure PUnit.unit