Skip to content

Commit

Permalink
feat(data/multiset/basic): multiset inclusion is decidable (#16994)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Oct 14, 2022
1 parent 5c19b83 commit 7121691
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/data/list/perm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ begin
convert (subperm_append_right _).mpr nil_subperm using 1
end

instance decidable_subperm : decidable_rel ((<+~) : list α → list α → Prop) :=
λ l₁ l₂, decidable_of_iff _ list.subperm_ext_iff.symm

@[simp] lemma subperm_singleton_iff {α} {l : list α} {a : α} : [a] <+~ l ↔ a ∈ l :=
⟨λ ⟨s, hla, h⟩, by rwa [perm_singleton.mp hla, singleton_sublist] at h,
λ h, ⟨[a], perm.refl _, singleton_sublist.mpr h⟩⟩
Expand Down
3 changes: 3 additions & 0 deletions src/data/multiset/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ instance : partial_order (multiset α) :=
le_trans := by rintros ⟨l₁⟩ ⟨l₂⟩ ⟨l₃⟩; exact @subperm.trans _ _ _ _,
le_antisymm := by rintros ⟨l₁⟩ ⟨l₂⟩ h₁ h₂; exact quot.sound (subperm.antisymm h₁ h₂) }

instance decidable_le [decidable_eq α] : decidable_rel ((≤) : multiset α → multiset α → Prop) :=
λ s t, quotient.rec_on_subsingleton₂ s t list.decidable_subperm

section
variables {s t : multiset α} {a : α}

Expand Down

0 comments on commit 7121691

Please sign in to comment.