The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Multiset.Find
13 declarations. Mathlib docs · Source
theorem Multiset.choose.congr_simp E1 #
∀ {α : Type u_1} (p p_1 : α → Prop) (e_p : p = p_1) {inst : DecidablePred p} [inst_1 : DecidablePred p_1]
(l l_1 : Multiset α) (e_l : l = l_1) (hp : ∃! a, a ∈ l ∧ p a), Multiset.choose p l hp = Multiset.choose p_1 l_1 ⋯
theorem Multiset.find?.congr_simp E1 #
∀ {α : Type u_1} (p p_1 : α → Prop) (e_p : p = p_1) {inst : DecidablePred p} [inst_1 : DecidablePred p_1]
(s s_1 : Multiset α) (e_s : s = s_1) (a : {x | x ∈ s ∧ p x}.Subsingleton),
Multiset.find? p s a = Multiset.find? p_1 s_1 ⋯
def Multiset.find? E1 #
{α : Type u_1} → (p : α → Prop) → [DecidablePred p] → (s : Multiset α) → {x | x ∈ s ∧ p x}.Subsingleton → Option α
s.find? p ⋯ finds the subsingleton element of s satisfying the condition p, if one exists.
This is the multiset version of List.find?,
and is like Multiset.choose, but Option-valued.
theorem Multiset.find?_coe E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (l : List α) (hp : {x | x ∈ ↑l ∧ p x}.Subsingleton),
Multiset.find? p (↑l) hp = List.find? (fun a ↦ decide (p a)) l
theorem Multiset.find?_some E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] {a : α} {s : Multiset α} {hp : {x | x ∈ s ∧ p x}.Subsingleton},
Multiset.find? p s hp = some a → p a
theorem Multiset.find?_zero E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p], Multiset.find? p 0 ⋯ = none
theorem Multiset.find?_cons E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (a : α) (s : Multiset α)
(hp : {x | x ∈ a ::ₘ s ∧ p x}.Subsingleton),
Multiset.find? p (a ::ₘ s) hp = if h : p a then some a else Multiset.find? p s ⋯
theorem Multiset.find?_singleton E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (a : α) (hp : {x | x ∈ {a} ∧ p x}.Subsingleton),
Multiset.find? p {a} hp = if p a then some a else none
theorem Multiset.find?_add E0 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] (s t : Multiset α) (hp : {x | x ∈ s + t ∧ p x}.Subsingleton),
Multiset.find? p (s + t) hp = (Multiset.find? p s ⋯).or (Multiset.find? p t ⋯)
theorem Multiset.find?_eq_some_iff E0 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {a : α} {s : Multiset α} (hp : {x | x ∈ s ∧ p x}.Subsingleton),
Multiset.find? p s hp = some a ↔ a ∈ s ∧ p a
theorem Multiset.find?_eq_none_iff E0 #
∀ {α : Type u_1} {p : α → Prop} [inst : DecidablePred p] {s : Multiset α} (hp : {x | x ∈ s ∧ p x}.Subsingleton),
Multiset.find? p s hp = none ↔ ∀ a ∈ s, ¬p a
theorem Multiset.find?_congr E1 #
∀ {α : Type u_1} {p₁ p₂ : α → Prop} [inst : DecidablePred p₁] [inst_1 : DecidablePred p₂] {s t : Multiset α}
(hs : s = t) (hp₁ : {x | x ∈ s ∧ p₁ x}.Subsingleton) (h : ∀ x ∈ s, p₁ x ↔ p₂ x),
Multiset.find? p₁ s hp₁ = Multiset.find? p₂ t ⋯
If two predicates agree on all the elements, so does find?.
theorem Multiset.find?_eq_choose E1 #
∀ {α : Type u_1} (p : α → Prop) [inst : DecidablePred p] {s : Multiset α} (hp : ∃! x, x ∈ s ∧ p x),
Multiset.find? p s ⋯ = some (Multiset.choose p s hp)