123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366(************************************************************************)(* * 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) *)(************************************************************************)openUtilopenNamesopenLibnamesopenTac2expropenTac2valtypeglobal_data={gdata_expr:glb_tacexpr;gdata_type:type_scheme;gdata_mutable:bool;gdata_deprecation:Deprecation.toption;}typeconstructor_data={cdata_prms:int;cdata_type:type_constant;cdata_args:intglb_typexprlist;cdata_indx:intoption;}typeprojection_data={pdata_prms:int;pdata_type:type_constant;pdata_ptyp:intglb_typexpr;pdata_mutb:bool;pdata_indx:int;}typealias_data={alias_body:raw_tacexpr;alias_depr:Deprecation.toption;}typeltac_state={ltac_tactics:global_dataKNmap.t;ltac_constructors:constructor_dataKNmap.t;ltac_projections:projection_dataKNmap.t;ltac_types:glb_quant_typedefKNmap.t;ltac_aliases:alias_dataKNmap.t;}letempty_state={ltac_tactics=KNmap.empty;ltac_constructors=KNmap.empty;ltac_projections=KNmap.empty;ltac_types=KNmap.empty;ltac_aliases=KNmap.empty;}typecompile_info={source:string;}letltac_state=Summary.refempty_state~name:"ltac2-state"letcompiled_tacs=Summary.ref~local:true~name:"ltac2-compiled-state"KNmap.emptytypenotation_data=|UntypedNotaofraw_tacexpr|TypedNotaof{nota_prms:int;nota_argtys:intglb_typexprId.Map.t;nota_ty:intglb_typexpr;nota_body:glb_tacexpr;}letltac_notations=Summary.refKNmap.empty~name:"ltac2-notations"letdefine_globalkne=letstate=!ltac_stateinltac_state:={statewithltac_tactics=KNmap.addknestate.ltac_tactics}letinterp_globalkn=letdata=KNmap.findknltac_state.contents.ltac_tacticsindataletset_compiled_globalkninfov=assert(not(interp_globalkn).gdata_mutable);compiled_tacs:=KNmap.addkn(info,v)!compiled_tacsletget_compiled_globalkn=KNmap.find_optkn!compiled_tacsletglobals()=(!ltac_state).ltac_tacticsletdefine_constructorknt=letstate=!ltac_stateinltac_state:={statewithltac_constructors=KNmap.addkntstate.ltac_constructors}letinterp_constructorkn=KNmap.findknltac_state.contents.ltac_constructorsletfind_all_constructors_in_typekn=KNmap.filter(fun_data->KerName.equalkndata.cdata_type)(!ltac_state).ltac_constructorsletdefine_projectionknt=letstate=!ltac_stateinltac_state:={statewithltac_projections=KNmap.addkntstate.ltac_projections}letinterp_projectionkn=KNmap.findknltac_state.contents.ltac_projectionsletdefine_typekne=letstate=!ltac_stateinltac_state:={statewithltac_types=KNmap.addknestate.ltac_types}letinterp_typekn=KNmap.findknltac_state.contents.ltac_typesletdefine_alias?deprecationkntac=letstate=!ltac_stateinletdata={alias_body=tac;alias_depr=deprecation}inltac_state:={statewithltac_aliases=KNmap.addkndatastate.ltac_aliases}letinterp_aliaskn=KNmap.findknltac_state.contents.ltac_aliasesletdefine_notationkntac=ltac_notations:=KNmap.addkntac!ltac_notationsletinterp_notationkn=KNmap.findkn!ltac_notationsmoduleML=structtypet=ml_tactic_nameletcomparen1n2=letc=String.comparen1.mltac_pluginn2.mltac_plugininifInt.equalc0thenString.comparen1.mltac_tacticn2.mltac_tacticelsecendmoduleMLMap=Map.Make(ML)letprimitive_map=refMLMap.emptyletdefine_primitivenamef=letf=matchfwith|ValClsf->ValCls(annotate_closure(FrPrimname)f)|_->finprimitive_map:=MLMap.addnamef!primitive_mapletinterp_primitivename=MLMap.findname!primitive_map(** Name management *)moduleFullPath=structtypet=full_pathletequal=eq_full_pathletto_string=string_of_pathletreprsp=letdir,id=repr_pathspinid,(DirPath.reprdir)endtypetacref=Tac2expr.tacref=|TacConstantofltac_constant|TacAliasofltac_aliasmoduleTacRef=structtypet=tacrefletcomparer1r2=matchr1,r2with|TacConstantc1,TacConstantc2->KerName.comparec1c2|TacAliasc1,TacAliasc2->KerName.comparec1c2|TacConstant_,TacAlias_->-1|TacAlias_,TacConstant_->1letequalr1r2=comparer1r2==0endmoduleKnTab=Nametab.Make(FullPath)(KerName)moduleRfTab=Nametab.Make(FullPath)(TacRef)moduleRfMap=Map.Make(TacRef)typenametab={tab_ltac:RfTab.t;tab_ltac_rev:full_pathRfMap.t;tab_cstr:KnTab.t;tab_cstr_rev:full_pathKNmap.t;tab_type:KnTab.t;tab_type_rev:full_pathKNmap.t;tab_proj:KnTab.t;tab_proj_rev:full_pathKNmap.t;}letempty_nametab={tab_ltac=RfTab.empty;tab_ltac_rev=RfMap.empty;tab_cstr=KnTab.empty;tab_cstr_rev=KNmap.empty;tab_type=KnTab.empty;tab_type_rev=KNmap.empty;tab_proj=KnTab.empty;tab_proj_rev=KNmap.empty;}letnametab=Summary.refempty_nametab~name:"ltac2-nametab"letpush_ltacvisspkn=lettab=!nametabinlettab_ltac=RfTab.pushvisspkntab.tab_ltacinlettab_ltac_rev=RfMap.addknsptab.tab_ltac_revinnametab:={tabwithtab_ltac;tab_ltac_rev}letlocate_ltacqid=lettab=!nametabinRfTab.locateqidtab.tab_ltacletlocate_extended_all_ltacqid=lettab=!nametabinRfTab.find_prefixesqidtab.tab_ltacletpath_of_ltackn=RfMap.findkn(!nametab).tab_ltac_revletshortest_qualid_of_ltacavoidkn=lettab=!nametabinletsp=RfMap.findkntab.tab_ltac_revinRfTab.shortest_qualidavoidsptab.tab_ltacletpush_constructorvisspkn=lettab=!nametabinlettab_cstr=KnTab.pushvisspkntab.tab_cstrinlettab_cstr_rev=KNmap.addknsptab.tab_cstr_revinnametab:={tabwithtab_cstr;tab_cstr_rev}letlocate_constructorqid=lettab=!nametabinKnTab.locateqidtab.tab_cstrletlocate_extended_all_constructorqid=lettab=!nametabinKnTab.find_prefixesqidtab.tab_cstrletpath_of_constructorkn=KNmap.findkn(!nametab).tab_cstr_revletshortest_qualid_of_constructorkn=lettab=!nametabinletsp=KNmap.findkntab.tab_cstr_revinKnTab.shortest_qualidId.Set.emptysptab.tab_cstrletpush_typevisspkn=lettab=!nametabinlettab_type=KnTab.pushvisspkntab.tab_typeinlettab_type_rev=KNmap.addknsptab.tab_type_revinnametab:={tabwithtab_type;tab_type_rev}letlocate_typeqid=lettab=!nametabinKnTab.locateqidtab.tab_typeletlocate_extended_all_typeqid=lettab=!nametabinKnTab.find_prefixesqidtab.tab_typeletpath_of_typekn=KNmap.findkn(!nametab).tab_type_revletshortest_qualid_of_type?lockn=lettab=!nametabinletsp=KNmap.findkntab.tab_type_revinKnTab.shortest_qualid?locId.Set.emptysptab.tab_typeletpush_projectionvisspkn=lettab=!nametabinlettab_proj=KnTab.pushvisspkntab.tab_projinlettab_proj_rev=KNmap.addknsptab.tab_proj_revinnametab:={tabwithtab_proj;tab_proj_rev}letlocate_projectionqid=lettab=!nametabinKnTab.locateqidtab.tab_projletlocate_extended_all_projectionqid=lettab=!nametabinKnTab.find_prefixesqidtab.tab_projletshortest_qualid_of_projectionkn=lettab=!nametabinletsp=KNmap.findkntab.tab_proj_revinKnTab.shortest_qualidId.Set.emptysptab.tab_projtype'aor_glb_tacexpr=|GlbValof'a|GlbTacexprofglb_tacexprtypeenvironment={env_ist:valexprId.Map.t;}type('a,'b,'r)intern_fun=Genintern.glob_sign->'a->'b*'rglb_typexprtype('a,'b)ml_object={ml_intern:'r.(raw_tacexpr,glb_tacexpr,'r)intern_fun->('a,'bor_glb_tacexpr,'r)intern_fun;ml_subst:Mod_subst.substitution->'b->'b;ml_interp:environment->'b->valexprProofview.tactic;ml_print:Environ.env->Evd.evar_map->'b->Pp.t;ml_raw_print:Environ.env->Evd.evar_map->'a->Pp.t;}moduleMLTypeObj=structtype('a,'b)t=('a,'b)ml_objectendmoduleMLType=Tac2dyn.ArgMap(MLTypeObj)letml_object_table=refMLType.emptyletdefine_ml_objectttpe=ml_object_table:=MLType.addt(MLType.Packtpe)!ml_object_tableletinterp_ml_objectt=tryletMLType.Packans=MLType.findt!ml_object_tableinanswithNot_found->CErrors.anomalyPp.(str"Unknown object type "++str(Tac2dyn.Arg.reprt))(** Absolute paths *)letcoq_prefix=MPfile(DirPath.make(List.mapId.of_string["Init";"Ltac2"]))letstd_prefix=MPfile(DirPath.make(List.mapId.of_string["Std";"Ltac2"]))letltac1_prefix=MPfile(DirPath.make(List.mapId.of_string["Ltac1";"Ltac2"]))(** Generic arguments *)typevar_quotation_kind=|ConstrVar|PretermVar|PatternVarletwit_ltac2in1=Genarg.make0"ltac2in1"letwit_ltac2in1_val=Genarg.make0"ltac2in1val"letwit_ltac2_constr=Genarg.make0"ltac2:in-constr"letwit_ltac2_var_quotation=Genarg.make0"ltac2:quotation"letwit_ltac2_val=Genarg.make0"ltac2:value"let()=Geninterp.register_val0wit_ltac2in1Nonelet()=Geninterp.register_val0wit_ltac2in1_valNonelet()=Geninterp.register_val0wit_ltac2_constrNonelet()=Geninterp.register_val0wit_ltac2_var_quotationNoneletis_constructor_idid=letid=Id.to_stringidinassert(String.lengthid>0);matchidwith|"true"|"false"->true(* built-in constructors *)|_->matchid.[0]with|'A'..'Z'->true|_->falseletis_constructorqid=let(_,id)=repr_qualidqidinis_constructor_idid