1 (* Copyright (C) 2002, 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/.
27 Saturation.active_table * Saturation.passive_table * Equality.equality_bag
30 univ : Universe.universe;
31 tables : Saturation.active_table *
32 Saturation.passive_table *
33 Equality.equality_bag;
37 Saturation.make_active [],
38 Saturation.make_passive [],
39 Equality.mk_equality_bag ()
43 univ = Universe.empty;
44 tables = empty_tables ();
47 let pump cache steps =
48 let active, passive, bag = cache.tables in
49 let active, passive, bag =
50 Saturation.pump_actives
51 [] bag active passive steps infinity
53 let tables = active, passive, bag in
54 { cache with tables = tables }
57 let add_term_to_active cache metasenv subst context t ty_opt =
58 let actives, passives, bag = cache.tables in
59 let bag, metasenv, head, t, args, mes, ugraph =
62 bag, metasenv, ty, t, [], (CicUtil.metas_of_term (Cic.Appl [t;ty])),
63 CicUniv.oblivion_ugraph
66 CicTypeChecker.type_of_aux'
67 ~subst metasenv context t CicUniv.oblivion_ugraph
69 let bag, head, metasenv, args =
70 Equality.saturate_term bag metasenv subst context ty
72 let mes = CicUtil.metas_of_term (Cic.Appl (head::t::args)) in
73 let t = if args = [] then t else Cic.Appl (t:: args) in
74 bag, metasenv, head, t, args, mes, ugraph
80 let _,mc, mt = CicUtil.lookup_meta i metasenv in
82 CicTypeChecker.type_of_aux' metasenv mc mt ugraph
84 fst (CicReduction.are_convertible mc sort (Cic.Sort Cic.Prop) u)
86 | CicUtil.Meta_not_found _ -> false)
92 let env = metasenv, context, CicUniv.oblivion_ugraph in
94 List.filter (fun (i,_,_) -> List.mem_assoc i mes) metasenv
97 Saturation.add_to_active bag actives passives env head t newmetas
99 { cache with tables = tables }
103 prerr_endline "Automation cache";
104 prerr_endline "----------------------------------------------";
105 prerr_endline "universe:";
106 Universe.iter cache.univ (fun _ ts ->
108 String.concat "\n " (List.map CicPp.ppterm ts)));
109 prerr_endline "tables/actives:";
110 let active, passive, _ = cache.tables in
112 (fun e -> prerr_endline (" " ^ Equality.string_of_equality e))
113 (Saturation.list_of_active active);
114 prerr_endline "tables/passives:";
116 (fun e -> prerr_endline (" " ^ Equality.string_of_equality e))
117 (Saturation.list_of_passive passive);
118 prerr_endline "----------------------------------------------";