]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_kernel/nCicEnvironment.ml
e10aba9738e552f1b8f1bec57f650f14f1f8db06
[helm.git] / helm / software / components / ng_kernel / nCicEnvironment.ml
1 let cache = NUri.UriHash.create 313;;
2
3 let get_checked_obj u =
4   try NUri.UriHash.find cache u
5   with Not_found ->
6     let ouri = NUri.ouri_of_nuri u in
7     let o,_ = 
8       CicEnvironment.get_cooked_obj ~trust:false CicUniv.oblivion_ugraph 
9         ouri in
10     let no = OCic2NCic.convert_obj ouri o in
11     NUri.UriHash.add cache u no;
12     no
13 ;;
14
15 let get_checked_def = function
16   | NReference.Ref (_, uri, NReference.Def) ->
17       (match get_checked_obj uri with
18       | _,height,_,_, NCic.Constant (rlv,name,Some bo,ty,att) ->
19           rlv,name,bo,ty,att,height
20       | _,_,_,_, NCic.Constant (_,_,None,_,_) ->
21           prerr_endline "get_checked_def on an axiom"; assert false
22       | _ -> prerr_endline "get_checked_def on a non def 2"; assert false)
23   | _ -> prerr_endline "get_checked_def on a non def"; assert false
24 ;;
25
26 let get_checked_fix_or_cofix b = function
27   | NReference.Ref (_, uri, NReference.Fix (fixno,_)) ->
28       (match get_checked_obj uri with
29       | _,height,_,_, NCic.Fixpoint (is_fix,funcs,att) when is_fix = b ->
30          let rlv, name, _, ty, bo = List.nth funcs fixno in
31          rlv, name, bo, ty, att, height
32       | _ ->prerr_endline "get_checked_(co)fix on a non (co)fix 2";assert false)
33   | _ -> prerr_endline "get_checked_(co)fix on a non (co)fix"; assert false
34 ;;
35 let get_checked_fix r = get_checked_fix_or_cofix true r;;
36 let get_checked_cofix r = get_checked_fix_or_cofix false r;;
37
38 let get_indty_leftno = function 
39   | NReference.Ref (_, uri, NReference.Ind _) 
40   | NReference.Ref (_, uri, NReference.Con _) ->
41       (match get_checked_obj uri with
42       | _,_,_,_, NCic.Inductive (_,left,_,_) -> left
43       | _ ->prerr_endline "get_indty_leftno called on a non ind 2";assert false)
44   | _ -> prerr_endline "get_indty_leftno called on a non indty";assert false