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 ~universe t ty id ty' =
51 None -> Tactics.auto ~dbd ~params:[] ~universe
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 ]
80 let bydone ~dbd ~universe t =
83 None -> Tactics.auto ~dbd ~params:[] ~universe
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 ~dbd ~universe t id1 t1 id2 t2 =
125 let aux (proof, goal) =
126 let (n,metasenv,bo,ty,attrs) = proof in
127 let metano,context,_ = CicUtil.lookup_meta goal metasenv in
128 let t2, metasenv, _ = t2 (Some (Cic.Name id1, Cic.Decl t1) :: context) metasenv CicUniv.oblivion_ugraph in
129 let proof' = (n,metasenv,bo,ty,attrs) in
130 ProofEngineTypes.apply_tactic (
132 ~start:(Tactics.cut (Cic.Appl [Cic.MutInd (UriManager.uri_of_string "cic:/matita/logic/connectives/ex.ind", 0, []); t1 ; Cic.Lambda (Cic.Name id1, t1, t2)]))
134 [ Tactics.elim_intros (Cic.Rel 1)
135 ~mk_fresh_name_callback:
139 if !i = 1 then Cic.Name id1 else Cic.Name id2) ;
141 None -> Tactics.auto ~dbd ~params:[] ~universe
142 | Some t -> Tactics.apply t)
145 ProofEngineTypes.mk_tactic aux
148 let andelim t id1 t1 id2 t2 =
149 Tactics.elim_intros t
150 ~mk_fresh_name_callback:
154 if !i = 1 then Cic.Name id1 else Cic.Name id2)
156 let rewritingstep ~dbd ~universe lhs rhs just last_step =
157 let aux ((proof,goal) as status) =
158 let (curi,metasenv,proofbo,proofty, attrs) = proof in
159 let _,context,gty = CicUtil.lookup_meta goal metasenv in
161 match LibraryObjects.eq_URI () with
162 None -> raise (ProofEngineTypes.Fail (lazy "You need to register the default equality first. Please use the \"default\" command"))
164 Cic.MutInd (uri,0,[]), Cic.Const (LibraryObjects.trans_eq_URI ~eq:uri,[])
167 CicTypeChecker.type_of_aux' metasenv context rhs CicUniv.empty_ugraph in
172 if not (List.exists (fun (k,_) -> k = "paramodulation") params) then
173 ("paramodulation","1")::params
176 if not (List.exists (fun (k,_) -> k = "timeout") params) then
177 ("timeout","3")::params
180 Tactics.auto ~dbd ~params ~universe
181 | `Term just -> Tactics.apply just
183 let plhs,prhs,prepare =
188 Cic.Appl [_;_;plhs;prhs] -> plhs,prhs
193 ProofEngineTypes.apply_tactic continuation status)
197 Cic.Appl [_;_;plhs;prhs] -> plhs,prhs
200 (*CSC: manca check plhs convertibile con lhs *)
203 ProofEngineTypes.apply_tactic continuation status)
204 | Some (Some name,lhs) ->
205 let newmeta = CicMkImplicit.new_meta metasenv [] in
207 CicMkImplicit.identity_relocation_list_for_metavariable context in
209 let prhs = Cic.Meta(newmeta,irl) in
212 let metasenv = (newmeta, context, ty)::metasenv in
213 let mk_fresh_name_callback =
214 fun metasenv context _ ~typ ->
215 FreshNamesGenerator.mk_fresh_name ~subst:[] metasenv context
218 let proof = curi,metasenv,proofbo,proofty, attrs in
220 ProofEngineTypes.apply_tactic
222 ~start:(Tactics.cut ~mk_fresh_name_callback
223 (Cic.Appl [eq ; ty ; lhs ; prhs]))
224 ~continuations:[Tacticals.id_tac ; continuation]) (proof,goal)
228 [g1;g2] -> [g2;newmeta;g1]
235 (*CSC:manca controllo sul fatto che rhs sia convertibile con prhs*)
239 ~start:(Tactics.apply ~term:(Cic.Appl [trans;ty;plhs;rhs;prhs]))
240 ~continuations:[just ; Tacticals.id_tac]
244 ProofEngineTypes.mk_tactic aux
247 let we_proceed_by_cases_on t pat =
248 (*BUG here: pat unused *)
249 Tactics.cases_intros t
252 let we_proceed_by_induction_on t pat =
253 let pattern = None, [], Some pat in
254 Tactics.elim_intros ~depth:0 ~pattern t
257 let case id ~params =
258 (*BUG here: id unused*)
259 (*BUG here: it does not verify that the previous branch is closed *)
260 (*BUG here: the params should be parsed telescopically*)
261 (*BUG here: the tactic_terms should be terms*)
262 let rec aux ~params ((proof,goal) as status) =
266 match ProofEngineTypes.apply_tactic (assume id t) status with
267 proof,[goal] -> aux tl (proof,goal)
270 ProofEngineTypes.mk_tactic (aux ~params)
273 let thesisbecomes t =
277 Tactics.change ~pattern:(None,[],Some (Cic.Implicit (Some `Hole)))
278 (fun _ metasenv ugraph -> t,metasenv,ugraph)
280 (*BUG here: missing check on t *)
281 Tactics.change ~pattern:(None,[],Some (Cic.Implicit (Some `Hole)))
282 (fun _ metasenv ugraph -> ty,metasenv,ugraph)
285 let byinduction t id = suppose t id None;;