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 nn_2_on = function
19 | "_" -> Cic.Anonymous
23 let convert_term uri n_fl t =
24 let rec convert_term k = function (* pass k along *)
25 | NCic.Rel i -> Cic.Rel i
26 | NCic.Meta _ -> assert false
27 | NCic.Appl l -> Cic.Appl (List.map (convert_term k) l)
28 | NCic.Prod (n,s,t) ->
29 Cic.Prod (nn_2_on n,convert_term k s, convert_term (k+1) t)
30 | NCic.Lambda (n,s,t) ->
31 Cic.Lambda(nn_2_on n,convert_term k s, convert_term (k+1) t)
32 | NCic.LetIn (n,ty_s,s,t) ->
33 Cic.LetIn (nn_2_on n,convert_term k s,convert_term k ty_s, convert_term (k+1) t)
34 | NCic.Sort NCic.Prop -> Cic.Sort Cic.Prop
35 | NCic.Sort NCic.CProp -> Cic.Sort Cic.CProp
36 | NCic.Sort (NCic.Type _) -> Cic.Sort (Cic.Type (CicUniv.fresh ()))
37 | NCic.Implicit _ -> assert false
38 | NCic.Const (NReference.Ref (_,u,NReference.Ind (_,i))) ->
39 Cic.MutInd (ouri_of_nuri u,i,[])
40 | NCic.Const (NReference.Ref (_,u,NReference.Con (i,j))) ->
41 Cic.MutConstruct (ouri_of_nuri u,i,j,[])
42 | NCic.Const (NReference.Ref (_,u,NReference.Def))
43 | NCic.Const (NReference.Ref (_,u,NReference.Decl)) ->
44 Cic.Const (ouri_of_nuri u,[])
45 | NCic.Match (NReference.Ref (_,u,NReference.Ind (_,i)),oty,t,pl) ->
46 Cic.MutCase (ouri_of_nuri u,i, convert_term k oty, convert_term k t,
47 List.map (convert_term k) pl)
48 | NCic.Const (NReference.Ref (_,u,NReference.Fix (i,_)))
49 | NCic.Const (NReference.Ref (_,u,NReference.CoFix i)) ->
51 Cic.Rel (n_fl - i + k)
53 let ouri = ouri_of_nuri u in
55 UriManager.uri_of_string
56 (UriManager.buri_of_uri ouri ^ "/" ^
57 UriManager.name_of_uri ouri ^ string_of_int i ^ ".con") in
64 let convert_fix is_fix uri k fl =
65 let n_fl = List.length fl in
69 (fun (_, name,recno,ty,bo) ->
70 name, recno, convert_term uri n_fl ty, convert_term uri n_fl bo)
77 (fun (_, name,_,ty,bo) ->
78 name, convert_term uri n_fl ty, convert_term uri n_fl bo)
84 let convert_nobj = function
85 | u,_,_,_,NCic.Constant (_, name, Some bo, ty, _) ->
86 [ouri_of_nuri u,Cic.Constant
87 (name, Some (convert_term u 0 bo), convert_term u 0 ty, [],[])]
88 | u,_,_,_,NCic.Constant (_, name, None, ty, _) ->
89 [ouri_of_nuri u,Cic.Constant (name, None, convert_term u 0 ty, [],[])]
90 | u,_,_,_,NCic.Fixpoint (is_fix, fl, _) ->
94 UriManager.name_of_uri (ouri_of_nuri u) ^ string_of_int nth in
95 let buri = UriManager.buri_of_uri (ouri_of_nuri u) in
96 let uri = UriManager.uri_of_string (buri ^"/"^name^".con") in
99 Some (convert_fix is_fix u nth fl),
100 convert_term u 0 (let _,_,_,ty,_ = List.hd fl in ty), [], []))
101 (let rec seq = function 0 -> [0]|n -> n::seq (n-1) in
102 seq (List.length fl-1))
103 | _,_,_,_,NCic.Inductive _ -> assert false