Module docstring
{"# List Sub-permutations
This file develops theory about the List.Subperm relation.
Notation
The notation <+~ is used for sub-permutations.
"}
{"# List Sub-permutations
This file develops theory about the List.Subperm relation.
The notation <+~ is used for sub-permutations.
"}
List.subperm_iff_count
theorem
[DecidableEq α] : l₁ <+~ l₂ ↔ ∀ a, count a l₁ ≤ count a l₂
/-- See also `List.subperm_ext_iff`. -/
lemma subperm_iff_count [DecidableEq α] : l₁ <+~ l₂l₁ <+~ l₂ ↔ ∀ a, count a l₁ ≤ count a l₂ :=
subperm_ext_iff.trans <| forall_congr' fun a ↦ by
by_cases ha : a ∈ l₁ <;> simp [ha, count_eq_zero_of_not_mem]
List.subperm_iff
theorem
: l₁ <+~ l₂ ↔ ∃ l, l ~ l₂ ∧ l₁ <+ l
lemma subperm_iff : l₁ <+~ l₂l₁ <+~ l₂ ↔ ∃ l, l ~ l₂ ∧ l₁ <+ l := by
refine ⟨?_, fun ⟨l, h₁, h₂⟩ ↦ h₂.subperm.trans h₁.subperm⟩
rintro ⟨l, h₁, h₂⟩
obtain ⟨l', h₂⟩ := h₂.exists_perm_append
exact ⟨l₁ ++ l', (h₂.trans (h₁.append_right _)).symm, (prefix_append _ _).sublist⟩
List.subperm_singleton_iff
theorem
: l <+~ [a] ↔ l = [] ∨ l = [a]
@[simp] lemma subperm_singleton_iff : l <+~ [a]l <+~ [a] ↔ l = [] ∨ l = [a] := by
constructor
· rw [subperm_iff]
rintro ⟨s, hla, h⟩
rwa [perm_singleton.mp hla, sublist_singleton] at h
· rintro (rfl | rfl)
exacts [nil_subperm, Subperm.refl _]
List.subperm_cons_self
theorem
: l <+~ a :: l
lemma subperm_cons_self : l <+~ a :: l := ⟨l, Perm.refl _, sublist_cons_self _ _⟩
List.cons_subperm_of_mem
theorem
{a : α} {l₁ l₂ : List α} (_ : Nodup l₁) (h₁ : a ∉ l₁) (h₂ : a ∈ l₂) (s : l₁ <+~ l₂) : a :: l₁ <+~ l₂
List.Nodup.subperm
theorem
(d : Nodup l₁) (H : l₁ ⊆ l₂) : l₁ <+~ l₂
protected theorem Nodup.subperm (d : Nodup l₁) (H : l₁ ⊆ l₂) : l₁ <+~ l₂ :=
subperm_of_subset d H