2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
14 let ouri_of_nuri u = UriManager.uri_of_string (NUri.string_of_uri u);;
16 let ouri_of_reference (NReference.Ref (u,_)) = ouri_of_nuri u;;
18 let cprop = [false, NUri.uri_of_string ("cic:/matita/pts/CProp.univ")];;
20 let nn_2_on = function
21 | "_" -> Cic.Anonymous
25 let convert_term uri n_fl t =
26 let rec convert_term k = function (* pass k along *)
27 | NCic.Rel i -> Cic.Rel i
28 | NCic.Meta _ -> assert false
29 | NCic.Appl l -> Cic.Appl (List.map (convert_term k) l)
30 | NCic.Prod (n,s,t) ->
31 Cic.Prod (nn_2_on n,convert_term k s, convert_term (k+1) t)
32 | NCic.Lambda (n,s,t) ->
33 Cic.Lambda(nn_2_on n,convert_term k s, convert_term (k+1) t)
34 | NCic.LetIn (n,ty_s,s,t) ->
35 Cic.LetIn (nn_2_on n,convert_term k s,convert_term k ty_s, convert_term (k+1) t)
36 | NCic.Sort NCic.Prop -> Cic.Sort Cic.Prop
37 | NCic.Sort (NCic.Type u) when
38 (* BUG HERE: I should use NCicEnvironment.universe_eq, but I do not
39 want to add this recursion between the modules *)
40 (*NCicEnvironment.universe_eq*) u=cprop -> Cic.Sort (Cic.CProp (CicUniv.fresh ()))
41 | NCic.Sort (NCic.Type _) -> Cic.Sort (Cic.Type (CicUniv.fresh ()))
42 | NCic.Implicit _ -> assert false
43 | NCic.Const (NReference.Ref (u,NReference.Ind (_,i,_))) ->
44 Cic.MutInd (ouri_of_nuri u,i,[])
45 | NCic.Const (NReference.Ref (u,NReference.Con (i,j,_))) ->
46 Cic.MutConstruct (ouri_of_nuri u,i,j,[])
47 | NCic.Const (NReference.Ref (u,NReference.Def _))
48 | NCic.Const (NReference.Ref (u,NReference.Decl)) ->
49 Cic.Const (ouri_of_nuri u,[])
50 | NCic.Match (NReference.Ref (u,NReference.Ind (_,i,_)),oty,t,pl) ->
51 Cic.MutCase (ouri_of_nuri u,i, convert_term k oty, convert_term k t,
52 List.map (convert_term k) pl)
53 | NCic.Const (NReference.Ref (u,NReference.Fix (i,_,_)))
54 | NCic.Const (NReference.Ref (u,NReference.CoFix i)) ->
56 Cic.Rel (n_fl - i + k)
58 let ouri = ouri_of_nuri u in
60 UriManager.uri_of_string
61 (UriManager.buri_of_uri ouri ^ "/" ^
62 UriManager.name_of_uri ouri ^ string_of_int i ^ ".con") in
69 let convert_fix is_fix uri k fl =
70 let n_fl = List.length fl in
74 (fun (_, name,recno,ty,bo) ->
75 name, recno, convert_term uri n_fl ty, convert_term uri n_fl bo)
82 (fun (_, name,_,ty,bo) ->
83 name, convert_term uri n_fl ty, convert_term uri n_fl bo)
89 let convert_nobj = function
90 | u,_,_,_,NCic.Constant (_, name, Some bo, ty, _) ->
91 [ouri_of_nuri u,Cic.Constant
92 (name, Some (convert_term u 0 bo), convert_term u 0 ty, [],[])]
93 | u,_,_,_,NCic.Constant (_, name, None, ty, _) ->
94 [ouri_of_nuri u,Cic.Constant (name, None, convert_term u 0 ty, [],[])]
95 | u,_,_,_,NCic.Fixpoint (is_fix, fl, _) ->
99 UriManager.name_of_uri (ouri_of_nuri u) ^ string_of_int nth in
100 let buri = UriManager.buri_of_uri (ouri_of_nuri u) in
101 let uri = UriManager.uri_of_string (buri ^"/"^name^".con") in
104 Some (convert_fix is_fix u nth fl),
105 convert_term u 0 (let _,_,_,ty,_ = List.hd fl in ty), [], []))
106 (let rec seq = function 0 -> [0]|n -> n::seq (n-1) in
107 seq (List.length fl-1))
108 | u,_,_,_,NCic.Inductive (inductive,leftno,itl,_) ->
111 (function (_,name,ty,cl) ->
112 let cl=List.map (function (_,name,ty) -> name,convert_term u 0 ty) cl in
113 name,inductive,convert_term u 0 ty,cl
116 [ouri_of_nuri u, Cic.InductiveDefinition (itl,[],leftno,[])]