1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768(************************************************************************)(* * 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) *)(************************************************************************)openCErrorsopenUtilopenEvdopenEvarutilopenEvarsolveopenPpopenGlob_termopenLtac_pretype(******************************************)(* Instantiation of existential variables *)(******************************************)typeglob_constr_ltac_closure=ltac_var_map*glob_constrletdepends_on_evarsigmaevk_(pbty,_,t1,t2)=tryEvar.equal(head_evarsigmat1)evkwithNoHeadEvar->tryEvar.equal(head_evarsigmat2)evkwithNoHeadEvar->falseletdefine_and_solve_constraintsevkcenvevd=ifTermops.occur_evarevdevkcthenPretype_errors.error_occur_checkenvevdevkc;letevd=defineevkcevdinlet(evd,pbs)=extract_changed_conv_pbsevd(depends_on_evarevdevk)inmatchList.fold_left(funp(pbty,env,t1,t2)->matchpwith|Successevd->Evarconv.evar_conv_x(Evarconv.default_flags_ofTransparentState.full)envevdpbtyt1t2|UnifFailure_asx->x)(Successevd)pbswith|Successevd->evd|UnifFailure_->user_errPp.(str"Instance does not satisfy the constraints.")letw_refine(evk,evi)(ltac_var,rawc)envsigma=ifEvd.is_definedsigmaevkthenuser_errPp.(str"Instantiate called on already-defined evar");letenv=Evd.evar_filtered_envenveviinletsigma',typed_c=letflags={Pretyping.use_typeclasses=Pretyping.UseTC;Pretyping.solve_unification_constraints=true;Pretyping.fail_evar=false;Pretyping.expand_evars=true;Pretyping.program_mode=false;Pretyping.polymorphic=false;}intryPretyping.understand_ltacflagsenvsigmaltac_var(Pretyping.OfTypeevi.evar_concl)rawcwithewhenCErrors.noncriticale->letloc=Glob_ops.loc_of_glob_constrrawcinuser_err?loc(str"Instance is not well-typed in the environment of "++Termops.pr_existential_keysigmaevk++str".")indefine_and_solve_constraintsevktyped_cenv(evars_reset_evdsigma'sigma)