Skip to content

Commit

Permalink
feat: add more lemmas about lists
Browse files Browse the repository at this point in the history
These are 'leftover' lemmas I created while trying to prove
`String.splitOn_of_valid`. See
leanprover-community#743.
  • Loading branch information
chabulhwi committed Oct 16, 2024
1 parent e5dd0d8 commit 06dd197
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Batteries/Data/List/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ namespace List
theorem head_cons_tail : ∀ (l : List α) (hne : l ≠ []), l.head hne :: l.tail = l
| _::_, _ => rfl

theorem singleton_head_eq_self (l : List α) (hne : l ≠ []) (htl : l.tail = []) :
[l.head hne] = l := by
conv => rhs; rw [← head_cons_tail l hne, htl]

/-! ### next? -/

@[simp] theorem next?_nil : @next? α [] = none := rfl
Expand Down Expand Up @@ -489,6 +493,9 @@ end Diff

/-! ### prefix, suffix, infix -/

theorem singleton_prefix_cons (a) : [a] <+: a :: l :=
(prefix_cons_inj a).mpr nil_prefix

theorem ne_nil_of_not_prefix (h : ¬l₁ <+: l₂) : l₁ ≠ [] := by
intro heq
simp [heq, nil_prefix] at h
Expand Down

0 comments on commit 06dd197

Please sign in to comment.