Sum and difference of multisets #
This file defines the following operations on multisets:
- Add (Multiset α)instance:- s + tadds the multiplicities of the elements of- sand- t
- Sub (Multiset α)instance:- s - tsubtracts the multiplicities of the elements of- sand- t
- Multiset.erase:- s.erase xreduces the multiplicity of- xin- sby one.
Notation (defined later) #
- s + t: The multiset for which the number of occurrences of each- ais the sum of the occurrences of- ain- sand- t.
- s - t: The multiset for which the number of occurrences of each- ais the difference of the occurrences of- ain- sand- t.
Additive monoid #
The sum of two multisets is the lift of the list append operation.
This adds the multiplicities of each element,
i.e. count a (s + t) = count a s + count a t.
Equations
- s₁.add s₂ = Quotient.liftOn₂ s₁ s₂ (fun (l₁ l₂ : List α) => ↑(l₁ ++ l₂)) ⋯
Instances For
Equations
- Multiset.instAdd = { add := Multiset.add }
Alias of the forward direction of Multiset.add_le_add_iff_left.
Alias of the reverse direction of Multiset.add_le_add_iff_left.
Alias of the reverse direction of Multiset.add_le_add_iff_right.
Alias of the forward direction of Multiset.add_le_add_iff_right.
Erasing one copy of an element #
Alias of Multiset.erase_of_notMem.
Subtraction #
s - t is the multiset such that count a (s - t) = count a s - count a t for all a.
(note that it is truncated subtraction, so count a (s - t) = 0 if count a s ≤ count a t).
Equations
- s.sub t = Quotient.liftOn₂ s t (fun (l₁ l₂ : List α) => ↑(l₁.diff l₂)) ⋯
Instances For
Equations
- Multiset.instSub = { sub := Multiset.sub }
This is a special case of tsub_zero, which should be used instead of this.
This is needed to prove OrderedSub (Multiset α).
This is a special case of tsub_le_iff_right, which should be used instead of this.
This is needed to prove OrderedSub (Multiset α).
This is a special case of tsub_le_iff_left, which should be used instead of this.