File: .lake/packages/lean4/src/lean/Init/Data/List/Impl.lean

full_name: List.length_add_eq_lengthTRAux
code: theorem length_add_eq_lengthTRAux (as : List α) (n : Nat) : as.length + n = as.lengthTRAux n 
goal: as.length + n = as.lengthTRAux n

full_name: List.length_eq_lengthTR
code: @[csimp] theorem length_eq_lengthTR : @List.length = @List.lengthTR 
goal: @List.length = @List.lengthTR

full_name: List.setTR.go
code: /-- Tail recursive version of `List.set`. -/
@[inline] def setTR (l : List α) (n : Nat) (a : α) : List α 
goal: List α → Nat → Array α → List α

full_name: List.setTR
code: /-- Tail recursive version of `List.set`. -/
@[inline] def setTR (l : List α) (n : Nat) (a : α) : List α 
goal: List α

full_name: List.set_eq_setTR.go
code: @[csimp] theorem set_eq_setTR : @set = @setTR 
goal: l = acc.data ++ xs → List.setTR.go l a xs n acc = acc.data ++ xs.set n a

full_name: List.set_eq_setTR
code: @[csimp] theorem set_eq_setTR : @set = @setTR 
goal: @List.set = @List.setTR

full_name: List.mapTR.loop
code: /-- Tail-recursive version of `List.map`. -/
@[inline] def mapTR (f : α → β) (as : List α) : List β 
goal: List α → List β → List β

full_name: List.mapTR
code: /-- Tail-recursive version of `List.map`. -/
@[inline] def mapTR (f : α → β) (as : List α) : List β 
goal: List β

full_name: List.mapTR_loop_eq
code: theorem mapTR_loop_eq (f : α → β) (as : List α) (bs : List β) :
    mapTR.loop f as bs = bs.reverse ++ map f as 
goal: List.mapTR.loop f as bs = bs.reverse ++ List.map f as

full_name: List.map_eq_mapTR
code: @[csimp] theorem map_eq_mapTR : @map = @mapTR 
goal: @List.map = @List.mapTR

full_name: List.filterTR
code: /-- Tail-recursive version of `List.filter`. -/
@[inline] def filterTR (p : α → Bool) (as : List α) : List α 
goal: List α

full_name: List.filterTR.loop
code: /-- Tail-recursive version of `List.filter`. -/
@[inline] def filterTR (p : α → Bool) (as : List α) : List α 
goal: List α → List α → List α

full_name: List.filterTR_loop_eq
code: theorem filterTR_loop_eq (p : α → Bool) (as bs : List α) :
    filterTR.loop p as bs = bs.reverse ++ filter p as 
goal: List.filterTR.loop p as bs = bs.reverse ++ List.filter p as

full_name: List.filter_eq_filterTR
code: @[csimp] theorem filter_eq_filterTR : @filter = @filterTR 
goal: @List.filter = @List.filterTR

full_name: List.filterMapTR.go
code: /-- Tail recursive version of `filterMap`. -/
@[inline] def filterMapTR (f : α → Option β) (l : List α) : List β 
goal: List α → Array β → List β

full_name: List.filterMapTR
code: /-- Tail recursive version of `filterMap`. -/
@[inline] def filterMapTR (f : α → Option β) (l : List α) : List β 
goal: List β

full_name: List.filterMap_eq_filterMapTR
code: @[csimp] theorem filterMap_eq_filterMapTR : @List.filterMap = @filterMapTR 
goal: @List.filterMap = @List.filterMapTR

full_name: List.filterMap_eq_filterMapTR.go
code: @[csimp] theorem filterMap_eq_filterMapTR : @List.filterMap = @filterMapTR 
goal: List.filterMapTR.go f as acc = acc.data ++ List.filterMap f as

full_name: List.foldrTR
code: /-- Tail recursive version of `List.foldr`. -/
@[specialize] def foldrTR (f : α → β → β) (init : β) (l : List α) : β 
goal: β

full_name: List.foldr_eq_foldrTR
code: @[csimp] theorem foldr_eq_foldrTR : @foldr = @foldrTR 
goal: @List.foldr = @List.foldrTR

full_name: List.bindTR.go
code: /-- Tail recursive version of `List.bind`. -/
@[inline] def bindTR (as : List α) (f : α → List β) : List β 
goal: List α → Array β → List β

full_name: List.bindTR
code: /-- Tail recursive version of `List.bind`. -/
@[inline] def bindTR (as : List α) (f : α → List β) : List β 
goal: List β

full_name: List.bind_eq_bindTR
code: @[csimp] theorem bind_eq_bindTR : @List.bind = @bindTR 
goal: @List.bind = @List.bindTR

full_name: List.bind_eq_bindTR.go
code: @[csimp] theorem bind_eq_bindTR : @List.bind = @bindTR 
goal: List.bindTR.go f as acc = acc.data ++ as.bind f

full_name: List.joinTR
code: /-- Tail recursive version of `List.join`. -/
@[inline] def joinTR (l : List (List α)) : List α 
goal: List α

full_name: List.join_eq_joinTR
code: @[csimp] theorem join_eq_joinTR : @join = @joinTR 
goal: @List.join = @List.joinTR

full_name: List.replicateTR.loop
code: /-- Tail-recursive version of `List.replicate`. -/
def replicateTR {α : Type u} (n : Nat) (a : α) : List α 
goal: Nat → List α → List α

full_name: List.replicateTR
code: /-- Tail-recursive version of `List.replicate`. -/
def replicateTR {α : Type u} (n : Nat) (a : α) : List α 
goal: List α

full_name: List.replicateTR_loop_replicate_eq
code: theorem replicateTR_loop_replicate_eq (a : α) (m n : Nat) :
  replicateTR.loop a n (replicate m a) = replicate (n + m) a 
goal: List.replicateTR.loop a n (List.replicate m a) = List.replicate (n + m) a

full_name: List.replicateTR_loop_eq
code: theorem replicateTR_loop_eq : ∀ n, replicateTR.loop a n acc = replicate n a ++ acc
  
goal: ∀ {α : Type u_1} {a : α} {acc : List α} (n : Nat), List.replicateTR.loop a n acc = List.replicate n a ++ acc

full_name: List.replicate_eq_replicateTR
code: @[csimp] theorem replicate_eq_replicateTR : @List.replicate = @List.replicateTR 
goal: @List.replicate = @List.replicateTR

full_name: List.takeTR.go
code: /-- Tail recursive version of `List.take`. -/
@[inline] def takeTR (n : Nat) (l : List α) : List α 
goal: List α → Nat → Array α → List α

full_name: List.takeTR
code: /-- Tail recursive version of `List.take`. -/
@[inline] def takeTR (n : Nat) (l : List α) : List α 
goal: List α

full_name: List.take_eq_takeTR
code: @[csimp] theorem take_eq_takeTR : @take = @takeTR 
goal: @List.take = @List.takeTR

full_name: List.takeWhileTR
code: /-- Tail recursive version of `List.takeWhile`. -/
@[inline] def takeWhileTR (p : α → Bool) (l : List α) : List α 
goal: List α

full_name: List.takeWhileTR.go
code: /-- Tail recursive version of `List.takeWhile`. -/
@[inline] def takeWhileTR (p : α → Bool) (l : List α) : List α 
goal: List α → Array α → List α

full_name: List.takeWhile_eq_takeWhileTR
code: @[csimp] theorem takeWhile_eq_takeWhileTR : @takeWhile = @takeWhileTR 
goal: @List.takeWhile = @List.takeWhileTR

full_name: List.dropLastTR
code: /-- Tail recursive version of `dropLast`. -/
@[inline] def dropLastTR (l : List α) : List α 
goal: List α

full_name: List.dropLast_eq_dropLastTR
code: @[csimp] theorem dropLast_eq_dropLastTR : @dropLast = @dropLastTR 
goal: @List.dropLast = @List.dropLastTR

full_name: List.replaceTR.go
code: /-- Tail recursive version of `List.replace`. -/
@[inline] def replaceTR [BEq α] (l : List α) (b c : α) : List α 
goal: List α → Array α → List α

full_name: List.replaceTR
code: /-- Tail recursive version of `List.replace`. -/
@[inline] def replaceTR [BEq α] (l : List α) (b c : α) : List α 
goal: List α

full_name: List.replace_eq_replaceTR
code: @[csimp] theorem replace_eq_replaceTR : @List.replace = @replaceTR 
goal: @List.replace = @List.replaceTR

full_name: List.eraseTR.go
code: /-- Tail recursive version of `List.erase`. -/
@[inline] def eraseTR [BEq α] (l : List α) (a : α) : List α 
goal: List α → Array α → List α

full_name: List.eraseTR
code: /-- Tail recursive version of `List.erase`. -/
@[inline] def eraseTR [BEq α] (l : List α) (a : α) : List α 
goal: List α

full_name: List.erase_eq_eraseTR
code: @[csimp] theorem erase_eq_eraseTR : @List.erase = @eraseTR 
goal: @List.erase = @List.eraseTR

full_name: List.eraseIdxTR.go
code: /-- Tail recursive version of `List.eraseIdx`. -/
@[inline] def eraseIdxTR (l : List α) (n : Nat) : List α 
goal: List α → Nat → Array α → List α

full_name: List.eraseIdxTR
code: /-- Tail recursive version of `List.eraseIdx`. -/
@[inline] def eraseIdxTR (l : List α) (n : Nat) : List α 
goal: List α

full_name: List.eraseIdx_eq_eraseIdxTR
code: @[csimp] theorem eraseIdx_eq_eraseIdxTR : @eraseIdx = @eraseIdxTR 
goal: @List.eraseIdx = @List.eraseIdxTR

full_name: List.zipWithTR
code: /-- Tail recursive version of `List.zipWith`. -/
@[inline] def zipWithTR (f : α → β → γ) (as : List α) (bs : List β) : List γ 
goal: List γ

full_name: List.zipWithTR.go
code: /-- Tail recursive version of `List.zipWith`. -/
@[inline] def zipWithTR (f : α → β → γ) (as : List α) (bs : List β) : List γ 
goal: List α → List β → Array γ → List γ

full_name: List.zipWith_eq_zipWithTR.go
code: @[csimp] theorem zipWith_eq_zipWithTR : @zipWith = @zipWithTR 
goal: List.zipWithTR.go f as bs acc = acc.data ++ List.zipWith f as bs

full_name: List.zipWith_eq_zipWithTR
code: @[csimp] theorem zipWith_eq_zipWithTR : @zipWith = @zipWithTR 
goal: @List.zipWith = @List.zipWithTR

full_name: List.unzipTR
code: /-- Tail recursive version of `List.unzip`. -/
def unzipTR (l : List (α × β)) : List α × List β 
goal: List α × List β

full_name: List.unzip_eq_unzipTR
code: @[csimp] theorem unzip_eq_unzipTR : @unzip = @unzipTR 
goal: @List.unzip = @List.unzipTR

full_name: List.iotaTR.go
code: /-- Tail-recursive version of `List.iota`. -/
def iotaTR (n : Nat) : List Nat 
goal: Nat → List Nat → List Nat

full_name: List.iotaTR
code: /-- Tail-recursive version of `List.iota`. -/
def iotaTR (n : Nat) : List Nat 
goal: List Nat

full_name: List.iota_eq_iotaTR
code: @[csimp]
theorem iota_eq_iotaTR : @iota = @iotaTR 
goal: List.iota = List.iotaTR

full_name: List.enumFromTR
code: /-- Tail recursive version of `List.enumFrom`. -/
def enumFromTR (n : Nat) (l : List α) : List (Nat × α) 
goal: List (Nat × α)

full_name: List.enumFrom_eq_enumFromTR.go
code: @[csimp] theorem enumFrom_eq_enumFromTR : @enumFrom = @enumFromTR 
goal: let f := fun a x =>
  match x with
  | (n, acc) => (n - 1, (n - 1, a) :: acc);
List.foldr f (n + l.length, []) l = (n, List.enumFrom n l)

full_name: List.enumFrom_eq_enumFromTR
code: @[csimp] theorem enumFrom_eq_enumFromTR : @enumFrom = @enumFromTR 
goal: @List.enumFrom = @List.enumFromTR

full_name: List.intersperseTR
code: /-- Tail recursive version of `List.intersperse`. -/
def intersperseTR (sep : α) : List α → List α
  
goal: List α → List α

full_name: List.intersperse_eq_intersperseTR
code: @[csimp] theorem intersperse_eq_intersperseTR : @intersperse = @intersperseTR 
goal: @List.intersperse = @List.intersperseTR

full_name: List.intercalateTR
code: /-- Tail recursive version of `List.intercalate`. -/
def intercalateTR (sep : List α) : List (List α) → List α
  
goal: List (List α) → List α

full_name: List.intercalateTR.go
code: /-- Tail recursive version of `List.intercalate`. -/
def intercalateTR (sep : List α) : List (List α) → List α
  
goal: List α → List (List α) → Array α → List α

full_name: List.intercalate_eq_intercalateTR.go
code: @[csimp] theorem intercalate_eq_intercalateTR : @intercalate = @intercalateTR 
goal: List.intercalateTR.go (List.toArray sep) x xs acc = acc.data ++ (List.intersperse sep (x :: xs)).join

full_name: List.intercalate_eq_intercalateTR
code: @[csimp] theorem intercalate_eq_intercalateTR : @intercalate = @intercalateTR 
goal: @List.intercalate = @List.intercalateTR