I am currently learning coq thanks to the Software Fondation's ebook. I successfully wrote the addition as follow:
Definition cnat := forall X : Type, (X -> X) -> X -> X.
Definition plus (n m : cnat) : cnat :=
fun (X : Type) (f : X -> X) (x : X) => n X f (m X f x).
But I'm stuck with exp because of the following error:
Definition exp (n m : cnat) : cnat :=
m cnat (mult n) n.
(*
In environment
n : cnat
m : cnat
The term "cnat" has type "Type@{cnat.u0+1}"
while it is expected to have type "Type@{cnat.u0}"
(universe inconsistency).
*)
Since they wrote:
If you hit a "Universe inconsistency" error, try iterating over a different type. Iterating over cnat itself is usually problematic. I tried using the definition of cnat:
Definition exp (n m : cnat) : cnat :=
m (forall X : Type, (X -> X) -> X) (mult n) n.
But then I have:
In environment
n : cnat
m : cnat
The term "mult n" has type "cnat -> cnat"
while it is expected to have type
"(forall X : Type, (X -> X) -> X) -> forall X : Type, (X -> X) -> X"
(universe inconsistency).
I do not ask for a solution, but I'd really like to understand these errors. Thanks for your lights !