123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293(************************************************************************)(* * The Rocq Prover / The Rocq 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) *)(************************************************************************)openUtilopenTermopsopenEConstrmoduleNamedDecl=Context.Named.Declaration(* tactical to save as name a subproof such that the generalisation of
the current goal, abstracted with respect to the local signature,
is solved by tac *)(** d1 is the section variable in the global context, d2 in the goal context *)letinterpretable_as_section_declenvsigmad1d2=letopenContext.Named.Declarationinlete_eq_constr_univssigmac1c2=matcheq_constr_universesenvsigmac1c2with|None->false|Somecstr->trylet_sigma=Evd.add_universe_constraintssigmacstrintruewithUGraph.UniverseInconsistency_|UState.UniversesDiffer->falseinmatchd2,d1with|LocalDef_,LocalAssum_->false|LocalDef(_,b1,t1),LocalDef(_,b2,t2)->e_eq_constr_univssigmab1b2&&e_eq_constr_univssigmat1t2|LocalAssum(_,t1),d2->e_eq_constr_univssigmat1(NamedDecl.get_typed2)letname_op_to_name~name_op~namesuffix=matchname_opwith|Somes->s|None->Nameops.add_suffixnamesuffixletdeclare_abstract=ref(fun~name~poly~sign~secsign~opaque~solve_tacsigmaconcl->CErrors.anomaly(Pp.str"Abstract declaration hook not registered"))letcache_term_by_tactic_then~opaque~name_op?(goal_type=None)tactacK=letopenTacticalsinletopenTacmachinletopenProofview.NotationsinProofview.tclProofInfo[@ocaml.warning"-3"]>>=fun(name,poly)->letsuffix=ifopaquethen"_subproof"else"_subterm"inletname=name_op_to_name~name_op~namesuffixinProofview.Goal.enterbeginfungl->letenv=Proofview.Goal.envglinletsigma=Proofview.Goal.sigmaglinletsection_sign=Global.named_context_val()inletgoal_sign=Proofview.Goal.hypsglinletsign,secsign=List.fold_right(fund(s1,s2)->letid=NamedDecl.get_iddinifmem_named_context_validsection_sign&&interpretable_as_section_declenvsigma(lookup_named_validsection_sign)dthen(s1,push_named_context_valds2)else(Context.Named.addds1,s2))goal_sign(Context.Named.empty,Environ.empty_named_context_val)inletname=Namegen.next_global_ident_awayname(pf_ids_set_of_hypsgl)inletconcl=matchgoal_typewith|None->Proofview.Goal.conclgl|Somety->tyinletconcl=it_mkNamedProd_or_LetInsigmaconclsigninletsolve_tac=tclCOMPLETE(Tactics.intros_mustbe_force(List.rev_mapNamedDecl.get_idsign)<*>tac)inleteffs,sigma,lem,args,safe=!declare_abstract~name~poly~sign~secsign~opaque~solve_tacsigmaconclinletsolve=Proofview.tclEFFECTSeffs<*>tacKlemargsinlettac=ifnotsafethenProofview.mark_as_unsafe<*>solveelsesolveinProofview.tclTHEN(Proofview.Unsafe.tclEVARSsigma)tacendletabstract_subproof~opaquetac=cache_term_by_tactic_then~opaquetac(funlemargs->Tactics.exact_no_check(applist(lem,args)))lettclABSTRACT?(opaque=true)name_optac=abstract_subproof~opaque~name_optac