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
23 let status = new P.status
26 failwith "probe: malformed term"
28 let rec set_list c ts cts =
29 let map cts t = (c, t) :: cts in
30 L.fold_left map cts ts
32 let set_funs c rfs cts =
33 let map cts (_, _, _, t0, t1) = set_list c [t0; t1] cts in
34 L.fold_left map cts rfs
36 let set_type c cts (_, _, t, css) =
37 let map cts (_, _, t) = (c, t) :: cts in
38 (c, t) :: L.fold_left map cts css
41 try match List.nth c (pred i) with
42 | _, C.Decl _ -> succ a
47 let scan_gref a = function
50 | R.Ref (_, R.Con _) -> succ a
53 | R.Ref (u, R.CoFix _) ->
54 if US.mem u !O.objs then a else succ a
56 let rec scan_term a = function
59 | (_, C.Implicit _) :: tl -> scan_term a tl
60 | (_, C.Sort _) :: tl -> scan_term (succ a) tl
61 | (c, C.Rel i) :: tl -> scan_term (scan_lref a c i) tl
62 | (_, C.Const p) :: tl -> scan_term (scan_gref a p) tl
63 | (_, C.Appl []) :: tl -> malformed ()
64 | (c, C.Appl ts) :: tl ->
65 scan_term (L.length ts + pred a) (set_list c ts tl)
66 | (c, C.Match (_, t0, t1, ts)) :: tl ->
67 scan_term a (set_list c (t0::t1::ts) tl)
68 | (c, C.Prod (s, t0, t1)) :: tl
69 | (c, C.Lambda (s, t0, t1)) :: tl ->
70 scan_term (succ a) ((c, t0) :: ((s, C.Decl t0) :: c, t1) :: tl)
71 | (c, C.LetIn (s, t0, t1, t2)) :: tl ->
72 scan_term a ((c, t0) :: (c, t1) :: ((s, C.Def (t1, t0)) :: c, t2) :: tl)
75 let _, _, _, _, obj = E.get_checked_obj status u in
77 | C.Constant (_, _, None, t, _) ->
78 scan_term (succ a) [[], t]
79 | C.Constant (_, _, Some t0, t1, _) ->
80 scan_term (succ a) (set_list [] [t0; t1] [])
81 | C.Fixpoint (_, rfs, _) ->
82 scan_term (a + L.length rfs) (set_funs [] rfs [])
83 | C.Inductive (_, _, its, _) ->
84 let cts = L.fold_left (set_type []) [] its in
85 scan_term (a + L.length cts) cts
88 let _, _, _, _, obj = E.get_checked_obj status u in
89 let g = match obj with
90 | C.Constant (_, _, _, _, (g, _, _))
91 | C.Fixpoint (_, _, (g, _, _))
92 | C.Inductive (_, _, _, (g, _)) -> g
94 if L.mem g !O.exclude then false else true
97 if !O.exclude <> [] then
98 O.objs := US.filter accept_obj !O.objs;
99 O.net := US.fold scan_obj !O.objs !O.net