where ∃ is the usual Coq existential (exists) and P : A → B → Prop is an arbitrary binary predicate.
1. Imports and notations
coq
(* The standard library already defines the existential type
as a dependent pair (sig). We only need the basic definitions. *)
Require Import Coq.Init.Specif. (* gives { x | P x } and the notations *)
Require Import Coq.Logic.FunctionalExtensionality. (* not needed for the proof itself,
but handy if you want to reason about the
resulting function later *)
Coq.Init.Specif defines
coq
Inductive sig (A : Type) (P : A → Prop) : Type :=
exist : forall x : A, P x → sig A P.
Notation "{ x | P }" := (sig _ (fun x => P)).
and the usual exists notation is just a synonym for sig:
coq
Notation "∃ x , P" := (exists x, P) (at level 200, right associativity).
2. Statement of the lemma
coq
Lemma constructive_choice
{A B : Type} (* the two domains *)
(P : A -> B -> Prop) (* the binary predicate *)
: (forall x : A, exists y : B, P x y) (* premise *)
-> exists f : A -> B, forall x : A, P x (f x). (* conclusion *)
3. Proof
The proof is a single line of term construction once we realise that each
hypothesis H x : exists y, P x y is a sigma‑pairexist y Hy.
We can extract the first component (y) with proj1_sig and the proof
(Hy) with proj2_sig.
coq
Proof.
intros H. (* H : ∀ x, ∃ y, P x y *)
(* Define the required function f point‑wise by picking the witness
supplied by H for each x. *)
exists (fun x => proj1_sig (H x)). (* f : A → B *)
(* Now we have to show that f really satisfies P everywhere. *)
intro x.
(* H x is a sigma pair; its second projection is exactly the proof we need. *)
exact (proj2_sig (H x)).
Qed.
That’s it! The proof uses only the primitive eliminators of the sig type,
so it is constructive – no classical axioms are needed.
4. A tiny “run‑time” example (optional)
To see the lemma in action, let us instantiate it with a concrete predicate:
coq
Definition P_nat (n m : nat) : Prop := m = n + 1.
Example choice_nat :
(forall n : nat, exists m : nat, P_nat n m) ->
exists f : nat -> nat, forall n, P_nat n (f n).
Proof.
apply constructive_choice.
Qed.
The premise is trivially satisfied (take m = n+1), and the conclusion
produces the function f n = n+1, together with the proof that f n indeed
equals n+1.
5. Remarks
The lemma we just proved is exactly the one you asked for, written with
Coq’s built‑in exists. It is sometimes called sig_forall in the
standard library (Coq.Init.Specif).
In classical set theory the statement is known as the axiom of choice.
In constructive type theory it is provable because ∃ is not a
non‑constructive “there exists” but a pair containing an explicit witness.
If you ever need the functional extensionality principle to reason about
the function f you obtained (e.g., to prove f = g), you can import the
module Coq.Logic.FunctionalExtensionality as shown at the top. The
lemma itself does not depend on it.
Full source (copy‑paste ready)
coq
Require Import Coq.Init.Specif.
Require Import Coq.Logic.FunctionalExtensionality.
Lemma constructive_choice
{A B : Type}
(P : A -> B -> Prop) :
(forall x : A, exists y : B, P x y) ->
exists f : A -> B, forall x : A, P x (f x).
Proof.
intros H.
exists (fun x => proj1_sig (H x)).
intro x.
exact (proj2_sig (H x)).
Qed.
Feel free to experiment with different A, B, and P to see how the
choice function f is automatically built from the point‑wise witnesses.