1 (* Copyright (C) 2006, 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 (Tactics.intros ~howmany:1
30 ~mk_fresh_name_callback:(fun _ _ _ ~typ -> Cic.Name id) ())
32 (Tactics.change ~pattern:(None,[id,Cic.Implicit (Some `Hole)],None)
33 (fun _ metasenv ugraph -> t,metasenv,ugraph))
37 (*BUG: check on t missing *)
38 let ty = match ty with None -> t | Some ty -> ty in
41 (Tactics.intros ~howmany:1
42 ~mk_fresh_name_callback:(fun _ _ _ ~typ -> Cic.Name id) ())
44 (Tactics.change ~pattern:(None,[id,Cic.Implicit (Some `Hole)],None)
45 (fun _ metasenv ugraph -> ty,metasenv,ugraph))
48 let by_term_we_proved ~dbd t ty id ty' =
51 None -> Tactics.auto ~dbd ~params:[]
52 | Some t -> Tactics.apply t
60 ~start:(Tactics.change
61 ~pattern:(ProofEngineTypes.conclusion_pattern None)
62 (fun _ metasenv ugraph -> ty,metasenv,ugraph))
68 None -> Tacticals.id_tac
70 Tactics.change ~pattern:(None,[id,Cic.Implicit (Some `Hole)],None)
71 (fun _ metasenv ugraph -> ty',metasenv,ugraph)
76 ~mk_fresh_name_callback:(fun _ _ _ ~typ -> Cic.Name id))
77 ~continuations:[ continuation ; just ]
83 None -> Tactics.auto ~dbd ~params:[]
84 | Some t -> Tactics.apply t
89 let we_need_to_prove t id ty =
93 None -> Tacticals.id_tac (*BUG: check missing here *)
95 Tactics.change ~pattern:(ProofEngineTypes.conclusion_pattern None)
96 (fun _ metasenv ugraph -> ty,metasenv,ugraph))
101 None -> Tacticals.id_tac,t
103 Tactics.change ~pattern:(None,[id,Cic.Implicit (Some `Hole)],None)
104 (fun _ metasenv ugraph -> t,metasenv,ugraph), ty in
106 ProofEngineTypes.apply_tactic
110 ~mk_fresh_name_callback:(fun _ _ _ ~typ -> Cic.Name id))
111 ~continuations:[cont])
116 [fst; snd] -> [snd; fst]
121 ProofEngineTypes.mk_tactic aux
124 let existselim t id1 t1 id2 t2 =
125 (*BUG: t1 and t2 not used *)
126 (*PARSING BUG: t2 is parsed in the current context, but it may
127 have occurrences of id1 in it *)
128 Tactics.elim_intros t
129 ~mk_fresh_name_callback:
133 if !i = 1 then Cic.Name id1 else Cic.Name id2)
135 let andelim = existselim;;
137 let rewritingstep ~dbd lhs rhs just conclude =
138 let aux ((proof,goal) as status) =
139 let (curi,metasenv,proofbo,proofty) = proof in
140 let _,context,_ = CicUtil.lookup_meta goal metasenv in
142 match LibraryObjects.eq_URI () with
143 None -> raise (ProofEngineTypes.Fail (lazy "You need to register the default equality first. Please use the \"default\" command"))
145 Cic.MutInd (uri,0,[]), Cic.Const (LibraryObjects.trans_eq_URI ~eq:uri,[])
148 CicTypeChecker.type_of_aux' metasenv context rhs CicUniv.empty_ugraph in
153 ~params:["paramodulation","1"; "timeout","3"]
154 | Some just -> Tactics.apply just
161 (CicTypeChecker.type_of_aux' metasenv context (Cic.Rel 1)
162 CicUniv.empty_ugraph)
164 Cic.Appl [_;_;plhs;prhs] -> plhs,prhs
165 | _ -> assert false in
168 (Some (Cic.Name id,_))::_ -> id
173 ProofEngineTypes.apply_tactic
175 ~start:(Tactics.apply ~term:trans)
177 [ Tactics.apply prhs ;
178 Tactics.apply (Cic.Rel 1) ;
181 let mk_fresh_name_callback =
182 fun metasenv context _ ~typ ->
183 FreshNamesGenerator.mk_fresh_name ~subst:[]
184 metasenv context name ~typ
186 ProofEngineTypes.apply_tactic
188 ~start:(Tactics.cut ~mk_fresh_name_callback
189 (Cic.Appl [eq ; ty ; plhs ; rhs]))
191 [ Tactics.clear ~hyps:[last_hyp_name] ;
193 ~start:(Tactics.apply ~term:trans)
195 [ Tactics.apply prhs ;
196 Tactics.apply (Cic.Rel 1) ;
201 None -> ProofEngineTypes.apply_tactic just status
203 let mk_fresh_name_callback =
204 fun metasenv context _ ~typ ->
205 FreshNamesGenerator.mk_fresh_name ~subst:[]
206 metasenv context name ~typ
208 ProofEngineTypes.apply_tactic
211 (Tactics.cut ~mk_fresh_name_callback
212 (Cic.Appl [eq ; ty ; lhs ; rhs]))
213 ~continuations:[ Tacticals.id_tac ; just ]) status
215 ProofEngineTypes.mk_tactic aux
218 let we_proceed_by_induction_on t pat =
219 (*BUG here: pat unused *)
220 Tactics.elim_intros ~depth:0 t
223 let case id ~params =
224 (*BUG here: id unused*)
225 (*BUG here: it does not verify that the previous branch is closed *)
226 (*BUG here: the params should be parsed telescopically*)
227 (*BUG here: the tactic_terms should be terms*)
228 let rec aux ~params ((proof,goal) as status) =
232 match ProofEngineTypes.apply_tactic (assume id t) status with
233 proof,[goal] -> aux tl (proof,goal)
236 ProofEngineTypes.mk_tactic (aux ~params)
239 let thesisbecomes t =
241 (*BUG here: missing check on t *)
243 None -> Tacticals.id_tac
245 Tactics.change ~pattern:(None,[],Some (Cic.Implicit (Some `Hole)))
246 (fun _ metasenv ugraph -> ty,metasenv,ugraph)
249 let byinduction t id = suppose t id None;;