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,ty_s,s,t) ->
16 Cic.LetIn (nn_2_on n,convert_term k s,convert_term k ty_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.Type _) -> Cic.Sort (Cic.Type (CicUniv.fresh ()))
20 | NCic.Implicit _ -> assert false
21 | NCic.Const (NReference.Ref (_,u,NReference.Ind i)) ->
22 Cic.MutInd (NUri.ouri_of_nuri u,i,[])
23 | NCic.Const (NReference.Ref (_,u,NReference.Con (i,j))) ->
24 Cic.MutConstruct (NUri.ouri_of_nuri u,i,j,[])
25 | NCic.Const (NReference.Ref (_,u,NReference.Def))
26 | NCic.Const (NReference.Ref (_,u,NReference.Decl)) ->
27 Cic.Const (NUri.ouri_of_nuri u,[])
28 | NCic.Match (NReference.Ref (_,u,NReference.Ind i),oty,t,pl) ->
29 Cic.MutCase (NUri.ouri_of_nuri u,i, convert_term k oty, convert_term k t,
30 List.map (convert_term k) pl)
31 | NCic.Const (NReference.Ref (_,u,NReference.Fix (i,_)))
32 | NCic.Const (NReference.Ref (_,u,NReference.CoFix i)) ->
34 Cic.Rel (n_fl - i + k)
36 let ouri = NUri.ouri_of_nuri u in
38 UriManager.uri_of_string
39 (UriManager.buri_of_uri ouri ^ "/" ^
40 UriManager.name_of_uri ouri ^ string_of_int i ^ ".con") in
47 let convert_fix is_fix uri k fl =
48 let n_fl = List.length fl in
52 (fun (_, name,recno,ty,bo) ->
53 name, recno, convert_term uri n_fl ty, convert_term uri n_fl bo)
60 (fun (_, name,_,ty,bo) ->
61 name, convert_term uri n_fl ty, convert_term uri n_fl bo)
67 let convert_nobj = function
68 | u,_,_,_,NCic.Constant (_, name, Some bo, ty, _) ->
69 [NUri.ouri_of_nuri u,Cic.Constant
70 (name, Some (convert_term u 0 bo), convert_term u 0 ty, [],[])]
71 | u,_,_,_,NCic.Constant (_, name, None, ty, _) ->
72 [NUri.ouri_of_nuri u,Cic.Constant (name, None, convert_term u 0 ty, [],[])]
73 | u,_,_,_,NCic.Fixpoint (is_fix, fl, _) ->
77 UriManager.name_of_uri (NUri.ouri_of_nuri u) ^ string_of_int nth in
78 let buri = UriManager.buri_of_uri (NUri.ouri_of_nuri u) in
79 let uri = UriManager.uri_of_string (buri ^"/"^name^".con") in
82 Some (convert_fix is_fix u nth fl),
83 convert_term u 0 (let _,_,_,ty,_ = List.hd fl in ty), [], []))
84 (let rec seq = function 0 -> [0]|n -> n::seq (n-1) in
85 seq (List.length fl-1))
86 | _,_,_,_,NCic.Inductive _ -> assert false