123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137(************************************************************************)(* * 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) *)(************************************************************************)openNamesopenGenargmoduleStore=Store.Make()typentnvar_status={mutablentnvar_used:boollist;mutablentnvar_used_as_binder:bool;mutablentnvar_scopes:Notation_term.subscopesoption;mutablentnvar_binding_ids:Notation_term.notation_var_bindersoption;ntnvar_typ:Notation_term.notation_var_internalization_type;}typeintern_variable_status={intern_ids:Id.Set.t;notation_variable_status:ntnvar_statusId.Map.t;}typeglob_sign={ltacvars:Id.Set.t;genv:Environ.env;extra:Store.t;intern_sign:intern_variable_status;strict_check:bool;}letempty_intern_sign={intern_ids=Id.Set.empty;notation_variable_status=Id.Map.empty;}letempty_glob_sign~strictenv={ltacvars=Id.Set.empty;genv=env;extra=Store.empty;intern_sign=empty_intern_sign;strict_check=strict;}(** In globalize tactics, we need to keep the initial [constr_expr] to recompute
in the environment by the effective calls to Intro, Inversion, etc
The [constr_expr] field is [None] in TacDef though *)typeglob_constr_and_expr=Glob_term.glob_constr*Constrexpr.constr_exproptiontypeglob_constr_pattern_and_expr=Id.Set.t*glob_constr_and_expr*Pattern.constr_patterntype('raw,'glb)intern_fun=glob_sign->'raw->glob_sign*'glbtype'glbntn_subst_fun=ntnvar_statusId.Map.t->(Id.t->Glob_term.glob_constroption)->'glb->'glbmoduleInternObj=structtype('raw,'glb,'top)obj=('raw,'glb)intern_funletname="intern"letdefault_=NoneendmoduleNtnSubstObj=structtype('raw,'glb,'top)obj='glbntn_subst_funletname="notation_subst"letdefault_=NoneendmoduleIntern=Register(InternObj)moduleNtnSubst=Register(NtnSubstObj)letintern=Intern.objletregister_intern0=Intern.register0letgeneric_internist(GenArg(Rawwitwit,v))=let(ist,v)=internwitistvin(ist,in_gen(glbwitwit)v)type('raw,'glb)intern_pat_fun=?loc:Loc.t->('raw,'glb)intern_funmoduleInternPatObj=structtype('raw,'glb,'top)obj=('raw,'glb)intern_pat_funletname="intern_pat"letdefaulttag=Some(fun?loc->letname=Genarg.(ArgT.reprtag)inCErrors.user_err?locPp.(str"This quotation is not supported in tactic patterns ("++strname++str")"))endmoduleInternPat=Register(InternPatObj)letintern_pat=InternPat.objletregister_intern_pat=InternPat.register0letgeneric_intern_pat?locist(GenArg(Rawwitwit,v))=let(ist,v)=intern_patwit?locistvin(ist,in_gen(glbwitwit)v)(** Notation substitution *)letsubstitute_notation=NtnSubst.objletregister_ntn_subst0=NtnSubst.register0letgeneric_substitute_notationavoidenv(GenArg(Glbwitwit,v)asorig)=letv'=substitute_notationwitavoidenvvinifv'==vthenorigelsein_gen(glbwitwit)v'letwith_used_ntnvarsntnvarsf=let()=Id.Map.iter(fun_status->status.ntnvar_used<-false::status.ntnvar_used)ntnvarsinmatchf()with|v->letused=Id.Map.fold(funidstatusacc->matchstatus.ntnvar_usedwith|[]->assertfalse|false::rest->status.ntnvar_used<-rest;acc|true::rest->letrest=matchrestwith|[]|true::_->rest|false::rest->true::restinstatus.ntnvar_used<-rest;Id.Set.addidacc)ntnvarsId.Set.emptyinused,v|exceptione->lete=Exninfo.captureeinlet()=Id.Map.iter(fun_status->status.ntnvar_used<-List.tlstatus.ntnvar_used)ntnvarsinExninfo.iraisee