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

full_name: List.length_take
code: @[simp] theorem length_take : ∀ (i : Nat) (l : List α), length (take i l) = min i (length l)
  
goal: (List.take i l).length = min i l.length

full_name: List.length_take_le
code: theorem length_take_le (n) (l : List α) : length (take n l) ≤ n 
goal: (List.take n l).length ≤ n

full_name: List.length_take_le'
code: theorem length_take_le' (n) (l : List α) : length (take n l) ≤ l.length 
goal: (List.take n l).length ≤ l.length

full_name: List.length_take_of_le
code: theorem length_take_of_le (h : n ≤ length l) : length (take n l) = n 
goal: ∀ {α : Type u_1} {l : List α}, n ≤ l.length → (List.take n l).length = n

full_name: List.take_take
code: theorem take_take : ∀ (n m) (l : List α), take n (take m l) = take (min n m) l
  
goal: List.take n (List.take m l) = List.take (min n m) l

full_name: List.take_replicate
code: @[simp] theorem take_replicate (a : α) : ∀ n m : Nat, take n (replicate m a) = replicate (min n m) a
  
goal: List.take n (List.replicate m a) = List.replicate (min n m) a

full_name: List.drop_replicate
code: @[simp] theorem drop_replicate (a : α) : ∀ n m : Nat, drop n (replicate m a) = replicate (m - n) a
  
goal: List.drop n (List.replicate m a) = List.replicate (m - n) a

full_name: List.take_append_eq_append_take
code: /-- Taking the first `n` elements in `l₁ ++ l₂` is the same as appending the first `n` elements
of `l₁` to the first `n - l₁.length` elements of `l₂`. -/
theorem take_append_eq_append_take {l₁ l₂ : List α} {n : Nat} :
    take n (l₁ ++ l₂) = take n l₁ ++ take (n - l₁.length) l₂ 
goal: List.take n (l₁ ++ l₂) = List.take n l₁ ++ List.take (n - l₁.length) l₂

full_name: List.take_append_of_le_length
code: theorem take_append_of_le_length {l₁ l₂ : List α} {n : Nat} (h : n ≤ l₁.length) :
    (l₁ ++ l₂).take n = l₁.take n 
goal: List.take n (l₁ ++ l₂) = List.take n l₁

full_name: List.take_append
code: /-- Taking the first `l₁.length + i` elements in `l₁ ++ l₂` is the same as appending the first
`i` elements of `l₂` to `l₁`. -/
theorem take_append {l₁ l₂ : List α} (i : Nat) :
    take (l₁.length + i) (l₁ ++ l₂) = l₁ ++ take i l₂ 
goal: List.take (l₁.length + i) (l₁ ++ l₂) = l₁ ++ List.take i l₂

full_name: List.getElem_take
code: /-- The `i`-th element of a list coincides with the `i`-th element of any of its prefixes of
length `> i`. Version designed to rewrite from the big list to the small list. -/
theorem getElem_take (L : List α) {i j : Nat} (hi : i < L.length) (hj : i < j) :
    L[i] = (L.take j)[i]'(length_take .. ▸ Nat.lt_min.mpr ⟨hj, hi⟩) 
goal: L[i] = (List.take j L)[i]

full_name: List.getElem_take'
code: /-- The `i`-th element of a list coincides with the `i`-th element of any of its prefixes of
length `> i`. Version designed to rewrite from the small list to the big list. -/
theorem getElem_take' (L : List α) {j i : Nat} {h : i < (L.take j).length} :
    (L.take j)[i] =
    L[i]'(Nat.lt_of_lt_of_le h (length_take_le' _ _)) 
goal: (List.take j L)[i] = L[i]

full_name: List.get_take
code: /-- The `i`-th element of a list coincides with the `i`-th element of any of its prefixes of
length `> i`. Version designed to rewrite from the big list to the small list. -/
@[deprecated getElem_take (since := "2024-06-12")]
theorem get_take (L : List α) {i j : Nat} (hi : i < L.length) (hj : i < j) :
    get L ⟨i, hi⟩ = get (L.take j) ⟨i, length_take .. ▸ Nat.lt_min.mpr ⟨hj, hi⟩⟩ 
goal: L.get ⟨i, hi⟩ = (List.take j L).get ⟨i, ⋯⟩

full_name: List.get_take'
code: /-- The `i`-th element of a list coincides with the `i`-th element of any of its prefixes of
length `> i`. Version designed to rewrite from the small list to the big list. -/
@[deprecated getElem_take (since := "2024-06-12")]
theorem get_take' (L : List α) {j i} :
    get (L.take j) i =
    get L ⟨i.1, Nat.lt_of_lt_of_le i.2 (length_take_le' _ _)⟩ 
goal: (List.take j L).get i = L.get ⟨↑i, ⋯⟩

full_name: List.getElem?_take_eq_none
code: theorem getElem?_take_eq_none {l : List α} {n m : Nat} (h : n ≤ m) :
    (l.take n)[m]? = none 
goal: (List.take n l)[m]? = none

full_name: List.get?_take_eq_none
code: @[deprecated getElem?_take_eq_none (since := "2024-06-12")]
theorem get?_take_eq_none {l : List α} {n m : Nat} (h : n ≤ m) :
    (l.take n).get? m = none 
goal: (List.take n l).get? m = none

full_name: List.getElem?_take_eq_if
code: theorem getElem?_take_eq_if {l : List α} {n m : Nat} :
    (l.take n)[m]? = if m < n then l[m]? else none 
goal: (List.take n l)[m]? = if m < n then l[m]? else none

full_name: List.get?_take_eq_if
code: @[deprecated getElem?_take_eq_if (since := "2024-06-12")]
theorem get?_take_eq_if {l : List α} {n m : Nat} :
    (l.take n).get? m = if m < n then l.get? m else none 
goal: (List.take n l).get? m = if m < n then l.get? m else none

full_name: List.take_eq_take
code: @[simp]
theorem take_eq_take :
    ∀ {l : List α} {m n : Nat}, l.take m = l.take n ↔ min m l.length = min n l.length
  
goal: List.take m l = List.take n l ↔ min m l.length = min n l.length

full_name: List.take_add
code: theorem take_add (l : List α) (m n : Nat) : l.take (m + n) = l.take m ++ (l.drop m).take n 
goal: List.take (m + n) l = List.take m l ++ List.take n (List.drop m l)

full_name: List.dropLast_take
code: theorem dropLast_take {n : Nat} {l : List α} (h : n < l.length) :
    (l.take n).dropLast = l.take n.pred 
goal: (List.take n l).dropLast = List.take n.pred l

full_name: List.map_eq_append_split
code: theorem map_eq_append_split {f : α → β} {l : List α} {s₁ s₂ : List β}
    (h : map f l = s₁ ++ s₂) : ∃ l₁ l₂, l = l₁ ++ l₂ ∧ map f l₁ = s₁ ∧ map f l₂ = s₂ 
goal: ∃ l₁ l₂, l = l₁ ++ l₂ ∧ List.map f l₁ = s₁ ∧ List.map f l₂ = s₂

full_name: List.drop_length_cons
code: theorem drop_length_cons {l : List α} (h : l ≠ []) (a : α) :
    (a :: l).drop l.length = [l.getLast h] 
goal: List.drop l.length (a :: l) = [l.getLast h]

full_name: List.drop_append_eq_append_drop
code: /-- Dropping the elements up to `n` in `l₁ ++ l₂` is the same as dropping the elements up to `n`
in `l₁`, dropping the elements up to `n - l₁.length` in `l₂`, and appending them. -/
theorem drop_append_eq_append_drop {l₁ l₂ : List α} {n : Nat} :
    drop n (l₁ ++ l₂) = drop n l₁ ++ drop (n - l₁.length) l₂ 
goal: List.drop n (l₁ ++ l₂) = List.drop n l₁ ++ List.drop (n - l₁.length) l₂

full_name: List.drop_append_of_le_length
code: theorem drop_append_of_le_length {l₁ l₂ : List α} {n : Nat} (h : n ≤ l₁.length) :
    (l₁ ++ l₂).drop n = l₁.drop n ++ l₂ 
goal: List.drop n (l₁ ++ l₂) = List.drop n l₁ ++ l₂

full_name: List.drop_append
code: /-- Dropping the elements up to `l₁.length + i` in `l₁ + l₂` is the same as dropping the elements
up to `i` in `l₂`. -/
@[simp]
theorem drop_append {l₁ l₂ : List α} (i : Nat) : drop (l₁.length + i) (l₁ ++ l₂) = drop i l₂ 
goal: List.drop (l₁.length + i) (l₁ ++ l₂) = List.drop i l₂

full_name: List.lt_length_drop
code: theorem lt_length_drop (L : List α) {i j : Nat} (h : i + j < L.length) : j < (L.drop i).length 
goal: j < (List.drop i L).length

full_name: List.getElem_drop
code: /-- The `i + j`-th element of a list coincides with the `j`-th element of the list obtained by
dropping the first `i` elements. Version designed to rewrite from the big list to the small list. -/
theorem getElem_drop (L : List α) {i j : Nat} (h : i + j < L.length) :
    L[i + j] = (L.drop i)[j]'(lt_length_drop L h) 
goal: L[i + j] = (List.drop i L)[j]

full_name: List.get_drop
code: /-- The `i + j`-th element of a list coincides with the `j`-th element of the list obtained by
dropping the first `i` elements. Version designed to rewrite from the big list to the small list. -/
@[deprecated getElem_drop (since := "2024-06-12")]
theorem get_drop (L : List α) {i j : Nat} (h : i + j < L.length) :
    get L ⟨i + j, h⟩ = get (L.drop i) ⟨j, lt_length_drop L h⟩ 
goal: L.get ⟨i + j, h⟩ = (List.drop i L).get ⟨j, ⋯⟩

full_name: List.getElem_drop'
code: /-- The `i + j`-th element of a list coincides with the `j`-th element of the list obtained by
dropping the first `i` elements. Version designed to rewrite from the small list to the big list. -/
theorem getElem_drop' (L : List α) {i : Nat} {j : Nat} {h : j < (L.drop i).length} :
    (L.drop i)[j] = L[i + j]'(by
      rw [Nat.add_comm]
      exact Nat.add_lt_of_lt_sub (length_drop i L ▸ h)) 
goal: (List.drop i L)[j] = L[i + j]

full_name: List.get_drop'
code: /-- The `i + j`-th element of a list coincides with the `j`-th element of the list obtained by
dropping the first `i` elements. Version designed to rewrite from the small list to the big list. -/
@[deprecated getElem_drop' (since := "2024-06-12")]
theorem get_drop' (L : List α) {i j} :
    get (L.drop i) j = get L ⟨i + j, by
      rw [Nat.add_comm]
      exact Nat.add_lt_of_lt_sub (length_drop i L ▸ j.2)⟩ 
goal: (List.drop i L).get j = L.get ⟨i + ↑j, ⋯⟩

full_name: List.getElem?_drop
code: @[simp]
theorem getElem?_drop (L : List α) (i j : Nat) : (L.drop i)[j]? = L[i + j]? 
goal: (List.drop i L)[j]? = L[i + j]?

full_name: List.get?_drop
code: @[deprecated getElem?_drop (since := "2024-06-12")]
theorem get?_drop (L : List α) (i j : Nat) : get? (L.drop i) j = get? L (i + j) 
goal: (List.drop i L).get? j = L.get? (i + j)

full_name: List.set_eq_take_append_cons_drop
code: theorem set_eq_take_append_cons_drop {l : List α} {n : Nat} {a : α} :
    l.set n a = if n < l.length then l.take n ++ a :: l.drop (n + 1) else l 
goal: l.set n a = if n < l.length then List.take n l ++ a :: List.drop (n + 1) l else l

full_name: List.drop_take
code: theorem drop_take : ∀ (m n : Nat) (l : List α), drop n (take m l) = take (m - n) (drop n l)
  
goal: List.drop n (List.take m l) = List.take (m - n) (List.drop n l)

full_name: List.take_reverse
code: theorem take_reverse {α} {xs : List α} (n : Nat) (h : n ≤ xs.length) :
    xs.reverse.take n = (xs.drop (xs.length - n)).reverse 
goal: List.take n xs.reverse = (List.drop (xs.length - n) xs).reverse

full_name: List.reverse_take
code: @[deprecated (since := "2024-06-15")] abbrev reverse_take 
goal: List.take n xs.reverse = (List.drop (xs.length - n) xs).reverse

full_name: List.rotateLeft_replicate
code: @[simp] theorem rotateLeft_replicate (n) (a : α) : rotateLeft (replicate m a) n = replicate m a 
goal: (List.replicate m a).rotateLeft n = List.replicate m a

full_name: List.rotateRight_replicate
code: @[simp] theorem rotateRight_replicate (n) (a : α) : rotateRight (replicate m a) n = replicate m a 
goal: (List.replicate m a).rotateRight n = List.replicate m a

full_name: List.length_zipWith
code: @[simp] theorem length_zipWith (f : α → β → γ) (l₁ l₂) :
    length (zipWith f l₁ l₂) = min (length l₁) (length l₂) 
goal: (List.zipWith f l₁ l₂).length = min l₁.length l₂.length

full_name: List.zipWith_eq_zipWith_take_min
code: theorem zipWith_eq_zipWith_take_min : ∀ (l₁ : List α) (l₂ : List β),
    zipWith f l₁ l₂ = zipWith f (l₁.take (min l₁.length l₂.length)) (l₂.take (min l₁.length l₂.length))
  
goal: ∀ {α_1 : Type u_3} {f : α → β → α_1} (l₁ : List α) (l₂ : List β),
  List.zipWith f l₁ l₂ =
    List.zipWith f (List.take (min l₁.length l₂.length) l₁) (List.take (min l₁.length l₂.length) l₂)

full_name: List.zipWith_replicate
code: @[simp] theorem zipWith_replicate {a : α} {b : β} {m n : Nat} :
    zipWith f (replicate m a) (replicate n b) = replicate (min m n) (f a b) 
goal: ∀ {α_1 : Type u_3} {f : α → β → α_1} {a : α} {b : β} {m n : Nat},
  List.zipWith f (List.replicate m a) (List.replicate n b) = List.replicate (min m n) (f a b)

full_name: List.length_zip
code: @[simp] theorem length_zip (l₁ : List α) (l₂ : List β) :
    length (zip l₁ l₂) = min (length l₁) (length l₂) 
goal: (l₁.zip l₂).length = min l₁.length l₂.length

full_name: List.zip_eq_zip_take_min
code: theorem zip_eq_zip_take_min : ∀ (l₁ : List α) (l₂ : List β),
    zip l₁ l₂ = zip (l₁.take (min l₁.length l₂.length)) (l₂.take (min l₁.length l₂.length))
  
goal: l₁.zip l₂ = (List.take (min l₁.length l₂.length) l₁).zip (List.take (min l₁.length l₂.length) l₂)

full_name: List.zip_replicate
code: @[simp] theorem zip_replicate {a : α} {b : β} {m n : Nat} :
    zip (replicate m a) (replicate n b) = replicate (min m n) (a, b) 
goal: (List.replicate m a).zip (List.replicate n b) = List.replicate (min m n) (a, b)

full_name: List.minimum?_eq_some_iff'
code: theorem minimum?_eq_some_iff' {xs : List Nat} :
    xs.minimum? = some a ↔ (a ∈ xs ∧ ∀ b ∈ xs, a ≤ b) 
goal: xs.minimum? = some a ↔ a ∈ xs ∧ ∀ (b : Nat), b ∈ xs → a ≤ b

full_name: List.maximum?_eq_some_iff'
code: theorem maximum?_eq_some_iff' {xs : List Nat} :
    xs.maximum? = some a ↔ (a ∈ xs ∧ ∀ b ∈ xs, b ≤ a) 
goal: xs.maximum? = some a ↔ a ∈ xs ∧ ∀ (b : Nat), b ∈ xs → b ≤ a