Skip to content

Commit

Permalink
feat(data/list/basic): drop_eq_nil_iff_le (#6336)
Browse files Browse the repository at this point in the history
The iff version of a recently added lemma.
  • Loading branch information
pechersky committed Feb 21, 2021
1 parent 473bb7d commit ab03ebe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/data/list/basic.lean
Expand Up @@ -1580,6 +1580,19 @@ end
l.drop k = [] :=
by simpa [←length_eq_zero] using nat.sub_eq_zero_of_le h

lemma drop_eq_nil_iff_le {l : list α} {k : ℕ} :
l.drop k = [] ↔ l.length ≤ k :=
begin
refine ⟨λ h, _, drop_eq_nil_of_le⟩,
induction k with k hk generalizing l,
{ simp only [drop] at h,
simp [h] },
{ cases l,
{ simp },
{ simp only [drop] at h,
simpa [nat.succ_le_succ_iff] using hk h } }
end

lemma tail_drop (l : list α) (n : ℕ) : (l.drop n).tail = l.drop (n + 1) :=
begin
induction l with hd tl hl generalizing n,
Expand Down

0 comments on commit ab03ebe

Please sign in to comment.