1 (* Copyright (C) 2000, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (*****************************************************************************)
30 (* Enrico Tassi <tassi@cs.unibo.it> *)
33 (* This module implements some useful function regarding univers graphs *)
35 (*****************************************************************************)
37 (* uri is the uri of the actual object that must be 'skipped' *)
38 let universes_of_obj uri t =
39 let eq = UriManager.eq in
44 C.Const (u,exp_named_subst)
45 | C.Var (u,exp_named_subst) ->
46 if List.mem u !don then [] else
48 aux_obj (CicEnvironment.get_obj CicUniv.empty_ugraph u))
49 | C.MutInd (u,_,exp_named_subst) ->
50 if List.mem u !don || eq u uri then
55 (match fst(CicEnvironment.get_obj CicUniv.empty_ugraph u)
57 | C.InductiveDefinition (l,_,_,_) ->
62 fun x (_,t) -> x @ (aux t) )
65 | _ -> assert false) @
66 List.fold_left (fun x (uri,t) -> x @ (aux t) ) [] exp_named_subst
68 | C.MutConstruct (u,_,_,exp_named_subst) ->
69 if List.mem u !don || eq u uri then
74 (match fst(CicEnvironment.get_obj CicUniv.empty_ugraph u) with
75 | C.InductiveDefinition (l,_,_,_) ->
80 fun y (_,t) -> y @ (aux t) )
83 | _ -> assert false) @
84 List.fold_left (fun x (uri,t) -> x @ (aux t) ) [] exp_named_subst
90 Some t' -> x @ (aux t')
93 | C.Sort ( C.Type i) -> [i]
101 | C.Lambda (b,s,t) ->
106 List.fold_left (fun x t -> x @ (aux t)) [] li
107 | C.MutCase (uri,n1,ty,te,patterns) ->
109 (List.fold_left (fun x t -> x @ (aux t)) [] patterns)
110 | C.Fix (no, funs) ->
111 List.fold_left (fun x (_,_,b,c) -> x @ (aux b) @ (aux c)) [] funs
112 | C.CoFix (no,funs) ->
113 List.fold_left (fun x (_,b,c) -> x @ (aux b) @ (aux c)) [] funs
114 and aux_obj ?(boo=false) (t,_) =
116 C.Constant (_,Some te,ty,v,_) -> aux te @ aux ty @
119 l @ if eq u uri then [] else
120 (aux_obj (CicEnvironment.get_obj CicUniv.empty_ugraph u)))
122 | C.Constant (_,None,ty,v,_) -> aux ty @
125 l @ if eq u uri then [] else
126 (aux_obj (CicEnvironment.get_obj CicUniv.empty_ugraph u)))
128 | C.CurrentProof (_,conjs,te,ty,v,_) -> aux te @ aux ty @
131 l @ if eq u uri then [] else
132 (aux_obj (CicEnvironment.get_obj CicUniv.empty_ugraph u)))
134 | C.Variable (_,Some bo,ty,v,_) -> aux bo @ aux ty @
137 l @ if eq u uri then [] else
138 (aux_obj (CicEnvironment.get_obj CicUniv.empty_ugraph u)))
140 | C.Variable (_,None ,ty,v,_) -> aux ty @
143 l @ if eq u uri then [] else
144 (aux_obj (CicEnvironment.get_obj CicUniv.empty_ugraph u)))
146 | C.InductiveDefinition (l,v,_,_) ->
149 x @ aux t @ List.fold_left (
150 fun y (_,t) -> y @ aux t)
155 l @ if eq u uri then [] else
156 (aux_obj (CicEnvironment.get_obj CicUniv.empty_ugraph u)))
160 aux_obj (t,CicUniv.empty_ugraph)
162 let clean_and_fill uri obj ugraph =
163 let list_of_universes = universes_of_obj uri obj in
164 let ugraph = CicUniv.clean_ugraph ugraph list_of_universes in
165 let ugraph = CicUniv.fill_empty_nodes_with_uri ugraph uri in