Skip to content

Commit d910a95

Browse files
authored
feat: add List.perm_ext_iff_of_nodup (#14211)
This PR adds `List.perm_ext_iff_of_nodup`: two duplicate-free lists are permutations of each other if and only if they have the same elements. This is currently only available in Batteries (where it is proved via `Subperm`); here it is proved directly from `perm_iff_count`.
1 parent c81da09 commit d910a95

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Init/Data/List/Perm.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,16 @@ theorem perm_insert_swap (x y : α) (l : List α) :
472472

473473
end LawfulBEq
474474

475+
/-- Two lists without duplicates are permutations of each other if and only if
476+
they have the same elements. -/
477+
theorem perm_ext_iff_of_nodup {l₁ l₂ : List α} (d₁ : Nodup l₁) (d₂ : Nodup l₂) :
478+
l₁ ~ l₂ ↔ ∀ a, a ∈ l₁ ↔ a ∈ l₂ := by
479+
classical
480+
rw [perm_iff_count]
481+
refine ⟨fun h a => by rw [← count_pos_iff, ← count_pos_iff, h], fun h a => ?_⟩
482+
rw [d₁.count, d₂.count]
483+
simp only [h a]
484+
475485
theorem Perm.pairwise_iff {R : α → α → Prop} (S : ∀ {x y}, R x y → R y x) :
476486
∀ {l₁ l₂ : List α} (_p : l₁ ~ l₂), Pairwise R l₁ ↔ Pairwise R l₂ :=
477487
suffices ∀ {l₁ l₂}, l₁ ~ l₂ → Pairwise R l₁ → Pairwise R l₂

0 commit comments

Comments
 (0)