Skip to content

Commit

Permalink
feat(data/list/basic): tail_drop, cons_nth_le_drop_succ (#6265)
Browse files Browse the repository at this point in the history
  • Loading branch information
pechersky committed Feb 19, 2021
1 parent 1fecd52 commit 75149c3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/data/list/basic.lean
Expand Up @@ -1580,6 +1580,26 @@ end
l.drop k = [] :=
by simpa [←length_eq_zero] using nat.sub_eq_zero_of_le h

lemma tail_drop (l : list α) (n : ℕ) : (l.drop n).tail = l.drop (n + 1) :=
begin
induction l with hd tl hl generalizing n,
{ simp },
{ cases n,
{ simp },
{ simp [hl] } }
end

lemma cons_nth_le_drop_succ {l : list α} {n : ℕ} (hn : n < l.length) :
l.nth_le n hn :: l.drop (n + 1) = l.drop n :=
begin
induction l with hd tl hl generalizing n,
{ exact absurd n.zero_le (not_le_of_lt (by simpa using hn)) },
{ cases n,
{ simp },
{ simp only [nat.succ_lt_succ_iff, list.length] at hn,
simpa [list.nth_le, list.drop] using hl hn } }
end

theorem drop_nil : ∀ n, drop n [] = ([] : list α) :=
λ _, drop_eq_nil_of_le (nat.zero_le _)

Expand Down

0 comments on commit 75149c3

Please sign in to comment.