123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192(************************************************************************)(* * 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) *)(************************************************************************)openUtilopenNamegenopenTermopsopenEnvironopenReductionopsopenEvdopenTypingopenTacredopenLogicopenContext.Named.DeclarationmoduleNamedDecl=Context.Named.Declarationletre_sigitgc={it=it;sigma=gc;}(**************************************************************)(* Operations for handling terms under a local typing context *)(**************************************************************)typetactic=Proofview.V82.tacletsig_itx=x.itletprojectx=x.sigmaletpf_envgls=Global.env_of_context(Goal.V82.hyps(projectgls)(sig_itgls))letpf_hypsgls=EConstr.named_context_of_val(Goal.V82.hyps(projectgls)(sig_itgls))lettest_conversionenvsigmapbc1c2=Reductionops.check_conv~pbenvsigmac1c2letpf_conclgls=Goal.V82.concl(projectgls)(sig_itgls)letpf_hyps_typesgls=letsign=Environ.named_context(pf_envgls)inList.map(functionLocalAssum(id,x)|LocalDef(id,_,x)->id,EConstr.of_constrx)signletpf_nth_hyp_idglsn=List.nth(pf_hypsgls)(n-1)|>NamedDecl.get_idletpf_last_hypgl=List.hd(pf_hypsgl)letpf_get_hypglsid=letenv,sigma=pf_envgls,projectglsintryContext.Named.lookupid(pf_hypsgls)withNot_found->raise(RefinerError(env,sigma,NoSuchHypid))letpf_get_hyp_typglsid=id|>pf_get_hypgls|>NamedDecl.get_typeletpf_ids_of_hypsgls=ids_of_named_context(pf_hypsgls)letpf_ids_set_of_hypsgls=Environ.ids_of_named_context_val(Environ.named_context_val(pf_envgls))letpf_get_new_ididgls=next_ident_awayid(pf_ids_set_of_hypsgls)letpf_applyfgls=f(pf_envgls)(projectgls)letpf_eapplyfglsx=on_siggls(funevm->f(pf_envgls)evmx)letpf_reduce=pf_applyletpf_e_reduce=pf_applyletpf_whd_all=pf_reducewhd_allletpf_hnf_constr=pf_reducehnf_constrletpf_nf=pf_reducesimplletpf_nf_betaiota=pf_reducenf_betaiotaletpf_compute=pf_reducecomputeletpf_unfoldnubinds=pf_reduce(unfoldnubinds)letpf_type_of=pf_reducetype_ofletpf_get_type_of=pf_reduceRetyping.get_type_ofletpf_conv_xgl=pf_reducetest_conversionglReduction.CONVletpf_const_value=pf_reduce(funenv_c->EConstr.of_constr(constant_value_inenvc))letpf_reduce_to_quantified_ind=pf_reducereduce_to_quantified_indletpf_reduce_to_atomic_ind=pf_reducereduce_to_atomic_indletpf_hnf_type_ofgls=pf_get_type_ofgls%>pf_whd_allgls(* Pretty-printers *)openPpletdb_pr_goalsigmag=letenv=Goal.V82.envsigmaginletpenv=Termops.Internal.print_named_contextenvinletpc=Termops.Internal.print_constr_envenvsigma(Goal.V82.conclsigmag)instr" "++hv0(penv++fnl()++str"============================"++fnl()++str" "++pc)++fnl()letpr_glsgls=hov0(pr_evar_map(Some2)(pf_envgls)(projectgls)++fnl()++db_pr_goal(projectgls)(sig_itgls))(* Variants of [Tacmach] functions built with the new proof engine *)moduleNew=structletprojectgl=Proofview.Goal.sigmaglletpf_applyfgl=f(Proofview.Goal.envgl)(projectgl)letof_oldfgl=f{Evd.it=Proofview.Goal.goalgl;sigma=projectgl;}letpf_env=Proofview.Goal.envletpf_concl=Proofview.Goal.conclletpf_type_ofglt=pf_applytype_ofgltletpf_conv_xglt1t2=pf_applyis_convglt1t2letpf_ids_of_hypsgl=(* We only get the identifiers in [hyps] *)lethyps=Proofview.Goal.hypsglinids_of_named_contexthypsletpf_ids_set_of_hypsgl=(* We only get the identifiers in [hyps] *)letenv=Proofview.Goal.envglinEnviron.ids_of_named_context_val(Environ.named_context_valenv)letpf_get_new_ididgl=letids=pf_ids_set_of_hypsglinnext_ident_awayididsletpf_get_hypidgl=lethyps=Proofview.Goal.envglinletsigma=projectglinletsign=tryEConstr.lookup_namedidhypswithNot_found->raise(RefinerError(hyps,sigma,NoSuchHypid))insignletpf_get_hyp_typidgl=pf_get_hypidgl|>NamedDecl.get_typeletpf_hyps_typesgl=letenv=Proofview.Goal.envglinletsign=Environ.named_contextenvinList.map(functionLocalAssum(id,x)|LocalDef(id,_,x)->id.Context.binder_name,EConstr.of_constrx)signletpf_last_hypgl=lethyps=Proofview.Goal.hypsglinList.hdhypsletpf_nf_concl(gl:Proofview.Goal.t)=(* We normalize the conclusion just after *)letconcl=Proofview.Goal.conclglinletsigma=projectglinnf_evarsigmaconclletpf_whd_allglt=pf_applywhd_allgltletpf_get_type_ofglt=pf_applyRetyping.get_type_ofgltletpf_reduce_to_quantified_indglt=pf_applyreduce_to_quantified_indgltletpf_hnf_constrglt=pf_applyhnf_constrgltletpf_hnf_type_ofglt=pf_whd_allgl(pf_get_type_ofglt)letpf_computeglt=pf_applycomputegltletpf_nf_evarglt=nf_evar(projectgl)t(* deprecated *)letpf_unsafe_type_ofglt=pf_apply(unsafe_type_of[@warning"-3"])gltletpr_glsgl=hov0(pr_evar_map(Some2)(pf_envgl)(projectgl)++fnl()++db_pr_goal(projectgl)(Proofview.Goal.goalgl))end(* deprecated *)letpf_unsafe_type_of=pf_reduceunsafe_type_of[@warning"-3"]