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/.
29 let clearbody ~hyp (proof, goal) =
31 let curi,metasenv,pbo,pty = proof in
32 let metano,_,_ = CicUtil.lookup_meta goal metasenv in
41 (m,canonical_context,ty) when m = metano ->
42 let canonical_context' =
46 Some (C.Name hyp',C.Def (term,ty)) when hyp = hyp' ->
53 (CicTypeChecker.type_of_aux' metasenv context term
54 CicUniv.empty_ugraph) (* TASSI: FIXME *)
56 Some (C.Name hyp, Cic.Decl ty)
58 cleared_entry::context
59 | None -> None::context
61 | Some (n,C.Def (t,None)) ->
64 CicTypeChecker.type_of_aux' metasenv context t
65 CicUniv.empty_ugraph (* TASSI: FIXME *)
70 ("The correctness of hypothesis " ^
72 " relies on the body of " ^ hyp)
76 | Some (_,Cic.Def (_,Some _)) -> assert false
77 ) canonical_context []
81 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
82 CicUniv.empty_ugraph (* TASSI: FIXME *)
87 ("The correctness of the goal relies on the body of " ^
90 m,canonical_context',ty
94 (curi,metasenv',pbo,pty), [goal]
96 mk_tactic (clearbody ~hyp)
99 let clear ~hyp (proof, goal) =
100 let module C = Cic in
101 let curi,metasenv,pbo,pty = proof in
102 let metano,context,ty =
103 CicUtil.lookup_meta goal metasenv
113 (m,canonical_context,ty) when m = metano ->
114 let context_changed, canonical_context' =
116 (fun entry (b, context) ->
118 Some (Cic.Name hyp',_) when hyp' = hyp ->
119 (true, None::context)
120 | None -> (b, None::context)
121 | Some (_,Cic.Def (_,Some _)) -> assert false
123 | Some (n,C.Def (t,None)) ->
127 CicTypeChecker.type_of_aux' metasenv context t
132 ("Hypothesis " ^ string_of_name n ^
133 " uses hypothesis " ^ hyp))
138 ) canonical_context (false, [])
140 if not context_changed then
141 raise (Fail ("Hypothesis " ^ hyp ^ " does not exist"));
144 CicTypeChecker.type_of_aux' metasenv canonical_context' ty
147 raise (Fail ("Hypothesis " ^ hyp ^ " occurs in the goal"))
149 m,canonical_context',ty
153 (curi,metasenv',pbo,pty), [goal]
155 mk_tactic (clear ~hyp)
158 ProofEngineTypes.mk_tactic
159 (fun (proof, goal) ->
160 let (_, metasenv, _, _) = proof in
161 if CicUtil.exists_meta n metasenv then
164 raise (ProofEngineTypes.Fail ("no such meta: " ^ string_of_int n)))