Existential quantifier in Coq impredicative logic (System F)
Question
I was trying to code into Coq logical connectives encoded in lambda calculus with type à la System F. Here is the bunch of code I wrote (standard things, I think)
Definition True := forall X : Prop, X -> X.TrueTrueforall X : Prop, X -> Xapply H. Qed. Section s. Variables A B : Prop. (* conjunction *) Definition and := forall X : Prop, (A -> B -> X) -> X. Infix "/\" := and.X: Prop
H: XXA, B: PropA -> B -> A /\ BA, B: PropA -> B -> A /\ BA, B: Prop
HA: A
HB: B(A /\ B)%typeA, B: Prop
HA: A
HB: BAA, B: Prop
HA: A
HB: BBapply HA.A, B: Prop
HA: A
HB: BAapply HB. Qed.A, B: Prop
HA: A
HB: BBA, B: PropA /\ B -> AA, B: PropA /\ B -> AA, B: Prop
H: (A /\ B)%typeAapply HA. Qed.A, B: Prop
HA: A
HB: BAA, B: PropA /\ B -> BA, B: PropA /\ B -> BA, B: Prop
H: (A /\ B)%typeBapply HB. Qed. (* disjunction *) Definition or := forall X : Prop, (A -> X) -> (B -> X) -> X. Infix "\/" := or.A, B: Prop
HA: A
HB: BBA, B: PropA -> A \/ BA, B: PropA -> A \/ BA, B: Prop
HA: A(A \/ B)%typeapply HA. Qed.A, B: Prop
HA: AAA, B: Propforall C : Prop, A \/ B -> (A -> C) -> (B -> C) -> CA, B: Propforall C : Prop, A \/ B -> (A -> C) -> (B -> C) -> CA, B, C: Prop
HOR: (A \/ B)%type
HAC: A -> C
HBC: B -> CCA, B, C: Prop
H: A
HAC: A -> C
HBC: B -> CCA, B, C: Prop
H: B
HAC: A -> C
HBC: B -> CCapply (HBC H). Qed. (* falsity *) Definition False := forall Y : Prop, Y.A, B, C: Prop
H: B
HAC: A -> C
HBC: B -> CCA, B: PropFalse -> AA, B: PropFalse -> AA, B: Prop(forall Y : Prop, Y) -> Aapply (H A). Qed. End s.A, B: Prop
H: forall Y : Prop, YA
Basically, I wrote down the elimination and introduction laws for conjunction, disjunction, true and false. I am not sure of having done thing correctly, but I think that things should work that way. Now I would like to define the existential quantification, but I have no idea of how to proceed. Does anyone have a suggestion?
Answer
Existential quantification is just a generalization of conjunction, where the type of the second component of the pair depends on the value of the first component. When there's no dependency they're equivalent:
forall P1 P2 : Prop, (exists _ : P1, P2) <-> P1 /\ P2split; intros [H1 H2]; eauto. Qed.forall P1 P2 : Prop, (exists _ : P1, P2) <-> P1 /\ P2
Coq'Art has a section on impredicativity starting at page 130.
The problem with impredicative definitions (unless I'm mistaken) is that there's no dependent elimination. It's possible prove
forall (A : Type) (P : A -> Prop) (Q : Prop),
(forall x : A, P x -> Q) -> (exists x : A, P x) -> Q
but not
forall (A : Type) (P : A -> Prop)
(Q : (exists x : A, P x) -> Prop),
(forall (x : A) (H : P x), Q (ex_intro P x H)) ->
forall H : exists x : A, P x, Q H