1 (* Copyright (C) 2003-2005, 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 module UM = UriManager
33 module S = Set.Make (Int)
36 let predicate x = S.mem x s1 in
39 let get_rels_from_premise h t =
40 let rec aux d g = function
44 if i < d then g else fun a -> g (S.add (i - d + h + 1) a)
45 | C.Appl ss -> List.fold_left (aux d) g ss
48 | C.MutConstruct (_, _, _, ss)
50 let map g (_, t) = aux d g t in
51 List.fold_left map g ss
57 List.fold_left map g ss
58 | C.Cast (t1, t2) -> aux d (aux d g t2) t1
60 | C.Lambda (_, t1, t2)
61 | C.Prod (_, t1, t2) -> aux d (aux (succ d) g t2) t1
62 | C.MutCase (_, _, t1, t2, ss) ->
63 aux d (aux d (List.fold_left (aux d) g ss) t2) t1
65 let k = List.length ss in
66 let map g (_, _, t1, t2) = aux d (aux (d + k) g t2) t1 in
67 List.fold_left map g ss
69 let k = List.length ss in
70 let map g (_, t1, t2) = aux d (aux (d + k) g t2) t1 in
71 List.fold_left map g ss
76 let get_mutinds_of_uri u t =
77 let rec aux g = function
81 | C.Appl ss -> List.fold_left aux g ss
83 | C.MutConstruct (_, _, _, ss)
85 let map g (_, t) = aux g t in
86 List.fold_left map g ss
87 | C.MutInd (uri, tyno, ss) ->
88 let map g (_, t) = aux g t in
89 let g = List.fold_left map g ss in
90 if UM.eq u uri then fun a -> g (S.add tyno a) else g
96 List.fold_left map g ss
97 | C.Cast (t1, t2) -> aux (aux g t2) t1
99 | C.Lambda (_, t1, t2)
100 | C.Prod (_, t1, t2) -> aux (aux g t2) t1
101 | C.MutCase (_, _, t1, t2, ss) ->
102 aux (aux (List.fold_left aux g ss) t2) t1
104 let map g (_, _, t1, t2) = aux (aux g t2) t1 in
105 List.fold_left map g ss
107 let map g (_, t1, t2) = aux (aux g t2) t1 in
108 List.fold_left map g ss