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 fis the image finset inβ.Finset.map: Given an embeddingf : α ↪ β,s.map fis the image finset inβ.Finset.filterMapGiven a functionf : α → Option β,s.filterMap fis the image finset inβ, filtering outnones.Finset.subtype:s.subtype pis the finset ofSubtype pwhose elements belong tos.Finset.fin:s.fin nis the finset of all elements ofsless 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 := ⋯ }
Instances For
If the only elements outside s are those left fixed by σ, then mapping by σ has no effect.
Alias of the reverse direction of Finset.map_subset_map.
Associate to an embedding f from α to β the order embedding that maps a finset to its
image under f.
Equations
Instances For
Alias of the reverse direction of Finset.map_ssubset_map.
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.map f s.val).toFinset
Instances For
Alias of the forward direction of Finset.image_nonempty.
filterMap #
filterMap f s is a combination filter/map operation on s.
The function f : α → Option β is applied to each element of s;
if f a is some b then b is included in the result, otherwise
a is excluded from the resulting finset.
In notation, filterMap f s is the finset {b : β | ∃ a ∈ s, f a = some b}.
Equations
- Finset.filterMap f s f_inj = { val := Multiset.filterMap f s.val, nodup := ⋯ }
Instances For
Subtype #
Given a finset s and a predicate p, s.subtype p is the finset of Subtype p whose
elements belong to s.
Equations
- Finset.subtype p s = Finset.map { toFun := fun (x : { x : α // x ∈ Finset.filter p s }) => ⟨↑x, ⋯⟩, inj' := ⋯ } (Finset.filter p s).attach
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.
Alias of Finset.notMem_map_subtype_of_not_property.
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 is a subset of the image of a Set under f,
then it is equal to the Finset.image of a Finset subset of that Set.
If a finset t is a subset of the image of another finset s under f, then it is equal to the
image of a subset of s.
For the version where s is a set, see subset_set_image_iff.
A special case of subset_image_iff,
which corresponds to Set.subset_range_iff_exists_image_eq for Set.
Given an equivalence α to β, produce an equivalence between Finset α and Finset β.
Equations
- e.finsetCongr = { toFun := fun (s : Finset α) => Finset.map e.toEmbedding s, invFun := fun (s : Finset β) => Finset.map e.symm.toEmbedding s, left_inv := ⋯, right_inv := ⋯ }
Instances For
Given a predicate p : α → Prop, produces an equivalence between
Finset {a : α // p a} and {s : Finset α // ∀ a ∈ s, p a}.
Equations
- One or more equations did not get rendered due to their size.