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_1
α : Type u
β : Type v
γ : Type w
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)
state_after: case pos
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l : List α
h : n < l.length
⊢ (if n < l.length then (#[].toList ++ take n l, drop n l) else (l, [])) = (take n l, drop n l)

case neg
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l : List α
h : ¬n < l.length
⊢ (if n < l.length then (#[].toList ++ take n l, drop n l) else (l, [])) = (take n l, drop n l)

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

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

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_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l : List α
h : ¬n < l.length
⊢ (if n < l.length then (#[].toList ++ take n l, drop n l) else (l, [])) = (take n l, drop n l)
state_after: no goals

tactic: split_ifs with h
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
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 < xs.length then (acc.toList ++ take n xs, drop n xs) else (l, [])
state_after: case pos
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n✝ : ℕ
l✝ : List α
n : ℕ
l xs : List α
acc : Array α
h : n < xs.length
⊢ splitAt.go l xs n acc = (acc.toList ++ take n xs, drop n xs)

case neg
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n✝ : ℕ
l✝ : List α
n : ℕ
l xs : List α
acc : Array α
h : ¬n < xs.length
⊢ splitAt.go l xs n acc = (l, [])

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

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

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

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

tactic: contradiction
state_before: case pos.zero.x_4
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : 0 < [].length
h₁ : xs = []
⊢ False
state_after: no goals

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

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

tactic: cases xs with
| nil => contradiction
| cons hd tl =>
  rw [length] at h
  rw [splitAt.go, take, drop, append_cons, Array.toList_eq, ← Array.push_data,
    ← Array.toList_eq]
  exact ih _ _ <| (by omega)
state_before: case pos.succ
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
xs : List α
acc : Array α
h : n✝ + 1 < xs.length
⊢ splitAt.go l xs (n✝ + 1) acc = (acc.toList ++ take (n✝ + 1) xs, drop (n✝ + 1) xs)
state_after: no goals

tactic: contradiction
state_before: case pos.succ.nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
acc : Array α
h : n✝ + 1 < [].length
⊢ splitAt.go l [] (n✝ + 1) acc = (acc.toList ++ take (n✝ + 1) [], drop (n✝ + 1) [])
state_after: no goals

tactic: rw [length] at h
state_before: case pos.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < (hd :: tl).length
⊢ splitAt.go l (hd :: tl) (n✝ + 1) acc = (acc.toList ++ take (n✝ + 1) (hd :: tl), drop (n✝ + 1) (hd :: tl))
state_after: case pos.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < tl.length + 1
⊢ splitAt.go l (hd :: tl) (n✝ + 1) acc = (acc.toList ++ take (n✝ + 1) (hd :: tl), drop (n✝ + 1) (hd :: tl))

tactic: rw [splitAt.go, take, drop, append_cons, Array.toList_eq, ← Array.push_data,
  ← Array.toList_eq]
state_before: case pos.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < tl.length + 1
⊢ splitAt.go l (hd :: tl) (n✝ + 1) acc = (acc.toList ++ take (n✝ + 1) (hd :: tl), drop (n✝ + 1) (hd :: tl))
state_after: case pos.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < tl.length + 1
⊢ splitAt.go l tl n✝ (acc.push hd) = ((acc.push hd).toList ++ take n✝ tl, drop n✝ tl)

tactic: exact ih _ _ <| (by omega)
state_before: case pos.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < tl.length + 1
⊢ splitAt.go l tl n✝ (acc.push hd) = ((acc.push hd).toList ++ take n✝ tl, drop n✝ tl)
state_after: no goals

tactic: omega
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (acc.toList ++ take n✝ xs, drop n✝ xs)
acc : Array α
hd : α
tl : List α
h : n✝ + 1 < tl.length + 1
⊢ n✝ < tl.length
state_after: no goals

tactic: replace h : xs.length = 0 := by omega
state_before: case neg.zero
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : ¬0 < xs.length
⊢ splitAt.go l xs 0 acc = (l, [])
state_after: case neg.zero
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : xs.length = 0
⊢ splitAt.go l xs 0 acc = (l, [])

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

tactic: omega
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
p : α → Bool
xs✝ ys : List α
ls : List (List α)
f : List α → List α
n : ℕ
l✝ l xs : List α
acc : Array α
h : ¬0 < xs.length
⊢ xs.length = 0
state_after: no goals

tactic: rw [splitAt.go]
state_before: case neg.succ.nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
h : ¬n✝ + 1 < [].length
⊢ splitAt.go l [] (n✝ + 1) acc = (l, [])
state_after: no goals

tactic: rw [length] at h
state_before: case neg.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
hd : α
tl : List α
h : ¬n✝ + 1 < (hd :: tl).length
⊢ splitAt.go l (hd :: tl) (n✝ + 1) acc = (l, [])
state_after: case neg.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
hd : α
tl : List α
h : ¬n✝ + 1 < tl.length + 1
⊢ splitAt.go l (hd :: tl) (n✝ + 1) acc = (l, [])

tactic: rw [splitAt.go]
state_before: case neg.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
hd : α
tl : List α
h : ¬n✝ + 1 < tl.length + 1
⊢ splitAt.go l (hd :: tl) (n✝ + 1) acc = (l, [])
state_after: case neg.succ.cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
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✝ < xs.length → splitAt.go l xs n✝ acc = (l, [])
acc : Array α
hd : α
tl : List α
h : ¬n✝ + 1 < tl.length + 1
⊢ splitAt.go l tl n✝ (acc.push hd) = (l, [])