Image and map operations on finite sets #
This file provides the finite analog of Set.image
, along with some other similar functions.
Note there are two ways to take the image over a finset; via Finset.image
which applies the
function then removes duplicates (requiring DecidableEq
), or via Finset.map
which exploits
injectivity of the function to avoid needing to deduplicate. Choosing between these is similar to
choosing between insert
and Finset.cons
, or between Finset.union
and Finset.disjUnion
.
Main definitions #
Finset.image
: Given a functionf : α → β
,s.image f
is the image finset inβ
.Finset.map
: Given an embeddingf : α ↪ β
,s.map f
is the image finset inβ
.Finset.subtype
:s.subtype p
is the finset ofSubtype p
whose elements belong tos
.Finset.fin
:s.fin n
is the finset of all elements ofs
less thann
.
map #
When f
is an embedding of α
in β
and s
is a finset in α
, then s.map f
is the image
finset in β
. The embedding condition guarantees that there are no duplicates in the image.
Equations
- Finset.map f s = { val := Multiset.map (↑f) s.val, nodup := (_ : Multiset.Nodup (Multiset.map (↑f) s.val)) }
Instances For
If the only elements outside s
are those left fixed by σ
, then mapping by σ
has no effect.
Associate to an embedding f
from α
to β
the order embedding that maps a finset to its
image under f
.
Equations
- Finset.mapEmbedding f = OrderEmbedding.ofMapLEIff (Finset.map f) (_ : ∀ (x x_1 : Finset α), Finset.map f x ⊆ Finset.map f x_1 ↔ x ⊆ x_1)
Instances For
A version of Finset.map_disjUnion
for writing in the other direction.
Alias of the reverse direction of Finset.map_nonempty
.
image #
image f s
is the forward image of s
under f
.
Equations
- Finset.image f s = Multiset.toFinset (Multiset.map f s.val)
Instances For
Equations
Subtype #
Given a finset s
and a predicate p
, s.subtype p
is the finset of Subtype p
whose
elements belong to s
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
s.subtype p
converts back to s.filter p
with
Embedding.subtype
.
If all elements of a Finset
satisfy the predicate p
,
s.subtype p
converts back to s
with Embedding.subtype
.
If a Finset
of a subtype is converted to the main type with
Embedding.subtype
, all elements of the result have the property of
the subtype.
If a Finset
of a subtype is converted to the main type with
Embedding.subtype
, the result does not contain any value that does
not satisfy the property of the subtype.
If a Finset
of a subtype is converted to the main type with
Embedding.subtype
, the result is a subset of the set giving the
subtype.
Fin #
Given a finset s
of natural numbers and a bound n
,
s.fin n
is the finset of all elements of s
less than n
.
Equations
- Finset.fin n s = Finset.map (Equiv.toEmbedding Fin.equivSubtype.symm) (Finset.subtype (fun i => i < n) s)