Skip to content

Commit 084bbea

Browse files
committed
feat(Data/List/NodupEquivFin): add equiv with count = 1 hypothesis (#30215)
1 parent ae1cfd8 commit 084bbea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Mathlib/Data/List/NodupEquivFin.lean

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def getEquiv (l : List α) (H : Nodup l) : Fin (length l) ≃ { x // x ∈ l } w
5757
/-- If `l` lists all the elements of `α` without duplicates, then `List.get` defines
5858
an equivalence between `Fin l.length` and `α`.
5959
60-
See `List.Nodup.getBijectionOfForallMemList` for a version without
61-
decidable equality. -/
60+
See `List.Nodup.getBijectionOfForallMemList` for a version without decidable equality. -/
6261
@[simps]
6362
def getEquivOfForallMemList (l : List α) (nd : l.Nodup) (h : ∀ x : α, x ∈ l) :
6463
Fin l.length ≃ α where
@@ -69,6 +68,13 @@ def getEquivOfForallMemList (l : List α) (nd : l.Nodup) (h : ∀ x : α, x ∈
6968

7069
end Nodup
7170

71+
/-- Alternative phrasing of `List.Nodup.getEquivOfForallMemList` using `List.count`. -/
72+
@[simps!]
73+
def getEquivOfForallCountEqOne [DecidableEq α] (l : List α) (h : ∀ x, l.count x = 1) :
74+
Fin l.length ≃ α :=
75+
Nodup.getEquivOfForallMemList _ (List.nodup_iff_count_eq_one.mpr fun _ _ ↦ h _)
76+
fun _ ↦ List.count_pos_iff.mp <| h _ ▸ Nat.one_pos
77+
7278
namespace Sorted
7379

7480
variable [Preorder α] {l : List α}

0 commit comments

Comments
 (0)