+(** {2 Auxiliary functions} *)
+
let uri = UriManager.uri_of_string
let const ?(subst = []) uri = Cic.Const (uri, subst)
let mutconstruct ?(subst = []) uri typeno consno =
Cic.MutConstruct (uri, typeno, consno, subst)
+(** {2 Helm's objects shorthands} *)
+
module Logic =
struct
let eq_URI = uri "cic:/Coq/Init/Logic/eq.ind"
let rtheory = const rtheory_URI
end
+module Peano =
+ struct
+ let plus_URI = uri "cic:/Coq/Init/Peano/plus.con"
+ let mult_URI = uri "cic:/Coq/Init/Peano/mult.con"
+ let pred_URI = uri "cic:/Coq/Init/Peano/pred.con"
+
+ let plus = const plus_URI
+ let mult = const mult_URI
+ let pred = const pred_URI
+ end
+
+(** {2 Helpers for creating common terms}
+ * (e.g. numbers)} *)
+
+exception NegativeInteger
+
+let build_nat n =
+ if n < 0 then raise NegativeInteger;
+ let rec aux = function
+ | 0 -> Datatypes.zero
+ | n -> Cic.Appl [ Datatypes.succ; (aux (n - 1)) ]
+ in
+ aux n
+
+let build_real n =
+ if n < 0 then raise NegativeInteger;
+ let rec aux = function
+ | 0 -> Reals.r0
+ | 1 -> Reals.r1 (* to avoid trailing "+ 0" *)
+ | n -> Cic.Appl [ Reals.rplus; Reals.r1; (aux (n - 1)) ]
+ in
+ aux n
+