Skip to content

Commit

Permalink
feat(data/list/basic): list.nodup_diff (#1168)
Browse files Browse the repository at this point in the history
* feat(data/list/basic): list.nodup_diff

* Update basic.lean

* Update basic.lean
  • Loading branch information
ChrisHughes24 authored and mergify[bot] committed Jul 4, 2019
1 parent e6b9696 commit 00de1cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/data/list/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3940,6 +3940,10 @@ end
theorem nodup_erase_of_nodup [decidable_eq α] (a : α) {l} : nodup l → nodup (l.erase a) :=
nodup_of_sublist (erase_sublist _ _)

theorem nodup_diff [decidable_eq α] : ∀ {l₁ l₂ : list α} (h : l₁.nodup), (l₁.diff l₂).nodup
| l₁ [] h := h
| l₁ (a::l₂) h := by rw diff_cons; exact nodup_diff (nodup_erase_of_nodup _ h)

theorem mem_erase_iff_of_nodup [decidable_eq α] {a b : α} {l} (d : nodup l) :
a ∈ l.erase b ↔ a ≠ b ∧ a ∈ l :=
by rw nodup_erase_eq_filter b d; simp only [mem_filter, and_comm]
Expand Down

0 comments on commit 00de1cb

Please sign in to comment.