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 (* TODO se ce n'e' piu' di una, prende la prima che trova... sarebbe meglio
28 chiedere: find dovrebbe restituire una lista di hyp (?) da passare all'utonto con una
29 funzione di callback che restituisce la (sola) hyp da applicare *)
32 let module PET = ProofEngineTypes in
33 let assumption_tac status =
34 let (proof, goal) = status in
36 let module R = CicReduction in
37 let module S = CicSubstitution in
38 let module PT = PrimitiveTactics in
39 let _,metasenv,_,_ = proof in
40 let _,context,ty = CicUtil.lookup_meta goal metasenv in
41 let rec find n = function
44 (Some (_, C.Decl t)) when
45 fst (R.are_convertible context (S.lift n t) ty
46 CicUniv.empty_ugraph) -> n
47 | (Some (_, C.Def (_,Some ty'))) when
48 fst (R.are_convertible context ty' ty CicUniv.empty_ugraph) -> n
49 | (Some (_, C.Def (t,None))) ->
50 let ty_t, u = (* TASSI: FIXME *)
51 CicTypeChecker.type_of_aux' metasenv context (S.lift n t)
52 CicUniv.empty_ugraph in
53 let b,_ = R.are_convertible context ty_t ty u in
54 if b then n else find (n+1) tl
57 | [] -> raise (PET.Fail "Assumption: No such assumption")
58 in PET.apply_tactic (PT.apply_tac ~term:(C.Rel (find 1 context))) status
60 PET.mk_tactic assumption_tac
63 (* ANCORA DA DEBUGGARE *)
65 exception AllSelectedTermsMustBeConvertible;;
67 (* serve una funzione che cerchi nel ty dal basso a partire da term, i lambda
68 e li aggiunga nel context, poi si conta la lunghezza di questo nuovo
69 contesto e si lifta di tot... COSA SIGNIFICA TUTTO CIO'?????? *)
72 ?(mk_fresh_name_callback = FreshNamesGenerator.mk_fresh_name ~subst:[]) terms
74 let module PET = ProofEngineTypes in
75 let generalize_tac mk_fresh_name_callback terms status =
76 let (proof, goal) = status in
78 let module P = PrimitiveTactics in
79 let module T = Tacticals in
80 let _,metasenv,_,_ = proof in
81 let _,context,ty = CicUtil.lookup_meta goal metasenv in
86 (* We need to check that all the convertibility of all the terms *)
87 let u = List.fold_left ( (* TASSI: FIXME *)
89 let b,u1 = CicReduction.are_convertible context he t u in
91 raise AllSelectedTermsMustBeConvertible
93 u1) CicUniv.empty_ugraph tl in
94 (CicTypeChecker.type_of_aux' metasenv context he u)
101 (mk_fresh_name_callback metasenv context C.Anonymous ~typ:typ),
103 (ProofEngineReduction.replace_lifting_csc 1
106 ~with_what:(List.map (function _ -> C.Rel 1) terms)
109 ~continuations: [(P.apply_tac ~term:(C.Rel 1)) ; T.id_tac])
112 PET.mk_tactic (generalize_tac mk_fresh_name_callback terms)