I am interested in strategies for encoding classical mathematics in Coq as a way of learning more about Coq and getting my hands dirty, so to speak.
To that end, I have found this paper. I have read the paper and I understand its motivation (encoding classical mathematics in Coq in sometimes-tricky ways) to an extent, but I don't understand the paper overall very well.
The very first axiom is given below. Its meaning in English is that elements of sets are sets.
(*** interpret types as being classical sets ***)
Definition E := Type.
(*** elements of a set are themselves sets ***)
Parameter R : forall x : E, x -> E.
Axiom R_inj : forall (x : E) (a b : x), R a = R b -> a = b.
The paper mentions Coq 8.0. I'm using Coq 8.15 and the axiom fails to compile:
sh:1 $ coqc set.v
File "./set.v", line 5, characters 42-43:
Error:
In environment
x : E
a : x
b : x
The term "a" has type "x" while it is expected to have type "E".
To resolve this error in my local environment, I tried inlining the parameter R
(*** interpret types as being classical sets ***)
Definition E := Type.
(* Inline the parameter R *)
Axiom R_inj : forall (r : (forall x : E, x -> E)) (x : E) (a b : x), r a = r b -> a = b.
And annoyingly, I get exactly the same error:
sh:1 $ coqc set.v
File "./set.v", line 5, characters 71-72:
Error:
In environment
r : forall x : E, x -> E
x : E
a : x
b : x
The term "a" has type "x" while it is expected to have type "E".
I tried to fix this issue by insisting via axiom on an explicit "value" for R
.
In the code sample below, inject
is supposed to take any x
such that x : k : Type
for some type k
and convert it into a k
.
sh:1 $ cat set.v
(*** interpret types as being classical sets ***)
Definition E := Type.
Definition SetInjector := forall x : E, x -> E.
Axiom inject : SetInjector.
Definition SetInjectorInjective := forall (x : E) (a b : x), (inject a) = (inject b) -> a = b.
This also fails, in the identical way.
sh:1 $ coqc set.v
File "./set.v", line 7, characters 69-70:
Error:
In environment
x : E
a : x
b : x
The term "a" has type "x" while it is expected to have type "E".
Can someone help me understand what is happening here?
- Has Coq changed its semantics since 8.0?
- Is there a way to express the intent of this axiom correctly?
coqc
to do your work? If so, consider using a better user interface. $\endgroup$coqc
and shell tools frequently, yes, but I'm a hobbyist. I don't really work on large Coq projects. If I have to do anything complicated though I use Proof General. $\endgroup$