123456789101112131415161718192021222324252627282930313233343536373839404142434445(************************************************************************)(* * 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) *)(************************************************************************)openContextopenContext.Named.Declaration(** [start_deriving f suchthat lemma] starts a proof of [suchthat]
(which can contain references to [f]) in the context extended by
[f:=?x]. When the proof ends, [f] is defined as the value of [?x]
and [lemma] as the proof. *)letstart_derivingfsuchthatname:Declare.Proof.t=letenv=Global.env()inletsigma=Evd.from_envenvinletkind=Decls.(IsDefinitionDefinition)in(* create a sort variable for the type of [f] *)(* spiwack: I don't know what the rigidity flag does, picked the one
that looked the most general. *)let(sigma,f_type_sort)=Evd.new_sort_variableEvd.univ_flexible_algsigmainletf_type_type=EConstr.mkSortf_type_sortin(* create the initial goals for the proof: |- Type ; |- ?1 ; f:=?2 |- suchthat *)letgoals=letopenProofviewinTCons(env,sigma,f_type_type,(funsigmaf_type->TCons(env,sigma,f_type,(funsigmaef->letf_type=EConstr.Unsafe.to_constrf_typeinletef=EConstr.Unsafe.to_constrefinletenv'=Environ.push_named(LocalDef(annotRf,ef,f_type))envinletsigma,suchthat=Constrintern.interp_type_evars~program_mode:falseenv'sigmasuchthatinTCons(env',sigma,suchthat,(funsigma_->TNilsigma))))))inletinfo=Declare.Info.make~poly:false~kind()inletlemma=Declare.Proof.start_derive~name~f~infogoalsinDeclare.Proof.maplemma~f:(funp->Util.pi1@@Proof.run_tacticenvProofview.(tclFOCUS12shelve)p)