Finite sets #
This file defines predicates finite : set α → Prop
and infinite : set α → Prop
and proves some
basic facts about finite sets.
The subtype corresponding to a finite set is a finite type. Note
that because finite
isn't a typeclass, this will not fire if it
is made into an instance
Equations
- h.fintype = classical.choice _
See also fintype_or_infinite
.
Finite sets can be lifted to finsets.
Equations
- set.finset.can_lift = {coe := coe coe_to_lift, cond := set.finite α, prf := _}
Membership of a subset of a finite type is decidable.
Using this as an instance leads to potential loops with subtype.fintype
under certain decidability
assumptions, so it should only be declared a local instance.
Equations
Equations
- set.fintype_empty = fintype.of_finset ∅ set.fintype_empty._proof_1
Equations
- set.fintype_insert a s = dite (a ∈ s) (λ (h : a ∈ s), _.mpr (_.mpr _inst_2)) (λ (h : a ∉ s), s.fintype_insert' h)
Equations
Equations
Equations
Embedding of ℕ
into an infinite set.
Equations
Equations
- s.fintype_union t = fintype.of_finset (s.to_finset ∪ t.to_finset) _
Equations
- s.fintype_sep p = fintype.of_finset (finset.filter p s.to_finset) _
Equations
- s.fintype_inter t = s.fintype_sep t
A fintype
structure on a set defines a fintype
structure on its subset.
Equations
- s.fintype_subset h = _.mpr (s.fintype_inter t)
Equations
- s.fintype_image f = fintype.of_finset (finset.image f s.to_finset) _
Equations
Equations
If a function f
has a partial inverse and sends a set s
to a set with [fintype]
instance,
then s
has a fintype
structure as well.
Equations
- s.fintype_of_fintype_image I = fintype.of_finset {val := multiset.filter_map g (f '' s).to_finset.val, nodup := _} _
Equations
- set.fintype_Union f = fintype.of_finset (finset.univ.bUnion (λ (i : plift ι), (f i.down).to_finset)) _
A union of sets with fintype
structure over a set with fintype
structure has a fintype
structure.
Equations
- set.fintype_bUnion f H = _.mpr (set.fintype_Union (λ (i : ↥s), f ↑i))
Equations
- set.fintype_bUnion' f = set.fintype_bUnion (λ (i : ι), f i) (λ (i : ι) (_x : i ∈ s), H i)
Equations
Equations
- set.fintype_le_nat n = _.mpr (_.mp (set.fintype_lt_nat (n + 1)))
image2 f s t
is finitype if s
and t
are.
Equations
- set.fintype_image2 f s t = _.mpr ((s ×ˢ t).fintype_image (λ (x : α × β), f x.fst x.snd))
If s : set α
is a set with fintype
instance and f : α → set β
is a function such that
each f a
, a ∈ s
, has a fintype
structure, then s >>= f
has a fintype
structure.
Equations
- s.fintype_bind f H = set.fintype_bUnion (λ (i : α), f i) H
Equations
- s.fintype_bind' f = s.fintype_bind f (λ (i : α) (_x : i ∈ s), H i)
Equations
- f.fintype_seq s = _.mpr (set.fintype_bUnion' (λ (i : α → β), i '' s))
Equations
- f.fintype_seq' s = f.fintype_seq s
An increasing union distributes over finite intersection.
Equations
If P
is some relation between terms of γ
and sets in γ
,
such that every finite set t : set γ
has some c : γ
related to it,
then there is a recursively defined sequence u
in γ
so u n
is related to the image of {0, 1, ..., n-1}
under u
.
(We use this later to show sequentially compact sets are totally bounded.)
Equations
- s.fintype_sdiff t = fintype.of_finset (s.to_finset \ t.to_finset) _
A finite set is bounded above.
A finite set is bounded below.
A finset is bounded above.
A finset is bounded below.
If two subtypes of a fintype have equal cardinality, so do their complements.
If a set s
does not contain any elements between any pair of elements x, z ∈ s
with x ≤ z
(i.e if given x, y, z ∈ s
such that x ≤ y ≤ z
, then y
is either x
or z
), then s
is
finite.