1 (** {2 Auxiliary functions} *)
3 let uri = UriManager.uri_of_string
5 let const ?(subst = []) uri = Cic.Const (uri, subst)
6 let var ?(subst = []) uri = Cic.Var (uri, subst)
7 let mutconstruct ?(subst = []) uri typeno consno =
8 Cic.MutConstruct (uri, typeno, consno, subst)
9 let mutind ?(subst = []) uri typeno = Cic.MutInd (uri, typeno, subst)
11 let indtyuri_of_uri uri =
12 let index_sharp = String.index uri '#' in
13 let index_num = index_sharp + 3 in
14 (UriManager.uri_of_string (String.sub uri 0 index_sharp),
15 int_of_string(String.sub uri index_num (String.length uri - index_num)) - 1)
17 let indconuri_of_uri uri =
18 let index_sharp = String.index uri '#' in
19 let index_div = String.rindex uri '/' in
20 let index_con = index_div + 1 in
21 (UriManager.uri_of_string (String.sub uri 0 index_sharp),
23 (String.sub uri (index_sharp + 3) (index_div - index_sharp - 3)) - 1,
25 (String.sub uri index_con (String.length uri - index_con)))
27 (** {2 Helm's objects shorthands} *)
31 let eq_SURI = "cic:/Coq/Init/Logic/eq.ind"
32 let eq_URI = uri eq_SURI
33 let eq_XURI = eq_SURI ^ "#xpointer(1/1)"
34 let eq_ind_URI = uri "cic:/Coq/Init/Logic/eq_ind.con"
35 let eq_ind_r_URI = uri "cic:/Coq/Init/Logic/eq_ind_r.con"
36 let true_URI = uri "cic:/Coq/Init/Logic/True.ind"
37 let false_URI = uri "cic:/Coq/Init/Logic/False.ind"
38 let false_ind_URI = uri "cic:/Coq/Init/Logic/False_ind.con"
39 let ex_SURI = "cic:/Coq/Init/Logic/ex.ind"
40 let ex_URI = uri ex_SURI
41 let ex_XURI = ex_SURI ^ "#xpointer(1/1)"
42 let ex_ind_URI = uri "cic:/Coq/Init/Logic/ex_ind.con"
43 let and_SURI = "cic:/Coq/Init/Logic/and.ind"
44 let and_URI = uri and_SURI
45 let and_XURI = and_SURI ^ "#xpointer(1/1)"
46 let and_ind_URI = uri "cic:/Coq/Init/Logic/and_ind.con"
47 let or_SURI = "cic:/Coq/Init/Logic/or.ind"
48 let or_URI = uri or_SURI
49 let or_XURI = or_SURI ^ "#xpointer(1/1)"
50 let not_SURI = "cic:/Coq/Init/Logic/not.con"
51 let not_URI = uri not_SURI
52 let iff_SURI = "cic:/Coq/Init/Logic/iff.con"
53 let iff_URI = uri "cic:/Coq/Init/Logic/iff.con"
54 let sym_eq_URI = uri "cic:/Coq/Init/Logic/sym_eq.con"
55 let trans_eq_URI = uri "cic:/Coq/Init/Logic/trans_eq.con"
56 let absurd_URI = uri "cic:/Coq/Init/Logic/absurd.con"
61 let bool_URI = uri "cic:/Coq/Init/Datatypes/bool.ind"
62 let nat_URI = uri "cic:/Coq/Init/Datatypes/nat.ind"
64 let trueb = mutconstruct bool_URI 0 1
65 let falseb = mutconstruct bool_URI 0 2
66 let zero = mutconstruct nat_URI 0 1
67 let succ = mutconstruct nat_URI 0 2
72 let r_URI = uri "cic:/Coq/Reals/Rdefinitions/R.con"
73 let rplus_SURI = "cic:/Coq/Reals/Rdefinitions/Rplus.con"
74 let rplus_URI = uri rplus_SURI
75 let rminus_SURI = "cic:/Coq/Reals/Rdefinitions/Rminus.con"
76 let rminus_URI = uri rminus_SURI
77 let rmult_SURI = "cic:/Coq/Reals/Rdefinitions/Rmult.con"
78 let rmult_URI = uri rmult_SURI
79 let rdiv_SURI = "cic:/Coq/Reals/Rdefinitions/Rdiv.con"
80 let rdiv_URI = uri rdiv_SURI
81 let ropp_SURI = "cic:/Coq/Reals/Rdefinitions/Ropp.con"
82 let ropp_URI = uri ropp_SURI
83 let rinv_SURI = "cic:/Coq/Reals/Rdefinitions/Rinv.con"
84 let rinv_URI = uri rinv_SURI
85 let r0_SURI = "cic:/Coq/Reals/Rdefinitions/R0.con"
86 let r0_URI = uri r0_SURI
87 let r1_SURI = "cic:/Coq/Reals/Rdefinitions/R1.con"
88 let r1_URI = uri r1_SURI
89 let rle_SURI = "cic:/Coq/Reals/Rdefinitions/Rle.con"
90 let rle_URI = uri rle_SURI
91 let rge_SURI = "cic:/Coq/Reals/Rdefinitions/Rge.con"
92 let rge_URI = uri rge_SURI
93 let rlt_SURI = "cic:/Coq/Reals/Rdefinitions/Rlt.con"
94 let rlt_URI = uri rlt_SURI
95 let rgt_SURI = "cic:/Coq/Reals/Rdefinitions/Rgt.con"
96 let rgt_URI = uri rgt_SURI
97 let rtheory_URI = uri "cic:/Coq/Reals/RIneq/RTheory.con"
98 let rinv_r1_URI = uri "cic:/Coq/Reals/RIneq/Rinv_1.con"
99 let pow_URI = uri "cic:/Coq/Reals/Rfunctions/pow.con"
102 let rplus = const rplus_URI
103 let rmult = const rmult_URI
104 let ropp = const ropp_URI
105 let r0 = const r0_URI
106 let r1 = const r1_URI
107 let rtheory = const rtheory_URI
112 let plus_SURI = "cic:/Coq/Init/Peano/plus.con"
113 let plus_URI = uri plus_SURI
114 let minus_SURI = "cic:/Coq/Init/Peano/minus.con"
115 let minus_URI = uri minus_SURI
116 let mult_SURI = "cic:/Coq/Init/Peano/mult.con"
117 let mult_URI = uri mult_SURI
118 let pred_URI = uri "cic:/Coq/Init/Peano/pred.con"
119 let le_SURI = "cic:/Coq/Init/Peano/le.ind"
120 let le_URI = uri le_SURI
121 let le_XURI = le_SURI ^ "#xpointer(1/1)"
122 let ge_SURI = "cic:/Coq/Init/Peano/ge.con"
123 let ge_URI = uri ge_SURI
124 let lt_SURI = "cic:/Coq/Init/Peano/lt.con"
125 let lt_URI = uri lt_SURI
126 let gt_SURI = "cic:/Coq/Init/Peano/gt.con"
127 let gt_URI = uri gt_SURI
129 let plus = const plus_URI
130 let mult = const mult_URI
131 let pred = const pred_URI
136 let positive_SURI = "cic:/Coq/NArith/BinPos/positive.ind"
137 let positive_URI = uri positive_SURI
138 let xI = mutconstruct positive_URI 0 1
139 let xO = mutconstruct positive_URI 0 2
140 let xH = mutconstruct positive_URI 0 3
141 let pplus_SURI = "cic:/Coq/NArith/BinPos/Pplus.con"
142 let pplus_URI = uri pplus_SURI
143 let pplus = const pplus_URI
144 let pminus_SURI = "cic:/Coq/NArith/BinPos/Pminus.con"
145 let pminus_URI = uri pminus_SURI
146 let pminus = const pminus_URI
147 let pmult_SURI = "cic:/Coq/NArith/BinPos/Pmult.con"
148 let pmult_URI = uri pmult_SURI
149 let pmult = const pmult_URI
154 let zmult_URI = uri "cic:/Coq/ZArith/BinInt/Zmult.con"
155 let zmult = const zmult_URI
156 let zplus_SURI = "cic:/Coq/ZArith/BinInt/Zplus.con"
157 let zplus_URI = uri zplus_SURI
158 let zplus = const zplus_URI
159 let zminus_SURI = "cic:/Coq/ZArith/BinInt/Zminus.con"
160 let zminus_URI = uri zminus_SURI
161 let zminus = const zminus_URI
162 let z_SURI = "cic:/Coq/ZArith/BinInt/Z.ind"
163 let z_URI = uri z_SURI
164 let z0 = mutconstruct z_URI 0 1
165 let zpos = mutconstruct z_URI 0 2
166 let zneg = mutconstruct z_URI 0 3
167 let zopp_SURI = "cic:/Coq/ZArith/BinInt/Zopp.con"
168 let zopp_URI = uri zopp_SURI
169 let zopp = const zopp_URI
170 let zpower_URI = uri "cic:/Coq/ZArith/Zpower/Zpower.con"
173 (** {2 Helpers for creating common terms}
176 exception NegativeInteger
179 if n < 0 then raise NegativeInteger;
180 let rec aux = function
181 | 0 -> Datatypes.zero
182 | n -> Cic.Appl [ Datatypes.succ; (aux (n - 1)) ]
187 if n < 0 then raise NegativeInteger;
188 let rec aux = function
190 | 1 -> Reals.r1 (* to avoid trailing "+ 0" *)
191 | n -> Cic.Appl [ Reals.rplus; Reals.r1; (aux (n - 1)) ]
195 let build_bin_pos n =
196 if n < 1 then raise NegativeInteger;
197 let rec aux = function
199 | n when n mod 2 = 0 -> Cic.Appl [ BinPos.xO; aux (n / 2) ]
200 | n -> Cic.Appl [ BinPos.xI; aux (n / 2) ]