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

[Merged by Bors] - feat: port Data.Multiset.Basic #1491

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
db33bfd
feat: port Data.Multiset.Basic
jcommelin Jan 11, 2023
93a8bed
Initial file copy from mathport
jcommelin Jan 11, 2023
31b371b
Mathbin -> Mathlib; add import to Mathlib.lean
jcommelin Jan 11, 2023
45cfaeb
tiny start
jcommelin Jan 11, 2023
f31679d
fixes
jcommelin Jan 11, 2023
56bd35e
wip
jcommelin Jan 12, 2023
0e9c962
small fix
ChrisHughes24 Jan 12, 2023
56d54ba
more fixes
ChrisHughes24 Jan 12, 2023
e1ec678
fixed all red errors
jcommelin Jan 12, 2023
d2926b4
Update Mathlib.lean
Ruben-VandeVelde Jan 12, 2023
a293406
fix boring warnings
rwbarton Jan 12, 2023
50709bd
fix warnings
jcommelin Jan 12, 2023
a06298c
<= 100 chars
qawbecrdtey Jan 12, 2023
276f484
long lines
jcommelin Jan 12, 2023
db95593
Removed 'unusedHavesSuffices' error
qawbecrdtey Jan 12, 2023
a33cb53
Update Mathlib/Data/Multiset/Basic.lean
jcommelin Jan 12, 2023
58ff7ef
Update Mathlib/Data/Multiset/Basic.lean
jcommelin Jan 12, 2023
5930c5f
wip
jcommelin Jan 12, 2023
2296d6f
lint
jcommelin Jan 13, 2023
3aa30a4
fix final lint issues
jcommelin Jan 13, 2023
3d68856
fix final lint issues
jcommelin Jan 13, 2023
db4f812
naming and docs fixes
jcommelin Jan 13, 2023
463207b
please check these fixes
jcommelin Jan 13, 2023
e71a483
fix induction names
jcommelin Jan 13, 2023
561d04e
move Quot induction principles to new file
jcommelin Jan 13, 2023
d571d07
lint
jcommelin Jan 13, 2023
e8ea977
Update Mathlib/Data/Multiset/Basic.lean
jcommelin Jan 13, 2023
d52133e
Apply suggestions from code review
jcommelin Jan 13, 2023
d37f186
Update Mathlib/Data/Multiset/Basic.lean
ChrisHughes24 Jan 13, 2023
b34da81
minor changes
ChrisHughes24 Jan 13, 2023
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
1 change: 1 addition & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ import Mathlib.Init.Function
import Mathlib.Init.Logic
import Mathlib.Init.Meta.WellFoundedTactics
import Mathlib.Init.Propext
import Mathlib.Init.Quot
import Mathlib.Init.Set
import Mathlib.Init.ZeroOne
import Mathlib.Lean.EnvExtension
Expand Down
34 changes: 16 additions & 18 deletions Mathlib/Data/List/Perm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ theorem Perm.pmap {p : α → Prop} (f : ∀ a, p a → β) {l₁ l₂ : List α
exact fun a m => H₂ a (p₂.subset m)
#align list.perm.pmap List.Perm.pmap

theorem Perm.filter (p : α → Prop) [DecidablePred p] {l₁ l₂ : List α} (s : l₁ ~ l₂) :
theorem Perm.filter (p : α → Bool) {l₁ l₂ : List α} (s : l₁ ~ l₂) :
filter p l₁ ~ filter p l₂ := by rw [← filterMap_eq_filter] ; apply s.filterMap _
#align list.perm.filter List.Perm.filter

theorem filter_append_perm (p : α → Prop) [DecidablePred p] (l : List α) :
theorem filter_append_perm (p : α → Bool) (l : List α) :
filter p l ++ filter (fun x => ¬p x) l ~ l :=
by
induction' l with x l ih
Expand Down Expand Up @@ -476,7 +476,7 @@ theorem Subperm.subset {l₁ l₂ : List α} : l₁ <+~ l₂ → l₁ ⊆ l₂
| ⟨_l, p, s⟩ => Subset.trans p.symm.subset s.subset
#align list.subperm.subset List.Subperm.subset

theorem Subperm.filter (p : α → Prop) [DecidablePred p] ⦃l l' : List α⦄ (h : l <+~ l') :
theorem Subperm.filter (p : α → Bool) ⦃l l' : List α⦄ (h : l <+~ l') :
filter p l <+~ filter p l' := by
obtain ⟨xs, hp, h⟩ := h
exact ⟨_, hp.filter p, h.filter p⟩
Expand All @@ -494,19 +494,18 @@ theorem Sublist.exists_perm_append : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ →
⟨l, p.cons a⟩
#align list.sublist.exists_perm_append List.Sublist.exists_perm_append

theorem Perm.countp_eq (p : α → Prop) [DecidablePred p] {l₁ l₂ : List α} (s : l₁ ~ l₂) :
theorem Perm.countp_eq (p : α → Bool) {l₁ l₂ : List α} (s : l₁ ~ l₂) :
countp p l₁ = countp p l₂ := by
rw [countp_eq_length_filter, countp_eq_length_filter] ; exact (s.filter _).length_eq
#align list.perm.countp_eq List.Perm.countp_eq

theorem Subperm.countp_le (p : α → Prop) [DecidablePred p] {l₁ l₂ : List α} :
theorem Subperm.countp_le (p : α → Bool) {l₁ l₂ : List α} :
l₁ <+~ l₂ → countp p l₁ ≤ countp p l₂
| ⟨_l, p', s⟩ => p'.countp_eq p ▸ s.countp_le p
#align list.subperm.countp_le List.Subperm.countp_le

theorem Perm.countp_congr (s : l₁ ~ l₂) {p p' : α → Prop} [DecidablePred p] [DecidablePred p']
(hp : ∀ x ∈ l₁, p x = p' x) : l₁.countp p = l₂.countp p' :=
by
theorem Perm.countp_congr (s : l₁ ~ l₂) {p p' : α → Bool}
(hp : ∀ x ∈ l₁, p x = p' x) : l₁.countp p = l₂.countp p' := by
rw [← s.countp_eq p']
clear s
induction' l₁ with y s hs
Expand All @@ -515,9 +514,8 @@ theorem Perm.countp_congr (s : l₁ ~ l₂) {p p' : α → Prop} [DecidablePred
simp only [countp_cons, hs hp.2, hp.1]
#align list.perm.countp_congr List.Perm.countp_congr

theorem countp_eq_countp_filter_add (l : List α) (p q : α → Prop) [DecidablePred p]
[DecidablePred q] : l.countp p = (l.filter q).countp p + (l.filter fun a => ¬q a).countp p :=
by
theorem countp_eq_countp_filter_add (l : List α) (p q : α → Bool) :
l.countp p = (l.filter q).countp p + (l.filter fun a => ¬q a).countp p := by
rw [← countp_append]
exact Perm.countp_eq _ (filter_append_perm _ _).symm
#align list.countp_eq_countp_filter_add List.countp_eq_countp_filter_add
Expand Down Expand Up @@ -861,7 +859,7 @@ theorem subset_cons_diff {a : α} {l₁ l₂ : List α} : (a :: l₁).diff l₂
subperm_cons_diff.subset
#align list.subset_cons_diff List.subset_cons_diff

theorem Perm.bag_inter_right {l₁ l₂ : List α} (t : List α) (h : l₁ ~ l₂) :
theorem Perm.bagInter_right {l₁ l₂ : List α} (t : List α) (h : l₁ ~ l₂) :
l₁.bagInter t ~ l₂.bagInter t :=
by
induction' h with x _ _ _ _ x y _ _ _ _ _ _ ih_1 ih_2 generalizing t; · simp
Expand All @@ -874,21 +872,21 @@ theorem Perm.bag_inter_right {l₁ l₂ : List α} (t : List α) (h : l₁ ~ l
· simp [xt, yt, mt mem_of_mem_erase, Perm.cons]
· simp [xt, yt]
· exact (ih_1 _).trans (ih_2 _)
#align list.perm.bag_inter_right List.Perm.bag_inter_right
#align list.perm.bag_inter_right List.Perm.bagInter_right

theorem Perm.bag_inter_left (l : List α) {t₁ t₂ : List α} (p : t₁ ~ t₂) :
theorem Perm.bagInter_left (l : List α) {t₁ t₂ : List α} (p : t₁ ~ t₂) :
l.bagInter t₁ = l.bagInter t₂ :=
by
induction' l with a l IH generalizing t₁ t₂ p; · simp
by_cases a ∈ t₁
· simp [h, p.subset h, IH (p.erase _)]
· simp [h, mt p.mem_iff.2 h, IH p]
#align list.perm.bag_inter_left List.Perm.bag_inter_left
#align list.perm.bag_inter_left List.Perm.bagInter_left

theorem Perm.bag_inter {l₁ l₂ t₁ t₂ : List α} (hl : l₁ ~ l₂) (ht : t₁ ~ t₂) :
theorem Perm.bagInter {l₁ l₂ t₁ t₂ : List α} (hl : l₁ ~ l₂) (ht : t₁ ~ t₂) :
l₁.bagInter t₁ ~ l₂.bagInter t₂ :=
ht.bag_inter_left l₂ ▸ hl.bag_inter_right _
#align list.perm.bag_inter List.Perm.bag_inter
ht.bagInter_left l₂ ▸ hl.bagInter_right _
#align list.perm.bag_inter List.Perm.bagInter

theorem cons_perm_iff_perm_erase {a : α} {l₁ l₂ : List α} :
a :: l₁ ~ l₂ ↔ a ∈ l₂ ∧ l₁ ~ l₂.erase a :=
Expand Down
Loading