Skip to content

Commit

Permalink
refactor(logic/equiv/basic): remove fin_equiv_subtype (#14603)
Browse files Browse the repository at this point in the history
The types `fin n` and `{m // m < n}` are definitionally equal, so it doesn't make sense to have a dedicated equivalence between them (other than `equiv.refl`). We remove this equivalence and golf the places where it was used.
  • Loading branch information
vihdzp committed Jun 9, 2022
1 parent c2bb59e commit d997baa
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/computability/primrec.lean
Expand Up @@ -1026,7 +1026,7 @@ def subtype {p : α → Prop} [decidable_pred p]
instance fin {n} : primcodable (fin n) :=
@of_equiv _ _
(subtype $ nat_lt.comp primrec.id (const n))
(equiv.fin_equiv_subtype _)
(equiv.refl _)

instance vector {n} : primcodable (vector α n) :=
subtype ((@primrec.eq _ _ nat.decidable_eq).comp list_length (const _))
Expand Down
3 changes: 1 addition & 2 deletions src/data/fintype/card.lean
Expand Up @@ -184,8 +184,7 @@ e.bijective.prod_comp f
lemma fin.prod_univ_eq_prod_range [comm_monoid α] (f : ℕ → α) (n : ℕ) :
∏ i : fin n, f i = ∏ i in range n, f i :=
calc (∏ i : fin n, f i) = ∏ i : {x // x ∈ range n}, f i :
((equiv.fin_equiv_subtype n).trans
(equiv.subtype_equiv_right (λ _, mem_range.symm))).prod_comp (f ∘ coe)
(equiv.subtype_equiv_right $ λ m, (@mem_range n m).symm).prod_comp (f ∘ coe)
... = ∏ i in range n, f i : by rw [← attach_eq_univ, prod_attach]

@[to_additive]
Expand Down
2 changes: 1 addition & 1 deletion src/field_theory/finite/polynomial.lean
Expand Up @@ -192,7 +192,7 @@ calc module.rank K (R σ K) =
... = #(σ → {n // n < fintype.card K}) :
(@equiv.subtype_pi_equiv_pi σ (λ_, ℕ) (λs n, n < fintype.card K)).cardinal_eq
... = #(σ → fin (fintype.card K)) :
(equiv.arrow_congr (equiv.refl σ) (equiv.fin_equiv_subtype _).symm).cardinal_eq
(equiv.arrow_congr (equiv.refl σ) (equiv.refl _)).cardinal_eq
... = #(σ → K) :
(equiv.arrow_congr (equiv.refl σ) (fintype.equiv_fin K).symm).cardinal_eq
... = fintype.card (σ → K) : cardinal.mk_fintype _
Expand Down
2 changes: 1 addition & 1 deletion src/logic/encodable/basic.lean
Expand Up @@ -299,7 +299,7 @@ by cases a; refl
end subtype

instance _root_.fin.encodable (n) : encodable (fin n) :=
of_equiv _ (equiv.fin_equiv_subtype _)
subtype.encodable

instance _root_.int.encodable : encodable ℤ :=
of_equiv _ equiv.int_equiv_nat
Expand Down
4 changes: 0 additions & 4 deletions src/logic/equiv/basic.lean
Expand Up @@ -1281,10 +1281,6 @@ def list_equiv_of_equiv {α β : Type*} (e : α ≃ β) : list α ≃ list β :=
left_inv := λ l, by rw [list.map_map, e.symm_comp_self, list.map_id],
right_inv := λ l, by rw [list.map_map, e.self_comp_symm, list.map_id] }

/-- `fin n` is equivalent to `{m // m < n}`. -/
def fin_equiv_subtype (n : ℕ) : fin n ≃ {m // m < n} :=
⟨λ x, ⟨x.1, x.2⟩, λ x, ⟨x.1, x.2⟩, λ ⟨a, b⟩, rfl,λ ⟨a, b⟩, rfl⟩

/-- If `α` is equivalent to `β`, then `unique α` is equivalent to `unique β`. -/
def unique_congr (e : α ≃ β) : unique α ≃ unique β :=
{ to_fun := λ h, @equiv.unique _ _ h e.symm,
Expand Down

0 comments on commit d997baa

Please sign in to comment.