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_______________________________________________________________ *)
19 module E = NCicEnvironment
24 (* current complexity *)
30 let status = new P.status
33 failwith "probe: malformed term"
36 let u = U.uri_of_string str in
37 if US.mem u !O.names then Printf.eprintf "probe: name clash: %S\n" str;
38 O.names := US.add u !O.names
40 let add_attr n (_, xf, _) = O.add_xflavour n (xf:>O.def_xflavour)
42 let add_ind n = O.add_xflavour n `Inductive
44 let rec set_list c ts cts =
45 let map cts t = (c, t) :: cts in
46 L.fold_left map cts ts
48 let set_funs c rfs cts =
49 let map cts (_, s, _, t0, t1) =
51 set_list c [t0; t1] cts
53 L.fold_left map cts rfs
55 let set_type c cts (_, s, t, css) =
56 let map cts (_, s, t) = add_name s; (c, t) :: cts in
57 add_name s; (c, t) :: L.fold_left map cts css
59 let inc st = {st with c = succ st.c}
61 let add st c = {st with c = st.c + c}
63 let scan_lref st c i =
64 try match List.nth c (pred i) with
65 | _, C.Decl _ -> inc st
70 let scan_gref st = function
73 | R.Ref (u, R.Con _) ->
78 | R.Ref (u, R.CoFix _) ->
80 if US.mem u !O.objs then st else inc st
82 let rec scan_term st = function
85 | (_, C.Implicit _) :: tl -> scan_term st tl
86 | (_, C.Sort _) :: tl -> scan_term (inc st) tl
87 | (c, C.Rel i) :: tl -> scan_term (scan_lref st c i) tl
88 | (_, C.Const p) :: tl -> scan_term (scan_gref st p) tl
89 | (_, C.Appl []) :: tl -> malformed ()
90 | (c, C.Appl ts) :: tl ->
91 scan_term (add st (pred (L.length ts))) (set_list c ts tl)
92 | (c, C.Match (_, t0, t1, ts)) :: tl ->
93 scan_term st (set_list c (t0::t1::ts) tl)
94 | (c, C.Prod (s, t0, t1)) :: tl
95 | (c, C.Lambda (s, t0, t1)) :: tl ->
96 scan_term (inc st) ((c, t0) :: ((s, C.Decl t0) :: c, t1) :: tl)
97 | (c, C.LetIn (s, t0, t1, t2)) :: tl ->
98 scan_term st ((c, t0) :: (c, t1) :: ((s, C.Def (t1, t0)) :: c, t2) :: tl)
102 let _, _, _, _, obj = E.get_checked_obj status u in
103 let st = match obj with
104 | C.Constant (_, s, None, t, m) ->
105 add_name s; add_attr 1 m;
106 scan_term (inc st) [[], t]
107 | C.Constant (_, s, Some t0, t1, m) ->
108 add_name s; add_attr 1 m;
109 scan_term (inc st) (set_list [] [t0; t1] [])
110 | C.Fixpoint (_, rfs, m) ->
111 add_attr (L.length rfs) m;
112 scan_term (add st (L.length rfs)) (set_funs [] rfs [])
113 | C.Inductive (_, _, its, _) ->
114 add_ind (L.length its);
115 let cts = L.fold_left (set_type []) [] its in
116 scan_term (add st (L.length cts)) cts
121 let _, _, _, _, obj = E.get_checked_obj status u in
122 let g = match obj with
123 | C.Constant (_, _, _, _, (g, _, _))
124 | C.Fixpoint (_, _, (g, _, _))
125 | C.Inductive (_, _, _, (g, _)) -> g
127 if L.mem g !O.exclude then false else true
130 if !O.exclude <> [] then
131 O.objs := US.filter accept_obj !O.objs;
132 O.net := US.fold scan_obj !O.objs !O.net