(* Copyright (C) 2002, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://cs.unibo.it/helm/. *) (* let induction_tac ~term ~status:((proof,goal) as status) = let module C = Cic in let module R = CicReduction in let module P = PrimitiveTactics in let module T = Tacticals in let module S = ProofEngineStructuralRules in let module U = UriManager in let (_,metasenv,_,_) = proof in let _,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in let termty = T.type_of_aux' metasenv context term in let uri,exp_named_subst,typeno,args = match termty with C.MutInd (uri,typeno,exp_named_subst) -> (uri,exp_named_subst,typeno,[]) | C.Appl ((C.MutInd (uri,typeno,exp_named_subst))::args) -> (uri,exp_named_subst,typeno,args) | _ -> raise (ProofEngineTypes.Fail "Induction: Not an Inductive Type to Eliminate") in let eliminator_uri = let base = U.buri_of_uri uri in let name = match CicEnvironment.get_obj uri with C.InductiveDefinition (tys,_,_) -> let (name,_,_,_) = List.nth tys typeno in name | _ -> assert false in let ext = match T.type_of_aux' metasenv context ty with C.Sort C.Prop -> "_ind" | C.Sort C.Set -> "_rec" | C.Sort C.Type -> "_rect" | _ -> assert false in U.uri_of_string (base ^ "/" ^ name ^ ext ^ ".con") in apply_tac ~term:(C.Const (eliminator_uri , exp_named_subst)) (* come mi devo comportare con gli args??? *) ;; *) let elim_type_tac ~term ~status = let module C = Cic in let module P = PrimitiveTactics in let module T = Tacticals in T.thens ~start: (P.cut_tac ~term) ~continuations:[ P.elim_intros_simpl_tac ~term:(C.Rel 1) ; T.id_tac ] ~status ;; (* Questa era gia' in ring.ml!!!! NB: adesso in ring non c'e' piu' :-) let elim_type_tac ~term ~status = warn "in Ring.elim_type_tac"; Tacticals.thens ~start:(cut_tac ~term) ~continuations:[elim_simpl_intros_tac ~term:(Cic.Rel 1) ; Tacticals.id_tac] ~status *) (* PROVE DI DECOMPOSE (* in realta' non so bene cosa contiene la lista what, io ho supposto contenga dei term (Const uri) *) let decompose_tac ~what ~where ~status:((proof,goal) as status) = let module C = Cic in let module R = CicReduction in let module P = PrimitiveTactics in let module T = Tacticals in let module S = ProofEngineStructuralRules in let rec decomposing ty what = match (what) with [] -> C.Implicit (* qui mi servirebbe un termine per cui elim_simpl_intros fallisce *) | hd::tl as what -> match ty with (C.Appl (hd::_)) -> hd | _ -> decomposing ty tl in let (_,metasenv,_,_) = proof in let _,context,_ = List.find (function (m,_,_) -> m=goal) metasenv in T.repeat_tactic ~tactic:(T.then_ ~start:(P.elim_simpl_intros_tac ~term:(decomposing (R.whd context where) what)) ~continuation:(S.clear ~hyp:(Some ((C.Name "name"), (C.Decl where)))) (* ma che ipotesi sto cancellando??? *) ) ~status ;; let decompose_tac ~clist ~status:((proof,goal) as status) = let module C = Cic in let module R = CicReduction in let module P = PrimitiveTactics in let module T = Tacticals in let module S = ProofEngineStructuralRules in let (_,metasenv,_,_) = proof in let _,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in let rec repeat_elim ~term ~status = (* term -> status -> proof * (goal list) *) try let (proof, goallist) = T.then_ ~start:(P.elim_simpl_intros_tac ~term) ~continuation:(S.clear ~hyp:(Some ((C.Name "name"), (C.Decl ty)))) (* non so che ipotesi sto cancellando??? *) ~status in let rec step proof goallist = match goallist with [] -> (proof, []) | hd::tl -> let (proof', goallist') = repeat_elim ~term ~status:(proof, hd) in let (proof'', goallist'') = step proof' tl in proof'', goallist'@goallist'' in step proof goallist with (Fail _) -> T.id_tac in let rec decomposing ty clist = (* term -> (term list) -> bool *) match (clist) with [] -> false | hd::tl as clist -> match ty with (C.Appl (hd::_)) -> true | _ -> decomposing ty tl in let term = decomposing (R.whd context ty) clist in if (term == C.Implicit) then (Fail "Decompose: nothing to decompose or no application") else repeat_elim ~term ~status ;; *) let decompose_tac ~clist ~status = let module C = Cic in let module R = CicReduction in let module P = PrimitiveTactics in let module T = Tacticals in let module S = ProofEngineStructuralRules in let rec choose ty = function [] -> C.Implicit (* a cosa serve? *) | hd::tl -> match ty with (C.Appl (hd::_)) -> hd | _ -> choose ty tl in let decompose_one_tac ~clist ~status:((proof,goal) as status) = let (_,metasenv,_,_) = proof in let _,context,ty = List.find (function (m,_,_) -> m=goal) metasenv in let term = choose (R.whd context ty) clist in if (term == C.Implicit) then raise (ProofEngineTypes.Fail "Decompose: nothing to decompose or no application") else T.then_ ~start:(P.elim_intros_simpl_tac ~term) ~continuation:(S.clear ~hyp:(List.hd context)) (* (S.clear ~hyp:(Some ((C.Name "FOO") , (C.Decl ty)))) (* ma che ipotesi sto cancellando??? *)*) ~status in T.repeat_tactic ~tactic:(decompose_one_tac ~clist) ~status ;;