Imports
import Mathlib.TacticAPI for ExistsUnique
Here we review some of the API provided for ExistsUnique in Mathlib, and provide some additional tools. (Some of these might be suitable for upstreaming to Mathlib.)
#check existsUnique_of_exists_of_unique#check ExistsUnique.exists#check ExistsUnique.unique#check ExistsUnique.introThis implements the axiom of unique choice.
noncomputable def ExistsUnique.choose {α: Sort*} {p: α → Prop} (h : ∃! x, p x) : α := h.exists.choosetheorem ExistsUnique.choose_spec {α: Sort*} {p: α → Prop} (h : ∃! x, p x) :
p h.choose := h.exists.choose_spectheorem ExistsUnique.choose_eq {α: Sort*} {p: α → Prop} (h : ∃! x, p x) {x : α} (hx : p x) :
h.choose = x := h.unique h.choose_spec hxtheorem ExistsUnique.choose_iff {α: Sort*} {p: α → Prop} (h : ∃! x, p x) (x : α):
p x ↔ x = h.choose :=
⟨ α:Sort u_1p:α → Proph:∃! x, p xx:α⊢ p x → x = h.choose α:Sort u_1p:α → Proph:∃! x, p xx:αhx:p x⊢ x = h.choose; All goals completed! 🐙, α:Sort u_1p:α → Proph:∃! x, p xx:α⊢ x = h.choose → p x α:Sort u_1p:α → Proph:∃! x, p x⊢ p h.choose; All goals completed! 🐙 ⟩theorem ExistsUnique.choose_eq_choose {α: Sort*} {p: α → Prop} (h : ∃! x, p x) : Exists.choose h = h.choose := α:Sort u_1p:α → Proph:∃! x, p x⊢ Exists.choose h = h.choose
α:Sort u_1p:α → Proph:∃! x, p x⊢ p (Exists.choose h); All goals completed! 🐙An alternate form of the axiom of unique choice.
noncomputable def Subsingleton.choose {α: Sort*} [Subsingleton α] [hn: Nonempty α] : α := hn.sometheorem Subsingleton.choose_spec {α: Sort*} [hs: Subsingleton α] [Nonempty α] (x:α) : x = hs.choose := Subsingleton.elim _ _
The equivalence between ExistsUnique and Subsingleton/Nonempty does not require choice.
theorem ExistsUnique.iff_subsingleton_nonempty {α: Sort*} {p: α → Prop} :
(∃! x, p x) ↔ (Subsingleton {x // p x} ∧ Nonempty {x // p x}) := α:Sort u_1p:α → Prop⊢ (∃! x, p x) ↔ Subsingleton { x // p x } ∧ Nonempty { x // p x }
α:Sort u_1p:α → Prop⊢ (∃! x, p x) → Subsingleton { x // p x } ∧ Nonempty { x // p x }α:Sort u_1p:α → Prop⊢ Subsingleton { x // p x } ∧ Nonempty { x // p x } → ∃! x, p x
α:Sort u_1p:α → Prop⊢ (∃! x, p x) → Subsingleton { x // p x } ∧ Nonempty { x // p x } α:Sort u_1p:α → Proph:∃! x, p x⊢ Subsingleton { x // p x } ∧ Nonempty { x // p x }; α:Sort u_1p:α → Proph:∃! x, p xx₀:αhx₀:p x₀⊢ Subsingleton { x // p x } ∧ Nonempty { x // p x }
α:Sort u_1p:α → Proph:∃! x, p xx₀:αhx₀:p x₀⊢ ∀ (a b : { x // p x }), a = b
intro ⟨ x, hx ⟩ α:Sort u_1p:α → Proph:∃! x, p xx₀:αhx₀:p x₀x:αhx:p xy:αhy:p y⊢ ⟨x, hx⟩ = ⟨y, hy⟩
All goals completed! 🐙
α:Sort u_1p:α → Prophsing:Subsingleton { x // p x }x₀:αhx₀:p x₀⊢ ∃! x, p x
α:Sort u_1p:α → Prophsing:Subsingleton { x // p x }x₀:αhx₀:p x₀⊢ ∀ (y : α), p y → y = x₀; intro y α:Sort u_1p:α → Prophsing:Subsingleton { x // p x }x₀:αhx₀:p x₀y:αhy:p y⊢ y = x₀
All goals completed! 🐙#print axioms ExistsUnique.iff_subsingleton_nonempty