Theorem: List.prefix_take_iff
File: Mathlib/Data/List/Infix.lean

tactic: constructor
state_before: α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
⊢ x <+: take n y ↔ x <+: y ∧ x.length ≤ n
state_after: case mp
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
⊢ x <+: take n y → x <+: y ∧ x.length ≤ n

case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
⊢ x <+: y ∧ x.length ≤ n → x <+: take n y

tactic: intro h
state_before: case mp
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
⊢ x <+: take n y → x <+: y ∧ x.length ≤ n
state_after: case mp
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x <+: take n y
⊢ x <+: y ∧ x.length ≤ n

tactic: constructor
state_before: case mp
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x <+: take n y
⊢ x <+: y ∧ x.length ≤ n
state_after: case mp.left
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x <+: take n y
⊢ x <+: y

case mp.right
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x <+: take n y
⊢ x.length ≤ n

tactic: exact List.IsPrefix.trans h <| List.take_prefix n y
state_before: case mp.left
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x <+: take n y
⊢ x <+: y
state_after: no goals

tactic: replace h := h.length_le
state_before: case mp.right
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x <+: take n y
⊢ x.length ≤ n
state_after: case mp.right
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x.length ≤ (take n y).length
⊢ x.length ≤ n

tactic: rw [length_take, Nat.le_min] at h
state_before: case mp.right
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x.length ≤ (take n y).length
⊢ x.length ≤ n
state_after: case mp.right
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x.length ≤ n ∧ x.length ≤ y.length
⊢ x.length ≤ n

tactic: exact h.left
state_before: case mp.right
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
h : x.length ≤ n ∧ x.length ≤ y.length
⊢ x.length ≤ n
state_after: no goals

tactic: intro ⟨hp, hl⟩
state_before: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
⊢ x <+: y ∧ x.length ≤ n → x <+: take n y
state_after: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x <+: y
hl : x.length ≤ n
⊢ x <+: take n y

tactic: have hl' := hp.length_le
state_before: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x <+: y
hl : x.length ≤ n
⊢ x <+: take n y
state_after: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x <+: y
hl : x.length ≤ n
hl' : x.length ≤ y.length
⊢ x <+: take n y

tactic: rw [List.prefix_iff_eq_take] at *
state_before: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x <+: y
hl : x.length ≤ n
hl' : x.length ≤ y.length
⊢ x <+: take n y
state_after: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x = take x.length y
hl : x.length ≤ n
hl' : x.length ≤ y.length
⊢ x = take x.length (take n y)

tactic: rw [hp, List.take_take]
state_before: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x = take x.length y
hl : x.length ≤ n
hl' : x.length ≤ y.length
⊢ x = take x.length (take n y)
state_after: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x = take x.length y
hl : x.length ≤ n
hl' : x.length ≤ y.length
⊢ take x.length y = take (min (take x.length y).length n) y

tactic: simp [min_eq_left, hl, hl']
state_before: case mpr
α : Type u_1
β : Type u_2
l l₁ l₂ l₃ : List α
a b : α
m n✝ : ℕ
x y : List α
n : ℕ
hp : x = take x.length y
hl : x.length ≤ n
hl' : x.length ≤ y.length
⊢ take x.length y = take (min (take x.length y).length n) y
state_after: no goals