Documentation

Init.Data.Array.Bootstrap

Bootstrapping theorems about arrays #

This file contains some theorems about Array and List needed for Init.Data.List.Impl.

@[irreducible]
theorem Array.foldlM_toList.aux {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} [Monad m] (f : βαm β) (arr : Array α) (i j : Nat) (H : arr.size i + j) (b : β) :
foldlM.loop f arr arr.size i j b = List.foldlM f b (List.drop j arr.toList)
@[simp]
theorem Array.foldlM_toList {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} [Monad m] (f : βαm β) (init : β) (arr : Array α) :
List.foldlM f init arr.toList = foldlM f init arr
@[simp]
theorem Array.foldl_toList {β : Type u_1} {α : Type u_2} (f : βαβ) (init : β) (arr : Array α) :
List.foldl f init arr.toList = foldl f init arr
theorem Array.foldrM_eq_reverse_foldlM_toList.aux {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (arr : Array α) (init : β) (i : Nat) (h : i arr.size) :
List.foldlM (fun (x : β) (y : α) => f y x) init (List.take i arr.toList).reverse = foldrM.fold f arr 0 i h init
theorem Array.foldrM_eq_reverse_foldlM_toList {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (init : β) (arr : Array α) :
foldrM f init arr = List.foldlM (fun (x : β) (y : α) => f y x) init arr.toList.reverse
@[simp]
theorem Array.foldrM_toList {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (init : β) (arr : Array α) :
List.foldrM f init arr.toList = foldrM f init arr
@[simp]
theorem Array.foldr_toList {α : Type u_1} {β : Type u_2} (f : αββ) (init : β) (arr : Array α) :
List.foldr f init arr.toList = foldr f init arr
@[simp]
theorem Array.push_toList {α : Type u_1} (arr : Array α) (a : α) :
(arr.push a).toList = arr.toList ++ [a]
@[simp]
theorem Array.toListAppend_eq {α : Type u_1} (arr : Array α) (l : List α) :
arr.toListAppend l = arr.toList ++ l
@[simp]
theorem Array.toListImpl_eq {α : Type u_1} (arr : Array α) :
@[simp]
theorem Array.pop_toList {α : Type u_1} (arr : Array α) :
@[simp]
theorem Array.append_eq_append {α : Type u_1} (arr arr' : Array α) :
arr.append arr' = arr ++ arr'
@[simp]
theorem Array.toList_append {α : Type u_1} (arr arr' : Array α) :
(arr ++ arr').toList = arr.toList ++ arr'.toList
@[simp]
theorem Array.toList_empty {α : Type u_1} :
@[simp]
theorem Array.append_empty {α : Type u_1} (as : Array α) :
as ++ #[] = as
@[reducible, inline, deprecated Array.append_empty (since := "2025-01-13")]
abbrev Array.append_nil {α : Type u_1} (as : Array α) :
as ++ #[] = as
Equations
Instances For
    @[simp]
    theorem Array.empty_append {α : Type u_1} (as : Array α) :
    #[] ++ as = as
    @[reducible, inline, deprecated Array.empty_append (since := "2025-01-13")]
    abbrev Array.nil_append {α : Type u_1} (as : Array α) :
    #[] ++ as = as
    Equations
    Instances For
      @[simp]
      theorem Array.append_assoc {α : Type u_1} (as bs cs : Array α) :
      as ++ bs ++ cs = as ++ (bs ++ cs)
      @[simp]
      theorem Array.appendList_eq_append {α : Type u_1} (arr : Array α) (l : List α) :
      arr.appendList l = arr ++ l
      @[simp]
      theorem Array.toList_appendList {α : Type u_1} (arr : Array α) (l : List α) :
      (arr ++ l).toList = arr.toList ++ l
      @[reducible, inline, deprecated Array.toList_appendList (since := "2024-12-11")]
      abbrev Array.appendList_toList {α : Type u_1} (arr : Array α) (l : List α) :
      (arr ++ l).toList = arr.toList ++ l
      Equations
      Instances For
        @[deprecated "Use the reverse direction of `foldrM_toList`." (since := "2024-11-13")]
        theorem Array.foldrM_eq_foldrM_toList {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (init : β) (arr : Array α) :
        foldrM f init arr = List.foldrM f init arr.toList
        @[deprecated "Use the reverse direction of `foldlM_toList`." (since := "2024-11-13")]
        theorem Array.foldlM_eq_foldlM_toList {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} [Monad m] (f : βαm β) (init : β) (arr : Array α) :
        foldlM f init arr = List.foldlM f init arr.toList
        @[deprecated "Use the reverse direction of `foldr_toList`." (since := "2024-11-13")]
        theorem Array.foldr_eq_foldr_toList {α : Type u_1} {β : Type u_2} (f : αββ) (init : β) (arr : Array α) :
        foldr f init arr = List.foldr f init arr.toList
        @[deprecated "Use the reverse direction of `foldl_toList`." (since := "2024-11-13")]
        theorem Array.foldl_eq_foldl_toList {β : Type u_1} {α : Type u_2} (f : βαβ) (init : β) (arr : Array α) :
        foldl f init arr = List.foldl f init arr.toList
        @[reducible, inline, deprecated Array.foldlM_toList (since := "2024-09-09")]
        abbrev Array.foldlM_eq_foldlM_data {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} [Monad m] (f : βαm β) (init : β) (arr : Array α) :
        List.foldlM f init arr.toList = foldlM f init arr
        Equations
        Instances For
          @[reducible, inline, deprecated Array.foldl_toList (since := "2024-09-09")]
          abbrev Array.foldl_eq_foldl_data {β : Type u_1} {α : Type u_2} (f : βαβ) (init : β) (arr : Array α) :
          List.foldl f init arr.toList = foldl f init arr
          Equations
          Instances For
            @[reducible, inline, deprecated Array.foldrM_eq_reverse_foldlM_toList (since := "2024-09-09")]
            abbrev Array.foldrM_eq_reverse_foldlM_data {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (init : β) (arr : Array α) :
            foldrM f init arr = List.foldlM (fun (x : β) (y : α) => f y x) init arr.toList.reverse
            Equations
            Instances For
              @[reducible, inline, deprecated Array.foldrM_toList (since := "2024-09-09")]
              abbrev Array.foldrM_eq_foldrM_data {m : Type u_1 → Type u_2} {α : Type u_3} {β : Type u_1} [Monad m] (f : αβm β) (init : β) (arr : Array α) :
              List.foldrM f init arr.toList = foldrM f init arr
              Equations
              Instances For
                @[reducible, inline, deprecated Array.foldr_toList (since := "2024-09-09")]
                abbrev Array.foldr_eq_foldr_data {α : Type u_1} {β : Type u_2} (f : αββ) (init : β) (arr : Array α) :
                List.foldr f init arr.toList = foldr f init arr
                Equations
                Instances For
                  @[reducible, inline, deprecated Array.push_toList (since := "2024-09-09")]
                  abbrev Array.push_data {α : Type u_1} (arr : Array α) (a : α) :
                  (arr.push a).toList = arr.toList ++ [a]
                  Equations
                  Instances For
                    @[reducible, inline, deprecated Array.toListImpl_eq (since := "2024-09-09")]
                    abbrev Array.toList_eq {α : Type u_1} (arr : Array α) :
                    Equations
                    Instances For
                      @[reducible, inline, deprecated Array.pop_toList (since := "2024-09-09")]
                      abbrev Array.pop_data {α : Type u_1} (arr : Array α) :
                      Equations
                      Instances For
                        @[reducible, inline, deprecated Array.toList_append (since := "2024-09-09")]
                        abbrev Array.append_data {α : Type u_1} (arr arr' : Array α) :
                        (arr ++ arr').toList = arr.toList ++ arr'.toList
                        Equations
                        Instances For
                          @[reducible, inline, deprecated Array.toList_appendList (since := "2024-09-09")]
                          abbrev Array.appendList_data {α : Type u_1} (arr : Array α) (l : List α) :
                          (arr ++ l).toList = arr.toList ++ l
                          Equations
                          Instances For