Equivalences and sets #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
In this file we provide lemmas linking equivalences to sets.
Some notable definitions are:
equiv.of_injective
: an injective function is (noncomputably) equivalent to its range.equiv.set_congr
: two equal sets are equivalent as types.equiv.set.union
: a disjoint union of sets is equivalent to theirsum
.
This file is separate from equiv/basic
such that we do not require the full lattice structure
on sets before defining what an equivalence is.
A set s
in α × β
is equivalent to the sigma-type Σ x, {y | (x, y) ∈ s}
.
The subtypes corresponding to equal sets are equivalent.
Equations
If sets s
and t
are separated by a decidable predicate, then s ∪ t
is equivalent to
s ⊕ t
.
Equations
- equiv.set.union' p hs ht = {to_fun := λ (x : ↥(s ∪ t)), dite (p ↑x) (λ (hp : p ↑x), sum.inl ⟨x.val, _⟩) (λ (hp : ¬p ↑x), sum.inr ⟨x.val, _⟩), inv_fun := λ (o : ↥s ⊕ ↥t), equiv.set.union'._match_1 o, left_inv := _, right_inv := _}
- equiv.set.union'._match_1 (sum.inr x) = ⟨↑x, _⟩
- equiv.set.union'._match_1 (sum.inl x) = ⟨↑x, _⟩
If sets s
and t
are disjoint, then s ∪ t
is equivalent to s ⊕ t
.
Equations
- equiv.set.union H = equiv.set.union' (λ (x : α), x ∈ s) equiv.set.union._proof_1 _
If a ∉ s
, then insert a s
is equivalent to s ⊕ punit
.
Equations
- equiv.set.insert H = ((equiv.set.of_eq equiv.set.insert._proof_1).trans (equiv.set.union _)).trans ((equiv.refl ↥s).sum_congr (equiv.set.singleton a))
If s : set α
is a set with decidable membership, then s ⊕ sᶜ
is equivalent to α
.
Equations
- equiv.set.sum_compl s = ((equiv.set.union _).symm.trans (equiv.set.of_eq _)).trans (equiv.set.univ α)
sum_diff_subset s t
is the natural equivalence between
s ⊕ (t \ s)
and t
, where s
and t
are two sets.
Equations
- equiv.set.sum_diff_subset h = (equiv.set.union equiv.set.sum_diff_subset._proof_1).symm.trans (equiv.set.of_eq _)
If s
is a set with decidable membership, then the sum of s ∪ t
and s ∩ t
is equivalent
to s ⊕ t
.
Equations
- equiv.set.union_sum_inter s t = ((((_.mpr (equiv.refl (↥(s ∪ t) ⊕ ↥(s ∩ t)))).trans ((equiv.set.union _).sum_congr (equiv.refl ↥(s ∩ t)))).trans (equiv.sum_assoc ↥s ↥(t \ s) ↥(s ∩ t))).trans ((equiv.refl ↥s).sum_congr (equiv.set.union' (λ (_x : α), _x ∉ s) _ _).symm)).trans (_.mpr (equiv.refl (↥s ⊕ ↥t)))
Given an equivalence e₀
between sets s : set α
and t : set β
, the set of equivalences
e : α ≃ β
such that e ↑x = ↑(e₀ x)
for each x : s
is equivalent to the set of equivalences
between sᶜ
and tᶜ
.
The set product of two sets is equivalent to the type product of their coercions to types.
Equations
If a function f
is injective on a set s
, then s
is equivalent to f '' s
.
If f
is an injective function, then s
is equivalent to f '' s
.
Equations
- equiv.set.image f s H = equiv.set.image_of_inj_on f s _
The set {x ∈ s | t x}
is equivalent to the set of x : s
such that t x
.
Equations
If f : α → β
has a left-inverse when α
is nonempty, then α
is computably equivalent to the
range of f
.
While awkward, the nonempty α
hypothesis on f_inv
and hf
allows this to be used when α
is
empty too. This hypothesis is absent on analogous definitions on stronger equiv
s like
linear_equiv.of_left_inverse
and ring_equiv.of_left_inverse
as their typeclass assumptions
are already sufficient to ensure non-emptiness.
If f : α → β
has a left-inverse, then α
is computably equivalent to the range of f
.
Note that if α
is empty, no such f_inv
exists and so this definition can't be used, unlike
the stronger but less convenient of_left_inverse
.
If f : α → β
is an injective function, then domain α
is equivalent to the range of f
.
Equations
- equiv.of_injective f hf = equiv.of_left_inverse f (λ (h : nonempty α), function.inv_fun f) _
sigma_fiber_equiv f
for f : α → β
is the natural equivalence between
the type of all preimages of points under f
and the total space α
.
Equations
If a function is a bijection between two sets s
and t
, then it induces an
equivalence between the types ↥s
and ↥t
.
Equations
- set.bij_on.equiv f h = equiv.of_bijective (set.maps_to.restrict f s t _) _
The composition of an updated function with an equiv on a subset can be expressed as an updated function.