Equivalence between types #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
In this file we define two types:
-
equiv α β
a.k.a.α ≃ β
: a bijective mapα → β
bundled with its inverse map; we use this (and not equality!) to express that variousType
s orSort
s are equivalent. -
equiv.perm α
: the group of permutationsα ≃ α
. More lemmas aboutequiv.perm
can be found ingroup_theory/perm
.
Then we define
-
canonical isomorphisms between various types: e.g.,
equiv.refl α
is the identity map interpreted asα ≃ α
;
-
operations on equivalences: e.g.,
-
equiv.symm e : β ≃ α
is the inverse ofe : α ≃ β
; -
equiv.trans e₁ e₂ : α ≃ γ
is the composition ofe₁ : α ≃ β
ande₂ : β ≃ γ
(note the order of the arguments!);
-
-
definitions that transfer some instances along an equivalence. By convention, we transfer instances from right to left.
equiv.inhabited
takese : α ≃ β
and[inhabited β]
and returnsinhabited α
;equiv.unique
takese : α ≃ β
and[unique β]
and returnsunique α
;equiv.decidable_eq
takese : α ≃ β
and[decidable_eq β]
and returnsdecidable_eq α
.
More definitions of this kind can be found in other files. E.g.,
data/equiv/transfer_instance
does it for many algebraic type classes likegroup
,module
, etc.
Many more such isomorphisms and operations are defined in logic/equiv/basic
.
Tags #
equivalence, congruence, bijective map
- to_fun : α → β
- inv_fun : β → α
- left_inv : function.left_inverse self.inv_fun self.to_fun
- right_inv : function.right_inverse self.inv_fun self.to_fun
α ≃ β
is the type of functions from α → β
with a two-sided inverse.
Instances for equiv
- equiv.has_sizeof_inst
- equiv.has_coe_t
- equiv.equiv_like
- equiv.has_coe_to_fun
- equiv.inhabited'
- equiv.equiv_subsingleton_cod
- equiv.equiv_subsingleton_dom
- equiv.perm_unique
- equiv.function.bijective.can_lift
- equiv.coe_embedding
- equiv.perm.coe_embedding
- equiv.perm.perm_group
- equiv.perm.apply_mul_action
- equiv.perm.apply_has_faithful_smul
- equiv.finite_right
- equiv.finite_left
- nonempty_equiv_of_countable
- equiv.fintype
- equiv.perm.disjoint.is_symm
- affine_equiv.equiv.has_coe
- equiv_functor_perm
- lie_module_equiv.has_coe_to_equiv
- equiv.perm.repr_perm
Equations
- equiv.equiv_like = {coe := equiv.to_fun β, inv := equiv.inv_fun β, left_inv := _, right_inv := _, coe_injective' := _}
Equations
The map coe_fn : (r ≃ s) → (r → s)
is injective.
Equations
- equiv.inhabited' = {default := equiv.refl α}
See Note [custom simps projection]
Equations
- equiv.simps.symm_apply e = ⇑(e.symm)
Equations
This cannot be a simp
lemmas as it incorrectly matches against e : α ≃ synonym α
, when
synonym α
is semireducible. This makes a mess of multiplicative.of_add
etc.
If α
is equivalent to β
, then perm α
is equivalent to perm β
.
Equations
- e.perm_congr = e.equiv_congr e
Two empty types are equivalent.
Equations
- equiv.equiv_of_is_empty α β = {to_fun := is_empty_elim (λ (a : α), β), inv_fun := is_empty_elim (λ (a : β), α), left_inv := _, right_inv := _}
If α
is an empty type, then it is equivalent to the empty
type.
Equations
If α
is an empty type, then it is equivalent to the pempty
type in any universe.
Equations
α
is equivalent to an empty type iff α
is empty.
Equations
- equiv.equiv_empty_equiv α = {to_fun := _, inv_fun := equiv.equiv_empty α, left_inv := _, right_inv := _}
The Sort
of proofs of a false proposition is equivalent to pempty
.
Equations
If both α
and β
have a unique element, then α ≃ β
.
Equations
- equiv.equiv_of_unique α β = {to_fun := inhabited.default (pi.inhabited α), inv_fun := inhabited.default (pi.inhabited β), left_inv := _, right_inv := _}
If α
has a unique element, then it is equivalent to any punit
.
Equations
The Sort
of proofs of a true proposition is equivalent to punit
.
Equations
ulift α
is equivalent to α
.
Equations
- equiv.ulift = {to_fun := ulift.down α, inv_fun := ulift.up α, left_inv := _, right_inv := _}
plift α
is equivalent to α
.
Equations
- equiv.plift = {to_fun := plift.down α, inv_fun := plift.up α, left_inv := _, right_inv := _}
A version of equiv.arrow_congr
in Type
, rather than Sort
.
The equiv_rw
tactic is not able to use the default Sort
level equiv.arrow_congr
,
because Lean's universe rules will not unify ?l_1
with imax (1 ?m_1)
.
Equations
- hα.arrow_congr' hβ = hα.arrow_congr hβ
punit
sorts in any two universes are equivalent.
If α
is subsingleton
and a : α
, then the type of dependent functions Π (i : α), β i
is equivalent to β i
.
Equations
- equiv.Pi_subsingleton β a = {to_fun := function.eval a, inv_fun := λ (x : β a) (b : α), cast _ x, left_inv := _, right_inv := _}
If α
has a unique term, then the type of function α → β
is equivalent to β
.
Equations
- equiv.fun_unique α β = equiv.Pi_subsingleton (λ (ᾰ : α), β) inhabited.default
The sort of maps from punit
is equivalent to the codomain.
Equations
The sort of maps from true
is equivalent to the codomain.
Equations
A psigma
with Prop
fibers is equivalent to the subtype.
A sigma
with plift
fibers is equivalent to the subtype.
Equations
- equiv.sigma_plift_equiv_subtype P = ((equiv.psigma_equiv_sigma (λ (i : α), plift (P i))).symm.trans (equiv.psigma_congr_right (λ (a : α), equiv.plift))).trans (equiv.psigma_equiv_subtype P)
A family of permutations Π a, perm (β a)
generates a permuation perm (Σ a, β₁ a)
.
Equations
Transporting a sigma type through an equivalence of the base and a family of equivalences of matching fibers
Equations
- f.sigma_congr F = (equiv.sigma_congr_right F).trans f.sigma_congr_left
sigma
type with a constant fiber is equivalent to the product.
Quotients are congruent on equivalences under equality of their relation.
An alternative is just to use rewriting with eq
, but then computational proofs get stuck.
Equations
- quot.congr_right eq = quot.congr (equiv.refl α) eq
An equivalence e : α ≃ β
generates an equivalence between the quotient space of α
by a relation ra
and the quotient space of β
by the image of this relation under e
.
Equations
- quot.congr_left e = quot.congr e _
An equivalence e : α ≃ β
generates an equivalence between quotient spaces,
if `ra a₁ a₂ ↔ rb (e a₁) (e a₂).
Equations
- quotient.congr e eq = quot.congr e eq