1 let convert_term = Obj.magic;;
8 let rec convert_fix_definition acc = function
9 | Cic.Lambda (n,s,t) ->
10 convert_fix_definition ((n,s)::acc) t
11 | Cic.Fix (_, [name,rno,ty,bo]) ->
12 let acc = List.map (fun (n,s) -> cn_to_s n, convert_term s) acc in
13 let ty = convert_term ty in
14 let bo = convert_term bo in
15 Some (true,[[],name,rno,
16 List.fold_right (fun (n,s) acc -> NCic.Prod(n,s,acc)) acc ty,
17 List.fold_right (fun (n,s) acc -> NCic.Lambda(n,s,acc)) acc bo])
18 | Cic.CoFix (_, [name,ty,bo]) ->
19 let acc = List.map (fun (n,s) -> cn_to_s n, convert_term s) acc in
20 let ty = convert_term ty in
21 let bo = convert_term bo in
22 Some (false,[[],name,0,
23 List.fold_right (fun (n,s) acc -> NCic.Prod(n,s,acc)) acc ty,
24 List.fold_right (fun (n,s) acc -> NCic.Lambda(n,s,acc)) acc bo])
28 let convert_obj_aux = function
29 | Cic.Constant (name, None, ty, _, _) ->
30 NCic.Constant ([], name, None, convert_term ty,
31 (`Provided,`Theorem,`Regular))
32 | Cic.Constant (name, Some bo, ty, _, _) ->
33 (match convert_fix_definition [] bo with
35 NCic.Constant ([], name, Some (convert_term bo), convert_term ty,
36 (`Provided,`Theorem,`Regular))
37 | Some (recursive, ifl) ->
38 NCic.Fixpoint (recursive, ifl, (`Provided, `Definition)))
39 | Cic.InductiveDefinition (itl,_,leftno,_) ->
40 let ind = let _,x,_,_ = List.hd itl in x in
43 (fun name, _, ty, cl ->
44 [], name, convert_term ty,
45 List.map (fun name, ty -> [], name, convert_term ty) cl)
48 NCic.Inductive (ind, leftno, itl, (`Provided, `Regular))
50 | Cic.CurrentProof _ -> assert false
53 let convert_obj uri obj = NUri.nuri_of_ouri uri,0, [], [], convert_obj_aux obj;;