Skip to content

Commit

Permalink
feat(data/list/basic): some more theorems about sublist (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
minchaowu authored and digama0 committed Aug 18, 2018
1 parent dfc9f8e commit 157004c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions data/list/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2594,6 +2594,13 @@ theorem diff_sublist_of_sublist : ∀ {l₁ l₂ l₃: list α}, l₁ <+ l₂
| l₁ l₂ (a::l₃) h := by simp
[diff_cons, diff_sublist_of_sublist (erase_sublist_erase _ h)]

theorem erase_diff_erase_sublist_of_sublist {a : α} : ∀ {l₁ l₂ : list α},
l₁ <+ l₂ → (l₂.erase a).diff (l₁.erase a) <+ l₂.diff l₁
| [] l₂ h := by simp [erase_sublist]
| (b::l₁) l₂ h := if heq : b = a then by simp [heq]
else by simpa [heq, erase_comm a b l₂]
using erase_diff_erase_sublist_of_sublist (erase_sublist_erase b h)

end diff

/- zip & unzip -/
Expand Down
6 changes: 6 additions & 0 deletions data/list/perm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,12 @@ else
have h₂ : a ∉ l₂, from mt (mem_of_perm p).2 h₁,
by rw [erase_of_not_mem h₁, erase_of_not_mem h₂]; exact p

theorem erase_subperm (a : α) (l : list α) : l.erase a <+~ l :=
⟨l.erase a, perm.refl _, erase_sublist _ _⟩

theorem erase_subperm_erase {l₁ l₂ : list α} (a : α) (h : l₁ <+~ l₂) : l₁.erase a <+~ l₂.erase a :=
let ⟨l, hp, hs⟩ := h in ⟨l.erase a, erase_perm_erase _ hp, erase_sublist_erase _ hs⟩

theorem perm_diff_left {l₁ l₂ : list α} (t : list α) (h : l₁ ~ l₂) : l₁.diff t ~ l₂.diff t :=
by induction t generalizing l₁ l₂ h; simp [*, erase_perm_erase]

Expand Down

0 comments on commit 157004c

Please sign in to comment.