Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add list function and lemmas #987

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
344bd60
feat: add lemmas about lists
chabulhwi Mar 18, 2024
87f4b94
feat: add more lemmas about lists
chabulhwi Oct 14, 2024
02599d9
style: avoid using `@` symbol
chabulhwi Oct 15, 2024
f39e00a
refactor: remove implicit instances of theorem
chabulhwi Oct 15, 2024
2d30498
refactor: put theorem in section
chabulhwi Oct 15, 2024
6b39d44
feat: add `List.commonPrefix` and its lemmas
chabulhwi Oct 15, 2024
ce38099
refactor: rename and restate theorem
chabulhwi Oct 15, 2024
6b7c0e4
chore: move definition to another file
chabulhwi Oct 15, 2024
ab8e65a
feat: add theorem `List.commonPrefix_comm`
chabulhwi Oct 16, 2024
9e0d971
style: avoid using `Decidable.em` directly
chabulhwi Oct 16, 2024
d257184
refactor: golf proofs
chabulhwi Oct 16, 2024
fa83dc7
Revert "refactor: golf proofs"
chabulhwi Oct 16, 2024
ffbd01f
Revert "style: avoid using `Decidable.em` directly"
chabulhwi Oct 16, 2024
49f306e
Revert "feat: add theorem `List.commonPrefix_comm`"
chabulhwi Oct 16, 2024
0e6bfd8
Revert "chore: move definition to another file"
chabulhwi Oct 16, 2024
10a0c0d
Revert "refactor: rename and restate theorem"
chabulhwi Oct 16, 2024
75ec590
Revert "feat: add `List.commonPrefix` and its lemmas"
chabulhwi Oct 16, 2024
f3a2b95
Revert "refactor: put theorem in section"
chabulhwi Oct 16, 2024
1d57ce4
Revert "refactor: remove implicit instances of theorem"
chabulhwi Oct 16, 2024
7c5ef34
chore: remove theorem
chabulhwi Oct 16, 2024
fa178b5
Merge branch 'main' into add-more-list-lemmas
fgdorais Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Batteries/Data/List/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ namespace List

@[deprecated (since := "2024-08-15")] alias isEmpty_iff_eq_nil := isEmpty_iff

/-! ### head and tail -/

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 @@ -482,6 +491,15 @@ theorem Sublist.erase_diff_erase_sublist {a : α} :

end Diff

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

theorem singleton_prefix_cons (a) : [a] <+: a :: l :=
(prefix_cons_inj a).mpr nil_prefix
fgdorais marked this conversation as resolved.
Show resolved Hide resolved

theorem ne_nil_of_not_prefix (h : ¬l₁ <+: l₂) : l₁ ≠ [] := by
intro heq
simp [heq, nil_prefix] at h
Comment on lines +499 to +501
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
theorem ne_nil_of_not_prefix (h : ¬l₁ <+: l₂) : l₁ ≠ [] := by
intro heq
simp [heq, nil_prefix] at h
theorem ne_nil_of_not_prefix : ¬l₁ <+: l₂ → l₁ ≠ [] := by
apply mt; intro h; simp [h]


/-! ### drop -/

theorem disjoint_take_drop : ∀ {l : List α}, l.Nodup → m ≤ n → Disjoint (l.take m) (l.drop n)
Expand Down