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 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
33 (* Missing description *)
35 (******************************************************************************)
47 let soften_classification =
49 Backbone _ -> InConclusion
50 | Branch _ -> InHypothesis
56 Backbone n -> `MainConclusion (Some n)
57 | Branch n -> `MainHypothesis (Some n)
63 Backbone n -> `MainConclusion (Some n)
64 | Branch n -> `MainHypothesis (Some n)
65 | InConclusion -> `InConclusion
66 | InHypothesis -> `InHypothesis
70 let (@@) (l1,l2,l3) (l1',l2',l3') =
72 List.fold_left (fun i t -> if List.mem t l2 then i else t::i) l2 l1
74 merge l1 l1', merge l2 l2', merge l3 l3'
77 let get_constraints term =
78 let module U = UriManager in
80 let rec process_type_aux kind =
82 C.Var (uri,expl_named_subst) ->
83 (* andrea: this is a bug: variable are not indexedin the db
84 ([!!!kind, UriManager.string_of_uri uri],[],[]) @@ *)
85 (process_type_aux_expl_named_subst kind expl_named_subst)
89 | InHypothesis -> [],[],[]
90 | _ -> [],[!!kind],[])
99 | Cic.Type _ -> T.Type (* TASSI: ?? *)
100 | Cic.CProp -> T.CProp
104 | C.Meta _ -> [],[],[] (* ???? To be understood *)
105 | C.Implicit _ -> assert false
108 process_type_aux kind te
109 | C.Prod (_,sou,ta) ->
110 let (source_kind,target_kind) =
112 Backbone n -> (Branch 0, Backbone (n+1))
113 | Branch n -> (InHypothesis, Branch (n+1))
116 process_type_aux source_kind sou @@
117 process_type_aux target_kind ta
118 | C.Lambda (_,sou,ta) ->
119 let kind' = soften_classification kind in
120 process_type_aux kind' sou @@
121 process_type_aux kind' ta
122 | C.LetIn (_,te,ta)->
123 let kind' = soften_classification kind in
124 process_type_aux kind' te @@
125 process_type_aux kind ta
127 let kind' = soften_classification kind in
128 process_type_aux kind he @@
129 List.fold_left (fun i t -> i @@ process_type_aux kind' t) ([],[],[]) tl
130 | C.Appl _ -> assert false
132 [!!!kind, UriManager.string_of_uri uri],[],[]
133 | C.MutInd (uri,typeno,expl_named_subst) ->
134 ([!!!kind, U.string_of_uri uri ^ "#xpointer(1/" ^
135 string_of_int (typeno + 1) ^ ")"],[],[]) @@
136 (process_type_aux_expl_named_subst kind expl_named_subst)
137 | C.MutConstruct (uri,typeno,consno,expl_named_subst) ->
138 ([!!!kind, U.string_of_uri uri ^ "#xpointer(1/" ^
139 string_of_int (typeno + 1) ^ "/" ^ string_of_int consno ^ ")"],[],[])
140 @@ (process_type_aux_expl_named_subst kind expl_named_subst)
141 | C.MutCase (_,_,_,term,patterns) ->
142 (* outtype ignored *)
143 let kind' = soften_classification kind in
144 process_type_aux kind' term @@
145 List.fold_left (fun i t -> i @@ process_type_aux kind' t)
148 let kind' = soften_classification kind in
150 (fun i (_,_,bo,ty) ->
152 process_type_aux kind' bo @@
153 process_type_aux kind' ty
155 | C.CoFix (_,funs) ->
156 let kind' = soften_classification kind in
160 process_type_aux kind' bo @@
161 process_type_aux kind' ty
163 and process_type_aux_expl_named_subst kind =
165 (fun i (_,t) -> i @@ (process_type_aux (soften_classification kind) t))
168 let obj_constraints,rel_constraints,sort_constraints =
169 process_type_aux (Backbone 0) (CicMiniReduction.letin_nf term)
171 (obj_constraints,rel_constraints,sort_constraints)
174 (*CSC: Debugging only *)
176 let get_constraints term =
177 let res = get_constraints term in
178 let (objs,rels,sorts) = res in
180 U.text_of_position p ^ " " ^ U.text_of_depth p "NULL"
182 prerr_endline "Constraints on objs:" ;
184 (function (p, u) -> prerr_endline (text_of_pos p ^ " " ^ u)) objs ;
185 prerr_endline "Constraints on Rels:" ;
186 List.iter (function p -> prerr_endline (text_of_pos (p:>T.full_position))) rels ;
187 prerr_endline "Constraints on Sorts:" ;
189 (function (p, s) -> prerr_endline (text_of_pos (p:>T.full_position) ^ " " ^ U.text_of_sort s)
195 [T.MainHypothesis; T.InHypothesis; T.MainConclusion; T.InConclusion]