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 ~not_jet_cooked:true u
49 CicUniv.empty_ugraph))
50 | C.MutInd (u,_,exp_named_subst) ->
51 if List.mem u !don || eq u uri then
56 (match fst(CicEnvironment.get_obj ~not_jet_cooked:true u
59 | C.InductiveDefinition (l,_,_) ->
64 fun x (_,t) -> x @ (aux t) )
67 | _ -> assert false) @
68 List.fold_left (fun x (uri,t) -> x @ (aux t) ) [] exp_named_subst
70 | C.MutConstruct (u,_,_,exp_named_subst) ->
71 if List.mem u !don || eq u uri then
76 (match fst(CicEnvironment.get_obj ~not_jet_cooked:true u
77 CicUniv.empty_ugraph) with
78 | C.InductiveDefinition (l,_,_) ->
83 fun y (_,t) -> y @ (aux t) )
86 | _ -> assert false) @
87 List.fold_left (fun x (uri,t) -> x @ (aux t) ) [] exp_named_subst
93 Some t' -> x @ (aux t')
96 | C.Sort ( C.Type i) -> [i]
104 | C.Lambda (b,s,t) ->
109 List.fold_left (fun x t -> x @ (aux t)) [] li
110 | C.MutCase (uri,n1,ty,te,patterns) ->
112 (List.fold_left (fun x t -> x @ (aux t)) [] patterns)
113 | C.Fix (no, funs) ->
114 List.fold_left (fun x (_,_,b,c) -> x @ (aux b) @ (aux c)) [] funs
115 | C.CoFix (no,funs) ->
116 List.fold_left (fun x (_,b,c) -> x @ (aux b) @ (aux c)) [] funs
117 and aux_obj ?(boo=false) (t,_) =
119 C.Constant (_,Some te,ty,v) -> aux te @ aux ty @
122 l @ if eq u uri then [] else
123 (aux_obj (CicEnvironment.get_obj ~not_jet_cooked:true u
124 CicUniv.empty_ugraph)))
126 | C.Constant (_,None,ty,v) -> aux ty @
129 l @ if eq u uri then [] else
130 (aux_obj (CicEnvironment.get_obj ~not_jet_cooked:true u
131 CicUniv.empty_ugraph)))
133 | C.CurrentProof (_,conjs,te,ty,v) -> aux te @ aux ty @
136 l @ if eq u uri then [] else
137 (aux_obj (CicEnvironment.get_obj ~not_jet_cooked:true u
138 CicUniv.empty_ugraph)))
140 | C.Variable (_,Some bo,ty,v) -> aux bo @ aux ty @
143 l @ if eq u uri then [] else
144 (aux_obj (CicEnvironment.get_obj ~not_jet_cooked:true u
145 CicUniv.empty_ugraph)))
147 | C.Variable (_,None ,ty,v) -> aux ty @
150 l @ if eq u uri then [] else
151 (aux_obj (CicEnvironment.get_obj ~not_jet_cooked:true u
152 CicUniv.empty_ugraph)))
154 | C.InductiveDefinition (l,v,_) ->
157 x @ aux t @ List.fold_left (
158 fun y (_,t) -> y @ aux t)
163 l @ if eq u uri then [] else
164 (aux_obj (CicEnvironment.get_obj ~not_jet_cooked:true u
165 CicUniv.empty_ugraph)))
169 aux_obj (t,CicUniv.empty_ugraph)
171 let clean_and_fill uri obj ugraph =
172 let list_of_universes = universes_of_obj uri obj in
173 let ugraph = CicUniv.clean_ugraph ugraph list_of_universes in
174 let ugraph = CicUniv.fill_empty_nodes_with_uri ugraph uri in