123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443(************************************************************************)(* * 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) *)(************************************************************************)openPpopenNamesopenCErrorsopenUtilopenCAstopenExtendopenConstrexpropenVernacexpropenDeclaremodsopenPputilsopenPpconstrletdo_not_tag_x=xlettag_keyword=do_not_tag()lettag_vernac=do_not_tagletkeywords=tag_keyword(strs)letpr_smart_global=Pputils.pr_or_by_notationpr_qualidletpr_in_global_envfc:Pp.t=letenv=Global.env()inletsigma=Evd.from_envenvinfenvsigmac(* when not !Flags.beautify_file these just ignore the env/sigma *)letpr_constr_expr=pr_in_global_envpr_constr_exprletpr_lconstr_expr=pr_in_global_envpr_lconstr_exprletpr_binders=pr_in_global_envpr_bindersletpr_constr_pattern_expr=pr_in_global_envpr_constr_pattern_expr(* In principle this may use the env/sigma, in practice not sure if it
does except through pr_constr_expr in beautify mode. *)letpr_gen=pr_in_global_envPputils.pr_raw_generic(* No direct Global.env or pr_in_global_env use after this *)letpr_constr=pr_constr_exprletpr_lconstr=pr_lconstr_exprletpr_spc_lconstr=pr_sep_comspc@@pr_lconstr_exprletpr_red_expr=Ppred.pr_red_expr(pr_constr_expr,pr_lconstr_expr,pr_smart_global,pr_constr_expr,pr_or_varint)keywordletpr_uconstraint(l,d,r)=pr_sort_name_exprl++spc()++Univ.pr_constraint_typed++spc()++pr_sort_name_exprrletpr_full_univ_name_list=function|None->mt()|Some(ql,ul)->str"@{"++prlist_with_sepspcpr_lnameql++(ifList.is_emptyqlthenmt()elsestrbrk" | ")++prlist_with_sepspcpr_lnameul++str"}"letpr_variance_lident(lid,v)=letv=Option.cataUVars.Variance.pr(mt())vinv++pr_lidentlidletpr_univdecl_qualitieslextensible=(* "extensible" not really supported in syntax currently *)ifList.is_emptylthenmt()elseprlist_with_sepspcpr_lidentl++strbrk" | "letpr_univdecl_instancelextensible=prlist_with_sepspcpr_lidentl++(ifextensiblethenstr"+"elsemt())letpr_cumul_univdecl_instancelextensible=prlist_with_sepspcpr_variance_lidentl++(ifextensiblethenstr"+"elsemt())letpr_univdecl_constraintslextensible=ifList.is_emptyl&&extensiblethenmt()elsepr_spcbar()++prlist_with_seppr_commapr_uconstraintl++(ifextensiblethenstr"+"elsemt())letpr_universe_decll=letopenUStateinmatchlwith|None->mt()|Somel->str"@{"++pr_univdecl_qualitiesl.univdecl_qualitiesl.univdecl_extensible_qualities++pr_univdecl_instancel.univdecl_instancel.univdecl_extensible_instance++pr_univdecl_constraintsl.univdecl_constraintsl.univdecl_extensible_constraints++str"}"letpr_cumul_univ_decll=letopenUStateinmatchlwith|None->mt()|Somel->str"@{"++pr_univdecl_qualitiesl.univdecl_qualitiesl.univdecl_extensible_qualities++pr_cumul_univdecl_instancel.univdecl_instancel.univdecl_extensible_instance++pr_univdecl_constraintsl.univdecl_constraintsl.univdecl_extensible_constraints++str"}"letpr_ident_decl(lid,l)=pr_lidentlid++pr_universe_decllletpr_cumul_ident_decl(lid,l)=pr_lidentlid++pr_cumul_univ_decllletstring_of_fqidfqid=String.concat"."(List.mapId.to_stringfqid)letpr_fqidfqid=str(string_of_fqidfqid)letpr_lfqid{CAst.loc;v=fqid}=matchlocwith|None->pr_fqidfqid|Someloc->let(b,_)=Loc.unloclocinpr_locatedpr_fqid@@Loc.tag~loc:(Loc.make_loc(b,b+String.length(string_of_fqidfqid)))fqidletpr_lname_decl(n,u)=pr_lnamen++pr_universe_decluletpr_ltac_ref=Libnames.pr_qualidletpr_module=Libnames.pr_qualidletpr_import_cats=function|None->mt()|Some{negative;import_cats=cats}->(ifnegativethenstr"-"elsemt())++str"("++prlist_with_sep(fun()->str",")(funx->strx.v)cats++str")"letpr_one_import_filter_name(q,etc)=Libnames.pr_qualidq++ifetcthenstr"(..)"elsemt()letpr_import_module(m,f)=Libnames.pr_qualidm++matchfwith|ImportAll->mt()|ImportNamesns->surround(prlist_with_seppr_commapr_one_import_filter_namens)letsep_end=function|VernacSynPure(VernacBullet_|VernacSubproof_|VernacEndSubproof)->mt()|_->str"."letsep=fun_->spc()letsep_v2=fun_->str","++spc()letstring_of_theorem_kind=letopenDeclsinfunction|Theorem->"Theorem"|Lemma->"Lemma"|Fact->"Fact"|Remark->"Remark"|Property->"Property"|Proposition->"Proposition"|Corollary->"Corollary"letstring_of_definition_object_kind=letopenDeclsinfunction|Definition->"Definition"|Example->"Example"|Coercion->"Coercion"|SubClass->"SubClass"|CanonicalStructure->"Canonical Structure"|Instance->"Instance"|Let->"Let"|LetContext->CErrors.anomaly(Pp.str"Bound to Context.")|(StructureComponent|Scheme|CoFixpoint|Fixpoint|IdentityCoercion|Method)->CErrors.anomaly(Pp.str"Internal definition kind.")letstring_of_assumption_kind=letopenDeclsinfunction|Definitional->"Parameter"|Logical->"Axiom"|Conjectural->"Conjecture"|Context->"Context"letstring_of_logical_kind=letopenDeclsinfunction|IsAssumptionk->string_of_assumption_kindk|IsDefinitionk->string_of_definition_object_kindk|IsProofk->string_of_theorem_kindk|IsPrimitive->"Primitive"|IsSymbol->"Symbol"letpr_notation_entry=function|InConstrEntry->keyword"constr"|InCustomEntrys->keyword"custom"++spc()++strsletpr_abbreviationpr(ids,c)=prc++spc()++prlist_with_sepspcpr_ididsletpr_at_level=function|NumLeveln->spc()++keyword"at"++spc()++keyword"level"++spc()++intn|NextLevel->spc()++keyword"at"++spc()++keyword"next"++spc()++keyword"level"|DefaultLevel->mt()letlevel_of_pattern_level=functionNone->DefaultLevel|Somen->NumLevelnletpr_constr_as_binder_kind=letopenNotation_terminfunction|AsIdent->spc()++keyword"as ident"|AsName->spc()++keyword"as name"|AsAnyPattern->spc()++keyword"as pattern"|AsStrictPattern->spc()++keyword"as strict pattern"letpr_strictb=ifbthenstr"strict "elsemt()letpr_set_entry_typepr=function|ETIdent->str"ident"|ETName->str"name"|ETGlobal->str"global"|ETPattern(b,n)->pr_strictb++str"pattern"++pr_at_level(level_of_pattern_leveln)|ETConstr(s,bko,lev)->pr_notation_entrys++prlev++pr_optpr_constr_as_binder_kindbko|ETBigint->str"bigint"|ETBindertrue->str"binder"|ETBinderfalse->str"closed binder"letpr_set_simple_entry_type=pr_set_entry_typepr_at_levelletpr_commentpr_c=function|CommentConstrc->pr_cc|CommentStrings->qss|CommentIntn->intnletpr_in_out_modules=function|SearchInsidel->spc()++keyword"inside"++spc()++prlist_with_sepseppr_modulel|SearchOutside[]->mt()|SearchOutsidel->spc()++keyword"outside"++spc()++prlist_with_sepseppr_modulelletpr_search_where=function|Anywhere,false->mt()|Anywhere,true->str"head:"|InHyp,true->str"headhyp:"|InHyp,false->str"hyp:"|InConcl,true->str"headconcl:"|InConcl,false->str"concl:"letpr_delimiter_depth=function|DelimOnlyTmpScope->str"%_"|DelimUnboundedScope->str"%"letpr_scope_delimiter(d,sc)=pr_delimiter_depthd++strscletpr_search_item=function|SearchSubPattern(where,p)->pr_search_wherewhere++pr_constr_pattern_exprp|SearchString(where,s,sc)->pr_search_wherewhere++qss++pr_optpr_scope_delimitersc|SearchKindkind->str"is:"++str(string_of_logical_kindkind)letrecpr_search_request=function|SearchLiterala->pr_search_itema|SearchDisjConjl->str"["++prlist_with_sepspc(prlist_with_seppr_barpr_search_default)l++str"]"andpr_search_default(b,s)=(ifbthenmt()elsestr"-")++pr_search_requestsletpr_searchagoptbpr_p=pr_opt(fung->Goal_select.pr_goal_selectorg++str":"++spc())gopt++matchawith|SearchPatternc->keyword"SearchPattern"++spc()++pr_pc++pr_in_out_modulesb|SearchRewritec->keyword"SearchRewrite"++spc()++pr_pc++pr_in_out_modulesb|Searchsl->keyword"Search"++spc()++prlist_with_sepspcpr_search_defaultsl++pr_in_out_modulesbletpr_option_ref_value=function|Goptions.QualidRefValueid->pr_qualidid|Goptions.StringRefValues->qssletpr_printoptiontableb=prlist_with_sepspcstrtable++pr_opt(prlist_with_sepseppr_option_ref_value)bletpr_set_optionab=pr_printoptionaNone++(matchbwith|OptionUnset|OptionSetTrue->mt()|OptionSetIntn->spc()++intn|OptionSetStrings->spc()++quote(strs))letpr_opt_hintbasesl=matchlwith|[]->mt()|_asz->str":"++spc()++prlist_with_sepsepstrzletpr_reference_or_constrpr_c=function|HintsReferencer->pr_qualidr|HintsConstrc->pr_ccletpr_hint_mode=letopenHintsinfunction|ModeInput->str"+"|ModeNoHeadEvar->str"!"|ModeOutput->str"-"letpr_hint_infopr_pat{Typeclasses.hint_priority=pri;hint_pattern=pat}=pr_opt(funx->str"|"++intx)pri++pr_opt(funy->(ifOption.is_emptyprithenstr"| "elsemt())++pr_paty)patletpr_hintsdbhpr_cpr_pat=letopth=pr_opt_hintbasesdbinletpph=letopenHintsinmatchhwith|HintsResolvel->keyword"Resolve "++prlist_with_sepsep(fun(info,_,c)->pr_reference_or_constrpr_cc++pr_hint_infopr_patinfo)l|HintsResolveIFF(l2r,l,n)->keyword"Resolve "++str(ifl2rthen"->"else"<-")++prlist_with_sepseppr_qualidl|HintsImmediatel->keyword"Immediate"++spc()++prlist_with_sepsep(func->pr_reference_or_constrpr_cc)l|HintsUnfoldl->keyword"Unfold"++spc()++prlist_with_sepseppr_qualidl|HintsTransparency(l,b)->keyword(ifbthen"Transparent"else"Opaque")++spc()++(matchlwith|HintsVariables->keyword"Variables"|HintsConstants->keyword"Constants"|HintsProjections->keyword"Projections"|HintsReferencesl->prlist_with_sepseppr_qualidl)|HintsMode(m,l)->keyword"Mode"++spc()++pr_qualidm++spc()++prlist_with_sepspcpr_hint_model|HintsConstructorsc->keyword"Constructors"++spc()++prlist_with_sepspcpr_qualidc|HintsExtern(n,c,tac)->letpat=matchcwithNone->mt()|Somepat->pr_patpatinkeyword"Extern"++spc()++intn++spc()++pat++str" =>"++spc()++pr_gentacinhov2(keyword"Hint "++pph++opth)letpr_with_declarationpr_c=function|CWith_Definition(id,udecl,c)->letp=pr_ccinkeyword"Definition"++spc()++pr_lfqidid++pr_universe_decludecl++str" := "++p|CWith_Module(id,qid)->keyword"Module"++spc()++pr_lfqidid++str" := "++pr_qualidqidletrecpr_module_astleading_spacepr_c=function|{loc;v=CMidentqid}->ifleading_spacethenspc()++pr_locatedpr_qualid(loc,qid)elsepr_locatedpr_qualid(loc,qid)|{v=CMwith(mty,decl)}->letm=pr_module_astleading_spacepr_cmtyinletp=pr_with_declarationpr_cdeclinm++spc()++keyword"with"++spc()++p|{v=CMapply(me1,me2)}->pr_module_astleading_spacepr_cme1++spc()++pr_locatedpr_qualid(me2.loc,me2)letpr_inline=function|DefaultInline->mt()|NoInline->str"[no inline]"|InlineAti->str"[inline at level "++inti++str"]"letpr_assumption_inline=function|DefaultInline->str"Inline"|NoInline->mt()|InlineAti->str"Inline("++inti++str")"letpr_module_ast_inlleading_spacepr_c(mast,inl)=pr_module_astleading_spacepr_cmast++pr_inlineinlletpr_of_module_typeprc=function|Enforcemty->str":"++pr_module_ast_inltrueprcmty|Checkmtys->prlist_strict(funm->str"<:"++pr_module_ast_inltrueprcm)mtysletpr_export_flag=function|Export->keyword"Export"|Import->keyword"Import"letpr_export_with_cats(export,cats)=pr_export_flagexport++pr_import_catscatsletpr_require_token=function|Someexport->pr_export_with_catsexport++spc()|None->mt()letpr_module_vardeclspr_c(export,idl,(mty,inl))=letm=pr_module_asttruepr_cmtyinspc()++hov1(str"("++pr_require_tokenexport++prlist_with_sepspcpr_lidentidl++str":"++m++str")")letpr_module_binderslpr_c=prlist_strict(pr_module_vardeclspr_c)lletpr_type_optionpr_c=function|{v=CHole(SomeGNamedHole_)}asc->brk(0,2)++str" :"++pr_cc|{v=CHole_}->mt()|_asc->brk(0,2)++str" :"++pr_ccletpr_binders_arg=pr_non_empty_arg@@pr_bindersletpr_and_type_binders_argbl=pr_binders_argblletpr_onescheme(idop,{sch_type;sch_qualid;sch_sort})=letstr_identifier=matchidopwith|Someid->pr_lidentid++str" :="|None->str""inletstr_scheme=matchsch_typewith|SchemeInduction->keyword"Induction for"|SchemeMinimality->keyword"Minimality for"|SchemeElimination->keyword"Elimination for"|SchemeCase->keyword"Case for"inhov0str_identifier++spc()++hov0(str_scheme++spc()++pr_smart_globalsch_qualid)++spc()++hov0(keyword"Sort"++spc()++Sorts.pr_sort_familysch_sort)letpr_equality_scheme_typeschid=letstr_scheme=matchschwith|SchemeBooleanEquality->keyword"Boolean Equality for"|SchemeEquality->keyword"Equality for"inhov0(str_scheme++spc()++pr_smart_globalid)letbegin_of_inductive=function|[]->0|(_,({loc},_))::_->Option.cata(funloc->fst(Loc.unlocloc))0locletpr_class_rawexpr=function|FunClass->keyword"Funclass"|SortClass->keyword"Sortclass"|RefClassqid->pr_smart_globalqidletpr_assumption_tokenmanydischargekind=matchdischarge,kindwith|(NoDischarge,Decls.Logical)->keyword(ifmanythen"Axioms"else"Axiom")|(NoDischarge,Decls.Definitional)->keyword(ifmanythen"Parameters"else"Parameter")|(NoDischarge,Decls.Conjectural)->str"Conjecture"|(DoDischarge,Decls.Logical)->keyword(ifmanythen"Hypotheses"else"Hypothesis")|(DoDischarge,Decls.Definitional)->keyword(ifmanythen"Variables"else"Variable")|(DoDischarge,Decls.Conjectural)->anomaly(Pp.str"Don't know how to beautify a local conjecture.")|(_,Decls.Context)->anomaly(Pp.str"Context is used only internally.")letpr_paramspr_c(xl,(c,t))=hov2(prlist_with_sepseppr_lidentxl++spc()++(ifcthenstr":>"elsestr":"++spc()++pr_ct))letrecfactorize=function|[]->[]|(c,(idl,t))::l->matchfactorizelwith|(xl,((c',t')asr))::l'when(c:bool)==c'&&(=)tt'->(* FIXME: we need equality on constr_expr *)(idl@xl,r)::l'|l'->(idl,(c,t))::l'letpr_ne_params_listpr_cl=matchfactorizelwith|[p]->pr_paramspr_cp|l->prlist_with_sepspc(funp->hov1(str"("++pr_paramspr_cp++str")"))l(*
prlist_with_sep pr_semicolon (pr_params pr_c)
*)letpr_thm_tokenk=keyword(string_of_theorem_kindk)letpr_syntax_modifier=letopenGramlib.GramextinCAst.with_val(function|SetItemLevel(l,bko,n)->prlist_with_sepsep_v2strl++spc()++pr_at_leveln++pr_optpr_constr_as_binder_kindbko|SetItemScope(l,s)->prlist_with_sepsep_v2strl++spc()++str"in scope"++strs|SetLeveln->pr_at_level(NumLeveln)|SetCustomEntry(s,n)->keyword"in"++spc()++keyword"custom"++spc()++strs++(matchnwithNone->mt()|Somen->pr_at_level(NumLeveln))|SetAssocLeftA->keyword"left associativity"|SetAssocRightA->keyword"right associativity"|SetAssocNonA->keyword"no associativity"|SetEntryType(x,typ)->strx++spc()++pr_set_simple_entry_typetyp|SetOnlyPrinting->keyword"only printing"|SetOnlyParsing->keyword"only parsing"|SetFormat(TextFormats)->keyword"format "++pr_astqss)letpr_syntax_modifiers=function|[]->mt()|l->spc()++hov1(str"("++prlist_with_sepsep_v2pr_syntax_modifierl++str")")letpr_notation_declarationntn_decl=letopenVernacexprinlet{ntn_decl_string={CAst.loc;v=ntn};ntn_decl_interp=c;ntn_decl_modifiers=modifiers;ntn_decl_scope=scopt}=ntn_declinqsntn++spc()++str":="++spc()++Flags.without_optionFlags.beautifypr_constrc++pr_syntax_modifiersmodifiers++pr_opt(funsc->spc()++str":"++spc()++strsc)scoptletpr_where_notationdecl_ntn=fnl()++keyword"where "++pr_notation_declarationdecl_ntnletpr_rec_definition(rec_order,{fname;univs;binders;rtype;body_def;notations})=letpr_pure_lconstrc=Flags.without_optionFlags.beautifypr_lconstrcinletannot=pr_guard_annotpr_lconstr_exprbindersrec_orderinpr_ident_decl(fname,univs)++pr_binders_argbinders++annot++pr_type_option(func->spc()++pr_lconstr_exprc)rtype++pr_opt(fundef->str":="++brk(1,2)++pr_pure_lconstrdef)body_def++prlistpr_where_notationnotationsletpr_statementhead(idpl,(bl,c))=hov2(head++spc()++pr_ident_declidpl++spc()++(matchblwith[]->mt()|_->pr_bindersbl++spc())++str":"++pr_spc_lconstrc)letpr_rew_rule(ubinders,lhs,rhs)=letbinders=matchubinderswithNone->mt()|_->pr_universe_declubinders++spc()++str"|-"inletpr_pure_lconstrc=Flags.without_optionFlags.beautifypr_lconstrcinbinders++pr_pure_lconstrlhs++str"==>"++pr_pure_lconstrrhs(**************************************)(* Pretty printer for vernac commands *)(**************************************)letpr_constrargc=spc()++pr_constrcletpr_lconstrargc=spc()++pr_lconstrcletpr_intargn=spc()++intnletpr_vernac_attributes=function|[]->mt()|flags->str"#["++prlist_with_seppr_commaAttributes.pr_vernac_flagflags++str"]"++spc()letpr_occoeins=matchcoe,inswith|NoCoercion,NoInstance->str" :"|AddCoercion,NoInstance->str" :>"|NoCoercion,BackInstance->str" ::"|AddCoercion,BackInstance->str" ::>"letpr_record_field(x,{rfu_attrs=attr;rfu_coercion=coe;rfu_instance=ins;rfu_priority=pri;rfu_notation=ntn})=letprx=matchxwith|AssumExpr(id,binders,t)->hov1(pr_vernac_attributesattr++pr_lnameid++pr_binders_argbinders++spc()++pr_occoeins++spc()++pr_lconstr_exprt)|DefExpr(id,binders,b,opt)->(matchoptwith|Somet->hov1(pr_vernac_attributesattr++pr_lnameid++pr_binders_argbinders++spc()++pr_occoeins++spc()++pr_lconstr_exprt++str" :="++pr_lconstrb)|None->hov1(pr_vernac_attributesattr++pr_lnameid++str" :="++spc()++pr_lconstrb))inletprpri=matchpriwithNone->mt()|Somei->str"| "++intiinprx++prpri++prlistpr_where_notationntnletpr_record_declcfsobinder=pr_optpr_lidentc++pr_record"{""}"pr_record_fieldfs++pr_opt(funid->str"as "++pr_lidentid)obinderletpr_printable=function|PrintFullContext->keyword"Print All"|PrintSectionContexts->keyword"Print Section"++spc()++Libnames.pr_qualids|PrintGrammarent->keyword"Print Grammar"++spc()++prlist_with_sepspcstrent|PrintCustomGrammarent->keyword"Print Custom Grammar"++spc()++strent|PrintKeywords->keyword"Print Keywords"|PrintLoadPathdir->keyword"Print LoadPath"++pr_optDirPath.printdir|PrintLibraries->keyword"Print Libraries"|PrintMLLoadPath->keyword"Print ML Path"|PrintMLModules->keyword"Print ML Modules"|PrintDebugGC->keyword"Print ML GC"|PrintGraph->keyword"Print Graph"|PrintClasses->keyword"Print Classes"|PrintTypeclasses->keyword"Print Typeclasses"|PrintInstancesqid->keyword"Print Instances"++spc()++pr_smart_globalqid|PrintCoercions->keyword"Print Coercions"|PrintCoercionPaths(s,t)->keyword"Print Coercion Paths"++spc()++pr_class_rawexprs++spc()++pr_class_rawexprt|PrintCanonicalConversionsqids->keyword"Print Canonical Structures"++prlistpr_smart_globalqids|PrintTypingFlags->keyword"Print Typing Flags"|PrintTables->keyword"Print Tables"|PrintHintGoal->keyword"Print Hint"|PrintHintqid->keyword"Print Hint"++spc()++pr_smart_globalqid|PrintHintDb->keyword"Print Hint *"|PrintHintDbNames->keyword"Print HintDb"++spc()++strs|PrintUniverses{sort=b;subgraph=g;with_sources;file=fopt;}->letcmd=ifbthen"Print Sorted Universes"else"Print Universes"inletpr_debug_univ_name=function|NamedUnivx->pr_qualidx|RawUniv{CAst.v=x}->qstringxinletpr_subgraph=prlist_with_sepspcpr_debug_univ_nameinletpr_with_srcb=ifbthenstr"With Constraint Sources"elsestr"Without Constraint Sources"inkeywordcmd++pr_optpr_subgraphg++pr_optpr_with_srcwith_sources++pr_optstrfopt|PrintName(qid,udecl)->keyword"Print"++spc()++pr_smart_globalqid++pr_full_univ_name_listudecl|PrintModuleTypeqid->keyword"Print Module Type"++spc()++pr_qualidqid|PrintModuleqid->keyword"Print Module"++spc()++pr_qualidqid|PrintInspectn->keyword"Inspect"++spc()++intn|PrintScopes->keyword"Print Scopes"|PrintScopes->keyword"Print Scope"++spc()++strs|PrintVisibilitys->keyword"Print Visibility"++pr_optstrs|PrintAbout(qid,l,gopt)->pr_opt(fung->Goal_select.pr_goal_selectorg++str":"++spc())gopt++keyword"About"++spc()++pr_smart_globalqid++pr_full_univ_name_listl|PrintImplicitqid->keyword"Print Implicit"++spc()++pr_smart_globalqid(* spiwack: command printing all the axioms and section variables used in a
term *)|PrintAssumptions(b,t,qid)->letcmd=matchb,twith|true,true->"Print All Dependencies"|true,false->"Print Opaque Dependencies"|false,true->"Print Transparent Dependencies"|false,false->"Print Assumptions"inkeywordcmd++spc()++pr_smart_globalqid|PrintNamespacedp->keyword"Print Namespace"++DirPath.printdp|PrintStrategyNone->keyword"Print Strategies"|PrintStrategy(Someqid)->keyword"Print Strategy"++pr_smart_globalqid|PrintRegistered->keyword"Print Registered"|PrintRegisteredSchemes->keyword"Print Registered Schemes"|PrintNotation(Constrexpr.InConstrEntry,ntn_key)->keyword"Print Notation"++spc()++strntn_key|PrintNotation(Constrexpr.InCustomEntryent,ntn_key)->keyword"Print Notation"++spc()++strent++strntn_keyletpr_usinge=letrecaux=function|SsEmpty->"()"|SsType->"(Type)"|SsSingl{v=id}->"("^Id.to_stringid^")"|SsComple->"-"^auxe^""|SsUnion(e1,e2)->"("^auxe1^" + "^auxe2^")"|SsSubstr(e1,e2)->"("^auxe1^" - "^auxe2^")"|SsFwdClosee->"("^auxe^")*"inPp.str(auxe)letpr_extendscl=letpr_arga=trypr_genawithFailure_->str"<error in "++strs.ext_entry++str">"intryletrl=Egramml.get_extend_vernac_rulesinletrecauxrlcl=matchrl,clwith|Egramml.GramNonTerminal_::rl,arg::cl->pr_argarg::auxrlcl|Egramml.GramTerminals::rl,cl->strs::auxrlcl|[],[]->[]|_->assertfalseinhov1(pr_sequenceidentity(auxrlcl))withNot_found->hov1(str"TODO("++strs.ext_entry++spc()++prlist_with_sepseppr_argcl++str")")letpr_synpure_vernac_exprv=letreturn=tag_vernacvinmatchvwith(* Proof management *)|VernacAbortAll->return(keyword"Abort All")|VernacRestart->return(keyword"Restart")|VernacUnfocus->return(keyword"Unfocus")|VernacUnfocused->return(keyword"Unfocused")|VernacAbort->return(keyword"Abort")|VernacUndoi->return(ifInt.equali1thenkeyword"Undo"elsekeyword"Undo"++pr_intargi)|VernacUndoToi->return(keyword"Undo"++spc()++keyword"To"++pr_intargi)|VernacFocusi->return(keyword"Focus"++pr_optinti)|VernacShows->letpr_goal_reference=function|OpenSubgoals->mt()|NthGoaln->spc()++intn|GoalIdid->spc()++pr_ididinletpr_showable=function|ShowGoaln->keyword"Show"++pr_goal_referencen|ShowProof->keyword"Show Proof"|ShowExistentials->keyword"Show Existentials"|ShowUniverses->keyword"Show Universes"|ShowProofNames->keyword"Show Conjectures"|ShowIntrosb->keyword"Show "++(ifbthenkeyword"Intros"elsekeyword"Intro")|ShowMatchid->keyword"Show Match "++pr_qualididinreturn(pr_showables)|VernacCheckGuard->return(keyword"Guarded")|VernacValidateProof->return(keyword"Validate Proof")(* Resetting *)|VernacResetNameid->return(keyword"Reset"++spc()++pr_lidentid)|VernacResetInitial->return(keyword"Reset Initial")|VernacBacki->return(ifInt.equali1thenkeyword"Back"elsekeyword"Back"++pr_intargi)(* Syntax *)|VernacOpenCloseScope(opening,sc)->return(keyword(ifopeningthen"Open "else"Close ")++keyword"Scope"++spc()++strsc)|VernacDeclareScopesc->return(keyword"Declare Scope"++spc()++strsc)|VernacDelimiters(sc,Somekey)->return(keyword"Delimit Scope"++spc()++strsc++spc()++keyword"with"++spc()++strkey)|VernacDelimiters(sc,None)->return(keyword"Undelimit Scope"++spc()++strsc)|VernacBindScope(sc,cll)->return(keyword"Bind Scope"++spc()++strsc++spc()++keyword"with"++spc()++prlist_with_sepspcpr_class_rawexprcll)|VernacEnableNotation(on,rule,interp,flags,scope)->letpr_flag=function|EnableNotationEntryCAst.{v=InConstrEntry}->str"in constr"|EnableNotationEntryCAst.{v=InCustomEntrys}->str"in custom "++strs|EnableNotationOnlyOnlyParsing->str"only parsing"|EnableNotationOnlyOnlyPrinting->str"only printing"|EnableNotationOnlyParsingAndPrinting->assertfalse|EnableNotationAll->str"all"inletpr_flags=function|[]->mt()|l->str"("++prlist_with_seppr_commapr_flagl++str")"inletpr_rule=matchrulewith|None->mt()|Some(Inlntn)->quote(strntn)|Some(Inrabbrev)->pr_abbreviationpr_qualidabbrevinletpr_opt_scope=function|None->mt()|Some(NotationInScopes)->spc()++str": "++strs|SomeLastLonelyNotation->str":"++spc()++str"none"inletpp=pr_rule++pr_flagsflags++pr_opt_scopescopeinreturn(keyword(ifonthen"Enable Notation "else"Disable Notation ")++pp)(* Gallina *)|VernacDefinition((discharge,kind),id,b)->(* A verifier... *)letisgoal=Name.is_anonymous(fstid).vinletpr_def_token=keyword(ifisgoalthen"Goal"elsestring_of_definition_object_kindkind)inletpr_reduce=function|None->mt()|Somer->keyword"Eval"++spc()++pr_red_exprr++keyword" in"++spc()inletpr_def_body=matchbwith|DefineBody(bl,red,body,d)->letty=matchdwith|None->mt()|Somety->spc()++str":"++pr_spc_lconstrtyinpr_binders_argbl++ty++str" :="++spc()++pr_reducered++pr_lconstrbody|ProveBody(bl,t)->lettypu=ifisgoalthen(assert(bl=[]);u)else(str" :"++u)inpr_binders_argbl++typ(pr_spc_lconstrt)inreturn(hov2(pr_def_token++(ifisgoalthenmt()elsespc()++pr_lname_declid)++pr_def_body))|VernacStartTheoremProof(ki,l)->return(hov1(pr_statement(pr_thm_tokenki)(List.hdl)++prlist(pr_statement(spc()++keyword"with"))(List.tll)))|VernacEndProofAdmitted->return(keyword"Admitted")|VernacEndProof(Proved(opac,o))->return(matchowith|None->(matchopacwith|Transparent->keyword"Defined"|Opaque->keyword"Qed")|Someid->(ifopac<>Transparentthenkeyword"Save"elsekeyword"Defined")++spc()++pr_lidentid)|VernacExactProofc->return(hov2(keyword"Proof"++pr_lconstrargc))|VernacAssumption((discharge,kind),t,l)->letn=List.length(List.flatten(List.mapfst(List.mapsndl)))inletpr_params(c,(xl,t))=hov2(prlist_with_sepseppr_ident_declxl++spc()++str(matchcwithAddCoercion->":>"|NoCoercion->":")++spc()++pr_lconstr_exprt)inletassumptions=prlist_with_sepspc(funp->hov1(str"("++pr_paramsp++str")"))linreturn(hov2(pr_assumption_token(n>1)dischargekind++pr_non_empty_argpr_assumption_inlinet++spc()++assumptions))|VernacSymboll->letn=List.length(List.flatten(List.mapfst(List.mapsndl)))inletpr_params(c,(xl,t))=hov2(prlist_with_sepseppr_ident_declxl++spc()++str(matchcwithAddCoercion->":>"|NoCoercion->":")++spc()++pr_lconstr_exprt)inletassumptions=prlist_with_sepspc(funp->hov1(str"("++pr_paramsp++str")"))linreturn(hov2(keyword(if(n>1)then"Symbols"else"Symbol")++spc()++assumptions))|VernacInductive(f,l)->letpr_constructor((attr,coe,ins),(id,c))=hov2(pr_vernac_attributesattr++pr_lidentid++pr_occoeins++Flags.without_optionFlags.beautifypr_spc_lconstrc)inletpr_constructor_listl=matchlwith|Constructors[]->mt()|Constructorsl->letfst_sep=matchlwith[_]->" "|_->" | "inpr_com_at(begin_of_inductivel)++fnl()++strfst_sep++prlist_with_sep(fun_->fnl()++str" | ")pr_constructorl|RecordDecl(c,fs,obinder)->pr_record_declcfsobinderinletpr_oneindkey(((coe,iddecl),(indupar,indpar),s,lc),ntn)=hov0(strkey++spc()++str(matchcoewithAddCoercion->"> "|NoCoercion->"")++pr_cumul_ident_decliddecl++pr_and_type_binders_argindupar++pr_opt(funp->str"|"++spc()++pr_and_type_binders_argp)indpar++pr_opt(funs->str":"++spc()++pr_lconstr_exprs)s++str" :=")++pr_constructor_listlc++prlistpr_where_notationntninletkind=matchfwith|Record->"Record"|Structure->"Structure"|Inductive_kw->"Inductive"|CoInductive->"CoInductive"|Class_->"Class"|Variant->"Variant"inreturn(hov1(pr_oneindkind(List.hdl))++(prlist(funind->fnl()++hov1(pr_oneind"with"ind))(List.tll)))|VernacFixpoint(local,(rec_order,recs))->letlocal=matchlocalwith|DoDischarge->"Let "|NoDischarge->""inreturn(hov0(strlocal++keyword"Fixpoint"++spc()++prlist_with_sep(fun_->fnl()++keyword"with"++spc())pr_rec_definition(List.combinerec_orderrecs)))|VernacCoFixpoint(local,corecs)->letlocal=matchlocalwith|DoDischarge->keyword"Let"++spc()|NoDischarge->str""inletpr_onecorec{fname;univs;binders;rtype;body_def;notations}=pr_ident_decl(fname,univs)++spc()++pr_bindersbinders++spc()++str":"++spc()++pr_lconstr_exprrtype++pr_opt(fundef->str":="++brk(1,2)++pr_lconstrdef)body_def++prlistpr_where_notationnotationsinreturn(hov0(local++keyword"CoFixpoint"++spc()++prlist_with_sep(fun_->fnl()++keyword"with"++spc())pr_onecoreccorecs))|VernacSchemel->return(hov2(keyword"Scheme"++spc()++prlist_with_sep(fun_->fnl()++keyword"with"++spc())pr_oneschemel))|VernacSchemeEquality(sch,id)->return(hov2(keyword"Scheme "++pr_equality_scheme_typeschid))|VernacCombinedScheme(id,l)->return(hov2(keyword"Combined Scheme"++spc()++pr_lidentid++spc()++keyword"from"++spc()++prlist_with_sep(fun_->fnl()++str", ")pr_lidentl))|VernacUniversev->return(hov2(keyword"Universe"++spc()++prlist_with_sep(fun_->str",")pr_lidentv))|VernacConstraintv->return(hov2(keyword"Constraint"++spc()++prlist_with_sep(fun_->str",")pr_uconstraintv))(* Gallina extensions *)|VernacNameSectionHypSet(id,set)->return(hov2(keyword"Collection"++spc()++pr_lidentid++spc()++str":="++spc()++pr_usingset))|VernacCanonicalq->return(keyword"Canonical Structure"++spc()++pr_smart_globalq)|VernacCoercion(id,Some(c1,c2))->return(hov1(keyword"Coercion"++spc()++pr_smart_globalid++spc()++str":"++spc()++pr_class_rawexprc1++spc()++str">->"++spc()++pr_class_rawexprc2))|VernacCoercion(id,None)->return(hov1(keyword"Coercion"++spc()++pr_smart_globalid))|VernacIdentityCoercion(id,c1,c2)->return(hov1(keyword"Identity Coercion"++spc()++pr_lidentid++spc()++str":"++spc()++pr_class_rawexprc1++spc()++str">->"++spc()++pr_class_rawexprc2))|VernacInstance(instid,sup,cl,props,info)->return(hov1(keyword"Instance"++(matchinstidwith|{loc;v=Nameid},l->spc()++pr_ident_decl(CAst.(make?locid),l)++spc()|{v=Anonymous},_->mt())++pr_and_type_binders_argsup++str":"++spc()++pr_constrcl++pr_hint_infopr_constr_pattern_exprinfo++(matchpropswith|Some(true,{v=CRecordl})->spc()++str":="++spc()++pr_record_body"{""}"pr_lconstrl|Some(true,_)->assertfalse|Some(false,p)->spc()++str":="++spc()++pr_constrp|None->mt())))|VernacDeclareInstance(instid,sup,cl,info)->return(hov1(keyword"Declare Instance"++spc()++pr_ident_declinstid++spc()++pr_and_type_binders_argsup++str":"++spc()++pr_constrcl++pr_hint_infopr_constr_pattern_exprinfo))|VernacContextl->return(hov1(keyword"Context"++pr_and_type_binders_argl))|VernacExistingInstanceinsts->letpr_inst(id,info)=pr_qualidid++pr_hint_infopr_constr_pattern_exprinfoinreturn(hov1(keyword"Existing"++spc()++keyword(String.plural(List.lengthinsts)"Instance")++spc()++prlist_with_sepspcpr_instinsts))|VernacExistingClassid->return(hov1(keyword"Existing"++spc()++keyword"Class"++spc()++pr_qualidid))(* Commands *)|VernacCreateHintDb(dbname,b)->return(hov1(keyword"Create HintDb"++spc()++strdbname++(ifbthenstr" discriminated"elsemt())))|VernacRemoveHints(dbnames,ids)->return(hov1(keyword"Remove Hints"++spc()++prlist_with_sepspc(funr->pr_qualidr)ids++pr_opt_hintbasesdbnames))|VernacHints(dbnames,h)->return(pr_hintsdbnameshpr_constrpr_constr_pattern_expr)|VernacSyntacticDefinition(id,(ids,c),l)->return(hov2(keyword"Notation"++spc()++pr_abbreviationpr_lident(ids,id)++str":="++pr_constrargc++pr_syntax_modifiersl))|VernacArguments(q,args,more_implicits,mods)->return(hov2(keyword"Arguments"++spc()++pr_smart_globalq++letpr_s=prlist(fun{v=s}->pr_scope_delimiters)inletpr_ifbx=ifbthenxelsestr""inletpr_one_arg(x,k)=pr_ifk(str"!")++Name.printxinletpr_brimpforcex=letleft,right=matchimpwith|Glob_term.NonMaxImplicit->str"[",str"]"|Glob_term.MaxImplicit->str"{",str"}"|Glob_term.Explicit->ifforcethenstr"(",str")"elsemt(),mt()inleft++x++rightinletget_arguments_likesimptl=ifs=[]&&imp=Glob_term.Explicitthen[],tlelseletrecfoldextra=function|RealArgarg::tlwhenList.equal(funab->letda,a=a.CAst.vinletdb,b=b.CAst.vinda=db&&String.equalab)arg.notation_scopes&&arg.implicit_status=imp->fold((arg.name,arg.recarg_like)::extra)tl|args->List.revextra,argsinfold[]tlinletrecprint_arguments=function|[]->mt()|VolatileArg::l->spc()++str"/"++print_argumentsl|BidiArg::l->spc()++str"&"++print_argumentsl|RealArg{name=id;recarg_like=k;notation_scope=s;implicit_status=imp}::tl->letextra,tl=get_arguments_likesimptlinspc()++hov1(pr_brimp(extra<>[])(prlist_with_sepspcpr_one_arg((id,k)::extra))++pr_ss)++print_argumentstlinletrecprint_implicits=function|[]->mt()|(name,impl)::rest->spc()++pr_brimplfalse(Name.printname)++print_implicitsrestinprint_argumentsargs++ifnot(List.is_emptymore_implicits)thenprlist(funl->str","++print_implicitsl)more_implicitselse(mt())++(ifnot(List.is_emptymods)thenstr" : "elsestr"")++prlist_with_sep(fun()->str", "++spc())(function|`SimplDontExposeCase->keyword"simpl nomatch"|`SimplNeverUnfold->keyword"simpl never"|`DefaultImplicits->keyword"default implicits"|`Rename->keyword"rename"|`Assert->keyword"assert"|`ExtraScopes->keyword"extra scopes"|`ClearImplicits->keyword"clear implicits"|`ClearReduction->keyword"clear simpl"|`ClearScopes->keyword"clear scopes"|`ClearBidiHint->keyword"clear bidirectionality hint")mods))|VernacReservebl->letn=List.length(List.flatten(List.mapfstbl))inreturn(hov2(tag_keyword(str"Implicit Type"++str(ifn>1then"s "else" "))++pr_ne_params_listpr_lconstr_expr(List.map(funsb->false,sb)bl)))|VernacGeneralizableg->return(hov1(tag_keyword(str"Generalizable Variable"++matchgwith|None->str"s none"|Some[]->str"s all"|Someidl->str(ifList.lengthidl>1then"s "else" ")++prlist_with_sepspcpr_lidentidl)))|VernacSetOpacity((k,l),b)whenConv_oracle.is_transparentk->return(hov1(keyword(ifbthen"Transparent!"else"Transparent")++spc()++prlist_with_sepseppr_smart_globall))|VernacSetOpacity((Conv_oracle.Opaque,l),b)->return(hov1(keyword(ifbthen"Opaque!"else"Opaque")++spc()++prlist_with_sepseppr_smart_globall))|VernacSetOpacity_->return(CErrors.anomaly(keyword"VernacSetOpacity used to set something else."))|VernacSetStrategyl->letpr_lev=function|Conv_oracle.Opaque->keyword"opaque"|Conv_oracle.Expand->keyword"expand"|lwhenConv_oracle.is_transparentl->keyword"transparent"|Conv_oracle.Leveln->intninletpr_line(l,q)=hov2(pr_levl++spc()++str"["++prlist_with_sepseppr_smart_globalq++str"]")inreturn(hov1(keyword"Strategy"++spc()++hv0(prlist_with_sepseppr_linel)))|VernacAddOption(na,l)->return(hov2(keyword"Add"++spc()++pr_printoptionna(Somel)))|VernacRemoveOption(na,l)->return(hov2(keyword"Remove"++spc()++pr_printoptionna(Somel)))|VernacMemOption(na,l)->return(hov2(keyword"Test"++spc()++pr_printoptionna(Somel)))|VernacPrintOptionna->return(hov2(keyword"Test"++spc()++pr_printoptionnaNone))|VernacCheckMayEval(r,io,c)->letpr_mayevalrc=matchrwith|Somer0->hov2(keyword"Eval"++spc()++pr_red_exprr0++spc()++keyword"in"++spc()++pr_lconstrc)|None->hov2(keyword"Check"++spc()++pr_lconstrc)inletpr_i=matchiowithNone->mt()|Somei->Goal_select.pr_goal_selectori++str": "inreturn(pr_i++pr_mayevalrc)|VernacGlobalCheckc->return(hov2(keyword"Type"++pr_constrargc))|VernacDeclareReduction(s,r)->return(keyword"Declare Reduction"++spc()++strs++str" := "++pr_red_exprr)|VernacPrintp->return(pr_printablep)|VernacSearch(sea,g,sea_r)->return(pr_searchseagsea_r@@pr_constr_pattern_expr)|VernacLocateloc->letpr_locate=function|LocateAnyqid->pr_smart_globalqid|LocateTermqid->keyword"Term"++spc()++pr_smart_globalqid|LocateFilef->keyword"File"++spc()++qsf|LocateLibraryqid->keyword"Library"++spc()++pr_moduleqid|LocateModuleqid->keyword"Module"++spc()++pr_moduleqid|LocateOther(s,qid)->keywords++spc()++pr_ltac_refqidinreturn(keyword"Locate"++spc()++pr_locateloc)|VernacRegister(qid,RegisterCoqlibname)->return(hov2(keyword"Register"++spc()++pr_qualidqid++spc()++str"as"++spc()++pr_qualidname))|VernacRegister(qid,RegisterScheme{inductive;scheme_kind})->return(hov2(keyword"Register"++spc()++keyword"Scheme"++spc()++pr_qualidqid++spc()++str"as"++spc()++pr_qualidscheme_kind++spc()++str"for"++spc()++pr_qualidinductive))|VernacRegister(qid,RegisterInline)->return(hov2(keyword"Register Inline"++spc()++pr_qualidqid))|VernacPrimitive(id,r,typopt)->hov2(keyword"Primitive"++spc()++pr_ident_declid++(Option.cata(funty->spc()++str":"++pr_spc_lconstrty)(mt())typopt)++spc()++str":="++spc()++str(CPrimitives.op_or_type_to_stringr))|VernacCommentsl->return(hov2(keyword"Comments"++spc()++prlist_with_sepsep(pr_commentpr_constr)l))|VernacAttributesattrs->return(hov2(keyword"Attributes"++spc()++pr_vernac_attributesattrs))|VernacProof(None,None)->return(keyword"Proof")|VernacProof(None,Somee)->return(keyword"Proof "++spc()++keyword"using"++spc()++pr_usinge)|VernacProof(Somete,None)->return(keyword"Proof with"++spc()++pr_gente)|VernacProof(Somete,Somee)->return(keyword"Proof"++spc()++keyword"using"++spc()++pr_usinge++spc()++keyword"with"++spc()++pr_gente)|VernacBulletb->(* XXX: Redundant with Proof_bullet.print *)return(letopenProof_bulletinbeginmatchbwith|Dashn->str(String.maken'-')|Starn->str(String.maken'*')|Plusn->str(String.maken'+')end)|VernacSubproofNone->return(str"{")|VernacSubproof(Somei)->return(Goal_select.pr_goal_selectori++str":"++spc()++str"{")|VernacEndSubproof->return(str"}")|VernacAddRewRule(id,l)->return(hov0(keyword(ifList.lengthl>1then"Rewrite Rules"else"Rewrite Rule")++spc()++pr_lidentid++str":="++prlist_with_sep(fun_->fnl()++keyword"with"++spc())pr_rew_rulel))letpr_synterp_vernac_exprv=letreturn=tag_vernacvinmatchvwith|VernacLoad(f,s)->return(keyword"Load"++iffthen(spc()++keyword"Verbose"++spc())elsespc()++qss)|VernacBeginSectionid->return(hov2(keyword"Section"++spc()++pr_lidentid))|VernacEndSegmentid->return(hov2(keyword"End"++spc()++pr_lidentid))|VernacNotation(infix,ntn_decl)->return(hov2(hov0(keyword(ifinfixthen"Infix"else"Notation")++spc()++pr_notation_declarationntn_decl)))|VernacReservedNotation(_,(s,l))->return(keyword"Reserved Notation"++spc()++pr_astqss++pr_syntax_modifiersl)|VernacDeclareCustomEntrys->return(keyword"Declare Custom Entry "++strs)|VernacRequire(from,exp,l)->letfrom=matchfromwith|None->mt()|Somer->keyword"From"++spc()++pr_moduler++spc()inreturn(hov2(from++keyword"Require"++spc()++pr_require_tokenexp++prlist_with_sepseppr_import_modulel))|VernacImport(f,l)->return(pr_export_with_catsf++spc()++prlist_with_sepseppr_import_modulel)(* Modules and Module Types *)|VernacDefineModule(export,m,bl,tys,bd)->letb=pr_module_bindersblpr_lconstrinreturn(hov2(keyword"Module"++spc()++pr_require_tokenexport++pr_lidentm++b++pr_of_module_typepr_lconstrtys++(ifList.is_emptybdthenmt()elsestr":= ")++prlist_with_sep(fun()->str" <+")(pr_module_ast_inltruepr_lconstr)bd))|VernacDeclareModule(export,id,bl,m1)->letb=pr_module_bindersblpr_lconstrinreturn(hov2(keyword"Declare Module"++spc()++pr_require_tokenexport++pr_lidentid++b++str" :"++pr_module_ast_inltruepr_lconstrm1))|VernacDeclareModuleType(id,bl,tyl,m)->letb=pr_module_bindersblpr_lconstrinletpr_mt=pr_module_ast_inltruepr_lconstrinreturn(hov2(keyword"Module Type "++pr_lidentid++b++prlist_strict(funm->str" <:"++pr_mtm)tyl++(ifList.is_emptymthenmt()elsestr":= ")++prlist_with_sep(fun()->str" <+ ")pr_mtm))|VernacInclude(mexprs)->letpr_m=pr_module_ast_inlfalsepr_lconstrinreturn(hov2(keyword"Include"++spc()++prlist_with_sep(fun()->str" <+ ")pr_mmexprs))(* Auxiliary file and library management *)|VernacDeclareMLModule(l)->return(hov2(keyword"Declare ML Module"++spc()++prlist_with_sepsepqsl))|VernacChdirNone->return(keyword"Pwd")|VernacChdir(Somes)->return(keyword"Cd "++qss)|VernacSetOption(export,na,v)->letexport=ifexportthenkeyword"Export"++spc()elsemt()inletset=ifv==OptionUnsetthen"Unset"else"Set"inreturn(hov2(export++keywordset++spc()++pr_set_optionnav))|VernacExtraDependency(from,file,id)->return(hov2(keyword"From"++spc()++pr_modulefrom++spc()++keyword"Extra"++spc()++keyword"Dependency"++spc()++qsfile++pr_opt(funx->spc()++keyword"as"++spc()++pr_idx)id))|VernacExtend(s,c)->return(pr_extendsc)|VernacProofModes->return(keyword"Proof Mode"++strs)letpr_control_flag(p:control_flag)=letw=matchpwith|ControlTime->keyword"Time"|ControlInstructions->keyword"Instructions"|ControlProfilef->keyword"Profile"++pr_optqstringf|ControlRedirects->keyword"Redirect"++spc()++qss|ControlTimeoutn->keyword"Timeout "++intn|ControlFail->keyword"Fail"|ControlSucceed->keyword"Succeed"inw++spc()letpr_vernac_controlflags=Pp.prlistpr_control_flagflagsletpr_vernac_exprv=matchvwith|VernacSynPuree->pr_synpure_vernac_expre|VernacSynterpe->pr_synterp_vernac_expreletpr_vernac({v={control;attrs;expr}}asv)=tag_vernacv(pr_vernac_controlcontrol++pr_vernac_attributesattrs++pr_vernac_exprexpr++sep_endexpr)