The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Data.Set.Finite.Basic

186 declarations and 6 deprecated aliases. Mathlib docs · Source

Finite sets

This file provides Fintype instances for many set constructions. It also proves basic facts about finite sets and gives ways to manipulate Set.Finite expressions.

Note that the instances in this file are selected somewhat arbitrarily on the basis of them not needing any imports beyond Data.Fintype.Card (which is required by Finite.ofFinset); they can certainly be organized better.

Main definitions

  • Set.Finite.toFinset to noncomputably produce a Finset from a Set.Finite proof. (See Set.toFinset for a computable version.)

Implementation

A finite set is defined to be a set whose coercion to a type has a Finite instance.

There are two components to finiteness constructions. The first is Fintype instances for each construction. This gives a way to actually compute a Finset that represents the set, and these may be accessed using Set.toFinset. This gets the Finset in the correct form, since otherwise Finset.univ : Finset s is a Finset for the subtype for s. The second component is "constructors" for Set.Finite that give proofs that Fintype instances exist classically given other Set.Finite proofs. Unlike the Fintype instances, these do not use any decidability instances since they do not compute anything.

Tags

finite sets

Basic properties of Set.Finite.toFinset

Fintype instances

Every instance here should have a corresponding Set.Finite constructor in the next section.

Finset

Finite instances

There is seemingly some overlap between the following instances and the Fintype instances in Data.Set.Finite. While every Fintype instance gives a Finite instance, those instances that depend on Fintype or Decidable instances need an additional Finite instance to be able to generally apply.

Some set instances do not appear here since they are consequences of others, for example Subtype.Finite for subsets of a finite type.

Constructors for Set.Finite

Every constructor here should have a corresponding Fintype instance in the previous section (or in the Fintype module).

The implementation of these constructors ideally should be no more than Set.toFinite, after possibly setting up some Fintype and classical Decidable instances.

Properties

Cardinality

Infinite sets

theorem Set.Infinite.natEmbedding.congr_simp E1 #

∀ {α : Type u} (s : Set α) (h : s.Infinite), Set.Infinite.natEmbedding s h = Set.Infinite.natEmbedding s h

theorem Set.Finite.toFinset.congr_simp E1 #

∀ {α : Type u} {s s_1 : Set α} (e_s : s = s_1) (h : s.Finite), h.toFinset = ⋯.toFinset

theorem Set.finite_def E0 #

∀ {α : Type u} {s : Set α}, s.Finite ↔ Nonempty (Fintype ↑s)

theorem Set.Finite.nonempty_fintype E1 #

∀ {α : Type u} {s : Set α}, s.Finite → Nonempty (Fintype ↑s)

Alias of the forward direction of Set.finite_def.

theorem Set.Finite.ofFinset E1 #

∀ {α : Type u} {p : Set α} (s : Finset α), (∀ (x : α), x ∈ s ↔ x ∈ p) → p.Finite

Construct a Finite instance for a Set from a Finset with the same elements.

def Set.Finite.fintype E1 #

{α : Type u} → {s : Set α} → s.Finite → Fintype ↑s

A finite set coerced to a type is a Fintype. This is the Fintype projection for a Set.Finite.

Note that because Finite isn't a typeclass, this definition will not fire if it is made into an instance

def Set.Finite.toFinset E3 #

{α : Type u} → {s : Set α} → s.Finite → Finset α

Using choice, get the Finset that represents this Set.

theorem Set.Finite.toFinset_eq_toFinset E1 #

∀ {α : Type u} {s : Set α} [inst : Fintype ↑s] (h : s.Finite), h.toFinset = s.toFinset

theorem Set.toFinite_toFinset E0 #

∀ {α : Type u} (s : Set α) [inst : Fintype ↑s], ⋯.toFinset = s.toFinset

theorem Set.Finite.exists_finset E1 #

∀ {α : Type u} {s : Set α}, s.Finite → ∃ s', ∀ (a : α), a ∈ s' ↔ a ∈ s

theorem Set.Finite.exists_finset_coe E0 #

∀ {α : Type u} {s : Set α}, s.Finite → ∃ s', ↑s' = s

instance Set.instCanLiftFinsetCoeFinite E0 #

∀ {α : Type u}, CanLift (Set α) (Finset α) SetLike.coe Set.Finite

Finite sets can be lifted to finsets.

theorem Set.Finite.mem_toFinset E0 #

∀ {α : Type u} {s : Set α} {a : α} (hs : s.Finite), a ∈ hs.toFinset ↔ a ∈ s

theorem Set.Finite.coe_toFinset E0 #

∀ {α : Type u} {s : Set α} (hs : s.Finite), ↑hs.toFinset = s

theorem Set.Finite.toFinset_nonempty E0 #

∀ {α : Type u} {s : Set α} (hs : s.Finite), hs.toFinset.Nonempty ↔ s.Nonempty

theorem Set.Finite.coeSort_toFinset E1 #

∀ {α : Type u} {s : Set α} (hs : s.Finite), ↥hs.toFinset = ↑s

Note that this is an equality of types not holding definitionally. Use wisely.

def Set.Finite.subtypeEquivToFinset E1 #

{α : Type u} → {s : Set α} → (hs : s.Finite) → { x // x ∈ s } ≃ ↥hs.toFinset

The identity map, bundled as an equivalence between the subtypes of s : Set α and of h.toFinset : Finset α, where h is a proof of finiteness of s.

theorem Set.Finite.subtypeEquivToFinset_apply_coe E0 #

∀ {α : Type u} {s : Set α} (hs : s.Finite) (a : { a // a ∈ s }), ↑(hs.subtypeEquivToFinset a) = ↑a

theorem Set.Finite.subtypeEquivToFinset_symm_apply_coe E0 #

∀ {α : Type u} {s : Set α} (hs : s.Finite) (b : ↥hs.toFinset), ↑(hs.subtypeEquivToFinset.symm b) = ↑b

theorem Set.Finite.toFinset_inj E0 #

∀ {α : Type u} {s t : Set α} {hs : s.Finite} {ht : t.Finite}, hs.toFinset = ht.toFinset ↔ s = t

theorem Set.Finite.toFinset_subset E0 #

∀ {α : Type u} {s : Set α} {hs : s.Finite} {t : Finset α}, hs.toFinset ⊆ t ↔ s ⊆ ↑t

theorem Set.Finite.toFinset_ssubset E0 #

∀ {α : Type u} {s : Set α} {hs : s.Finite} {t : Finset α}, hs.toFinset ⊂ t ↔ s ⊂ ↑t

theorem Set.Finite.subset_toFinset E0 #

∀ {α : Type u} {t : Set α} {ht : t.Finite} {s : Finset α}, s ⊆ ht.toFinset ↔ ↑s ⊆ t

theorem Set.Finite.ssubset_toFinset E0 #

∀ {α : Type u} {t : Set α} {ht : t.Finite} {s : Finset α}, s ⊂ ht.toFinset ↔ ↑s ⊂ t

theorem Set.Finite.toFinset_subset_toFinset E1 #

∀ {α : Type u} {s t : Set α} {hs : s.Finite} {ht : t.Finite}, hs.toFinset ⊆ ht.toFinset ↔ s ⊆ t

theorem Set.Finite.toFinset_ssubset_toFinset E1 #

∀ {α : Type u} {s t : Set α} {hs : s.Finite} {ht : t.Finite}, hs.toFinset ⊂ ht.toFinset ↔ s ⊂ t

theorem Set.Finite.toFinset_mono E1 #

∀ {α : Type u} {s t : Set α} {hs : s.Finite} {ht : t.Finite}, s ⊆ t → hs.toFinset ⊆ ht.toFinset

Alias of the reverse direction of Set.Finite.toFinset_subset_toFinset.

theorem Set.Finite.toFinset_strictMono E1 #

∀ {α : Type u} {s t : Set α} {hs : s.Finite} {ht : t.Finite}, s ⊂ t → hs.toFinset ⊂ ht.toFinset

Alias of the reverse direction of Set.Finite.toFinset_ssubset_toFinset.

theorem Set.Finite.toFinset_ofPred E0 #

∀ {α : Type u} [inst : Fintype α] (p : α → Prop) [inst_1 : DecidablePred p] (h : {x | p x}.Finite),
  h.toFinset = {x | p x}

theorem Set.Finite.disjoint_toFinset E0 #

∀ {α : Type u} {s t : Set α} {hs : s.Finite} {ht : t.Finite}, Disjoint hs.toFinset ht.toFinset ↔ Disjoint s t

theorem Set.Finite.toFinset_inter E1 #

∀ {α : Type u} {s t : Set α} [inst : DecidableEq α] (hs : s.Finite) (ht : t.Finite) (h : (s ∩ t).Finite),
  h.toFinset = hs.toFinset ∩ ht.toFinset

theorem Set.Finite.toFinset_union E1 #

∀ {α : Type u} {s t : Set α} [inst : DecidableEq α] (hs : s.Finite) (ht : t.Finite) (h : (s ∪ t).Finite),
  h.toFinset = hs.toFinset ∪ ht.toFinset

theorem Set.Finite.toFinset_sdiff E1 #

∀ {α : Type u} {s t : Set α} [inst : DecidableEq α] (hs : s.Finite) (ht : t.Finite) (h : (s \ t).Finite),
  h.toFinset = hs.toFinset \ ht.toFinset

theorem Set.Finite.toFinset_symmDiff E1 #

∀ {α : Type u} {s t : Set α} [inst : DecidableEq α] (hs : s.Finite) (ht : t.Finite) (h : (symmDiff s t).Finite),
  h.toFinset = symmDiff hs.toFinset ht.toFinset

theorem Set.Finite.toFinset_compl E1 #

∀ {α : Type u} {s : Set α} [inst : DecidableEq α] [inst_1 : Fintype α] (hs : s.Finite) (h : sᶜ.Finite),
  h.toFinset = hs.toFinsetᶜ

theorem Set.Finite.toFinset_univ E1 #

∀ {α : Type u} [inst : Fintype α] (h : Set.univ.Finite), h.toFinset = Finset.univ

theorem Set.Finite.toFinset_eq_empty E0 #

∀ {α : Type u} {s : Set α} {h : s.Finite}, h.toFinset = ∅ ↔ s = ∅

theorem Set.Finite.toFinset_empty E1 #

∀ {α : Type u} (h : ∅.Finite), h.toFinset = ∅

theorem Set.Finite.toFinset_eq_univ E0 #

∀ {α : Type u} {s : Set α} [inst : Fintype α] {h : s.Finite}, h.toFinset = Finset.univ ↔ s = Set.univ

theorem Set.Finite.toFinset_image E1 #

∀ {α : Type u} {β : Type v} {s : Set α} [inst : DecidableEq β] (f : α → β) (hs : s.Finite) (h : (f '' s).Finite),
  h.toFinset = Finset.image f hs.toFinset

theorem Set.Finite.toFinset_range E1 #

∀ {α : Type u} {β : Type v} [inst : DecidableEq α] [inst_1 : Fintype β] (f : β → α) (h : (Set.range f).Finite),
  h.toFinset = Finset.image f Finset.univ

theorem Set.Finite.toFinset_nontrivial E0 #

∀ {α : Type u} {s : Set α} (h : s.Finite), h.toFinset.Nontrivial ↔ s.Nontrivial

instance Set.fintypeUniv E0 #

{α : Type u} → [Fintype α] → Fintype ↑Set.univ

instance Set.fintypeTop E0 #

{α : Type u} → [Fintype α] → Fintype ↑⊤

def Set.fintypeOfFiniteUniv E1 #

{α : Type u} → Set.univ.Finite → Fintype α

If (Set.univ : Set α) is finite then α is a finite type.

instance Set.fintypeUnion E0 #

{α : Type u} → [DecidableEq α] → (s t : Set α) → [Fintype ↑s] → [Fintype ↑t] → Fintype ↑(s ∪ t)

instance Set.fintypeSep E0 #

{α : Type u} → (s : Set α) → (p : α → Prop) → [Fintype ↑s] → [DecidablePred p] → Fintype ↑{a | a ∈ s ∧ p a}

instance Set.fintypeInter E0 #

{α : Type u} → (s t : Set α) → [DecidableEq α] → [Fintype ↑s] → [Fintype ↑t] → Fintype ↑(s ∩ t)

instance Set.fintypeInterOfLeft E0 #

{α : Type u} → (s t : Set α) → [Fintype ↑s] → [DecidablePred fun x ↦ x ∈ t] → Fintype ↑(s ∩ t)

A Fintype instance for set intersection where the left set has a Fintype instance.

instance Set.fintypeInterOfRight E0 #

{α : Type u} → (s t : Set α) → [Fintype ↑t] → [DecidablePred fun x ↦ x ∈ s] → Fintype ↑(s ∩ t)

A Fintype instance for set intersection where the right set has a Fintype instance.

def Set.fintypeSubset E1 #

{α : Type u} → (s : Set α) → {t : Set α} → [Fintype ↑s] → [DecidablePred fun x ↦ x ∈ t] → t ⊆ s → Fintype ↑t

A Fintype structure on a set defines a Fintype structure on its subset.

instance Set.fintypeDiff E0 #

{α : Type u} → [DecidableEq α] → (s t : Set α) → [Fintype ↑s] → [Fintype ↑t] → Fintype ↑(s \ t)

instance Set.fintypeDiffLeft E0 #

{α : Type u} → (s t : Set α) → [Fintype ↑s] → [DecidablePred fun x ↦ x ∈ t] → Fintype ↑(s \ t)

instance Set.fintypeEmpty E0 #

{α : Type u} → Fintype ↑∅

instance Set.fintypeSingleton E0 #

{α : Type u} → (a : α) → Fintype ↑{a}

instance Set.fintypeInsert E0 #

{α : Type u} → (a : α) → (s : Set α) → [DecidableEq α] → [Fintype ↑s] → Fintype ↑(insert a s)

A Fintype instance for inserting an element into a Set using the corresponding insert function on Finset. This requires DecidableEq α. There is also Set.fintypeInsert' when a ∈ s is decidable.

def Set.fintypeInsertOfNotMem E1 #

{α : Type u} → {a : α} → (s : Set α) → [Fintype ↑s] → a ∉ s → Fintype ↑(insert a s)

A Fintype structure on insert a s when inserting a new element.

def Set.fintypeInsertOfMem E1 #

{α : Type u} → {a : α} → (s : Set α) → [Fintype ↑s] → a ∈ s → Fintype ↑(insert a s)

A Fintype structure on insert a s when inserting a pre-existing element.

instance Set.fintypeInsert' E0 #

{α : Type u} → (a : α) → (s : Set α) → [Decidable (a ∈ s)] → [Fintype ↑s] → Fintype ↑(insert a s)

The Set.fintypeInsert instance requires decidable equality, but when a ∈ s is decidable for this particular a we can still get a Fintype instance by using Set.fintypeInsertOfNotMem or Set.fintypeInsertOfMem.

This instance pre-dates Set.fintypeInsert, and it is less efficient. When Set.decidableMemOfFintype is made a local instance, then this instance would override Set.fintypeInsert if not for the fact that its priority has been adjusted. See Note [lower instance priority].

instance Set.fintypeImage E0 #

{α : Type u} → {β : Type v} → [DecidableEq β] → (s : Set α) → (f : α → β) → [Fintype ↑s] → Fintype ↑(f '' s)

def Set.fintypeOfFintypeImage E1 #

{α : Type u} →
  {β : Type v} →
    (s : Set α) → {f : α → β} → {g : β → Option α} → Function.IsPartialInv f g → [Fintype ↑(f '' s)] → Fintype ↑s

If a function f has a partial inverse g and the image of s under f is a set with a Fintype instance, then s has a Fintype structure as well.

instance Set.fintypeMap E0 #

{α β : Type u_1} → [DecidableEq β] → (s : Set α) → (f : α → β) → [Fintype ↑s] → Fintype ↑(f <$> s)

instance Set.fintypeLTNat E0 #

(n : ℕ) → Fintype ↑{i | i < n}

instance Set.fintypeLENat E0 #

(n : ℕ) → Fintype ↑{i | i ≤ n}

def Set.Nat.fintypeIio E1 #

(n : ℕ) → Fintype ↑(Set.Iio n)

This is not an instance so that it does not conflict with the one in Mathlib/Order/Interval/Finset/Defs.lean.

instance Set.fintypeMemFinset E0 #

{α : Type u} → (s : Finset α) → Fintype ↑{a | a ∈ s}

theorem Finset.finite_toSet E0 #

∀ {α : Type u} (s : Finset α), (↑s).Finite

Gives a Set.Finite for the Finset coerced to a Set. This is a wrapper around Set.toFinite.

theorem Finset.finite_toSet_toFinset E1 #

∀ {α : Type u} (s : Finset α), ⋯.toFinset = s

theorem Finset.forall E1 #

∀ {α : Type u} {p : Finset α → Prop}, (∀ (s : Finset α), p s) ↔ ∀ (s : Set α) (hs : s.Finite), p hs.toFinset

This is a kind of induction principle. See Finset.induction for the usual induction principle for finsets.

theorem Finset.forall_toSet E1 #

∀ {α : Type u} {p : Set α → Prop}, (∀ (s : Finset α), p ↑s) ↔ ∀ (s : Set α), s.Finite → p s

theorem Finset.exists E1 #

∀ {α : Type u} {p : Finset α → Prop}, (∃ s, p s) ↔ ∃ s, ∃ (hs : s.Finite), p hs.toFinset

theorem Finset.exists_toSet E1 #

∀ {α : Type u} {p : Set α → Prop}, (∃ s, p ↑s) ↔ ∃ s, s.Finite ∧ p s

theorem Finset.mem_range_coe_iff E0 #

∀ {α : Type u} {s : Set α}, s ∈ Set.range SetLike.coe ↔ s.Finite

theorem Multiset.finite_toSet E0 #

∀ {α : Type u} (s : Multiset α), {x | x ∈ s}.Finite

theorem Multiset.finite_toSet_toFinset E0 #

∀ {α : Type u} [inst : DecidableEq α] (s : Multiset α), ⋯.toFinset = s.toFinset

theorem List.finite_toSet E0 #

∀ {α : Type u} (l : List α), {x | x ∈ l}.Finite

def OrderIso.finsetSetFinite E1 #

{α : Type u} → Finset α ≃o { s // s.Finite }

Finset α is order isomorphic to the type of finite sets in α.

theorem OrderIso.finsetSetFinite_symm_apply E0 #

∀ {α : Type u} (s : { s // s.Finite }), (RelIso.symm OrderIso.finsetSetFinite) s = ⋯.toFinset

theorem OrderIso.finsetSetFinite_apply_coe E0 #

∀ {α : Type u} (s : Finset α), ↑(OrderIso.finsetSetFinite s) = ↑s

instance instWellFoundedLTSubtypeSetFinite E0 #

∀ {α : Type u}, WellFoundedLT { s // s.Finite }

instance Finite.Set.finite_union E0 #

∀ {α : Type u} (s t : Set α) [Finite ↑s] [Finite ↑t], Finite ↑(s ∪ t)

instance Finite.Set.finite_sep E0 #

∀ {α : Type u} (s : Set α) (p : α → Prop) [Finite ↑s], Finite ↑{a | a ∈ s ∧ p a}

theorem Finite.Set.subset E1 #

∀ {α : Type u} (s : Set α) {t : Set α} [Finite ↑s], t ⊆ s → Finite ↑t

instance Finite.Set.finite_inter_of_right E0 #

∀ {α : Type u} (s t : Set α) [Finite ↑t], Finite ↑(s ∩ t)

instance Finite.Set.finite_inter_of_left E0 #

∀ {α : Type u} (s t : Set α) [Finite ↑s], Finite ↑(s ∩ t)

instance Finite.Set.finite_diff E0 #

∀ {α : Type u} (s t : Set α) [Finite ↑s], Finite ↑(s \ t)

instance Finite.Set.finite_insert E0 #

∀ {α : Type u} (a : α) (s : Set α) [Finite ↑s], Finite ↑(insert a s)

instance Finite.Set.finite_image E0 #

∀ {α : Type u} {β : Type v} (s : Set α) (f : α → β) [Finite ↑s], Finite ↑(f '' s)

theorem Set.Finite.of_subsingleton E1 #

∀ {α : Type u} [Subsingleton α] (s : Set α), s.Finite

theorem Set.finite_univ E0 #

∀ {α : Type u} [Finite α], Set.univ.Finite

theorem Set.finite_univ_iff E0 #

∀ {α : Type u}, Set.univ.Finite ↔ Finite α

theorem Finite.of_finite_univ E1 #

∀ {α : Type u}, Set.univ.Finite → Finite α

Alias of the forward direction of Set.finite_univ_iff.

theorem Set.Finite.subset E1 #

∀ {α : Type u} {s : Set α}, s.Finite → ∀ {t : Set α}, t ⊆ s → t.Finite

theorem Set.Finite.union E1 #

∀ {α : Type u} {s t : Set α}, s.Finite → t.Finite → (s ∪ t).Finite

theorem Set.Finite.finite_of_compl E1 #

∀ {α : Type u} {s : Set α}, s.Finite → sᶜ.Finite → Finite α

theorem Set.Finite.sup E1 #

∀ {α : Type u} {s t : Set α}, s.Finite → t.Finite → (s ∪ t).Finite

theorem Set.Finite.sep E1 #

∀ {α : Type u} {s : Set α}, s.Finite → ∀ (p : α → Prop), {a | a ∈ s ∧ p a}.Finite

theorem Set.Finite.inter_of_left E1 #

∀ {α : Type u} {s : Set α}, s.Finite → ∀ (t : Set α), (s ∩ t).Finite

theorem Set.Finite.inter_of_right E1 #

∀ {α : Type u} {s : Set α}, s.Finite → ∀ (t : Set α), (t ∩ s).Finite

theorem Set.Finite.inf_of_left E1 #

∀ {α : Type u} {s : Set α}, s.Finite → ∀ (t : Set α), (s ∩ t).Finite

theorem Set.Finite.inf_of_right E1 #

∀ {α : Type u} {s : Set α}, s.Finite → ∀ (t : Set α), (t ∩ s).Finite

theorem Set.Infinite.mono E1 #

∀ {α : Type u} {s t : Set α}, s ⊆ t → s.Infinite → t.Infinite

theorem Set.Finite.sdiff E0 #

∀ {α : Type u} {s t : Set α}, s.Finite → (s \ t).Finite

theorem Set.Finite.of_sdiff E1 #

∀ {α : Type u} {s t : Set α}, (s \ t).Finite → t.Finite → s.Finite

theorem Set.Finite.symmDiff E0 #

∀ {α : Type u} {s t : Set α}, s.Finite → t.Finite → (symmDiff s t).Finite

theorem Set.Finite.symmDiff_congr E1 #

∀ {α : Type u} {s t u : Set α}, (symmDiff s t).Finite → ((symmDiff s u).Finite ↔ (symmDiff t u).Finite)

theorem Set.finite_empty E0 #

∀ {α : Type u}, ∅.Finite

theorem Set.Infinite.nonempty E1 #

∀ {α : Type u} {s : Set α}, s.Infinite → s.Nonempty

theorem Set.finite_singleton E0 #

∀ {α : Type u} (a : α), {a}.Finite

theorem Set.Finite.insert E1 #

∀ {α : Type u} (a : α) {s : Set α}, s.Finite → (insert a s).Finite

theorem Set.finite_insert E0 #

∀ {α : Type u} {s : Set α} {a : α}, (insert a s).Finite ↔ s.Finite

theorem Set.Finite.image E1 #

∀ {α : Type u} {β : Type v} {s : Set α} (f : α → β), s.Finite → (f '' s).Finite

theorem Set.Finite.of_surjOn E1 #

∀ {α : Type u} {β : Type v} {s : Set α} {t : Set β} (f : α → β), Set.SurjOn f s t → s.Finite → t.Finite

theorem Set.Finite.map E1 #

∀ {α β : Type u_1} {s : Set α} (f : α → β), s.Finite → (f <$> s).Finite

theorem Set.Finite.of_finite_image E1 #

∀ {α : Type u} {β : Type v} {s : Set α} {f : α → β}, (f '' s).Finite → Set.InjOn f s → s.Finite

theorem Set.Finite.of_injOn E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set α} {t : Set β}, Set.MapsTo f s t → Set.InjOn f s → t.Finite → s.Finite

theorem Set.BijOn.finite_iff_finite E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set α} {t : Set β}, Set.BijOn f s t → (s.Finite ↔ t.Finite)

theorem Set.finite_of_finite_preimage E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set β}, (f ⁻¹' s).Finite → s ⊆ Set.range f → s.Finite

theorem Set.Finite.of_preimage E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set β}, (f ⁻¹' s).Finite → Function.Surjective f → s.Finite

theorem Set.Finite.preimage E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set β}, Set.InjOn f (f ⁻¹' s) → s.Finite → (f ⁻¹' s).Finite

theorem Set.Infinite.preimage E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set β}, s.Infinite → s ⊆ Set.range f → (f ⁻¹' s).Infinite

theorem Set.Infinite.preimage' E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set β}, (s ∩ Set.range f).Infinite → (f ⁻¹' s).Infinite

theorem Set.Finite.preimage_embedding E1 #

∀ {α : Type u} {β : Type v} {s : Set β} (f : α ↪ β), s.Finite → (⇑f ⁻¹' s).Finite

theorem Set.finite_lt_nat E1 #

∀ (n : ℕ), {i | i < n}.Finite

theorem Set.finite_le_nat E1 #

∀ (n : ℕ), {i | i ≤ n}.Finite

theorem Set.Finite.surjOn_iff_bijOn_of_mapsTo E1 #

∀ {α : Type u} {s : Set α} {f : α → α}, s.Finite → Set.MapsTo f s s → (Set.SurjOn f s s ↔ Set.BijOn f s s)

theorem Set.Finite.injOn_iff_bijOn_of_mapsTo E1 #

∀ {α : Type u} {s : Set α} {f : α → α}, s.Finite → Set.MapsTo f s s → (Set.InjOn f s ↔ Set.BijOn f s s)

theorem Set.finite_mem_finset E1 #

∀ {α : Type u} (s : Finset α), {a | a ∈ s}.Finite

theorem Set.Subsingleton.finite E1 #

∀ {α : Type u} {s : Set α}, s.Subsingleton → s.Finite

theorem Set.Infinite.nontrivial E1 #

∀ {α : Type u} {s : Set α}, s.Infinite → s.Nontrivial

theorem Set.finite_preimage_inl_and_inr E1 #

∀ {α : Type u} {β : Type v} {s : Set (α ⊕ β)}, (Sum.inl ⁻¹' s).Finite ∧ (Sum.inr ⁻¹' s).Finite ↔ s.Finite

theorem Set.exists_finite_iff_finset E1 #

∀ {α : Type u} {p : Set α → Prop}, (∃ s, s.Finite ∧ p s) ↔ ∃ s, p ↑s

theorem Set.exists_subset_image_finite_and E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set α} {p : Set β → Prop},
  (∃ t ⊆ f '' s, t.Finite ∧ p t) ↔ ∃ t ⊆ s, t.Finite ∧ p (f '' t)

theorem Set.finite_range_ite E1 #

∀ {α : Type u} {β : Type v} {p : α → Prop} [inst : DecidablePred p] {f g : α → β},
  (Set.range f).Finite → (Set.range g).Finite → (Set.range fun x ↦ if p x then f x else g x).Finite

theorem Set.finite_range_const E1 #

∀ {α : Type u} {β : Type v} {c : β}, (Set.range fun x ↦ c).Finite

instance Set.Finite.inhabited E0 #

{α : Type u} → Inhabited { s // s.Finite }

theorem Set.finite_union E0 #

∀ {α : Type u} {s t : Set α}, (s ∪ t).Finite ↔ s.Finite ∧ t.Finite

theorem Set.finite_image_iff E0 #

∀ {α : Type u} {β : Type v} {s : Set α} {f : α → β}, Set.InjOn f s → ((f '' s).Finite ↔ s.Finite)

theorem Set.finite_range_iff E0 #

∀ {α : Type u} {β : Type v} {f : α → β}, Function.Injective f → ((Set.range f).Finite ↔ Finite α)

theorem Set.univ_finite_iff_nonempty_fintype E1 #

∀ {α : Type u}, Set.univ.Finite ↔ Nonempty (Fintype α)

theorem Set.Finite.toFinset_singleton E1 #

∀ {α : Type u} {a : α} (ha : optParam {a}.Finite ⋯), ha.toFinset = {a}

theorem Set.Finite.toFinset_insert E0 #

∀ {α : Type u} [inst : DecidableEq α] {s : Set α} {a : α} (hs : (insert a s).Finite), hs.toFinset = insert a ⋯.toFinset

theorem Set.Finite.toFinset_insert' E1 #

∀ {α : Type u} [inst : DecidableEq α] {a : α} {s : Set α} (hs : s.Finite), ⋯.toFinset = insert a hs.toFinset

theorem Set.finite_option E1 #

∀ {α : Type u} {s : Set (Option α)}, s.Finite ↔ {x | some x ∈ s}.Finite

theorem Set.Finite.induction_on E2 #

∀ {α : Type u} {motive : (s : Set α) → s.Finite → Prop} (s : Set α) (hs : s.Finite),
  motive ∅ ⋯ → (∀ {a : α} {s : Set α}, a ∉ s → ∀ (hs : s.Finite), motive s hs → motive (insert a s) ⋯) → motive s hs

Induction principle for finite sets: To prove a property motive of a finite set s, it's enough to prove for the empty set and to prove that motive t → motive ({a} ∪ t) for all t.

See also Set.Finite.induction_on_subset for the version requiring to check motive t → motive ({a} ∪ t) only for t ⊆ s.

theorem Set.Finite.induction_on_subset E2 #

∀ {α : Type u} {motive : (s : Set α) → s.Finite → Prop} (s : Set α) (hs : s.Finite),
  motive ∅ ⋯ →
    (∀ {a : α} {t : Set α}, a ∈ s → ∀ (hts : t ⊆ s), a ∉ t → motive t ⋯ → motive (insert a t) ⋯) → motive s hs

Induction principle for finite sets: To prove a property C of a finite set s, it's enough to prove for the empty set and to prove that C t → C ({a} ∪ t) for all t ⊆ s.

This is analogous to Finset.induction_on'. See also Set.Finite.induction_on for the version requiring motive t → motive ({a} ∪ t) for all t.

theorem Set.seq_of_forall_finite_exists E1 #

∀ {γ : Type u_1} {P : γ → Set γ → Prop},
  (∀ (t : Set γ), t.Finite → ∃ c, P c t) → ∃ u, ∀ (n : ℕ), P (u n) (u '' Set.Iio n)

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.)

theorem Set.card_empty E1 #

∀ {α : Type u}, Fintype.card ↑∅ = 0

theorem Set.card_fintypeInsertOfNotMem E1 #

∀ {α : Type u} {a : α} (s : Set α) [inst : Fintype ↑s] (h : a ∉ s), Fintype.card ↑(insert a s) = Fintype.card ↑s + 1

theorem Set.card_insert E1 #

∀ {α : Type u} {a : α} (s : Set α) [inst : Fintype ↑s],
  a ∉ s → ∀ {d : Fintype ↑(insert a s)}, Fintype.card ↑(insert a s) = Fintype.card ↑s + 1

theorem Set.card_image_of_inj_on E1 #

∀ {α : Type u} {β : Type v} {s : Set α} [inst : Fintype ↑s] {f : α → β} [inst_1 : Fintype ↑(f '' s)],
  (∀ x ∈ s, ∀ y ∈ s, f x = f y → x = y) → Fintype.card ↑(f '' s) = Fintype.card ↑s

theorem Set.card_image_of_injective E1 #

∀ {α : Type u} {β : Type v} (s : Set α) [inst : Fintype ↑s] {f : α → β} [inst_1 : Fintype ↑(f '' s)],
  Function.Injective f → Fintype.card ↑(f '' s) = Fintype.card ↑s

theorem Set.card_singleton E0 #

∀ {α : Type u} (a : α), Fintype.card ↑{a} = 1

theorem Set.card_lt_card E1 #

∀ {α : Type u} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s ⊂ t → Fintype.card ↑s < Fintype.card ↑t

theorem Set.card_le_card E1 #

∀ {α : Type u} {s t : Set α} [inst : Fintype ↑s] [inst_1 : Fintype ↑t], s ⊆ t → Fintype.card ↑s ≤ Fintype.card ↑t

theorem Set.card_range_of_injective E1 #

∀ {α : Type u} {β : Type v} [inst : Fintype α] {f : α → β},
  Function.Injective f → ∀ [inst_1 : Fintype ↑(Set.range f)], Fintype.card ↑(Set.range f) = Fintype.card α

theorem Set.Finite.card_toFinset E1 #

∀ {α : Type u} {s : Set α} [inst : Fintype ↑s] (h : s.Finite), h.toFinset.card = Fintype.card ↑s

theorem Set.card_ne_eq E0 #

∀ {α : Type u} [inst : Fintype α] (a : α) [inst_1 : Fintype ↑{x | x ≠ a}],
  Fintype.card ↑{x | x ≠ a} = Fintype.card α - 1

theorem Set.infinite_univ_iff E0 #

∀ {α : Type u}, Set.univ.Infinite ↔ Infinite α

theorem Set.infinite_univ E1 #

∀ {α : Type u} [h : Infinite α], Set.univ.Infinite

theorem Set.Infinite.to_type E1 #

∀ {α : Type u} {s : Set α}, s.Infinite → Infinite α

theorem Set.Infinite.exists_notMem_finite E1 #

∀ {α : Type u} {s t : Set α}, s.Infinite → t.Finite → ∃ a ∈ s, a ∉ t

theorem Set.Infinite.exists_notMem_finset E1 #

∀ {α : Type u} {s : Set α}, s.Infinite → ∀ (t : Finset α), ∃ a ∈ s, a ∉ t

theorem Set.Finite.exists_notMem E1 #

∀ {α : Type u} {s : Set α} [Infinite α], s.Finite → ∃ a, a ∉ s

theorem Finset.exists_notMem E1 #

∀ {α : Type u} [Infinite α] (s : Finset α), ∃ a, a ∉ s

def Set.Infinite.natEmbedding E1 #

{α : Type u} → (s : Set α) → s.Infinite → ℕ ↪ ↑s

Embedding of ℕ into an infinite set.

theorem Set.Infinite.exists_subset_card_eq E0 #

∀ {α : Type u} {s : Set α}, s.Infinite → ∀ (n : ℕ), ∃ t, ↑t ⊆ s ∧ t.card = n

theorem Set.infinite_of_finite_compl E1 #

∀ {α : Type u} [Infinite α] {s : Set α}, sᶜ.Finite → s.Infinite

theorem Set.Finite.infinite_compl E1 #

∀ {α : Type u} [Infinite α] {s : Set α}, s.Finite → sᶜ.Infinite

theorem Set.Infinite.sdiff E1 #

∀ {α : Type u} {s t : Set α}, s.Infinite → t.Finite → (s \ t).Infinite

theorem Set.Infinite.inter_of_finite_sdiff E1 #

∀ {α : Type u_1} {s t : Set α}, s.Infinite → (s \ t).Finite → (s ∩ t).Infinite

theorem Set.infinite_union E0 #

∀ {α : Type u} {s t : Set α}, (s ∪ t).Infinite ↔ s.Infinite ∨ t.Infinite

theorem Set.Infinite.of_image E1 #

∀ {α : Type u} {β : Type v} (f : α → β) {s : Set α}, (f '' s).Infinite → s.Infinite

theorem Set.infinite_image_iff E0 #

∀ {α : Type u} {β : Type v} {s : Set α} {f : α → β}, Set.InjOn f s → ((f '' s).Infinite ↔ s.Infinite)

theorem Set.infinite_range_iff E0 #

∀ {α : Type u} {β : Type v} {f : α → β}, Function.Injective f → ((Set.range f).Infinite ↔ Infinite α)

theorem Set.Infinite.image E1 #

∀ {α : Type u} {β : Type v} {s : Set α} {f : α → β}, Set.InjOn f s → s.Infinite → (f '' s).Infinite

Alias of the reverse direction of Set.infinite_image_iff.

theorem Set.infinite_of_injOn_mapsTo E1 #

∀ {α : Type u} {β : Type v} {s : Set α} {t : Set β} {f : α → β},
  Set.InjOn f s → Set.MapsTo f s t → s.Infinite → t.Infinite

theorem Set.Infinite.exists_ne_map_eq_of_mapsTo E1 #

∀ {α : Type u} {β : Type v} {s : Set α} {t : Set β} {f : α → β},
  s.Infinite → Set.MapsTo f s t → t.Finite → ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y

theorem Set.infinite_range_of_injective E1 #

∀ {α : Type u} {β : Type v} [Infinite α] {f : α → β}, Function.Injective f → (Set.range f).Infinite

theorem Set.infinite_of_injective_forall_mem E1 #

∀ {α : Type u} {β : Type v} [Infinite α] {s : Set β} {f : α → β},
  Function.Injective f → (∀ (x : α), f x ∈ s) → s.Infinite

theorem Set.not_injOn_infinite_finite_image E1 #

∀ {α : Type u} {β : Type v} {f : α → β} {s : Set α}, s.Infinite → (f '' s).Finite → ¬Set.InjOn f s

theorem Set.finite_range_findGreatest E1 #

∀ {α : Type u} {P : α → ℕ → Prop} [inst : (x : α) → DecidablePred (P x)] {b : ℕ},
  (Set.range fun x ↦ Nat.findGreatest (P x) b).Finite

theorem Finset.exists_card_eq E0 #

∀ {α : Type u} [Infinite α] (n : ℕ), ∃ s, s.card = n

theorem Finset.exists_subset_injOn_image_eq_of_surjOn E1 #

∀ {α : Type u} {β : Type v} [inst : DecidableEq β] {f : α → β} (s : Set α) (t : Finset β),
  Set.SurjOn f s ↑t → ∃ u, ↑u ⊆ s ∧ Set.InjOn f ↑u ∧ Finset.image f u = t

Finset version of Set.SurjOn.exists_subset_injOn_image_eq.

theorem Finite.of_forall_not_lt_lt E1 #

∀ {α : Type u} [inst : LinearOrder α], (∀ ⦃x y z : α⦄, x < y → y < z → False) → Finite α

If a linear order does not contain any triple of elements x < y < z, then this type is finite.

theorem Set.finite_of_forall_not_lt_lt E1 #

∀ {α : Type u} [inst : LinearOrder α] {s : Set α}, (∀ x ∈ s, ∀ y ∈ s, ∀ z ∈ s, x < y → y < z → False) → s.Finite

If a set s does not contain any triple of elements x < y < z, then s is finite.

Deprecated aliases

NameNew nameSince
Set.Finite.diffSet.Finite.sdiff2026-06-03
Set.Finite.of_diffSet.Finite.of_sdiff2026-06-03
Set.Finite.toFinset_diffSet.toFinset_sdiff2026-06-03
Set.Finite.toFinset_setOfSet.Finite.toFinset_ofPred2026-07-09
Set.Infinite.diffSet.Infinite.sdiff2026-06-03
Set.Infinite.inter_of_finite_diffSet.Infinite.inter_of_finite_sdiff2026-06-03