12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412(************************************************************************)(* * 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_occurrencesprvarprc=Ppred.pr_with_occurrencesprvarprkeywordcletpr_red_exprenvsigmaprc=Ppred.pr_red_expr_envenvsigmaprkeywordcletpr_may_evalenvsigmatestprcprlcpr2pr3pr4=function|ConstrEval(r,c)->hov0(keyword"eval"++brk(1,1)++pr_red_exprenvsigma(prc,prlc,pr2,pr3,pr4)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|Evaluable.EvalVarRefid->pr_idid|Evaluable.EvalConstRefsp->pr_global(GlobRef.ConstRefsp)|Evaluable.EvalProjectionRefp->str"TODO projection"(* TODO *)letpr_quantified_hypothesis=function|AnonHypn->intn|NamedHypid->pr_idid.CAst.vletpr_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)->prtac(LevelLel)arg|_->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|Evaluable.EvalVarRefid->pr_idid|Evaluable.EvalConstRefsp->Nametab.pr_global_env(Termops.vars_of_envenv)(GlobRef.ConstRefsp)|Evaluable.EvalProjectionRefp->str"TODO projection"(* TODO *)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_occurrences(pr_or_varint)pr_idoccs|occs,InHypTypeOnly->pr_with_occurrences(pr_or_varint)(funid->str"("++keyword"type of"++spc()++pr_idid++str")")occs|occs,InHypValueOnly->pr_with_occurrences(pr_or_varint)(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(pr_or_varint)(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(pr_or_varint)(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_occurrences(pr_or_varint)mt(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(pr_or_varint)(fun()->str" *")(occs,()))|{onhyps=Somel;concl_occs=occs}->letpr_occs=matchoccswith|NoOccurrences->mt()|_->pr_with_occurrences(pr_or_varint)(fun()->str" |- *")(occs,())inpr_in(prlist_with_sep(fun()->str",")(funid->spc()++pr_hyp_locationpr_idid)l++pr_occs)(* When the [ssreflect.SsrSynax] module is imported, ssreflect operates
in reduced compatibility mode. During printing, we try to account for
this when this module is imported. See [plugins/ssr/ssrparser.mlg] for
the code that enables the reduced compatibility mode. *)letssr_loaded=ref(fun()->false)letssr_loaded_hookf=ssr_loaded:=fletpr_orientb=ifbthenif!ssr_loaded()thenstr"-> "elsemt()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_goal_selector~toplevels=(iftoplevelthenmt()elsestr"only ")++Goal_select.pr_goal_selectors++str":"letpr_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=5(* in principle necessary only on the left-hand side of binary operators *)letlfun=5letlabstract=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_red_pattern:Environ.env->Evd.evar_map->'rpat->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_occvar:'occvar->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;red_pattern:'rpat;constant:'cst;reference:'ref;name:'nam;occvar:'occvar;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_red_pattern,pr.pr_occvar)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_occurrencespr.pr_occvar(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)(* 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_red_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|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|TacSelect(s,tac)->pr_goal_selector~toplevel:falses++spc()++pr_tacltoptac,ltactical|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_red_patternpr.pr_occvarc,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)inifNotation.prec_lessprecinheritedthenstrmelsestr"("++strm++str")"andpr_tacarg=function|Referencer->pr.pr_referencer|ConstrMayEvalc->pr_may_evalenvsigmapr.pr_constrpr.pr_lconstrpr.pr_constantpr.pr_red_patternpr.pr_occvarc|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_red_pattern=pr_constr_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_occvar=pr_or_varint;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_red_pattern=(funenvsigma->pr_and_constr_expr(pr_glob_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_occvar=pr_or_varint;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_red_pattern=pr_constr_pattern_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;pr_occvar=int;(* 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_levelenvsigmacletpp_ltac_call_kind=function|LtacNotationCalls->pr_alias_keys|LtacNameCallcst->pr_ltac_constantcst(* todo: don't want the KerName instead? *)|LtacVarCall(_,id,t)->Names.Id.printid|LtacAtomCallte->pr_glob_tactic(Global.env())(CAst.make(TacAtomte))|LtacConstrInterp(env,sigma,c,_)->pr_glob_constr_envenvsigmac|LtacMLCallte->(pr_glob_tactic(Global.env())te)letdeclare_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,int)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_print0Redexpr.wit_red_expr(lift_env(funenvsigma->pr_red_exprenvsigma(pr_constr_expr,pr_lconstr_expr,pr_or_by_notationpr_qualid,pr_constr_pattern_expr,pr_or_varint)))(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_and_constr_expr@@pr_glob_constr_pptacenvsigma),(pr_or_varint))))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)