Theorem: List.splitAt_eq_take_drop
File: Mathlib/Data/List/Basic.lean

tactic: by_cases h : n < l.length <;> rw [splitAt, go_eq_take_drop]
state_before: ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l : List α
⊢ splitAt n l = (take n l, drop n l)

tactic: rw [if_pos h]
state_before: case pos
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l : List α
h : n < length l
⊢ (if n < length l then (Array.toList #[] ++ take n l, drop n l) else (l, [])) = (take n l, drop n l)

tactic: rfl
state_before: case pos
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l : List α
h : n < length l
⊢ (Array.toList #[] ++ take n l, drop n l) = (take n l, drop n l)

tactic: rw [if_neg h, take_all_of_le <| le_of_not_lt h, drop_eq_nil_of_le <| le_of_not_lt h]
state_before: case neg
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l : List α
h : ¬n < length l
⊢ (if n < length l then (Array.toList #[] ++ take n l, drop n l) else (l, [])) = (take n l, drop n l)

tactic: split_ifs with h
state_before: ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n✝ : ℕ
l✝ : List α
n : ℕ
l xs : List α
acc : Array α
⊢ splitAt.go l xs n acc = if n < length xs then (Array.toList acc ++ take n xs, drop n xs) else (l, [])

tactic: rw [splitAt.go, take, drop, append_nil]
state_before: case inl.zero
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : zero < length xs
⊢ splitAt.go l xs zero acc = (Array.toList acc ++ take zero xs, drop zero xs)

tactic: intros h₁
state_before: case inl.zero.x_4
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : zero < length xs
⊢ xs = [] → False

tactic: rw [h₁] at h
state_before: case inl.zero.x_4
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : zero < length xs
h₁ : xs = []
⊢ False

tactic: contradiction
state_before: case inl.zero.x_4
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : zero < length []
h₁ : xs = []
⊢ False

tactic: intros
state_before: case inl.zero.x_5
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : zero < length xs
⊢ ∀ (x : α) (xs_1 : List α) (n : ℕ), xs = x :: xs_1 → zero = succ n → False

tactic: contradiction
state_before: case inl.zero.x_5
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : zero < length xs
x✝ : α
xs_1✝ : List α
n✝ : ℕ
x_1✝ : xs = x✝ :: xs_1✝
x_2✝ : zero = succ n✝
⊢ False

tactic: cases xs with
| nil => contradiction
| cons hd tl =>
  rw [length, succ_eq_add_one] at h
  rw [splitAt.go, take, drop, append_cons, Array.toList_eq, ←Array.push_data,
    ←Array.toList_eq]
  exact ih _ _ <| lt_of_add_lt_add_right h
state_before: case inl.succ
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih :
  ∀ (xs : List α) (acc : Array α),
    n✝ < length xs → splitAt.go l xs n✝ acc = (Array.toList acc ++ take n✝ xs, drop n✝ xs)
xs : List α
acc : Array α
h : succ n✝ < length xs
⊢ splitAt.go l xs (succ n✝) acc = (Array.toList acc ++ take (succ n✝) xs, drop (succ n✝) xs)

tactic: contradiction
state_before: case inl.succ.nil
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih :
  ∀ (xs : List α) (acc : Array α),
    n✝ < length xs → splitAt.go l xs n✝ acc = (Array.toList acc ++ take n✝ xs, drop n✝ xs)
acc : Array α
h : succ n✝ < length []
⊢ splitAt.go l [] (succ n✝) acc = (Array.toList acc ++ take (succ n✝) [], drop (succ n✝) [])

tactic: rw [length, succ_eq_add_one] at h
state_before: case inl.succ.cons
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih :
  ∀ (xs : List α) (acc : Array α),
    n✝ < length xs → splitAt.go l xs n✝ acc = (Array.toList acc ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : succ n✝ < length (hd :: tl)
⊢ splitAt.go l (hd :: tl) (succ n✝) acc = (Array.toList acc ++ take (succ n✝) (hd :: tl), drop (succ n✝) (hd :: tl))

tactic: rw [splitAt.go, take, drop, append_cons, Array.toList_eq, ←Array.push_data,
  ←Array.toList_eq]
state_before: case inl.succ.cons
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih :
  ∀ (xs : List α) (acc : Array α),
    n✝ < length xs → splitAt.go l xs n✝ acc = (Array.toList acc ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < length tl + 1
⊢ splitAt.go l (hd :: tl) (succ n✝) acc = (Array.toList acc ++ take (succ n✝) (hd :: tl), drop (succ n✝) (hd :: tl))

tactic: exact ih _ _ <| lt_of_add_lt_add_right h
state_before: case inl.succ.cons
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih :
  ∀ (xs : List α) (acc : Array α),
    n✝ < length xs → splitAt.go l xs n✝ acc = (Array.toList acc ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < length tl + 1
⊢ splitAt.go l tl n✝ (Array.push acc hd) = (Array.toList (Array.push acc hd) ++ take n✝ tl, drop n✝ tl)

tactic: rw [zero_eq, not_lt, nonpos_iff_eq_zero] at h
state_before: case inr.zero
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : ¬zero < length xs
⊢ splitAt.go l xs zero acc = (l, [])

tactic: rw [eq_nil_of_length_eq_zero h, splitAt.go]
state_before: case inr.zero
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : length xs = 0
⊢ splitAt.go l xs zero acc = (l, [])

tactic: rw [splitAt.go]
state_before: case inr.succ.nil
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih : ∀ (xs : List α) (acc : Array α), ¬n✝ < length xs → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
h : ¬succ n✝ < length []
⊢ splitAt.go l [] (succ n✝) acc = (l, [])

tactic: rw [length, succ_eq_add_one] at h
state_before: case inr.succ.cons
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih : ∀ (xs : List α) (acc : Array α), ¬n✝ < length xs → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
hd : α
tl : List α
h : ¬succ n✝ < length (hd :: tl)
⊢ splitAt.go l (hd :: tl) (succ n✝) acc = (l, [])

tactic: rw [splitAt.go]
state_before: case inr.succ.cons
ι : Type ?u.283895
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l : List α
n✝ : ℕ
ih : ∀ (xs : List α) (acc : Array α), ¬n✝ < length xs → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
hd : α
tl : List α
h : ¬n✝ + 1 < length tl + 1
⊢ splitAt.go l (hd :: tl) (succ n✝) acc = (l, [])