123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404(************************************************************************)(* * 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) *)(************************************************************************)openPpopenNamesopenNamegenopenCErrorsopenUtilopenConstrexpropenGenargopenGeninterpopenStdargopenTactypesopenLocusopenGenredexpropenPpconstropenPputilsopenPrinteropenGeninternopenTacexpropenTacargopenTacticsmoduleTag=structletkeyword="tactic.keyword"letprimitive="tactic.primitive"letstring="tactic.string"endlettagts=Pp.tagtsletdo_not_tag_x=xlettag_keyword=tagTag.keywordlettag_primitive=tagTag.primitivelettag_string=tagTag.stringlettag_glob_tactic_expr=do_not_taglettag_glob_atomic_tactic_expr=do_not_taglettag_raw_tactic_expr=do_not_taglettag_raw_atomic_tactic_expr=do_not_taglettag_atomic_tactic_expr=do_not_tagletpr_globalx=Nametab.pr_global_envId.Set.emptyxtype'agrammar_tactic_prod_item_expr=|TacTermofstring|TacNonTermof('a*Names.Id.toption)Loc.locatedtypegrammar_terminals=Genarg.ArgT.anyExtend.user_symbolgrammar_tactic_prod_item_exprlisttypepp_tactic={pptac_level:int;pptac_prods:grammar_terminals;}(* Tactic notations *)letprnotation_tab=Summary.ref~name:"pptactic-notation"KNmap.emptyletdeclare_notation_tactic_ppruleknpt=prnotation_tab:=KNmap.addknpt!prnotation_tabtype'araw_extra_genarg_printer=Environ.env->Evd.evar_map->(Environ.env->Evd.evar_map->constr_expr->Pp.t)->(Environ.env->Evd.evar_map->constr_expr->Pp.t)->(Environ.env->Evd.evar_map->entry_relative_level->raw_tactic_expr->Pp.t)->'a->Pp.ttype'aglob_extra_genarg_printer=Environ.env->Evd.evar_map->(Environ.env->Evd.evar_map->glob_constr_and_expr->Pp.t)->(Environ.env->Evd.evar_map->glob_constr_and_expr->Pp.t)->(Environ.env->Evd.evar_map->entry_relative_level->glob_tactic_expr->Pp.t)->'a->Pp.ttype'aextra_genarg_printer=Environ.env->Evd.evar_map->(Environ.env->Evd.evar_map->EConstr.constr->Pp.t)->(Environ.env->Evd.evar_map->EConstr.constr->Pp.t)->(Environ.env->Evd.evar_map->entry_relative_level->Val.t->Pp.t)->'a->Pp.ttype'araw_extra_genarg_printer_with_level=Environ.env->Evd.evar_map->(Environ.env->Evd.evar_map->constr_expr->Pp.t)->(Environ.env->Evd.evar_map->constr_expr->Pp.t)->(Environ.env->Evd.evar_map->entry_relative_level->raw_tactic_expr->Pp.t)->entry_relative_level->'a->Pp.ttype'aglob_extra_genarg_printer_with_level=Environ.env->Evd.evar_map->(Environ.env->Evd.evar_map->glob_constr_and_expr->Pp.t)->(Environ.env->Evd.evar_map->glob_constr_and_expr->Pp.t)->(Environ.env->Evd.evar_map->entry_relative_level->glob_tactic_expr->Pp.t)->entry_relative_level->'a->Pp.ttype'aextra_genarg_printer_with_level=Environ.env->Evd.evar_map->(Environ.env->Evd.evar_map->EConstr.constr->Pp.t)->(Environ.env->Evd.evar_map->EConstr.constr->Pp.t)->(Environ.env->Evd.evar_map->entry_relative_level->Val.t->Pp.t)->entry_relative_level->'a->Pp.tletstring_of_genarg_arg(ArgumentTypearg)=letrecaux:typeabc.(a,b,c)genarg_type->string=function|ListArgt->auxt^"_list"|OptArgt->auxt^"_opt"|PairArg(t1,t2)->assertfalse(* No parsing/printing rule for it *)|ExtraArgs->ArgT.reprsinauxargletkeywordx=tag_keyword(strx)letprimitivex=tag_primitive(strx)lethas_type(Val.Dyn(tag,_))t=matchVal.eqtagtwith|None->false|Some_->trueletunbox:typea.Val.t->aVal.typ->a=fun(Val.Dyn(tag,x))t->matchVal.eqtagtwith|None->assertfalse|SomeRefl->xletrecpr_valuelevv:Pp.t=ifhas_typevVal.typ_listthenpr_sequence(funx->pr_valuelevx)(unboxvVal.typ_list)elseifhas_typevVal.typ_optthenpr_opt_no_spc(funx->pr_valuelevx)(unboxvVal.typ_opt)elseifhas_typevVal.typ_pairthenlet(v1,v2)=unboxvVal.typ_pairinstr"("++pr_valuelevv1++str", "++pr_valuelevv2++str")"elseletVal.Dyn(tag,x)=vinletname=Val.reprtaginletdefault=str"<"++strname++str">"inmatchArgT.namenamewith|None->default|Some(ArgT.Anyarg)->letwit=ExtraArgarginmatchval_tag(Topwitwit)with|Val.Baset->beginmatchVal.eqttagwith|None->default|SomeRefl->letopenGenprintinmatchgeneric_top_print(in_gen(Topwitwit)x)with|TopPrinterBasicpr->pr()|TopPrinterNeedsContextpr->letenv=Global.env()inprenv(Evd.from_envenv)|TopPrinterNeedsContextAndLevel{default_ensure_surrounded;printer}->letenv=Global.env()inprinterenv(Evd.from_envenv)default_ensure_surroundedend|_->defaultletpr_with_occurrencesprc=Ppred.pr_with_occurrencesprkeywordcletpr_red_exprenvsigmaprc=Ppred.pr_red_expr_envenvsigmaprkeywordcletpr_may_evalenvsigmatestprcprlcpr2pr3=function|ConstrEval(r,c)->hov0(keyword"eval"++brk(1,1)++pr_red_exprenvsigma(prc,prlc,pr2,pr3)r++spc()++keyword"in"++spc()++prcenvsigmac)|ConstrContext({CAst.v=id},c)->hov0(keyword"context"++spc()++pr_idid++spc()++str"[ "++prlcenvsigmac++str" ]")|ConstrTypeOfc->hov1(keyword"type of"++spc()++prcenvsigmac)|ConstrTermcwhentestc->h(str"("++prcenvsigmac++str")")|ConstrTermc->prcenvsigmacletpr_may_evalenvsigmaa=pr_may_evalenvsigma(fun_->false)aletpr_argprx=spc()++prxletpr_and_short_namepr(c,_)=prcletpr_evaluable_reference=function|Tacred.EvalVarRefid->pr_idid|Tacred.EvalConstRefsp->pr_global(GlobRef.ConstRefsp)letpr_quantified_hypothesis=function|AnonHypn->intn|NamedHypid->pr_ididletpr_clear_flagclear_flagppx=matchclear_flagwith|Somefalse->surround(ppx)|Sometrue->str">"++ppx|None->ppxletpr_with_bindingsprcprlc(c,bl)=prcc++Miscprint.pr_bindingsprcprlcblletpr_with_bindings_argprcprlc(clear_flag,c)=pr_clear_flagclear_flag(pr_with_bindingsprcprlc)cletpr_with_constrprc=function|None->mt()|Somec->spc()++hov1(keyword"with"++spc()++prcc)letpr_message_tokenprid=function|MsgStrings->tag_string(qss)|MsgIntn->intn|MsgIdentid->prididletpr_fresh_ids=prlist(funs->spc()++pr_or_var(funs->tag_string(qss))s)letwith_evarsevs=ifevthen"e"^selsesletrectacarg_using_rule_tokenpr_gen=function|[]->[]|TacTerms::l->keywords::tacarg_using_rule_tokenpr_genl|TacNonTerm(_,((symb,arg),_))::l->pr_gensymbarg::tacarg_using_rule_tokenpr_genlletpr_tacarg_using_rulepr_genl=letl=matchlwith|TacTerms::l->(* First terminal token should be considered as the name of the tactic,
so we tag it differently than the other terminal tokens. *)primitives::tacarg_using_rule_tokenpr_genl|_->tacarg_using_rule_tokenpr_genlinpr_sequence(funx->x)lletpr_extend_genpr_gen_{mltac_name=s;mltac_index=i}l=letname=strs.mltac_plugin++str"::"++strs.mltac_tactic++str"@"++intiinletargs=matchlwith|[]->mt()|_->spc()++pr_sequencepr_genlinstr"<"++name++str">"++argsletrecpr_user_symbol=function|Extend.Ulist1tkn->"ne_"^pr_user_symboltkn^"_list"|Extend.Ulist1sep(tkn,_)->"ne_"^pr_user_symboltkn^"_list"|Extend.Ulist0tkn->pr_user_symboltkn^"_list"|Extend.Ulist0sep(tkn,_)->pr_user_symboltkn^"_list"|Extend.Uopttkn->pr_user_symboltkn^"_opt"|Extend.Uentrytag->letArgT.Anytag=taginArgT.reprtag|Extend.Uentryl(_,lvl)->"tactic"^string_of_intlvlletpr_alias_keykey=tryletprods=(KNmap.findkey!prnotation_tab).pptac_prodsinletpr=function|TacTerms->primitives|TacNonTerm(_,(symb,_))->str(Printf.sprintf"(%s)"(pr_user_symbolsymb))inpr_sequenceprprodswithNot_found->(* FIXME: This key, moreover printed with a low-level printer,
has no meaning user-side *)KerName.printkeyletpr_alias_genpr_genlevkeyl=tryletpp=KNmap.findkey!prnotation_tabinletrecpackprodsargs=matchprods,argswith|[],[]->[]|TacTerms::prods,args->TacTerms::packprodsargs|TacNonTerm(_,(_,None))::prods,args->packprodsargs|TacNonTerm(loc,(symb,(Some_asido)))::prods,arg::args->TacNonTerm(loc,((symb,arg),ido))::packprodsargs|_->raiseNot_foundinletprods=packpp.pptac_prodslinletp=pr_tacarg_using_rulepr_genprodsinifpp.pptac_level>levthensurroundpelsepwithNot_found->letpr_=str"_"inKerName.printkey++spc()++pr_sequenceprl++str" (* Generic printer *)"letpr_fargprtacarg=prtacLevelSome(CAst.make(TacArgarg))letis_genargtagwit=letArgT.Anytag=taginargument_type_eq(ArgumentType(ExtraArgtag))witletget_list:typel.lgeneric_argument->lgeneric_argumentlistoption=function(GenArg(wit,arg))->matchwitwith|Rawwit(ListArgwit)->Some(List.map(in_gen(rawwitwit))arg)|Glbwit(ListArgwit)->Some(List.map(in_gen(glbwitwit))arg)|_->Noneletget_opt:typel.lgeneric_argument->lgeneric_argumentoptionoption=function(GenArg(wit,arg))->matchwitwith|Rawwit(OptArgwit)->Some(Option.map(in_gen(rawwitwit))arg)|Glbwit(OptArgwit)->Some(Option.map(in_gen(glbwitwit))arg)|_->Noneletrecpr_any_arg:typel.(_->lgeneric_argument->Pp.t)->_->lgeneric_argument->Pp.t=funprtacsymbarg->matchsymbwith|Extend.Uentrytagwhenis_genargtag(genarg_tagarg)->prtacLevelSomearg|Extend.Ulist1s|Extend.Ulist0s->beginmatchget_listargwith|None->str"ltac:("++prtacLevelSomearg++str")"|Somel->pr_sequence(pr_any_argprtacs)lend|Extend.Ulist1sep(s,sep)|Extend.Ulist0sep(s,sep)->beginmatchget_listargwith|None->str"ltac:("++prtacLevelSomearg++str")"|Somel->prlist_with_sep(fun()->strsep)(pr_any_argprtacs)lend|Extend.Uopts->beginmatchget_optargwith|None->str"ltac:("++prtacLevelSomearg++str")"|Somel->pr_opt(pr_any_argprtacs)lend|Extend.Uentry_|Extend.Uentryl_->str"ltac:("++prtacLevelSomearg++str")"letpr_targprtacsymbarg=matchsymbwith|Extend.Uentrytagwhenis_genargtag(ArgumentTypewit_tactic)->prtacLevelSomearg|Extend.Uentryl(_,l)->prtacLevelSomearg|_->matchargwith|TacGeneric(isquot,arg)->letprlarg=prtacl(TacGeneric(isquot,arg))inpr_any_argprsymbarg|_->str"ltac:("++prtacLevelSomearg++str")"letpr_raw_extend_recprtac=pr_extend_gen(pr_fargprtac)letpr_glob_extend_recprtac=pr_extend_gen(pr_fargprtac)letpr_raw_aliasprtaclevkeyargs=pr_alias_gen(pr_targ(funla->prtacl(CAst.make@@TacArga)))levkeyargsletpr_glob_aliasprtaclevkeyargs=pr_alias_gen(pr_targ(funla->prtacl(CAst.make@@TacArga)))levkeyargs(**********************************************************************)(* The tactic printer *)letstrip_prod_binders_exprnty=letrecstrip_tyaccnty=matchty.CAst.vwithConstrexpr.CProdN(bll,a)->letbll=List.map(function|CLocalAssum(nal,_,t)->nal,t|_->user_errPp.(str"Cannot translate fix tactic: not only products"))bllinletnb=List.fold_left(funi(nal,t)->i+List.lengthnal)0bllinifnb>=nthen(List.rev(bll@acc)),aelsestrip_ty(bll@acc)(n-nb)a|_->user_errPp.(str"Cannot translate fix tactic: not enough products")instrip_ty[]ntyletpr_ltac_or_varpr=function|ArgArgx->prx|ArgVar{CAst.loc;v=id}->pr_with_comments?loc(pr_idid)letpr_ltac_constantkn=if!Flags.in_debuggerthenKerName.printknelsetrypr_qualid(Tacenv.shortest_qualid_of_tactickn)withNot_found->(* local tactic not accessible anymore *)str"<"++KerName.printkn++str">"letpr_evaluable_reference_envenv=function|Tacred.EvalVarRefid->pr_idid|Tacred.EvalConstRefsp->Nametab.pr_global_env(Termops.vars_of_envenv)(GlobRef.ConstRefsp)letpr_as_disjunctive_ipatprcipatl=keyword"as"++spc()++pr_or_var(fun{CAst.loc;v=p}->Miscprint.pr_or_and_intro_patternprcp)ipatlletpr_eqn_ipat{CAst.v=ipat}=keyword"eqn:"++Miscprint.pr_intro_pattern_namingipatletpr_with_induction_namesprc=function|None,None->mt()|Someeqpat,None->hov1(pr_eqn_ipateqpat)|None,Someipat->hov1(pr_as_disjunctive_ipatprcipat)|Someeqpat,Someipat->hov1(pr_as_disjunctive_ipatprcipat++spc()++pr_eqn_ipateqpat)letpr_as_intro_patternprcipat=spc()++hov1(keyword"as"++spc()++Miscprint.pr_intro_patternprcipat)letpr_with_inversion_namesprc=function|None->mt()|Someipat->pr_as_disjunctive_ipatprcipatletpr_as_ipatprc=function|None->mt()|Someipat->pr_as_intro_patternprcipatletpr_as_name=function|Anonymous->mt()|Nameid->spc()++keyword"as"++spc()++pr_lident(CAst.makeid)letpr_pose_as_styleprcnac=spc()++prcc++pr_as_namenaletpr_poseprcprlcnac=matchnawith|Anonymous->spc()++prcc|Nameid->spc()++surround(pr_idid++str" :="++spc()++prlcc)letpr_assertionprcprdc_prlcipatc=matchipatwith(* Use this "optimisation" or use only the general case ?
| IntroIdentifier id ->
spc() ++ surround (pr_intro_pattern ipat ++ str " :" ++ spc() ++ prlc c)
*)|ipat->spc()++prcc++pr_as_ipatprdcipatletpr_assumptionprcprdcprlcipatc=matchipatwith(* Use this "optimisation" or use only the general case ?*)(* it seems that this "optimisation" is somehow more natural *)|Some{CAst.v=IntroNaming(IntroIdentifierid)}->spc()++surround(pr_idid++str" :"++spc()++prlcc)|ipat->spc()++prcc++pr_as_ipatprdcipatletpr_by_tacticprt=function|Sometac->keyword"by"++spc()++prttac|None->mt()letpr_hyp_locationpr_id=function|occs,InHyp->pr_with_occurrencespr_idoccs|occs,InHypTypeOnly->pr_with_occurrences(funid->str"("++keyword"type of"++spc()++pr_idid++str")")occs|occs,InHypValueOnly->pr_with_occurrences(funid->str"("++keyword"value of"++spc()++pr_idid++str")")occsletpr_inpp=hov0(keyword"in"++pp)letpr_simple_hyp_clausepr_id=function|[]->mt()|l->pr_in(spc()++prlist_with_sepspcpr_idl)letpr_in_hyp_asprcpr_id=function|[]->mt()|l->pr_in(spc()++prlist_with_seppr_comma(fun(id,ipat)->pr_idid++pr_as_ipatprcipat)l)letpr_in_clausepr_id=function|{onhyps=None;concl_occs=NoOccurrences}->(str"* |-")|{onhyps=None;concl_occs=occs}->(pr_with_occurrences(fun()->str"*")(occs,()))|{onhyps=Somel;concl_occs=NoOccurrences}->prlist_with_sep(fun()->str", ")(pr_hyp_locationpr_id)l|{onhyps=Somel;concl_occs=occs}->letpr_occs=pr_with_occurrences(fun()->str" |- *")(occs,())in(prlist_with_sep(fun()->str", ")(pr_hyp_locationpr_id)l++pr_occs)(* Some true = default is concl; Some false = default is all; None = no default *)letpr_clauseshas_defaultpr_id=function|{onhyps=Some[];concl_occs=occs}when(matchhas_defaultwithSometrue->true|_->false)->pr_with_occurrencesmt(occs,())|{onhyps=None;concl_occs=AllOccurrences}when(matchhas_defaultwithSomefalse->true|_->false)->mt()|{onhyps=None;concl_occs=NoOccurrences}->pr_in(str" * |-")|{onhyps=None;concl_occs=occs}->pr_in(pr_with_occurrences(fun()->str" *")(occs,()))|{onhyps=Somel;concl_occs=occs}->letpr_occs=matchoccswith|NoOccurrences->mt()|_->pr_with_occurrences(fun()->str" |- *")(occs,())inpr_in(prlist_with_sep(fun()->str",")(funid->spc()++pr_hyp_locationpr_idid)l++pr_occs)letpr_orientb=ifbthenmt()elsestr"<- "letpr_multi=letopenEqualityinfunction|Precisely1->mt()|Preciselyn->intn++str"!"|UpTon->intn++str"?"|RepeatStar->str"?"|RepeatPlus->str"!"letpr_core_destruction_argprcprlc=function|ElimOnConstrc->pr_with_bindingsprcprlcc|ElimOnIdent{CAst.loc;v=id}->pr_with_comments?loc(pr_idid)|ElimOnAnonHypn->intnletpr_destruction_argprcprlc(clear_flag,h)=pr_clear_flagclear_flag(pr_core_destruction_argprcprlc)hletpr_inversion_kind=letopenInvinfunction|SimpleInversion->primitive"simple inversion"|FullInversion->primitive"inversion"|FullInversionClear->primitive"inversion_clear"letpr_range_selector(i,j)=ifInt.equalijthenintielseinti++str"-"++intjletpr_goal_selectortoplevel=letopenGoal_selectinfunction|SelectAlreadyFocused->str"!:"|SelectNthi->inti++str":"|SelectListl->prlist_with_sep(fun()->str", ")pr_range_selectorl++str":"|SelectIdid->str"["++Id.printid++str"]:"|SelectAll->asserttoplevel;str"all:"letpr_goal_selector~toplevels=(iftoplevelthenmt()elsestr"only ")++pr_goal_selectortoplevelsletpr_lazy=function|General->keyword"multi"|Select->keyword"lazy"|Once->mt()letpr_match_patternpr_pat=function|Terma->pr_pata|Subterm(None,a)->keyword"context"++str" [ "++pr_pata++str" ]"|Subterm(Someid,a)->keyword"context"++spc()++pr_idid++str"[ "++pr_pata++str" ]"letpr_match_hypspr_pat=function|Hyp(nal,mp)->pr_lnamenal++str":"++pr_match_patternpr_patmp|Def(nal,mv,mp)->pr_lnamenal++str":="++pr_match_patternpr_patmv++str":"++pr_match_patternpr_patmpletpr_match_rulemprpr_pat=function|Pat([],mp,t)whenm->pr_match_patternpr_patmp++spc()++str"=>"++brk(1,4)++prt(*
| Pat (rl,mp,t) ->
hv 0 (prlist_with_sep pr_comma (pr_match_hyps pr_pat) rl ++
(if rl <> [] then spc () else mt ()) ++
hov 0 (str "|-" ++ spc () ++ pr_match_pattern pr_pat mp ++ spc () ++
str "=>" ++ brk (1,4) ++ pr t))
*)|Pat(rl,mp,t)->hov0(hv0(prlist_with_seppr_comma(pr_match_hypspr_pat)rl)++(ifnot(List.is_emptyrl)thenspc()elsemt())++hov0(str"|-"++spc()++pr_match_patternpr_patmp++spc()++str"=>"++brk(1,4)++prt))|Allt->str"_"++spc()++str"=>"++brk(1,4)++prtletpr_funvarn=spc()++Name.printnletpr_let_clausekpr_genpr_arg(na,(bl,t))=letpr=function|TacGeneric(_,arg)->letname=string_of_genarg_arg(genarg_tagarg)inifname="unit"||name="int"then(* Hard-wired parsing rules *)pr_genargelsestrname++str":"++surround(pr_genarg)|_->pr_arg(CAst.make(TacArgt))inhov0(keywordk++spc()++pr_lnamena++prlistpr_funvarbl++str" :="++brk(1,1)++prt)letpr_let_clausesrecflagpr_genpr=function|hd::tl->hv0(pr_let_clause(ifrecflagthen"let rec"else"let")pr_genprhd++prlist(funt->spc()++pr_let_clause"with"pr_genprt)tl)|[]->anomaly(Pp.str"LetIn must declare at least one binding.")letpr_seq_bodyprtl=hv0(str"[ "++prlist_with_sep(fun()->spc()++str"| ")prtl++str" ]")letpr_dispatchprtl=hv0(str"[>"++prlist_with_sep(fun()->spc()++str"| ")prtl++str" ]")letpr_opt_tacticpr=function|{CAst.v=(TacId[])}->mt()|t->prtletpr_tac_extend_genprtftmtl=prvect_with_sepmt(funt->prt++spc()++str"| ")tf++pr_opt_tacticprtm++str".."++prvect_with_sepmt(funt->spc()++str"| "++prt)tlletpr_then_genprtftmtl=hv0(str"[ "++pr_tac_extend_genprtftmtl++str" ]")letpr_tac_extendprtftmtl=hv0(str"[>"++pr_tac_extend_genprtftmtl++str" ]")letpr_hintbases=function|None->keyword"with"++str" *"|Some[]->mt()|Somel->hov2(keyword"with"++prlist(funs->spc()++strs)l)letpr_auto_usingprc=function|[]->mt()|l->hov2(keyword"using"++spc()++prlist_with_seppr_commaprcl)letpr_then()=str";"letltop=LevelLe5letlseq=4letltactical=3letlorelse=2letllet=5letlfun=5letlcomplete=1letlabstract=3letlmatch=1letlatom=0letlcall=1letleval=1letltatom=1letlevel_ofp=matchpwithLevelLen->n|LevelLtn->n-1|LevelSome->lseq(** A printer for tactics that polymorphically works on the three
"raw", "glob" and "typed" levels *)type'aprinter={pr_tactic:entry_relative_level->'tacexpr->Pp.t;pr_constr:Environ.env->Evd.evar_map->'trm->Pp.t;pr_lconstr:Environ.env->Evd.evar_map->'trm->Pp.t;pr_dconstr:Environ.env->Evd.evar_map->'dtrm->Pp.t;pr_pattern:Environ.env->Evd.evar_map->'pat->Pp.t;pr_lpattern:Environ.env->Evd.evar_map->'pat->Pp.t;pr_constant:'cst->Pp.t;pr_reference:'ref->Pp.t;pr_name:'nam->Pp.t;pr_generic:Environ.env->Evd.evar_map->'levgeneric_argument->Pp.t;pr_extend:int->ml_tactic_entry->'agen_tactic_arglist->Pp.t;pr_alias:int->KerName.t->'agen_tactic_arglist->Pp.t;}constraint'a=<term:'trm;dterm:'dtrm;pattern:'pat;constant:'cst;reference:'ref;name:'nam;tacexpr:'tacexpr;level:'lev>letpr_atomenvsigmaprstrip_prod_binderstag_atom=letpr_with_bindings=pr_with_bindings(pr.pr_constrenvsigma)(pr.pr_lconstrenvsigma)inletpr_with_bindings_arg_full=pr_with_bindings_arginletpr_with_bindings_arg=pr_with_bindings_arg(pr.pr_constrenvsigma)(pr.pr_lconstrenvsigma)inletpr_red_expr=pr_red_exprenvsigma(pr.pr_constr,pr.pr_lconstr,pr.pr_constant,pr.pr_pattern)inlet_pr_constrargc=spc()++pr.pr_constrenvsigmacinletpr_lconstrargc=spc()++pr.pr_lconstrenvsigmacinletpr_intargn=spc()++intnin(* Some printing combinators *)letpr_eliminatorcb=keyword"using"++pr_argpr_with_bindingscbinletpr_binder_fix(nal,t)=(* match t with
| CHole _ -> spc() ++ prlist_with_sep spc (pr_lname) nal
| _ ->*)lets=prlist_with_sepspcpr_lnamenal++str":"++pr.pr_lconstrenvsigmatinspc()++hov1(str"("++s++str")")inletpr_fix_tac(id,n,c)=letrecset_nth_nameavoidn=function(nal,ty)::bll->ifn<=List.lengthnalthenmatchList.chop(n-1)nalwith_,{CAst.v=Nameid}::_->id,(nal,ty)::bll|bef,{CAst.loc;v=Anonymous}::aft->letid=next_ident_away(Id.of_string"y")avoidinid,((bef@(CAst.make?loc@@Nameid)::aft,ty)::bll)|_->assertfalseelselet(id,bll')=set_nth_nameavoid(n-List.lengthnal)bllin(id,(nal,ty)::bll')|[]->assertfalseinlet(bll,ty)=strip_prod_bindersncinletnames=List.fold_left(funln(nal,_)->List.fold_left(funlnna->matchnawith{CAst.v=Nameid}->Id.Set.addidln|_->ln)lnnal)Id.Set.emptybllinletidarg,bll=set_nth_namenamesnbllinletannot=ifInt.equal(Id.Set.cardinalnames)1thenmt()elsespc()++str"{"++keyword"struct"++spc()++pr_ididarg++str"}"inhov1(str"("++pr_idid++prlistpr_binder_fixbll++annot++str" :"++(pr_lconstrargty)++str")")in(* spc() ++
hov 0 (pr_id id ++ pr_intarg n ++ str":" ++ _pr_constrarg
c)
*)letpr_cofix_tac(id,c)=hov1(str"("++pr_idid++str" :"++pr_lconstrargc++str")")in(* Printing tactics as arguments *)letrecpr_atom0a=tag_atoma(matchawith|TacIntroPattern(false,[])->primitive"intros"|TacIntroPattern(true,[])->primitive"eintros"|t->str"("++pr_atom1t++str")")(* Main tactic printer *)andpr_atom1a=tag_atoma(matchawith(* Basic tactics *)|TacIntroPattern(_,[])ast->pr_atom0t|TacIntroPattern(ev,(_::_asp))->hov1(primitive(ifevthen"eintros"else"intros")++(matchpwith|[{CAst.v=IntroForthcomingfalse}]->mt()|_->spc()++prlist_with_sepspc(Miscprint.pr_intro_pattern@@pr.pr_dconstrenvsigma)p))|TacApply(a,ev,cb,inhyp)->hov1((ifathenmt()elseprimitive"simple ")++primitive(with_evarsev"apply")++spc()++prlist_with_seppr_commapr_with_bindings_argcb++pr_non_empty_arg(pr_in_hyp_as(pr.pr_dconstrenvsigma)pr.pr_name)inhyp)|TacElim(ev,cb,cbo)->hov1(primitive(with_evarsev"elim")++pr_argpr_with_bindings_argcb++pr_optpr_eliminatorcbo)|TacCase(ev,cb)->hov1(primitive(with_evarsev"case")++spc()++pr_with_bindings_argcb)|TacMutualFix(id,n,l)->hov1(primitive"fix"++spc()++pr_idid++pr_intargn++spc()++keyword"with"++spc()++prlist_with_sepspcpr_fix_tacl)|TacMutualCofix(id,l)->hov1(primitive"cofix"++spc()++pr_idid++spc()++keyword"with"++spc()++prlist_with_sepspcpr_cofix_tacl)|TacAssert(ev,b,Sometac,ipat,c)->hov1(primitive(ifbthenifevthen"eassert"else"assert"elseifevthen"eenough"else"enough")++pr_assumption(pr.pr_constrenvsigma)(pr.pr_dconstrenvsigma)(pr.pr_lconstrenvsigma)ipatc++pr_non_empty_arg(pr_by_tactic(pr.pr_tactic(LevelLeltactical)))tac)|TacAssert(ev,_,None,ipat,c)->hov1(primitive(ifevthen"epose proof"else"pose proof")++pr_assertion(pr.pr_constrenvsigma)(pr.pr_dconstrenvsigma)(pr.pr_lconstrenvsigma)ipatc)|TacGeneralizel->hov1(primitive"generalize"++spc()++prlist_with_seppr_comma(fun(cl,na)->pr_with_occurrences(pr.pr_constrenvsigma)cl++pr_as_namena)l)|TacLetTac(ev,na,c,cl,true,_)whenLocusops.is_nowherecl->hov1(primitive(ifevthen"epose"else"pose")++pr_pose(pr.pr_constrenvsigma)(pr.pr_lconstrenvsigma)nac)|TacLetTac(ev,na,c,cl,b,e)->hov1(primitive(ifbthenifevthen"eset"else"set"elseifevthen"eremember"else"remember")++(ifbthenpr_pose(pr.pr_constrenvsigma)(pr.pr_lconstrenvsigma)nacelsepr_pose_as_style(pr.pr_constrenvsigma)nac)++pr_opt(funp->pr_eqn_ipatp++spc())e++pr_non_empty_arg(pr_clauses(Someb)pr.pr_name)cl)(* | TacInstantiate (n,c,ConclLocation ()) ->
hov 1 (str "instantiate" ++ spc() ++
hov 1 (str"(" ++ pr_arg int n ++ str" :=" ++
pr_lconstrarg c ++ str ")" ))
| TacInstantiate (n,c,HypLocation (id,hloc)) ->
hov 1 (str "instantiate" ++ spc() ++
hov 1 (str"(" ++ pr_arg int n ++ str" :=" ++
pr_lconstrarg c ++ str ")" )
++ str "in" ++ pr_hyp_location pr.pr_name (id,[],(hloc,ref None)))
*)(* Derived basic tactics *)|TacInductionDestruct(isrec,ev,(l,el))->hov1(primitive(with_evarsev(ifisrecthen"induction"else"destruct"))++spc()++prlist_with_seppr_comma(fun(h,ids,cl)->pr_destruction_arg(pr.pr_dconstrenvsigma)(pr.pr_dconstrenvsigma)h++pr_non_empty_arg(pr_with_induction_names(pr.pr_dconstrenvsigma))ids++pr_opt(pr_clausesNonepr.pr_name)cl)l++pr_optpr_eliminatorel)(* Conversion *)|TacReduce(r,h)->hov1(pr_red_exprr++pr_non_empty_arg(pr_clauses(Sometrue)pr.pr_name)h)|TacChange(check,op,c,h)->letname=ifcheckthen"change"else"change_no_check"inhov1(primitivename++brk(1,1)++(matchopwithNone->mt()|Somep->pr.pr_patternenvsigmap++spc()++keyword"with"++spc())++pr.pr_dconstrenvsigmac++pr_non_empty_arg(pr_clauses(Sometrue)pr.pr_name)h)(* Equality and inversion *)|TacRewrite(ev,l,cl,tac)->hov1(primitive(with_evarsev"rewrite")++spc()++prlist_with_sep(fun()->str","++spc())(fun(b,m,c)->pr_orientb++pr_multim++pr_with_bindings_arg_full(pr.pr_dconstrenvsigma)(pr.pr_dconstrenvsigma)c)l++pr_non_empty_arg(pr_clauses(Sometrue)pr.pr_name)cl++pr_non_empty_arg(pr_by_tactic(pr.pr_tactic(LevelLeltactical)))tac)|TacInversion(DepInversion(k,c,ids),hyp)->hov1(primitive"dependent "++pr_inversion_kindk++spc()++pr_quantified_hypothesishyp++pr_with_inversion_names(pr.pr_dconstrenvsigma)ids++pr_with_constr(pr.pr_constrenvsigma)c)|TacInversion(NonDepInversion(k,cl,ids),hyp)->hov1(pr_inversion_kindk++spc()++pr_quantified_hypothesishyp++pr_non_empty_arg(pr_with_inversion_names@@pr.pr_dconstrenvsigma)ids++pr_non_empty_arg(pr_simple_hyp_clausepr.pr_name)cl)|TacInversion(InversionUsing(c,cl),hyp)->hov1(primitive"inversion"++spc()++pr_quantified_hypothesishyp++spc()++keyword"using"++spc()++pr.pr_constrenvsigmac++pr_non_empty_arg(pr_simple_hyp_clausepr.pr_name)cl))inpr_atom1letmake_pr_tacenvsigmaprstrip_prod_binderstag_atomtag=letextract_binders=function|Tacexp{CAst.loc;v=(TacFun(lvar,body))}->(lvar,Tacexpbody)|body->([],body)inletrecpr_tacinheritedtac=letreturn(doc,l)=(tagtacdoc,l)inlet(loc,tac)=CAst.(tac.loc,tac.v)inlet(strm,prec)=return(matchtacwith|TacAbstract(t,None)->keyword"abstract "++pr_tac(LevelLtlabstract)t,labstract|TacAbstract(t,Somes)->hov0(keyword"abstract"++str" ("++pr_tac(LevelLtlabstract)t++str")"++spc()++keyword"using"++spc()++pr_ids),labstract|TacLetIn(recflag,llc,u)->letllc=List.map(fun(id,t)->(id,extract_binderst))llcinv0(hv0(pr_let_clausesrecflag(pr.pr_genericenvsigma)(pr_tacltop)llc++spc()++keyword"in")++fnl()++pr_tac(LevelLellet)u),llet|TacMatch(lz,t,lrul)->hov0(pr_lazylz++keyword"match"++spc()++pr_tacltopt++spc()++keyword"with"++prlist(funr->fnl()++str"| "++pr_match_ruletrue(pr_tacltop)(pr.pr_lpatternenvsigma)r)lrul++fnl()++keyword"end"),lmatch|TacMatchGoal(lz,lr,lrul)->hov0(pr_lazylz++keyword(iflrthen"match reverse goal with"else"match goal with")++prlist(funr->fnl()++str"| "++pr_match_rulefalse(pr_tacltop)(pr.pr_lpatternenvsigma)r)lrul++fnl()++keyword"end"),lmatch|TacFun(lvar,body)->hov2(keyword"fun"++prlistpr_funvarlvar++str" =>"++spc()++pr_tac(LevelLelfun)body),lfun|TacThens(t,tl)->hov1(pr_tac(LevelLelseq)t++pr_then()++spc()++pr_seq_body(pr_opt_tactic(pr_tacltop))tl),lseq|TacThen(t1,t2)->hov1(pr_tac(LevelLelseq)t1++pr_then()++spc()++pr_tac(LevelLtlseq)t2),lseq|TacDispatchtl->pr_dispatch(pr_tacltop)tl,lseq|TacExtendTac(tf,t,tr)->pr_tac_extend(pr_tacltop)tfttr,lseq|TacThens3parts(t1,tf,t2,tl)->hov1(pr_tac(LevelLelseq)t1++pr_then()++spc()++pr_then_gen(pr_tacltop)tft2tl),lseq|TacTryt->hov1(keyword"try"++spc()++pr_tac(LevelLeltactical)t),ltactical|TacDo(n,t)->hov1(str"do"++spc()++pr_or_varintn++spc()++pr_tac(LevelLeltactical)t),ltactical|TacTimeout(n,t)->hov1(keyword"timeout "++pr_or_varintn++spc()++pr_tac(LevelLeltactical)t),ltactical|TacTime(s,t)->hov1(keyword"time"++pr_optqstrings++spc()++pr_tac(LevelLeltactical)t),ltactical|TacRepeatt->hov1(keyword"repeat"++spc()++pr_tac(LevelLeltactical)t),ltactical|TacProgresst->hov1(keyword"progress"++spc()++pr_tac(LevelLeltactical)t),ltactical|TacShowHypst->hov1(keyword"infoH"++spc()++pr_tac(LevelLeltactical)t),ltactical|TacOr(t1,t2)->hov1(pr_tac(LevelLtlorelse)t1++spc()++str"+"++brk(1,1)++pr_tac(LevelLelorelse)t2),lorelse|TacOncet->hov1(keyword"once"++spc()++pr_tac(LevelLeltactical)t),ltactical|TacExactlyOncet->hov1(keyword"exactly_once"++spc()++pr_tac(LevelLeltactical)t),ltactical|TacIfThenCatch(t,tt,te)->hov1(str"tryif"++spc()++pr_tac(LevelLeltactical)t++brk(1,1)++str"then"++spc()++pr_tac(LevelLeltactical)tt++brk(1,1)++str"else"++spc()++pr_tac(LevelLeltactical)te++brk(1,1)),ltactical|TacOrelse(t1,t2)->hov1(pr_tac(LevelLtlorelse)t1++spc()++str"||"++brk(1,1)++pr_tac(LevelLelorelse)t2),lorelse|TacFail(g,n,l)->letarg=matchnwith|ArgArg0->mt()|_->pr_arg(pr_or_varint)ninletname=matchgwith|TacGlobal->keyword"gfail"|TacLocal->keyword"fail"inhov1(name++arg++prlist(pr_arg(pr_message_tokenpr.pr_name))l),latom|TacFirsttl->keyword"first"++spc()++pr_seq_body(pr_tacltop)tl,llet|TacSolvetl->keyword"solve"++spc()++pr_seq_body(pr_tacltop)tl,llet|TacCompletet->pr_tac(LevelLelcomplete)t,lcomplete|TacSelect(s,tac)->pr_goal_selector~toplevel:falses++spc()++pr_tacltoptac,latom|TacIdl->keyword"idtac"++prlist(pr_arg(pr_message_tokenpr.pr_name))l,latom|TacAtomt->pr_with_comments?loc(hov1(pr_atomenvsigmaprstrip_prod_binderstag_atomt)),ltatom|TacArg(Tacexpe)->pr_tacinheritede,latom|TacArg(ConstrMayEval(ConstrTermc))->keyword"constr:"++pr.pr_constrenvsigmac,latom|TacArg(ConstrMayEvalc)->pr_may_evalenvsigmapr.pr_constrpr.pr_lconstrpr.pr_constantpr.pr_patternc,leval|TacArg(TacFreshIdl)->primitive"fresh"++pr_fresh_idsl,latom|TacArg(TacGeneric(isquot,arg))->letp=pr.pr_genericenvsigmaargin(matchisquotwithSomename->strname++str":("++p++str")"|None->p),latom|TacArg(TacCall{CAst.v=(f,[])})->pr.pr_referencef,latom|TacArg(TacCall{CAst.loc;v=(f,l)})->pr_with_comments?loc(hov1(pr.pr_referencef++spc()++prlist_with_sepspcpr_tacargl)),lcall|TacArga->pr_tacarga,latom|TacML(s,l)->pr_with_comments?loc(pr.pr_extend1sl),lcall|TacAlias(kn,l)->pr_with_comments?loc(pr.pr_alias(level_ofinherited)knl),latom)inifprec_lessprecinheritedthenstrmelsestr"("++strm++str")"andpr_tacarg=function|Referencer->pr.pr_referencer|ConstrMayEvalc->pr_may_evalenvsigmapr.pr_constrpr.pr_lconstrpr.pr_constantpr.pr_patternc|TacFreshIdl->keyword"fresh"++pr_fresh_idsl|TacPretypec->keyword"type_term"++pr.pr_constrenvsigmac|TacNumgoals->keyword"numgoals"|(TacCall_|Tacexp_|TacGeneric_)asa->hov0(keyword"ltac:"++surround(pr_tacltop(CAst.make(TacArga))))inpr_tacletstrip_prod_binders_glob_constrn(ty,_)=letrecstrip_tyaccnty=ifInt.equaln0then(List.revacc,(ty,None))elsematchDAst.gettywithGlob_term.GProd(na,Glob_term.Explicit,a,b)->strip_ty(([CAst.makena],(a,None))::acc)(n-1)b|_->user_errPp.(str"Cannot translate fix tactic: not enough products")instrip_ty[]ntyletraw_printers=(strip_prod_binders_expr)letrecpr_raw_tactic_levelenvsigman(t:raw_tactic_expr)=letpr={pr_tactic=pr_raw_tactic_levelenvsigma;pr_constr=pr_constr_expr;pr_dconstr=pr_constr_expr;pr_lconstr=pr_lconstr_expr;pr_pattern=pr_constr_pattern_expr;pr_lpattern=pr_lconstr_pattern_expr;pr_constant=pr_or_by_notationpr_qualid;pr_reference=pr_qualid;pr_name=pr_lident;pr_generic=Pputils.pr_raw_generic;pr_extend=pr_raw_extend_rec@@pr_raw_tactic_levelenvsigma;pr_alias=pr_raw_alias@@pr_raw_tactic_levelenvsigma;}inmake_pr_tacenvsigmaprraw_printerstag_raw_atomic_tactic_exprtag_raw_tactic_exprntletpr_raw_tacticenvsigma=pr_raw_tactic_levelenvsigmaltopletpr_and_constr_exprpr(c,_)=prcletpr_pat_and_constr_exprpr(_,(c,_),_)=prcletpr_glob_tactic_levelenvnt=letglob_printers=(strip_prod_binders_glob_constr)inletrecprtacn(t:glob_tactic_expr)=letpr={pr_tactic=prtac;pr_constr=(funenvsigma->pr_and_constr_expr(pr_glob_constr_envenvsigma));pr_dconstr=(funenvsigma->pr_and_constr_expr(pr_glob_constr_envenvsigma));pr_lconstr=(funenvsigma->pr_and_constr_expr(pr_lglob_constr_envenvsigma));pr_pattern=(funenvsigma->pr_pat_and_constr_expr(pr_glob_constr_envenvsigma));pr_constant=pr_or_var(pr_and_short_name(pr_evaluable_reference_envenv));pr_lpattern=(funenvsigma->pr_pat_and_constr_expr(pr_lglob_constr_envenvsigma));pr_reference=pr_ltac_or_var(pr_locatedpr_ltac_constant);pr_name=pr_lident;pr_generic=Pputils.pr_glb_generic;pr_extend=pr_glob_extend_recprtac;pr_alias=pr_glob_aliasprtac;}inmake_pr_tacenv(Evd.from_envenv)prglob_printerstag_glob_atomic_tactic_exprtag_glob_tactic_exprntinprtacntletpr_glob_tacticenv=pr_glob_tactic_levelenvltopletstrip_prod_binders_constrnty=letty=EConstr.Unsafe.to_constrtyinletrecstrip_tyaccnty=ifn=0then(List.revacc,EConstr.of_constrty)elsematchConstr.kindtywith|Constr.Prod(na,a,b)->strip_ty(([CAst.makena.Context.binder_name],EConstr.of_constra)::acc)(n-1)b|_->user_errPp.(str"Cannot translate fix tactic: not enough products")instrip_ty[]ntyletpr_atomic_tactic_levelenvsigmat=letprtac(t:atomic_tactic_expr)=letpr={pr_tactic=(fun__->str"<tactic>");pr_constr=pr_econstr_env;pr_dconstr=(funenvsigma->pr_and_constr_expr(pr_glob_constr_envenvsigma));pr_lconstr=pr_leconstr_env;pr_pattern=pr_constr_pattern_env;pr_lpattern=pr_lconstr_pattern_env;pr_constant=pr_evaluable_reference_envenv;pr_reference=pr_locatedpr_ltac_constant;pr_name=pr_id;(* Those are not used by the atomic printer *)pr_generic=(fun_->assertfalse);pr_extend=(fun___->assertfalse);pr_alias=(fun___->assertfalse);}inpr_atomenvsigmaprstrip_prod_binders_constrtag_atomic_tactic_exprtinprtactletpr_raw_generic=Pputils.pr_raw_genericletpr_glb_generic=Pputils.pr_glb_genericletpr_raw_extendenvsigma=pr_raw_extend_rec@@pr_raw_tactic_levelenvsigmaletpr_glob_extendenv=pr_glob_extend_rec(pr_glob_tactic_levelenv)letpr_aliasprlevkeyargs=pr_alias_gen(fun_arg->prarg)levkeyargsletpr_extendprlevmlargs=pr_extend_genprlevmlargsletpr_atomic_tacticenvsigmac=pr_atomic_tactic_levelenvsigmacletdeclare_extra_genarg_pprulewit(f:'araw_extra_genarg_printer)(g:'bglob_extra_genarg_printer)(h:'cextra_genarg_printer)=beginmatchwitwith|ExtraArg_->()|_->user_errPp.(str"Can declare a pretty-printing rule only for extra argument types.")end;letfx=Genprint.PrinterBasic(funenvsigma->fenvsigmapr_constr_exprpr_lconstr_exprpr_raw_tactic_levelx)inletgx=Genprint.PrinterBasic(funenvsigma->genvsigma(funenvsigma->pr_and_constr_expr(pr_glob_constr_envenvsigma))(funenvsigma->pr_and_constr_expr(pr_lglob_constr_envenvsigma))(funenvsigma->pr_glob_tactic_levelenv)x)inlethx=Genprint.TopPrinterNeedsContext(funenvsigma->henvsigmapr_econstr_envpr_leconstr_env(fun_env_sigma__->str"<tactic>")x)inGenprint.register_print0witfghletdeclare_extra_genarg_pprule_with_levelwit(f:'araw_extra_genarg_printer_with_level)(g:'bglob_extra_genarg_printer_with_level)(h:'cextra_genarg_printer_with_level)default_surroundeddefault_non_surrounded=beginmatchwitwith|ExtraArgs->()|_->user_errPp.(str"Can declare a pretty-printing rule only for extra argument types.")end;letopenGenprintinletfx=PrinterNeedsLevel{default_already_surrounded=default_surrounded;default_ensure_surrounded=default_non_surrounded;printer=(funenvsigman->fenvsigmapr_constr_exprpr_lconstr_exprpr_raw_tactic_levelnx)}inletgx=PrinterNeedsLevel{default_already_surrounded=default_surrounded;default_ensure_surrounded=default_non_surrounded;printer=(funenvsigman->genvsigma(funenvsigma->pr_and_constr_expr(pr_glob_constr_envenvsigma))(funenvsigma->pr_and_constr_expr(pr_lglob_constr_envenvsigma))(funenvsigma->pr_glob_tactic_levelenv)nx)}inlethx=TopPrinterNeedsContextAndLevel{default_already_surrounded=default_surrounded;default_ensure_surrounded=default_non_surrounded;printer=(funenvsigman->henvsigmapr_econstr_envpr_leconstr_env(fun_env_sigma__->str"<tactic>")nx)}inGenprint.register_print0witfghletdeclare_extra_vernac_genarg_pprulewitf=letfx=Genprint.PrinterBasic(funenvsigma->fenvsigmapr_constr_exprpr_lconstr_exprpr_raw_tactic_levelx)inGenprint.register_vernac_print0witf(** Registering *)letpr_intro_pattern_envp=Genprint.TopPrinterNeedsContext(funenvsigma->letprint_constrc=let(sigma,c)=cenvsigmainpr_econstr_envenvsigmacinMiscprint.pr_intro_patternprint_constrp)letpr_red_expr_envr=Genprint.TopPrinterNeedsContext(funenvsigma->pr_red_exprenvsigma((fune->pr_econstr_enve),(fune->pr_leconstr_enve),pr_evaluable_reference_envenv,pr_constr_pattern_env)r)letpr_bindings_envbl=Genprint.TopPrinterNeedsContext(funenvsigma->letsigma,bl=blenvsigmainMiscprint.pr_bindings(pr_econstr_envenvsigma)(pr_leconstr_envenvsigma)bl)letpr_with_bindings_envbl=Genprint.TopPrinterNeedsContext(funenvsigma->letsigma,bl=blenvsigmainpr_with_bindings(pr_econstr_envenvsigma)(pr_leconstr_envenvsigma)bl)letpr_destruction_arg_envc=Genprint.TopPrinterNeedsContext(funenvsigma->letsigma,c=matchcwith|clear_flag,ElimOnConstrg->letsigma,c=genvsigmainsigma,(clear_flag,ElimOnConstrc)|clear_flag,ElimOnAnonHypnasx->sigma,x|clear_flag,ElimOnIdentidasx->sigma,xinpr_destruction_arg(pr_econstr_envenvsigma)(pr_leconstr_envenvsigma)c)letmake_constr_printerfc=Genprint.TopPrinterNeedsContextAndLevel{Genprint.default_already_surrounded=Ppconstr.ltop;Genprint.default_ensure_surrounded=Ppconstr.lsimpleconstr;Genprint.printer=(funenvsigman->fenvsigmanc)}letliftfa=Genprint.PrinterBasic(funenvsigma->fa)letlift_envfa=Genprint.PrinterBasic(funenvsigma->fenvsigmaa)letlift_topfa=Genprint.TopPrinterBasic(fun()->fa)letregister_basic_print0witfgh=Genprint.register_print0wit(liftf)(liftg)(lift_toph)letpr_glob_constr_pptacenvsigmac=pr_glob_constr_envenvsigmacletpr_lglob_constr_pptacenvsigmac=pr_lglob_constr_envenvsigmacletpr_raw_intro_pattern=lift_env(funenvsigma->Miscprint.pr_intro_pattern@@pr_constr_exprenvsigma)letpr_glob_intro_pattern=lift_env(funenvsigma->Miscprint.pr_intro_pattern(fun(c,_)->pr_glob_constr_pptacenvsigmac))let()=letpr_boolb=ifbthenstr"true"elsestr"false"inletpr_unit_=str"()"inletopenGenprintinregister_basic_print0wit_int_or_var(pr_or_varint)(pr_or_varint)int;register_basic_print0wit_nat_or_var(pr_or_varint)(pr_or_varint)int;register_basic_print0wit_refpr_qualid(pr_or_var(pr_locatedpr_global))pr_global;register_basic_print0wit_smart_global(pr_or_by_notationpr_qualid)(pr_or_var(pr_locatedpr_global))pr_global;register_basic_print0wit_identpr_idpr_idpr_id;register_basic_print0wit_hyppr_lidentpr_lidentpr_id;register_print0wit_intropatternpr_raw_intro_patternpr_glob_intro_patternpr_intro_pattern_env[@warning"-3"];register_print0wit_simple_intropatternpr_raw_intro_patternpr_glob_intro_patternpr_intro_pattern_env;Genprint.register_print0wit_clause_dft_concl(lift(pr_clauses(Sometrue)pr_lident))(lift(pr_clauses(Sometrue)pr_lident))(func->Genprint.TopPrinterBasic(fun()->pr_clauses(Sometrue)(funid->pr_lident(CAst.makeid))c));Genprint.register_print0wit_constr(lift_envPpconstr.pr_constr_expr)(lift_env(funenvsigma(c,_)->pr_glob_constr_pptacenvsigmac))(make_constr_printerPrinter.pr_econstr_n_env);Genprint.register_print0wit_uconstr(lift_envPpconstr.pr_constr_expr)(lift_env(funenvsigma(c,_)->pr_glob_constr_pptacenvsigmac))(make_constr_printerPrinter.pr_closed_glob_n_env);Genprint.register_print0wit_open_constr(lift_envPpconstr.pr_constr_expr)(lift_env(funenvsigma(c,_)->pr_glob_constr_pptacenvsigmac))(make_constr_printerPrinter.pr_econstr_n_env);Genprint.register_print0wit_red_expr(lift_env(funenvsigma->pr_red_exprenvsigma(pr_constr_expr,pr_lconstr_expr,pr_or_by_notationpr_qualid,pr_constr_pattern_expr)))(lift_env(funenvsigma->pr_red_exprenvsigma((funenvsigma->pr_and_constr_expr@@pr_glob_constr_pptacenvsigma),(funenvsigma->pr_and_constr_expr@@pr_lglob_constr_pptacenvsigma),pr_or_var(pr_and_short_namepr_evaluable_reference),(funenvsigma->pr_pat_and_constr_expr@@pr_glob_constr_pptacenvsigma))))pr_red_expr_env;register_basic_print0wit_quant_hyppr_quantified_hypothesispr_quantified_hypothesispr_quantified_hypothesis;register_print0wit_bindings(lift_env(funenvsigma->Miscprint.pr_bindings_no_with(pr_constr_exprenvsigma)(pr_lconstr_exprenvsigma)))(lift_env(funenvsigma->Miscprint.pr_bindings_no_with(pr_and_constr_expr@@pr_glob_constr_pptacenvsigma)(pr_and_constr_expr@@pr_lglob_constr_pptacenvsigma)))pr_bindings_env;register_print0wit_constr_with_bindings(lift_env(funenvsigma->pr_with_bindings(pr_constr_exprenvsigma)(pr_lconstr_exprenvsigma)))(lift_env(funenvsigma->pr_with_bindings(pr_and_constr_expr@@pr_glob_constr_pptacenvsigma)(pr_and_constr_expr@@pr_lglob_constr_pptacenvsigma)))pr_with_bindings_env;register_print0wit_open_constr_with_bindings(lift_env(funenvsigma->pr_with_bindings(pr_constr_exprenvsigma)(pr_lconstr_exprenvsigma)))(lift_env(funenvsigma->pr_with_bindings(pr_and_constr_expr@@pr_glob_constr_pptacenvsigma)(pr_and_constr_expr@@pr_lglob_constr_pptacenvsigma)))pr_with_bindings_env;register_print0Tacarg.wit_destruction_arg(lift_env(funenvsigma->pr_destruction_arg(pr_constr_exprenvsigma)(pr_lconstr_exprenvsigma)))(lift_env(funenvsigma->pr_destruction_arg(pr_and_constr_expr@@pr_glob_constr_pptacenvsigma)(pr_and_constr_expr@@pr_lglob_constr_pptacenvsigma)))pr_destruction_arg_env;register_basic_print0Stdarg.wit_intintintint;register_basic_print0Stdarg.wit_boolpr_boolpr_boolpr_bool;register_basic_print0Stdarg.wit_unitpr_unitpr_unitpr_unit;register_basic_print0Stdarg.wit_pre_identstrstrstr;register_basic_print0Stdarg.wit_stringqstringqstringqstringlet()=letprinterenvsigma__prtac=prtacenvsigmaindeclare_extra_genarg_pprule_with_levelwit_tacticprinterprinterprinterltop(LevelLe0)let()=letpr_unit_env_sigma____()=str"()"inletprinterenvsigma__prtac=prtacenvsigmaindeclare_extra_genarg_pprule_with_levelwit_ltacprinterprinterpr_unitltop(LevelLe0)