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 *)
31 let assumption_tac ~status:((proof,goal) as status) =
33 let module R = CicReduction in
34 let module S = CicSubstitution in
35 let _,metasenv,_,_ = proof in
36 let _,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in
37 let rec find n = function
40 (Some (_, C.Decl t)) when
41 (R.are_convertible context (S.lift n t) ty) -> n
42 | (Some (_, C.Def (_,Some ty'))) when
43 (R.are_convertible context ty' ty) -> n
44 | (Some (_, C.Def (t,None))) when
45 (R.are_convertible context
46 (CicTypeChecker.type_of_aux' metasenv context (S.lift n t)) ty) -> n
49 | [] -> raise (ProofEngineTypes.Fail "Assumption: No such assumption")
50 in PrimitiveTactics.apply_tac ~status ~term:(C.Rel (find 1 context))
53 (* ANCORA DA DEBUGGARE *)
55 exception AllSelectedTermsMustBeConvertible;;
57 (* serve una funzione che cerchi nel ty dal basso a partire da term, i lambda
58 e li aggiunga nel context, poi si conta la lunghezza di questo nuovo
59 contesto e si lifta di tot... COSA SIGNIFICA TUTTO CIO'?????? *)
62 ?(mk_fresh_name_callback = ProofEngineHelpers.mk_fresh_name)
63 terms ~status:((proof,goal) as status)
66 let module P = PrimitiveTactics in
67 let module T = Tacticals in
68 let _,metasenv,_,_ = proof in
69 let _,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in
74 (* We need to check that all the convertibility of all the terms *)
77 if not (CicReduction.are_convertible context he t) then
78 raise AllSelectedTermsMustBeConvertible
80 (CicTypeChecker.type_of_aux' metasenv context he)
86 (mk_fresh_name_callback context C.Anonymous typ),
88 (ProofEngineReduction.replace_lifting_csc 1
91 ~with_what:(List.map (function _ -> C.Rel 1) terms)
94 ~continuations: [(P.apply_tac ~term:(C.Rel 1)) ; T.id_tac]