123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openPpmoduleNamedDecl=Context.Named.Declaration(* This module implements the abstract interface to goals *)(* A general invariant of the module, is that a goal whose associated
evar is defined in the current evar_map, should not be accessed. *)(* type of the goals *)typegoal=Evar.tletpr_goale=str"GOAL:"++Pp.int(Evar.repre)letuide=string_of_int(Evar.repre)(* Layer to implement v8.2 tactic engine ontop of the new architecture.
Types are different from what they used to be due to a change of the
internal types. *)moduleV82=struct(* Old style env primitive *)letenvevarsgl=letenv=Global.env()inletevi=Evd.findevarsglinEvd.evar_filtered_envenvevi(* Old style hyps primitive *)lethypsevarsgl=letevi=Evd.findevarsglinEvd.evar_filtered_hypsevi(* same as [hyps], but ensures that existential variables are
normalised. *)letnf_hypsevarsgl=lethyps=Environ.named_context_of_val(hypsevarsgl)inEnviron.val_of_named_context(Evarutil.nf_named_context_evarevarshyps)(* Access to ".evar_concl" *)letconclevarsgl=letevi=Evd.findevarsglinevi.Evd.evar_concl(* Old style mk_goal primitive *)letmk_goalevarshypsconcl=(* A goal created that way will not be used by refine and will not
be shelved. It must not appear as a future_goal, so the future
goals are restored to their initial value after the evar is
created. *)letevars=Evd.push_future_goalsevarsinletinst=EConstr.identity_subst_valhypsinlet(evars,evk)=Evarutil.new_pure_evar~src:(Loc.tagEvar_kinds.GoalEvar)~typeclass_candidate:false~identity:insthypsevarsconclinlet_,evars=Evd.pop_future_goalsevarsinletev=EConstr.mkEvar(evk,inst)in(evk,ev,evars)(* Instantiates a goal with an open term *)letpartial_solutionenvsigmaevkc=(* Check that the goal itself does not appear in the refined term *)let_=ifnot(Evarutil.occur_evar_uptosigmaevkc)then()elsePretype_errors.error_occur_checkenvsigmaevkcinEvd.defineevkcsigma(* Instantiates a goal with an open term, using name of goal for evk' *)letpartial_solution_toenvsigmaevkevk'c=letid=Evd.evar_identevksigmainletsigma=partial_solutionenvsigmaevkcinmatchidwith|None->sigma|Someid->Evd.renameevk'idsigmaletweak_progressglssgls=matchglss.Evd.itwith|[g]->not(Proofview.Progress.goal_equal~evd:gls.Evd.sigma~extended_evd:glss.Evd.sigmagls.Evd.itg)|_->trueletprogressglssgls=weak_progressglssgls(* spiwack: progress normally goes like this:
(Evd.progress_evar_map gls.Evd.sigma glss.Evd.sigma) || (weak_progress glss gls)
This is immensly slow in the current implementation. Maybe we could
reimplement progress_evar_map with restricted folds like "fold_undefined",
with a good implementation of them.
*)(* Used by the compatibility layer and typeclasses *)letnf_evarsigmagl=letevi=Evd.findsigmaglinletevi=Evarutil.nf_evar_infosigmaeviinletsigma=Evd.addsigmagleviin(gl,sigma)(* Goal represented as a type, doesn't take into account section variables *)letabstract_typesigmagl=letopenEConstrinlet(gl,sigma)=nf_evarsigmaglinletenv=envsigmaglinletgenv=Global.env()inletis_proof_vardecl=tryignore(Environ.lookup_named(NamedDecl.get_iddecl)genv);falsewithNot_found->trueinEnviron.fold_named_context_reverse(funtdecl->ifis_proof_vardeclthenletdecl=Termops.map_named_declEConstr.of_constrdeclinmkNamedProd_or_LetIndecltelset)~init:(conclsigmagl)envendmoduleSet=Evar.Set