123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328(************************************************************************)(* * 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) *)(************************************************************************)openUtilopenNamesopenLibnamesopenTac2expropenTac2valtypeglobal_data={gdata_expr:glb_tacexpr;gdata_type:type_scheme;gdata_mutable:bool;gdata_deprecation:Deprecation.toption;gdata_mutation_history:ModPath.tlist;}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 *)typetacref=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==0endmoduleDefV=structincludeTacRefletis_var_=Noneletstage=Summary.Stage.Interpletsummary_name="ltac2-deftab"moduleMap=Map.Make(TacRef)endmoduleDefTab=Nametab.EasyNoWarn(DefV)()moduleCtorV=structincludeKerNameletis_var_=NonemoduleMap=KNmapletstage=Summary.Stage.Interpletsummary_name="ltac2-ctortab"letobject_name="Ltac2 constructor"letwarning_name_base="ltac2-constructor"endmoduleCtorTab=Nametab.Easy(CtorV)()moduleTypV=structincludeKerNameletis_var_=Noneletstage=Summary.Stage.Interpletsummary_name="ltac2-typtab"moduleMap=KNmapendmoduleTypTab=Nametab.EasyNoWarn(TypV)()moduleProjV=structincludeKerNameletis_var_=Noneletstage=Summary.Stage.Interpletsummary_name="ltac2-projtab"moduleMap=KNmapendmoduleProjTab=Nametab.EasyNoWarn(ProjV)()letpush_ltac=DefTab.pushletlocate_ltac=DefTab.locateletlocate_extended_all_ltac=DefTab.locate_allletpath_of_ltac=DefTab.to_pathletshortest_qualid_of_ltac=DefTab.shortest_qualidletpush_constructor?user_warnsvisspkn=(* XXX support qf *)letuser_warns=Option.mapUserWarn.with_empty_qfuser_warnsinCtorTab.push?wdata:user_warnsvisspkn(* XXX expose nowarn argument? *)letlocate_constructorqid=CtorTab.locateqidletlocate_extended_all_constructor=CtorTab.locate_allletpath_of_constructor=CtorTab.to_pathletshortest_qualid_of_constructorkn=CtorTab.shortest_qualidId.Set.emptyknletpush_type=TypTab.pushletlocate_type=TypTab.locateletlocate_extended_all_type=TypTab.locate_allletpath_of_type=TypTab.to_pathletshortest_qualid_of_type?lockn=TypTab.shortest_qualidId.Set.empty?locknletpush_projection=ProjTab.pushletlocate_projection=ProjTab.locateletlocate_extended_all_projection=ProjTab.locate_allletshortest_qualid_of_projectionkn=ProjTab.shortest_qualidId.Set.emptykntype'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.('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 *)letrocq_prefix=MPfile(DirPath.make(List.mapId.of_string["Init";"Ltac2"]))letcoq_prefix=rocq_prefixletstd_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|PatternVar|HypVarletwit_ltac2_constr=Genarg.make0"ltac2:in-constr"letwit_ltac2_var_quotation=Genarg.make0"ltac2:quotation"letwit_ltac2_tac=Genarg.make0"ltac2:tactic"let()=Geninterp.register_val0wit_ltac2_tac(Some(Geninterp.val_tag(Genarg.topwitStdarg.wit_unit)))letis_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