6 let convert_term uri n_fl t =
7 let rec convert_term k = function (* pass k along *)
8 | NCic.Rel i -> Cic.Rel i
9 | NCic.Meta _ -> assert false
10 | NCic.Appl l -> Cic.Appl (List.map (convert_term k) l)
11 | NCic.Prod (n,s,t) ->
12 Cic.Prod (nn_2_on n,convert_term k s, convert_term (k+1) t)
13 | NCic.Lambda (n,s,t) ->
14 Cic.Lambda(nn_2_on n,convert_term k s, convert_term (k+1) t)
15 | NCic.LetIn (n,_,s,t) ->
16 Cic.LetIn (nn_2_on n,convert_term k s, convert_term (k+1) t)
17 | NCic.Sort NCic.Prop -> Cic.Sort Cic.Prop
18 | NCic.Sort NCic.CProp -> Cic.Sort Cic.CProp
19 | NCic.Sort NCic.Set -> Cic.Sort Cic.Set
20 | NCic.Sort (NCic.Type _) -> Cic.Sort (Cic.Type (CicUniv.fresh ()))
21 | NCic.Implicit _ -> assert false
22 | NCic.Const (NReference.Ref (_,u,NReference.Ind i)) ->
23 Cic.MutInd (NUri.ouri_of_nuri u,i,[])
24 | NCic.Const (NReference.Ref (_,u,NReference.Con (i,j))) ->
25 Cic.MutConstruct (NUri.ouri_of_nuri u,i,j,[])
26 | NCic.Const (NReference.Ref (_,u,NReference.Def))
27 | NCic.Const (NReference.Ref (_,u,NReference.Decl)) ->
28 Cic.Const (NUri.ouri_of_nuri u,[])
29 | NCic.Match (NReference.Ref (_,u,NReference.Ind i),oty,t,pl) ->
30 Cic.MutCase (NUri.ouri_of_nuri u,i, convert_term k oty, convert_term k t,
31 List.map (convert_term k) pl)
32 | NCic.Const (NReference.Ref (_,u,NReference.Fix (i,_)))
33 | NCic.Const (NReference.Ref (_,u,NReference.CoFix i)) ->
35 Cic.Rel (n_fl - i + k)
37 let ouri = NUri.ouri_of_nuri u in
39 UriManager.uri_of_string
40 (UriManager.buri_of_uri ouri ^ "/" ^
41 UriManager.name_of_uri ouri ^ string_of_int i ^ ".con") in
48 let convert_fix is_fix uri k fl =
49 let n_fl = List.length fl in
53 (fun (_, name,recno,ty,bo) ->
54 name, recno, convert_term uri n_fl ty, convert_term uri n_fl bo)
61 (fun (_, name,_,ty,bo) ->
62 name, convert_term uri n_fl ty, convert_term uri n_fl bo)
68 let convert_nobj = function
69 | u,_,_,_,NCic.Constant (_, name, Some bo, ty, _) ->
70 [NUri.ouri_of_nuri u,Cic.Constant
71 (name, Some (convert_term u 0 bo), convert_term u 0 ty, [],[])]
72 | u,_,_,_,NCic.Constant (_, name, None, ty, _) ->
73 [NUri.ouri_of_nuri u,Cic.Constant (name, None, convert_term u 0 ty, [],[])]
74 | u,_,_,_,NCic.Fixpoint (is_fix, fl, _) ->
78 UriManager.name_of_uri (NUri.ouri_of_nuri u) ^ string_of_int nth in
79 let buri = UriManager.buri_of_uri (NUri.ouri_of_nuri u) in
80 let uri = UriManager.uri_of_string (buri ^"/"^name^".con") in
83 Some (convert_fix is_fix u nth fl),
84 convert_term u 0 (let _,_,_,ty,_ = List.hd fl in ty), [], []))
85 (let rec seq = function 0 -> [0]|n -> n::seq (n-1) in
86 seq (List.length fl-1))
87 | _,_,_,_,NCic.Inductive _ -> assert false