123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665(************************************************************************)(* * 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) *)(************************************************************************)openPpopenUtilopenNamesopenNameopsopenNamegenopenConstropenContextopenTermopsopenEnvironopenPretype_errorsopenType_errorsopenTypeclasses_errorsopenIndrecopenCasesopenLogicopenPrinteropenEvdopenContext.Rel.DeclarationmoduleRelDecl=Context.Rel.Declaration(* This simplifies the typing context of Cases clauses *)(* hope it does not disturb other typing contexts *)letcontractenvsigmalc=letopenEConstrinletl=ref[]inletcontract_contextdeclenv=matchdeclwith|LocalDef(_,c',_)whenisRelsigmac'->l:=(Vars.substl!lc')::!l;env|_->lett=Vars.substl!l(RelDecl.get_typedecl)inletdecl=decl|>RelDecl.map_name(named_hdenvsigmat)|>RelDecl.map_value(Vars.substl!l)|>RelDecl.set_typetinl:=(mkRel1)::List.map(Vars.lift1)!l;push_reldeclenvinletenv=process_rel_contextcontract_contextenvin(env,List.map(Vars.substl!l)lc)letcontract2envsigmaab=matchcontractenvsigma[a;b]with|env,[a;b]->env,a,b|_->assertfalseletcontract3envsigmaabc=matchcontractenvsigma[a;b;c]with|env,[a;b;c]->env,a,b,c|_->assertfalseletcontract4envsigmaabcd=matchcontractenvsigma[a;b;c;d]with|env,[a;b;c;d]->(env,a,b,c),d|_->assertfalseletcontract1envsigmaav=matchcontractenvsigma(a::v)with|env,a::l->env,a,l|_->assertfalseletreccontract3'envsigmaabc=function|OccurCheck(evk,d)->letx,d=contract4envsigmaabcdinx,OccurCheck(evk,d)|NotClean((evk,args),env',d)->letargs=Evd.expand_existentialsigma(evk,args)inletenv',d,args=contract1env'sigmadargsinletargs=SList.of_full_listargsincontract3envsigmaabc,NotClean((evk,args),env',d)|ConversionFailed(env',t1,t2)->let(env',t1,t2)=contract2env'sigmat1t2incontract3envsigmaabc,ConversionFailed(env',t1,t2)|IncompatibleInstances(env',ev,t1,t2)->let(env',ev,t1,t2)=contract3env'sigma(EConstr.mkEvarev)t1t2incontract3envsigmaabc,IncompatibleInstances(env',EConstr.destEvarsigmaev,t1,t2)|NotSameArgSize|NotSameHead|NoCanonicalStructure|MetaOccurInBody_|InstanceNotSameType_|InstanceNotFunctionalType_|ProblemBeyondCapabilities|UnifUnivInconsistency_asx->contract3envsigmaabc,x|CannotSolveConstraint((pb,env',t,u),x)->letenv',t,u=contract2env'sigmatuinlety,x=contract3'envsigmaabcxiny,CannotSolveConstraint((pb,env',t,u),x)(** Ad-hoc reductions *)letj_nf_betaiotaevarenvsigmaj={uj_val=j.uj_val;uj_type=Reductionops.nf_betaiotaenvsigmaj.uj_type}letjv_nf_betaiotaevarenvsigmajl=Array.Smart.map(funj->j_nf_betaiotaevarenvsigmaj)jl(** Printers *)letpr_lconstr_envesc=quote(pr_lconstr_envesc)letpr_leconstr_envesc=quote(pr_leconstr_envesc)letpr_ljudge_envesc=letv,t=pr_ljudge_envescin(quotev,quotet)(** A canonisation procedure for constr such that comparing there
externalisation catches more equalities *)letcanonize_constrsigmac=(* replaces all the names in binders by [dn] ("default name"),
ensures that [alpha]-equivalent terms will have the same
externalisation. *)letopenEConstrinletdn=Name.Anonymousinletreccanonize_bindersc=matchEConstr.kindsigmacwith|Prod(x,t,b)->mkProd({xwithbinder_name=dn},t,b)|Lambda(x,t,b)->mkLambda({xwithbinder_name=dn},t,b)|LetIn(x,u,t,b)->mkLetIn({xwithbinder_name=dn},u,t,b)|_->EConstr.mapsigmacanonize_binderscincanonize_binderscletrecdisplay_expr_eqc1c2=letopenConstrexprinmatchCAst.(c1.v,c2.v)with|(CHole_|CEvar_),_|_,(CEvar_|CHole_)->true|_->Constrexpr_ops.constr_expr_eq_gendisplay_expr_eqc1c2(** Tries to realize when the two terms, albeit different are printed the same. *)letdisplay_eq~flagsenvsigmat1t2=(* terms are canonized, then their externalisation is compared syntactically *)letopenConstrexterninlett1=canonize_constrsigmat1inlett2=canonize_constrsigmat2inletct1=Flags.with_optionsflags(fun()->extern_constrenvsigmat1)()inletct2=Flags.with_optionsflags(fun()->extern_constrenvsigmat2)()indisplay_expr_eqct1ct2(** This function adds some explicit printing flags if the two arguments are
printed alike. *)letrecpr_explicit_auxenvsigmat1t2=function|[]->(* no specified flags: default. *)Printer.pr_leconstr_envenvsigmat1,Printer.pr_leconstr_envenvsigmat2|flags::rem->letequal=display_eq~flagsenvsigmat1t2inifequalthen(* The two terms are the same from the user point of view *)pr_explicit_auxenvsigmat1t2remelseletopenConstrexterninletct1=Flags.with_optionsflags(fun()->extern_constrenvsigmat1)()inletct2=Flags.with_optionsflags(fun()->extern_constrenvsigmat2)()inPpconstr.pr_lconstr_exprenvsigmact1,Ppconstr.pr_lconstr_exprenvsigmact2letexplicit_flags=letopenConstrexternin[[];(* First, try with the current flags *)[print_implicits];(* Then with implicit *)[print_universes];(* Then with universes *)[print_universes;print_implicits];(* With universes AND implicits *)[print_implicits;print_coercions;print_no_symbol];(* Then more! *)[print_universes;print_implicits;print_coercions;print_no_symbol](* and more! *)]letwith_diffspmpn=ifnot(Proof_diffs.show_diffs())thenpm,pnelsetrylettokenize_string=Proof_diffs.tokenize_stringinPp_diff.diff_pp~tokenize_stringpmpnwithPp_diff.Diff_Failuremsg->begintryignore(Sys.getenv("HIDEDIFFFAILUREMSG"))withNot_found->Proof_diffs.notify_proof_diff_failuremsgend;pm,pnletpr_explicitenvsigmat1t2=letp1,p2=pr_explicit_auxenvsigmat1t2explicit_flagsinletp1,p2=with_diffsp1p2inquotep1,quotep2letpr_dbenvi=trymatchenv|>lookup_reli|>get_namewith|Nameid->Id.printid|Anonymous->str"<>"withNot_found->str"UNBOUND_REL_"++intiletexplain_unbound_relenvsigman=letpe=pr_ne_context_of(str"In environment")envsigmainstr"Unbound reference: "++pe++str"The reference "++intn++str" is free."letexplain_unbound_varenvv=letvar=Id.printvinstr"No such section variable or assumption: "++var++str"."letexplain_not_typeenvsigmaj=letpe=pr_ne_context_of(str"In environment")envsigmainletpc,pt=pr_ljudge_envenvsigmajinpe++str"The term"++brk(1,1)++pc++spc()++str"has type"++spc()++pt++spc()++str"which should be Set, Prop or Type."letexplain_bad_assumptionenvsigmaj=letpe=pr_ne_context_of(str"In environment")envsigmainletpc,pt=pr_ljudge_envenvsigmajinpe++str"Cannot declare a variable or hypothesis over the term"++brk(1,1)++pc++spc()++str"of type"++spc()++pt++spc()++str"because this term is not a type."letexplain_reference_variablessigmaidc=pr_globalc++strbrk" depends on the variable "++Id.printid++strbrk" which is not declared in the context."letexplain_elim_arityenvsigmaindcokinds=letopenEConstrinletenv=make_all_name_differentenvsigmainletmib,mipasspecif=Inductive.lookup_mind_specifenv(fstind)inletpi=letpp()=pr_pinductiveenvsigmaindinmatchmip.mind_squashedwith|None|SomeAlwaysSquashed->pp()|Some(SometimesSquashed_)->(* universe instance matters, so print it regardless of Printing Universes *)Flags.with_optionConstrextern.print_universespp()inletpc=Option.map(pr_leconstr_envenvsigma)cinletmsg=matchokindswith|None->str"ill-formed elimination predicate."|Somesp->letppt?(ppunivs=false)()=letpp()=pr_leconstr_envenvsigma(mkSort(ESorts.makesp))inifppunivsthenFlags.with_optionConstrextern.print_universespp()elsepp()inletsquash=Option.get(Inductive.is_squashed(specif,sndind))inmatchsquashwith|SquashToSet->letppt=ppt()inhov0(str"the return type has sort"++spc()++ppt++spc()++str"while it should be SProp, Prop or Set.")++fnl()++hov0(str"Elimination of an inductive object of sort Set"++spc()++str"is not allowed on a predicate in sort "++ppt++fnl()++str"because"++spc()++str"strong elimination on non-small inductive types leads to paradoxes.")|SquashToQuality(QConstant(QSProp|QPropassquashq))->letppt=ppt()inletinds,sorts,explain=matchsquashqwith|QSProp->"SProp","SProp","strict proofs can be eliminated only to build strict proofs"|QProp->"Prop","SProp or Prop","proofs can be eliminated only to build proofs"|QType->assertfalseinhov0(str"the return type has sort"++spc()++ppt++spc()++str"while it should be "++strsorts++str".")++fnl()++hov0(str"Elimination of an inductive object of sort "++strinds++spc()++str"is not allowed on a predicate in sort "++ppt++fnl()++str"because"++spc()++strexplain++str".")|SquashToQuality(QConstantQType)->letppt=ppt~ppunivs:true()inhov0(str"the return type has sort"++spc()++ppt++spc()++str"while it may not be of a variable sort quality.")++fnl()++hov0(str"Elimination of a sort polymorphic inductive object instantiated to sort Type"++spc()++(* NB: this restriction is only for forward compat with possible future sort qualities *)str"is not allowed on a predicate in a variable sort quality.")|SquashToQuality(QVarsquashq)->letppt=ppt~ppunivs:true()inhov0(str"the return type has sort"++spc()++ppt++spc()++str"while it should be in sort quality "++pr_evd_qvarsigmasquashq++str".")++fnl()++hov0(str"Elimination of a sort polymorphic inductive object instantiated to a variable sort quality"++spc()++str"is only allowed on a predicate in the same sort quality.")inhov0(str"Incorrect elimination"++(matchpcwithNone->mt()|Somepc->str" of"++spc()++pc)++spc()++str"in the inductive type"++spc()++quotepi++str":")++fnl()++msgletexplain_case_not_inductiveenvsigmacj=letenv=make_all_name_differentenvsigmainletpc=pr_leconstr_envenvsigmacj.uj_valinletpct=pr_leconstr_envenvsigmacj.uj_typeinmatchEConstr.kindsigmacj.uj_typewith|Evar_->str"Cannot infer a type for this expression."|_->str"The term"++brk(1,1)++pc++spc()++str"has type"++brk(1,1)++pct++spc()++str"which is not a (co-)inductive type."letexplain_case_on_private_indenvsigmaind=str"Case analysis on private inductive "++pr_inductiveenvindletexplain_number_branchesenvsigmacjexpn=letenv=make_all_name_differentenvsigmainletpc=pr_leconstr_envenvsigmacj.uj_valinletpct=pr_leconstr_envenvsigmacj.uj_typeinstr"Matching on term"++brk(1,1)++pc++spc()++str"of type"++brk(1,1)++pct++spc()++str"expects "++intexpn++str" branches."letexplain_ill_formed_case_paramsenvsigma=str"Ill formed case parameters (bugged tactic?)."letexplain_ill_formed_branchenvsigmacciacttyexpty=letsimpt=Reductionops.nf_betaiotaenvsigmatinletenv=make_all_name_differentenvsigmainletpc=pr_leconstr_envenvsigmacinletpa,pe=pr_explicitenvsigma(simpactty)(simpexpty)instrbrk"In pattern-matching on term"++brk(1,1)++pc++spc()++strbrk"the branch for constructor"++spc()++quote(pr_pconstructorenvsigmaci)++spc()++str"has type"++brk(1,1)++pa++spc()++str"which should be"++brk(1,1)++pe++str"."letexplain_generalizationenvsigma(name,var)j=letpe=pr_ne_context_of(str"In environment")envsigmainletpv=pr_letype_envenvsigmavarinlet(pc,pt)=pr_ljudge_env(push_rel_assum(make_annotnameEConstr.ERelevance.relevant,var)env)sigmajinpe++str"Cannot generalize"++brk(1,1)++pv++spc()++str"over"++brk(1,1)++pc++str","++spc()++str"it has type"++spc()++pt++spc()++str"which should be Set, Prop or Type."letexplain_unification_errorenvsigmap1p2=function|None->mt()|Somee->letrecauxp1p2=function|OccurCheck(evk,rhs)->[str"cannot define "++quote(pr_existential_keyenvsigmaevk)++strbrk" with term "++pr_leconstr_envenvsigmarhs++strbrk" that would depend on itself"]|NotClean((evk,args),env,c)->letargs=Evd.expand_existentialsigma(evk,args)inletenv=make_all_name_differentenvsigmain[str"cannot instantiate "++quote(pr_existential_keyenvsigmaevk)++strbrk" because "++pr_leconstr_envenvsigmac++strbrk" is not in its scope"++(ifList.is_emptyargsthenmt()elsestrbrk": available arguments are "++pr_sequence(pr_leconstr_envenvsigma)(List.revargs))]|NotSameArgSize|NotSameHead|NoCanonicalStructure->(* Error speaks from itself *)[]|ConversionFailed(env,t1,t2)->lett1=Reductionops.nf_betaiotaenvsigmat1inlett2=Reductionops.nf_betaiotaenvsigmat2inifEConstr.eq_constrsigmat1p1&&EConstr.eq_constrsigmat2p2then[]elseletenv=make_all_name_differentenvsigmainifnot(EConstr.eq_constrsigmat1p1)||not(EConstr.eq_constrsigmat2p2)thenlett1,t2=pr_explicitenvsigmat1t2in[str"cannot unify "++t1++strbrk" and "++t2]else[]|IncompatibleInstances(env,ev,t1,t2)->letenv=make_all_name_differentenvsigmainletev=pr_leconstr_envenvsigma(EConstr.mkEvarev)inlett1=Reductionops.nf_betaiotaenvsigmat1inlett2=Reductionops.nf_betaiotaenvsigmat2inlett1,t2=pr_explicitenvsigmat1t2in[ev++strbrk" has otherwise to unify with "++t1++str" which is incompatible with "++t2]|MetaOccurInBodyevk->[str"instance for "++quote(pr_existential_keyenvsigmaevk)++strbrk" refers to a metavariable - please report your example"++strbrk"at "++strCoq_config.wwwbugtracker++str"."]|InstanceNotSameType(evk,env,t,u)->lett,u=pr_explicitenvsigmatuin[str"unable to find a well-typed instantiation for "++quote(pr_existential_keyenvsigmaevk)++strbrk": cannot ensure that "++t++strbrk" is a subtype of "++u]|InstanceNotFunctionalType(evk,env,f,u)->letenv=make_all_name_differentenvsigmainletf=pr_leconstr_envenvsigmafinletu=pr_leconstr_envenvsigmauin[str"unable to find a well-typed instantiation for "++quote(pr_existential_keyenvsigmaevk)++strbrk": "++f++strbrk" is expected to have a functional type but it has type "++u]|UnifUnivInconsistencyp->[str"universe inconsistency: "++UGraph.explain_universe_inconsistency(Termops.pr_evd_qvarsigma)(Termops.pr_evd_levelsigma)p]|CannotSolveConstraint((pb,env,t,u),e)->letenv=make_all_name_differentenvsigmain(strbrk"cannot satisfy constraint "++pr_leconstr_envenvsigmat++str" == "++pr_leconstr_envenvsigmau)::auxtue|ProblemBeyondCapabilities->[]inmatchauxp1p2ewith|[]->mt()|l->spc()++str"("++prlist_with_seppr_semicolon(funx->x)l++str")"letexplain_actual_typeenvsigmajtreason=letenv=make_all_name_differentenvsigmainletj=j_nf_betaiotaevarenvsigmajinlett=Reductionops.nf_betaiotaenvsigmatin(* Actually print *)letpe=pr_ne_context_of(str"In environment")envsigmainletpc=pr_leconstr_envenvsigma(Environ.j_valj)inlet(pt,pct)=pr_explicitenvsigmat(Environ.j_typej)inletppreason=explain_unification_errorenvsigmaj.uj_typetreasoninpe++hov0(str"The term"++brk(1,1)++pc++spc()++str"has type"++brk(1,1)++pct++spc()++str"while it is expected to have type"++brk(1,1)++pt++ppreason++str".")letexplain_incorrect_primitiveenvsigmajexp=letenv=make_all_name_differentenvsigmainlet{uj_val=p;uj_type=t}=jinlett=Reductionops.nf_betaiotaenvsigmatinletexp=Reductionops.nf_betaiotaenvsigmaexpin(* Actually print *)letpe=pr_ne_context_of(str"In environment")envsigmainlet(pt,pct)=pr_explicitenvsigmaexptinpe++hov0(str"The primitive"++brk(1,1)++str(CPrimitives.op_or_type_to_stringp)++spc()++str"has type"++brk(1,1)++pct++spc()++str"while it is expected to have type"++brk(1,1)++pt++str".")letexplain_cant_apply_bad_typeenvsigma?error(n,exptyp,actualtyp)ratorrandl=letrandl=jv_nf_betaiotaevarenvsigmarandlinletactualtyp=Reductionops.nf_betaiotaenvsigmaactualtypinletenv=make_all_name_differentenvsigmainleterror=explain_unification_errorenvsigmaactualtypexptyperrorinletactualtyp,exptyp=pr_explicitenvsigmaactualtypexptypinletnargs=Array.lengthrandlin(* let pe = pr_ne_context_of (str "in environment") env sigma in*)letpr,prt=pr_ljudge_envenvsigmaratorinletterm_string1=str(String.pluralnargs"term")inletterm_string2=ifnargs>1thenstr"The "++pr_nthn++str" term"elsestr"This term"inletappl=prvect_with_sepfnl(func->letpc,pct=pr_ljudge_envenvsigmacinhov2(pc++spc()++str": "++pct))randlinstr"Illegal application: "++(* pe ++ *)fnl()++str"The term"++brk(1,1)++pr++spc()++str"of type"++brk(1,1)++prt++spc()++str"cannot be applied to the "++term_string1++fnl()++str" "++v0appl++fnl()++term_string2++str" has type"++brk(1,1)++actualtyp++spc()++str"which should be a subtype of"++brk(1,1)++exptyp++str"."++errorletexplain_cant_apply_not_functionalenvsigmaratorrandl=letenv=make_all_name_differentenvsigmainletnargs=Array.lengthrandlin(* let pe = pr_ne_context_of (str "in environment") env sigma in*)letpr=pr_leconstr_envenvsigmarator.uj_valinletprt=pr_leconstr_envenvsigmarator.uj_typeinletappl=prvect_with_sepfnl(func->letpc=pr_leconstr_envenvsigmac.uj_valinletpct=pr_leconstr_envenvsigmac.uj_typeinhov2(pc++spc()++str": "++pct))randlinstr"Illegal application (Non-functional construction): "++(* pe ++ *)fnl()++str"The expression"++brk(1,1)++pr++spc()++str"of type"++brk(1,1)++prt++spc()++str"cannot be applied to the "++str(String.pluralnargs"term")++fnl()++str" "++v0applletexplain_unexpected_typeenvsigmaactual_typeexpected_typee=letpract,prexp=pr_explicitenvsigmaactual_typeexpected_typeinstr"Found type"++spc()++pract++spc()++str"where"++spc()++prexp++str" was expected"++explain_unification_errorenvsigmaactual_typeexpected_type(Somee)++str"."letexplain_not_productenvsigmac=letpr=pr_econstr_envenvsigmacinstr"The type of this term is a product"++spc()++str"while it is expected to be"++(ifEConstr.isTypesigmacthenstr" a sort"else(brk(1,1)++pr))++str"."letexplain_ill_formed_fix_bodyenvsigmanamesi=function(* Fixpoint guard errors *)|NotEnoughAbstractionInFixBody->str"Not enough abstractions in the definition"|RecursionNotOnInductiveTypec->str"Recursive definition on"++spc()++pr_leconstr_envenvsigmac++spc()++str"which should be a recursive inductive type"|RecursionOnIllegalTerm(j,(arg_env,arg),le_lt)->letarg_env=make_all_name_differentarg_envsigmainletcalled=matchnames.(j).binder_namewithNameid->Id.printid|Anonymous->str"the "++pr_nthi++str" definition"inletpr_dbx=quote(pr_dbenvx)inletvars=matchLazy.forcele_ltwith([],[])->assertfalse|([x],[])->str"a subterm of "++pr_dbx|(le,[])->str"a subterm of the following variables: "++pr_sequencepr_dble|(_,[x])->pr_dbx|(_,lt)->str"one of the following variables: "++pr_sequencepr_dbltinstr"Recursive call to "++called++spc()++strbrk"has principal argument equal to"++spc()++pr_leconstr_envarg_envsigmaarg++strbrk" instead of "++vars|NotEnoughArgumentsForFixCallj->letcalled=matchnames.(j).binder_namewithNameid->Id.printid|Anonymous->str"the "++pr_nthi++str" definition"instr"Recursive call to "++called++str" has not enough arguments"|FixpointOnIrrelevantInductive->strbrk"Fixpoints on proof irrelevant inductive types should produce proof irrelevant values"letexplain_ill_formed_cofix_bodyenvsigma=function(* CoFixpoint guard errors *)|CodomainNotInductiveTypec->str"The codomain is"++spc()++pr_leconstr_envenvsigmac++spc()++str"which should be a coinductive type"|NestedRecursiveOccurrences->str"Nested recursive occurrences"|UnguardedRecursiveCallc->str"Unguarded recursive call in"++spc()++pr_leconstr_envenvsigmac|RecCallInTypeOfAbstractionc->str"Recursive call forbidden in the domain of an abstraction:"++spc()++pr_leconstr_envenvsigmac|RecCallInNonRecArgOfConstructorc->str"Recursive call on a non-recursive argument of constructor"++spc()++pr_leconstr_envenvsigmac|RecCallInTypeOfDefc->str"Recursive call forbidden in the type of a recursive definition"++spc()++pr_leconstr_envenvsigmac|RecCallInCaseFunc->str"Invalid recursive call in a branch of"++spc()++pr_leconstr_envenvsigmac|RecCallInCaseArgc->str"Invalid recursive call in the argument of \"match\" in"++spc()++pr_leconstr_envenvsigmac|RecCallInCasePredc->str"Invalid recursive call in the \"return\" clause of \"match\" in"++spc()++pr_leconstr_envenvsigmac|NotGuardedFormc->str"Sub-expression "++pr_leconstr_envenvsigmac++strbrk" not in guarded form (should be a constructor,"++strbrk" an abstraction, a match, a cofix or a recursive call)"|ReturnPredicateNotCoInductivec->str"The return clause of the following pattern matching should be"++strbrk" a coinductive type:"++spc()++pr_leconstr_envenvsigmac(* TODO: use the names *)(* (co)fixpoints *)letexplain_ill_formed_rec_bodyenvsigmaerrnamesifixenvvdefj=letprt_namei=matchnames.(i).binder_namewithNameid->str"Recursive definition of "++Id.printid|Anonymous->str"The "++pr_nthi++str" definition"inletst=matcherrwith|FixGuardErrorerr->explain_ill_formed_fix_bodyenvsigmanamesierr|CoFixGuardErrorerr->explain_ill_formed_cofix_bodyenvsigmaerrinprt_namei++str" is ill-formed."++fnl()++pr_ne_context_of(str"In environment")envsigma++st++str"."++fnl()++(try(* May fail with unresolved globals. *)letfixenv=make_all_name_differentfixenvsigmainletpvd=pr_leconstr_envfixenvsigmavdefj.(i).uj_valinstr"Recursive definition is:"++spc()++pvd++str"."withewhenCErrors.noncriticale->mt())letexplain_ill_typed_rec_bodyenvsigmainamesvdefjvargs=letenv=make_all_name_differentenvsigmainletpvd=pr_leconstr_envenvsigmavdefj.(i).uj_valinletpvdt,pv=pr_explicitenvsigmavdefj.(i).uj_typevargs.(i)instr"The "++(matchvdefjwith[|_|]->mt()|_->pr_nth(i+1)++spc())++str"recursive definition"++spc()++pvd++spc()++str"has type"++spc()++pvdt++spc()++str"while it should be"++spc()++pv++str"."letexplain_cant_find_case_typeenvsigmac=letenv=make_all_name_differentenvsigmainletpe=pr_leconstr_envenvsigmacinstr"Cannot infer the return type of pattern-matching on"++ws1++pe++str"."letexplain_occur_checkenvsigmaevrhs=letenv=make_all_name_differentenvsigmainletpt=pr_leconstr_envenvsigmarhsinstr"Cannot define "++pr_existential_keyenvsigmaev++str" with term"++brk(1,1)++pt++spc()++str"that would depend on itself."letpr_trailing_ne_context_ofenvsigma=ifList.is_empty(Environ.rel_contextenv)&&List.is_empty(Environ.named_contextenv)thenstr"."else(strbrk" in environment:"++pr_context_unlimitedenvsigma)letrecexplain_evar_kindenvsigmaevkty=letopenEvar_kindsinfunction|Evar_kinds.NamedHoleid->strbrk"the existential variable named "++Id.printid|Evar_kinds.QuestionMark{qm_record_field=None}->strbrk"this placeholder of type "++ty|Evar_kinds.QuestionMark{qm_record_field=Some{fieldname;recordname}}->str"field "++(Printer.pr_constantenvfieldname)++str" of record "++(Printer.pr_inductiveenvrecordname)|Evar_kinds.CasesTypefalse->strbrk"the type of this pattern-matching problem"|Evar_kinds.CasesTypetrue->strbrk"a subterm of type "++ty++strbrk" in the type of this pattern-matching problem"|Evar_kinds.BinderType(Nameid)->strbrk"the type of "++Id.printid|Evar_kinds.BinderTypeAnonymous->strbrk"the type of this anonymous binder"|Evar_kinds.EvarType(ido,evk)->letpp=matchidowith|Someid->str"?"++Id.printid|None->trypr_existential_keyenvsigmaevkwith(* defined *)Not_found->strbrk"an internal placeholder"instrbrk"the type of "++pp|Evar_kinds.ImplicitArg(c,(n,ido),b)->letid=Option.getidoinstrbrk"the implicit parameter "++Id.printid++spc()++str"of"++spc()++Nametab.pr_global_envId.Set.emptyc++strbrk" whose type is "++ty|Evar_kinds.InternalHole->strbrk"an internal placeholder of type "++ty|Evar_kinds.TomatchTypeParameter(tyi,n)->strbrk"the "++pr_nthn++strbrk" argument of the inductive type ("++pr_inductiveenvtyi++strbrk") of this term"|Evar_kinds.GoalEvar->strbrk"an existential variable of type "++ty|Evar_kinds.ImpossibleCase->strbrk"the type of an impossible pattern-matching clause"|Evar_kinds.MatchingVar_->assertfalse|Evar_kinds.VarInstanceid->strbrk"an instance of type "++ty++str" for the variable "++Id.printid|Evar_kinds.SubEvar(where,evk')->letrecfind_sourceevk=letEvarInfoevi=Evd.findsigmaevkinmatchsnd(Evd.evar_sourceevi)with|Evar_kinds.SubEvar(_,evk)->find_sourceevk|src->EvarInfoevi,srcinletEvarInfoevi,src=find_sourceevk'inletpc=matchEvd.evar_bodyeviwith|Evar_definedc->pr_leconstr_envenvsigmac|Evar_empty->assertfalseinletty'=matchEvd.evar_bodyeviwith|Evar_empty->Evd.evar_conclevi|Evar_definedb->Retyping.get_type_ofenvsigmabinpr_existential_keyenvsigmaevk++strbrk" in the partial instance "++pc++strbrk" found for "++explain_evar_kindenvsigmaevk(pr_leconstr_envenvsigmaty')srcletexplain_typeclass_resolutionenvsigmaevik=matchTypeclasses.class_of_constrenvsigma(Evd.evar_conclevi)with|Some_->letenv=Evd.evar_filtered_envenveviinstr"Could not find an instance for "++pr_leconstr_envenvsigma(Evd.evar_conclevi)++pr_trailing_ne_context_ofenvsigma|_->mt()letexplain_placeholder_kindenvsigmace=matchewith|Some(SeveralInstancesFoundn)->strbrk" (several distinct possible type class instances found)"|None->matchTypeclasses.class_of_constrenvsigmacwith|Some_->strbrk" (no type class instance found)"|_->mt()letexplain_unsolvable_implicitenvsigmaevkexplain=letevi=Evarutil.nf_evar_infosigma(Evd.find_undefinedsigmaevk)inletenv=Evd.evar_filtered_envenveviinlettype_of_hole=pr_leconstr_envenvsigma(Evd.evar_conclevi)inletpe=pr_trailing_ne_context_ofenvsigmainstrbrk"Cannot infer "++explain_evar_kindenvsigmaevktype_of_hole(snd(Evd.evar_sourceevi))++explain_placeholder_kindenvsigma(Evd.evar_conclevi)explain++peletexplain_var_not_foundenvid=str"The variable"++spc()++Id.printid++spc()++str"was not found"++spc()++str"in the current"++spc()++str"environment"++str"."letexplain_evar_not_foundenvsigmaid=letundef=Evar.Map.domain(Evd.undefined_mapsigma)inletall_undef_evars=Evar.Set.elementsundefinletfev=Id.equalid(Termops.evar_suggested_name(Global.env())sigmaev)inifList.existsfall_undef_evarsthen(* The name is used for printing but is not user-given *)str"?"++Id.printid++strbrk" is a generated name. Only user-given names for existential variables"++strbrk" can be referenced. To give a user name to an existential variable,"++strbrk" introduce it with the ?[name] syntax."elsestr"Unknown existential variable."letexplain_wrong_case_infoenv(ind,u)ci=letpi=pr_inductiveenvindinifQInd.equalenvci.ci_indindthenstr"Pattern-matching expression on an object of inductive type"++spc()++pi++spc()++str"has invalid information."elseletpc=pr_inductiveenvci.ci_indinstr"A term of inductive type"++spc()++pi++spc()++str"was given to a pattern-matching expression on the inductive type"++spc()++pc++str"."letexplain_cannot_unifyenvsigmamne=letenv=make_all_name_differentenvsigmainletpm,pn=pr_explicitenvsigmamninletppreason=explain_unification_errorenvsigmamneinletpe=pr_ne_context_of(str"In environment")envsigmainpe++str"Unable to unify"++brk(1,1)++pm++spc()++str"with"++brk(1,1)++pn++ppreason++str"."letexplain_cannot_unify_localenvsigmamnsubn=letpm=pr_leconstr_envenvsigmaminletpn=pr_leconstr_envenvsigmaninletpsubn=pr_leconstr_envenvsigmasubninstr"Unable to unify"++brk(1,1)++pm++spc()++str"with"++brk(1,1)++pn++spc()++str"as"++brk(1,1)++psubn++str" contains local variables."letexplain_refiner_cannot_generalizeenvsigmaty=str"Cannot find a well-typed generalisation of the goal with type: "++pr_leconstr_envenvsigmaty++str"."letexplain_no_occurrence_foundenvsigmacid=str"Found no subterm matching"++spc()++pr_leconstr_envenvsigmac++spc()++str"in "++(matchidwith|Someid->Id.printid|None->str"the current goal")++str"."letexplain_cannot_unify_binding_typeenvsigmamn=letpm=pr_leconstr_envenvsigmaminletpn=pr_leconstr_envenvsigmaninstr"This binding has type"++brk(1,1)++pm++spc()++str"which should be unifiable with"++brk(1,1)++pn++str"."letexplain_cannot_find_well_typed_abstractionenvsigmaple=str"Abstracting over the "++str(String.plural(List.lengthl)"term")++spc()++hov0(pr_enum(func->pr_leconstr_envenvsigmac)l)++spc()++str"leads to a term"++spc()++pr_letype_env~goal_concl_style:trueenvsigmap++spc()++str"which is ill-typed."++(matchewithNone->mt()|Somee->fnl()++str"Reason is: "++e)letexplain_wrong_abstraction_typeenvsigmanaabsexpectedresult=letppname=matchnawithNameid->Id.printid++spc()|_->mt()instr"Cannot instantiate metavariable "++ppname++strbrk"of type "++pr_leconstr_envenvsigmaexpected++strbrk" with abstraction "++pr_leconstr_envenvsigmaabs++strbrk" of incompatible type "++pr_leconstr_envenvsigmaresult++str"."letexplain_abstraction_over_meta_mn=strbrk"Too complex unification problem: cannot find a solution for both "++Name.printm++spc()++str"and "++Name.printn++str"."letexplain_non_linear_unificationenvsigmamt=strbrk"Cannot unambiguously instantiate "++Name.printm++str":"++strbrk" which would require to abstract twice on "++pr_leconstr_envenvsigmat++str"."letexplain_unsatisfied_constraintsenvsigmacst=strbrk"Unsatisfied constraints: "++Univ.Constraints.pr(Termops.pr_evd_levelsigma)cst++spc()++str"(maybe a bugged tactic)."letexplain_unsatisfied_qconstraintsenvsigmacst=strbrk"Unsatisfied quality constraints: "++Sorts.QConstraints.pr(Termops.pr_evd_qvarsigma)cst++spc()++str"(maybe a bugged tactic)."letexplain_undeclared_universeenvsigmal=strbrk"Undeclared universe: "++Termops.pr_evd_levelsigmal++spc()++str"(maybe a bugged tactic)."letexplain_undeclared_qualitiesenvsigmal=letn=Sorts.QVar.Set.cardinallinstrbrk"Undeclared "++str(ifn=1then"quality"else"qualities")++strbrk": "++prlist_with_sepspc(Termops.pr_evd_qvarsigma)(Sorts.QVar.Set.elementsl)++spc()++str"(maybe a bugged tactic)."letexplain_disallowed_sprop()=Pp.(strbrk"SProp is disallowed because the "++str"\"Allow StrictProp\""++strbrk" flag is off.")letpr_relevancesigmar=letr=EConstr.ERelevance.kindsigmarinmatchrwith|Sorts.Relevant->str"relevant"|Sorts.Irrelevant->str"irrelevant"|Sorts.RelevanceVarq->str"a variable "++(* TODO names *)Sorts.QVar.raw_prqletpr_binderenvsigma=function|LocalAssum(na,t)->Pp.hov2(str"("++(Name.print@@na.binder_name)++str" : "++pr_leconstr_envenvsigmat++str")")|LocalDef(na,b,t)->Pp.hov2(str"("++(Name.print@@na.binder_name)++str" : "++pr_leconstr_envenvsigmat++str" := "++pr_leconstr_envenvsigmab++str")")letexplain_bad_binder_relevanceenvsigmarlvdecl=strbrk"Binder"++spc()++pr_binderenvsigmadecl++strbrk" has relevance mark set to "++pr_relevancesigma(RelDecl.get_relevancedecl)++strbrk" but was expected to be "++pr_relevancesigmarlv++spc()++str"(maybe a bugged tactic)."letexplain_bad_case_relevanceenvsigmarlvcase=let(_,_,_,(_,badr),_,_,_)=EConstr.destCasesigmacaseinstrbrk"Pattern-matching"++spc()++pr_leconstr_envenvsigmacase++strbrk" has relevance mark set to "++pr_relevancesigmabadr++strbrk" but was expected to be "++pr_relevancesigmarlv++spc()++str"(maybe a bugged tactic)."letexplain_bad_relevanceenvsigma=function|Typeops.BadRelevanceCase(r,c)->explain_bad_case_relevanceenvsigmarc|BadRelevanceBinder(r,d)->explain_bad_binder_relevanceenvsigmardletecast_bad_relevance=letopenTypeopsinfunction|BadRelevanceCase(r,c)->BadRelevanceCase(EConstr.ERelevance.maker,EConstr.of_constrc)|BadRelevanceBinder(r,d)->BadRelevanceBinder(EConstr.ERelevance.maker,EConstr.of_rel_decld)let()=CWarnings.register_printerTypeops.bad_relevance_msg(fun(env,b)->letsigma=Evd.from_envenvinexplain_bad_relevanceenvsigma(ecast_bad_relevanceb))let()=CWarnings.register_printerTyping.bad_relevance_msg(fun(env,sigma,b)->explain_bad_relevanceenvsigmab)letexplain_bad_invertenv=strbrk"Bad case inversion (maybe a bugged tactic)."letexplain_bad_varianceenvsigma~lev~expected~actual=str"Incorrect variance for universe "++Termops.pr_evd_levelsigmalev++str": expected "++UVars.Variance.prexpected++str" but cannot be less restrictive than "++UVars.Variance.practual++str"."letexplain_undeclared_used_variablesenvsigma~declared_vars~inferred_vars=letl=Id.Set.elements(Id.Set.diffinferred_varsdeclared_vars)inletn=List.lengthlinletdeclared_vars=Pp.pr_sequenceId.print(Id.Set.elementsdeclared_vars)inletinferred_vars=Pp.pr_sequenceId.print(Id.Set.elementsinferred_vars)inletmissing_vars=Pp.pr_sequenceId.print(List.revl)inPp.(prliststr["The following section ";(String.pluraln"variable");" ";(String.conjugate_verb_to_ben);" used but not declared:"]++fnl()++missing_vars++str"."++fnl()++fnl()++str"You can either update your proof to not depend on "++missing_vars++str", or you can update your Proof line from"++fnl()++str"Proof using "++declared_vars++fnl()++str"to"++fnl()++str"Proof using "++inferred_vars)letexplain_type_errorenvsigmaerr=letenv=make_all_name_differentenvsigmainmatcherrwith|UnboundReln->explain_unbound_relenvsigman|UnboundVarv->explain_unbound_varenvv|NotATypej->explain_not_typeenvsigmaj|BadAssumptionc->explain_bad_assumptionenvsigmac|ReferenceVariables(id,c)->explain_reference_variablessigmaidc|ElimArity(ind,c,okinds)->explain_elim_arityenvsigmaind(Somec)okinds|CaseNotInductivecj->explain_case_not_inductiveenvsigmacj|CaseOnPrivateIndind->explain_case_on_private_indenvsigmaind|NumberBranches(cj,n)->explain_number_branchesenvsigmacjn|IllFormedCaseParams->explain_ill_formed_case_paramsenvsigma|IllFormedBranch(c,i,actty,expty)->explain_ill_formed_branchenvsigmaciacttyexpty|Generalization(nvar,c)->explain_generalizationenvsigmanvarc|ActualType(j,pt)->explain_actual_typeenvsigmajptNone|IncorrectPrimitive(j,t)->explain_incorrect_primitiveenvsigmajt|CantApplyBadType(t,rator,randl)->explain_cant_apply_bad_typeenvsigmatratorrandl|CantApplyNonFunctional(rator,randl)->explain_cant_apply_not_functionalenvsigmaratorrandl|IllFormedRecBody(err,lna,i,fixenv,vdefj)->explain_ill_formed_rec_bodyenvsigmaerrlnaifixenvvdefj|IllTypedRecBody(i,lna,vdefj,vargs)->explain_ill_typed_rec_bodyenvsigmailnavdefjvargs|WrongCaseInfo(ind,ci)->explain_wrong_case_infoenvindci|UnsatisfiedConstraintscst->explain_unsatisfied_constraintsenvsigmacst|UnsatisfiedQConstraintscst->explain_unsatisfied_qconstraintsenvsigmacst|UndeclaredUniversel->explain_undeclared_universeenvsigmal|UndeclaredQualitiesl->explain_undeclared_qualitiesenvsigmal|DisallowedSProp->explain_disallowed_sprop()|BadBinderRelevance(rlv,decl)->explain_bad_binder_relevanceenvsigmarlvdecl|BadCaseRelevance(rlv,case)->explain_bad_case_relevanceenvsigmarlvcase|BadInvert->explain_bad_invertenv|BadVariance{lev;expected;actual}->explain_bad_varianceenvsigma~lev~expected~actual|UndeclaredUsedVariables{declared_vars;inferred_vars}->explain_undeclared_used_variablesenvsigma~declared_vars~inferred_varsletpr_position(cl,pos)=letclpos=matchclwith|None->str" of the goal"|Some(id,Locus.InHyp)->str" of hypothesis "++Id.printid|Some(id,Locus.InHypTypeOnly)->str" of the type of hypothesis "++Id.printid|Some(id,Locus.InHypValueOnly)->str" of the body of hypothesis "++Id.printidinintpos++clposletexplain_cannot_unify_occurrencesenvsigmanested((cl2,pos2),t2)((cl1,pos1),t1)=ifnestedthenstr"Found nested occurrences of the pattern at positions "++intpos1++strbrk" and "++pr_position(cl2,pos2)++str"."elsestr"Found incompatible occurrences of the pattern"++str":"++spc()++str"Matched term "++pr_leconstr_envenvsigmat2++strbrk" at position "++pr_position(cl2,pos2)++strbrk" is not compatible with matched term "++pr_leconstr_envenvsigmat1++strbrk" at position "++pr_position(cl1,pos1)++str"."letpr_constraintsprintenvmsgenvsigmaevarscstrs=let(ev,evi)=Evar.Map.chooseevarsinifEvar.Map.for_all(funev'evi'->eq_named_context_val(Evd.evar_hypsevi)(Evd.evar_hypsevi'))evarsthenletl=Evar.Map.bindingsevarsinletenv'=Evd.evar_envenveviinletpe=ifprintenvthenpr_ne_context_of(str"In environment:")env'sigmaelsemt()inletenv=Global.env()inletevs=prlist_with_sep(fun()->fnl()++fnl())(fun(ev,evi)->hov2(pr_existential_keyenvsigmaev++str" :"++spc()++Printer.pr_leconstr_envenv'sigma(Evd.evar_conclevi)))linh(pe++strmsg++fnl()++evs++pr_evar_constraintssigmacstrs)elseletfilterevk_=Evar.Map.memevkevarsinpr_evar_map_filter~with_univs:falsefilterenvsigmaletexplain_unsatisfiable_constraintsenvsigmaconstrcomp=let(_,constraints)=Evd.extract_all_conv_pbssigmainlettcs=Evd.get_typeclass_evarssigmainletundef=Evd.undefined_mapsigmain(* Only keep evars that are subject to resolution and members of the given
component. *)letis_keptevk_=Evar.Set.memevktcs&&Evar.Set.memevkcompinletundef=letm=Evar.Map.filteris_keptundefinifEvar.Map.is_emptymthenundefelseminmatchconstrwith|None->ifList.is_emptyconstraintsthenletmsg="Could not find an instance for the following existential variables:"inpr_constraintstruemsgenvsigmaundefconstraintselseletmsg="Unable to satisfy the following constraints:"inpr_constraintstruemsgenvsigmaundefconstraints|Some(ev,k)->letcstr=letremaining=Evar.Map.removeevundefinifnot(Evar.Map.is_emptyremaining)thenletmsg="With the following constraints:"inpr_constraintsfalsemsgenvsigmaremainingconstraintselsemt()inletinfo=Evar.Map.findevundefinexplain_typeclass_resolutionenvsigmainfok++fnl()++cstrletrecexplain_pretype_errorenvsigmaerr=letenv=Evardefine.env_nf_betaiotaevarsigmaenvinletenv=make_all_name_differentenvsigmainmatcherrwith|CantFindCaseTypec->explain_cant_find_case_typeenvsigmac|ActualTypeNotCoercible(j,t,e)->let{uj_val=c;uj_type=actty}=jinlet(env,c,actty,expty),e=contract3'envsigmacacttyteinletj={uj_val=c;uj_type=actty}inexplain_actual_typeenvsigmajexpty(Somee)|UnifOccurCheck(ev,rhs)->explain_occur_checkenvsigmaevrhs|UnsolvableImplicit(evk,exp)->explain_unsolvable_implicitenvsigmaevkexp|VarNotFoundid->explain_var_not_foundenvid|EvarNotFoundid->explain_evar_not_foundenvsigmaid|UnexpectedType(actual,expect,e)->letenv,actual,expect=contract2envsigmaactualexpectinexplain_unexpected_typeenvsigmaactualexpecte|NotProductc->explain_not_productenvsigmac|CannotUnify(m,n,e)->letenv,m,n=contract2envsigmamninexplain_cannot_unifyenvsigmamne|CannotUnifyLocal(m,n,sn)->explain_cannot_unify_localenvsigmamnsn|CannotGeneralizety->explain_refiner_cannot_generalizeenvsigmaty|NoOccurrenceFound(c,id)->explain_no_occurrence_foundenvsigmacid|CannotUnifyBindingType(m,n)->explain_cannot_unify_binding_typeenvsigmamn|CannotFindWellTypedAbstraction(p,l,e)->explain_cannot_find_well_typed_abstractionenvsigmapl(Option.map(fun(env',e)->explain_pretype_errorenv'sigmae)e)|WrongAbstractionType(n,a,t,u)->explain_wrong_abstraction_typeenvsigmanatu|AbstractionOverMeta(m,n)->explain_abstraction_over_metaenvmn|NonLinearUnification(m,c)->explain_non_linear_unificationenvsigmamc|TypingErrort->explain_type_errorenvsigmat|CantApplyBadTypeExplained((t,rator,randl),error)->explain_cant_apply_bad_typeenvsigma~errortratorrandl|CannotUnifyOccurrences(b,c1,c2)->explain_cannot_unify_occurrencesenvsigmabc1c2|UnsatisfiableConstraints(c,comp)->explain_unsatisfiable_constraintsenvsigmaccomp|DisallowedSProp->explain_disallowed_sprop()(* Module errors *)letpr_modpathmp=Libnames.pr_qualid(Nametab.shortest_qualid_of_modulemp)letpr_modtype_subpathuppermp=letrecauxmp=trylet(dir,id)=Libnames.repr_qualid(Nametab.shortest_qualid_of_modtypemp)inLibnames.add_dirpath_suffixdirid,[]withNot_found->matchmpwith|MPdot(mp',id)->letmp,suff=auxmp'inmp,Label.to_idid::suff|_->assertfalseinletmp,suff=auxmpin(ifsuff=[]thenmt()elsestr(ifupperthen"Module "else"module ")++DirPath.print(DirPath.makesuff)++str" of ")++DirPath.printmpopenModopsletexplain_not_match_error=function|InductiveFieldExpected_->strbrk"an inductive definition is expected"|DefinitionFieldExpected->strbrk"a definition is expected. Hint: you can rename the \
inductive or constructor and add a definition mapping the \
old name to the new name"|ModuleFieldExpected->strbrk"a module is expected"|ModuleTypeFieldExpected->strbrk"a module type is expected"|NotConvertibleInductiveFieldid|NotConvertibleConstructorFieldid->str"types given to "++Id.printid++str" differ"|NotConvertibleBodyField->str"the body of definitions differs"|NotConvertibleTypeField(env,typ1,typ2)->str"expected type"++spc()++quote(Printer.safe_pr_lconstr_envenv(Evd.from_envenv)typ2)++spc()++str"but found type"++spc()++quote(Printer.safe_pr_lconstr_envenv(Evd.from_envenv)typ1)|NotSameConstructorNamesField->str"constructor names differ"|NotSameInductiveNameInBlockField->str"inductive types names differ"|FiniteInductiveFieldExpectedisfinite->str"type is expected to be "++str(ifisfinitethen"coinductive"else"inductive")|InductiveNumbersFieldExpectedn->str"number of inductive types differs"|InductiveParamsNumberFieldn->str"inductive type has not the right number of parameters"|RecordFieldExpectedisrecord->str"type is expected "++str(ifisrecordthen""else"not ")++str"to be a record"|RecordProjectionsExpectednal->(ifList.lengthnal>=2thenstr"expected projection names are "elsestr"expected projection name is ")++pr_enum(functionNameid->Id.printid|_->str"_")nal|NotEqualInductiveAliases->str"Aliases to inductive types do not match"|CumulativeStatusExpectedb->letstatusb=ifbthenstr"cumulative"elsestr"non-cumulative"instr"a "++statusb++str" declaration was expected, but a "++status(notb)++str" declaration was found"|PolymorphicStatusExpectedb->letstatusb=ifbthenstr"polymorphic"elsestr"monomorphic"instr"a "++statusb++str" declaration was expected, but a "++status(notb)++str" declaration was found"|IncompatibleUniversesincon->str"the universe constraints are inconsistent: "++UGraph.explain_universe_inconsistencySorts.QVar.raw_prUnivNames.pr_level_with_global_universesincon|IncompatiblePolymorphism(env,t1,t2)->str"conversion of polymorphic values generates additional constraints: "++quote(Printer.safe_pr_lconstr_envenv(Evd.from_envenv)t1)++spc()++str"compared to "++spc()++quote(Printer.safe_pr_lconstr_envenv(Evd.from_envenv)t2)|IncompatibleConstraints{got;expect}->letopenUVarsinletpr_auctxauctx=letsigma=Evd.from_ctx(UState.of_names(Printer.universe_binders_with_opt_namesauctxNone))inletuctx=AbstractContext.reprauctxinPrinter.pr_universe_instance_constraintssigma(UContext.instanceuctx)(UContext.constraintsuctx)instr"incompatible polymorphic binders: got"++spc()++h(pr_auctxgot)++spc()++str"but expected"++spc()++h(pr_auctxexpect)++(ifnot(UVars.eq_sizes(AbstractContext.sizegot)(AbstractContext.sizeexpect))thenmt()elsefnl()++str"(incompatible constraints)")|IncompatibleVariance->str"incompatible variance information"|NoRewriteRulesSubtyping->strbrk"subtyping for rewrite rule blocks is not supported"letrecget_submodulesacc=function|[]->acc,[]|Submodulel::trace->get_submodules(l::acc)trace|(FunctorArgument_::_)astrace->acc,traceletget_submodulestrace=letsubmodules,trace=get_submodules[]tracein(String.concat"."(List.mapLabel.to_stringsubmodules)),traceletrecprint_trace=function|[]->assertfalse|(Submodule_::_)astrace->letsubmodules,trace=get_submodulestraceinstrsubmodules++(ifList.is_emptytracethenmt()elsespc()++str"in "++print_tracetrace)|FunctorArgumentn::trace->str"the "++str(CString.ordinaln)++str" functor argument"++(ifList.is_emptytracethenmt()elsespc()++str"of "++print_tracetrace)letexplain_signature_mismatchtracelwhy=letsubmodules,trace=get_submodulestraceinletl=ifString.is_emptysubmodulesthenLabel.printlelsestrsubmodules++str"."++Label.printlinstr"Signature components for field "++l++(ifList.is_emptytracethenmt()elsestr" in "++print_tracetrace)++str" do not match:"++spc()++explain_not_match_errorwhy++str"."letexplain_label_already_declaredl=str"The label "++Label.printl++str" is already declared."letexplain_not_a_functor()=str"Application of a non-functor."letexplain_is_a_functormp=pr_modtype_subpathtruemp++str" not expected to be a functor."letexplain_incompatible_module_typesmexpr1mexpr2=letopenDeclarationsinletrecget_arg=function|NoFunctor_->0|MoreFunctor(_,_,ty)->succ(get_argty)inletlen1=get_argmexpr1.mod_typeinletlen2=get_argmexpr2.mod_typeiniflen1<>len2thenstr"Incompatible module types: module expects "++intlen2++str" arguments, found "++intlen1++str"."elsestr"Incompatible module types."letexplain_not_equal_module_pathsmp1mp2=str"Module "++pr_modpathmp1++strbrk" is not equal to "++pr_modpathmp2++str"."letexplain_no_such_labellmp=str"No field named "++Label.printl++str" in "++pr_modtype_subpathfalsemp++str"."letexplain_not_a_module_labell=Label.printl++str" is not the name of a module field."letexplain_not_a_constantl=quote(Label.printl)++str" is not a constant."letexplain_incorrect_label_constraintl=str"Incorrect constraint for label "++quote(Label.printl)++str"."letexplain_generative_module_expectedl=str"The module "++Label.printl++str" is not generative."++strbrk" Only components of generative modules can be changed"++strbrk" using the \"with\" construct."letexplain_label_missingls=str"The field "++Label.printl++str" is missing in "++strs++str"."letexplain_include_restricted_functormp=str"Cannot include the functor "++pr_modpathmp++strbrk" since it has a restricted signature. "++strbrk"You may name first an instance of this functor, and include it."letexplain_module_error=function|SignatureMismatch(trace,l,err)->explain_signature_mismatchtracelerr|LabelAlreadyDeclaredl->explain_label_already_declaredl|NotAFunctor->explain_not_a_functor()|IsAFunctormp->explain_is_a_functormp|IncompatibleModuleTypes(m1,m2)->explain_incompatible_module_typesm1m2|NotEqualModulePaths(mp1,mp2)->explain_not_equal_module_pathsmp1mp2|NoSuchLabel(l,mp)->explain_no_such_labellmp|NotAModuleLabell->explain_not_a_module_labell|NotAConstantl->explain_not_a_constantl|IncorrectWithConstraintl->explain_incorrect_label_constraintl|GenerativeModuleExpectedl->explain_generative_module_expectedl|LabelMissing(l,s)->explain_label_missingls|IncludeRestrictedFunctormp->explain_include_restricted_functormp(* Module internalization errors *)(*
let explain_declaration_not_path _ =
str "Declaration is not a path."
*)letexplain_not_module_nor_modtypeqid=Libnames.pr_qualidqid++str" is not a module or module type."letexplain_not_a_moduleqid=Libnames.pr_qualidqid++str" is not a module."letexplain_not_a_module_typeqid=Libnames.pr_qualidqid++str" is not a module type."letexplain_incorrect_with_in_module()=str"The syntax \"with\" is not allowed for modules."letexplain_incorrect_module_application()=str"Illegal application to a module type."letexplain_module_internalization_error=letopenModinterninfunction|NotAModuleNorModtypeqid->explain_not_module_nor_modtypeqid|NotAModuleqid->explain_not_a_moduleqid|NotAModuleTypeqid->explain_not_a_module_typeqid|IncorrectWithInModule->explain_incorrect_with_in_module()|IncorrectModuleApplication->explain_incorrect_module_application()(* Typeclass errors *)letexplain_not_a_classenvsigmac=pr_econstr_envenvsigmac++str" is not a declared type class."letexplain_unbound_methodenvsigmacid{CAst.v=id}=str"Unbound method name "++Id.print(id)++spc()++str"of class"++spc()++pr_globalcid++str"."letexplain_typeclass_errorenvsigma=function|NotAClassc->explain_not_a_classenvsigmac|UnboundMethod(cid,id)->explain_unbound_methodenvsigmacidid(* Refiner errors *)letexplain_refiner_unresolved_bindingsl=str"Unable to find an instance for the "++str(String.plural(List.lengthl)"variable")++spc()++prlist_with_seppr_commaName.printl++str"."letexplain_refiner_cannot_applyenvsigmatharg=str"In refiner, a term of type"++brk(1,1)++pr_leconstr_envenvsigmat++spc()++str"could not be applied to"++brk(1,1)++pr_leconstr_envenvsigmaharg++str"."letexplain_intro_needs_product()=str"Introduction tactics needs products."letexplain_non_linear_proofenvsigmac=str"Cannot refine with term"++brk(1,1)++pr_leconstr_envenvsigmac++spc()++str"because a metavariable has several occurrences."letexplain_no_such_hypid=str"No such hypothesis: "++Id.printidletexplain_refiner_errorenvsigma=function|UnresolvedBindingst->explain_refiner_unresolved_bindingst|CannotApply(t,harg)->explain_refiner_cannot_applyenvsigmatharg|IntroNeedsProduct->explain_intro_needs_product()|NonLinearProofc->explain_non_linear_proofenvsigmac|NoSuchHypid->explain_no_such_hypid(* Inductive errors *)leterror_non_strictly_positiveenvcv=letpc=pr_lconstr_envenv(Evd.from_envenv)cinletpv=pr_lconstr_envenv(Evd.from_envenv)vinstr"Non strictly positive occurrence of "++pv++str" in"++brk(1,1)++pc++str"."leterror_ill_formed_inductiveenvcv=letpc=pr_lconstr_envenv(Evd.from_envenv)cinletpv=pr_lconstr_envenv(Evd.from_envenv)vinstr"Not enough arguments applied to the "++pv++str" in"++brk(1,1)++pc++str"."leterror_ill_formed_constructorenvidcvnparamsnargs=letpv=pr_lconstr_envenv(Evd.from_envenv)vinletatomic=Int.equal(nb_prodEvd.empty(EConstr.of_constrc))(* FIXME *)0instr"The type of constructor"++brk(1,1)++Id.printid++brk(1,1)++str"is not valid;"++brk(1,1)++strbrk(ifatomicthen"it must be "else"its conclusion must be ")++pv++(* warning: because of implicit arguments it is difficult to say which
parameters must be explicitly given *)(ifnot(Int.equalnparams0)thenstrbrk" applied to its "++str(String.pluralnparams"parameter")elsemt())++(ifnot(Int.equalnargs0)thenstr(ifnot(Int.equalnparams0)then" and"else" applied")++strbrk" to some "++str(String.pluralnargs"argument")elsemt())++str"."letpr_ltype_using_barendregt_convention_envenvc=(* Use goal_concl_style as an approximation of Barendregt's convention (?) *)quote(pr_ltype_env~goal_concl_style:trueenv(Evd.from_envenv)c)leterror_bad_ind_parametersenvcnv1v2=letpc=pr_ltype_using_barendregt_convention_envenvcinletpv1=pr_lconstr_envenv(Evd.from_envenv)v1inletpv2=pr_lconstr_envenv(Evd.from_envenv)v2instr"Last occurrence of "++pv2++str" must have "++pv1++str" as "++pr_nthn++str" argument in"++brk(1,1)++pc++str"."leterror_same_names_typesid=str"The name"++spc()++Id.printid++spc()++str"is used more than once."leterror_same_names_constructorsid=str"The constructor name"++spc()++Id.printid++spc()++str"is used more than once."leterror_same_names_overlapidl=strbrk"The following names are used both as type names and constructor "++str"names:"++spc()++prlist_with_seppr_commaId.printidl++str"."leterror_not_an_arityenvc=str"The type"++spc()++pr_lconstr_envenv(Evd.from_envenv)c++spc()++str"is not an arity."leterror_bad_entry()=str"Bad inductive definition."leterror_large_non_prop_inductive_not_in_type()=str"Large non-propositional inductive types must be in Type."leterror_inductive_missing_constraints(us,ind_univ)=str"Missing universe constraint declared for inductive type:"++spc()++v0(prlist_with_sepspc(funu->hov0(Printer.pr_sortEvd.emptyu++str" <= "++Printer.pr_sortEvd.emptyind_univ))us)(* Recursion schemes errors *)leterror_not_allowed_dependent_analysisenvisreci=str"Dependent "++str(ifisrecthen"induction"else"case analysis")++strbrk" is not allowed for inductive definition "++pr_inductiveenvi++str"."leterror_not_mutual_in_schemeenvindind'=ifQInd.equalenvindind'thenstr"The inductive type "++pr_inductiveenvind++str" occurs twice."elsestr"The inductive types "++pr_inductiveenvind++spc()++str"and"++spc()++pr_inductiveenvind'++spc()++str"are not mutually defined."(* Inductive constructions errors *)letexplain_inductive_error=function|NonPos(env,c,v)->error_non_strictly_positiveenvcv|NotEnoughArgs(env,c,v)->error_ill_formed_inductiveenvcv|NotConstructor(env,id,c,v,n,m)->error_ill_formed_constructorenvidcvnm|NonPar(env,c,n,v1,v2)->error_bad_ind_parametersenvcnv1v2|SameNamesTypesid->error_same_names_typesid|SameNamesConstructorsid->error_same_names_constructorsid|SameNamesOverlapidl->error_same_names_overlapidl|NotAnArity(env,c)->error_not_an_arityenvc|BadEntry->error_bad_entry()|LargeNonPropInductiveNotInType->error_large_non_prop_inductive_not_in_type()|MissingConstraintscsts->error_inductive_missing_constraintscsts(* Primitive errors *)letexplain_incompatible_prim_declarations(typea)(act:aPrimred.action_kind)(x:a)(y:a)=letopenPrimredinletenv=Global.env()in(* The newer constant/inductive (either coming from Primitive or a
Require) may be absent from the nametab as the error got raised
while adding it to the safe_env. In that case we can't use
nametab printing.
There are still cases where the constant/inductive is added
separately from its retroknowledge (using Register), so we still
try nametab based printing. *)matchactwith|IncompatTypestyp->letpx=trypr_constantenvxwithNot_found->Constant.printxinstr"Cannot declare "++px++str" as primitive "++str(CPrimitives.prim_type_to_stringtyp)++str": "++pr_constantenvy++str" is already declared."|IncompatIndind->letpx=trypr_inductiveenvxwithNot_found->MutInd.print(fstx)instr"Cannot declare "++px++str" as primitive "++str(CPrimitives.prim_ind_to_stringind)++str": "++pr_inductiveenvy++str" is already declared."(* Recursion schemes errors *)letexplain_recursion_scheme_errorenv=function|NotAllowedCaseAnalysis(isrec,k,i)->explain_elim_arityenv(Evd.from_envenv)iNone(Somek)(* error_not_allowed_case_analysis env isrec k i *)|NotMutualInScheme(ind,ind')->error_not_mutual_in_schemeenvindind'|NotAllowedDependentAnalysis(isrec,i)->error_not_allowed_dependent_analysisenvisreci(* Pattern-matching errors *)letexplain_bad_patternenvsigmacstrty=letenv=make_all_name_differentenvsigmainletpt=pr_leconstr_envenvsigmatyinletpc=pr_constructorenvcstrinstr"Found the constructor "++pc++brk(1,1)++str"while matching a term of type "++pt++brk(1,1)++str"which is not an inductive type."letexplain_bad_constructorenvcstrind=letpi=pr_inductiveenvindin(* let pc = pr_constructor env cstr in*)letpt=pr_inductiveenv(inductive_of_constructorcstr)instr"Found a constructor of inductive type "++pt++brk(1,1)++str"while a constructor of "++pi++brk(1,1)++str"is expected."letdecline_stringns=ifInt.equaln0thenstr"no "++strs++str"s"elseifInt.equaln1thenstr"1 "++strselse(intn++str" "++strs++str"s")letexplain_wrong_numarg_patternexpandednargsexpected_nassumsexpected_ndeclspp=(ifexpandedthenstrbrk"Once notations are expanded, the resulting "elsestrbrk"The ")++pp++strbrk" is expected to be applied to "++decline_stringexpected_nassums"argument"++(ifexpected_nassums=expected_ndeclsthenmt()elsestrbrk" (or "++decline_stringexpected_ndecls"argument"++strbrk" when including variables for local definitions)")++strbrk" while it is actually applied to "++decline_stringnargs"argument"++str"."letexplain_wrong_numarg_constructorenvcstrexpandednargsexpected_nassumsexpected_ndecls=letpp=strbrk"constructor "++pr_constructorenvcstr++strbrk" (in type "++pr_inductiveenv(inductive_of_constructorcstr)++strbrk")"inexplain_wrong_numarg_patternexpandednargsexpected_nassumsexpected_ndeclsppletexplain_wrong_numarg_inductiveenvindexpandednargsexpected_nassumsexpected_ndecls=letpp=strbrk"inductive type "++pr_inductiveenvindinexplain_wrong_numarg_patternexpandednargsexpected_nassumsexpected_ndeclsppletexplain_unused_clauseenvpats=str"Pattern \""++hov0(prlist_with_seppr_commapr_cases_patternpats)++strbrk"\" is redundant in this clause."letexplain_non_exhaustiveenvpats=str"Non exhaustive pattern-matching: no clause found for "++str(String.plural(List.lengthpats)"pattern")++spc()++hov0(prlist_with_seppr_commapr_cases_patternpats)letexplain_cannot_infer_predicateenvsigmatyps=lettyps=Array.to_listtypsinletenv=make_all_name_differentenvsigmainletpr_branch(cstr,typ)=letcstr,_=EConstr.decompose_appsigmacstrinstr"For "++pr_leconstr_envenvsigmacstr++str": "++pr_leconstr_envenvsigmatypinstr"Unable to unify the types found in the branches:"++spc()++hov0(prlist_with_sepfnlpr_branchtyps)letexplain_pattern_matching_errorenvsigma=function|BadPattern(c,t)->explain_bad_patternenvsigmact|BadConstructor(c,ind)->explain_bad_constructorenvcind|WrongNumargConstructor{cstr;expanded;nargs;expected_nassums;expected_ndecls}->explain_wrong_numarg_constructorenvcstrexpandednargsexpected_nassumsexpected_ndecls|WrongNumargInductive{ind;expanded;nargs;expected_nassums;expected_ndecls}->explain_wrong_numarg_inductiveenvindexpandednargsexpected_nassumsexpected_ndecls|UnusedClausetms->explain_unused_clauseenvtms|NonExhaustivetms->explain_non_exhaustiveenvtms|CannotInferPredicatetyps->explain_cannot_infer_predicateenvsigmatypsletexplain_reduction_tactic_error=function|Tacred.InvalidAbstraction(env,sigma,c,(env',e))->lete=of_type_erroreinstr"The abstracted term"++spc()++quote(pr_letype_env~goal_concl_style:trueenvsigmac)++spc()++str"is not well typed."++fnl()++explain_type_errorenv'(Evd.from_envenv')eletexplain_prim_token_notation_errorkindenvsigma=function|Notation.UnexpectedTermc->(strbrk"Unexpected term "++pr_constr_envenvsigmac++strbrk(" while parsing a "^kind^" notation."))|Notation.UnexpectedNonOptionTermc->(strbrk"Unexpected non-option term "++pr_constr_envenvsigmac++strbrk(" while parsing a "^kind^" notation."))(* Rewrite rules errors *)leterror_not_allowed_rewrite_rulessymb_or_rule=str(matchsymb_or_rulewithRule->"Rewrite rule"|Symb->"Symbol")++spc()++strbrk"declaration requires passing the flag "++strbrk"\"-allow-rewrite-rules\"."(** Registration of generic errors
Nota: explain_exn does NOT end with a newline anymore!
*)exceptionUnhandledletwrap_unhandledfe=trySome(fe)withUnhandled->Noneletexplain_exn_default=function(* Basic interaction exceptions *)|Gramlib.Grammar.Errortxt->hov0(str"Syntax error: "++strtxt++str".")|CLexer.Error.Eerr->hov0(str(CLexer.Error.to_stringerr))|Sys_errormsg->hov0(str"System error: "++quote(strmsg))|Out_of_memory->hov0(str"Out of memory.")|Stack_overflow->hov0(str"Stack overflow.")|CErrors.Timeout->hov0(str"Timeout!")|Sys.Break->hov0(str"User interrupt.")(* Otherwise, not handled here *)|_->raiseUnhandledlet_=CErrors.register_handler(wrap_unhandledexplain_exn_default)letrecvernac_interp_error_handler=function|UGraph.UniverseInconsistencyi->str"Universe inconsistency."++spc()++UGraph.explain_universe_inconsistencySorts.QVar.raw_prUnivNames.pr_level_with_global_universesi++str"."|TypeError(env,te)->lette=of_type_errorteinexplain_type_errorenv(Evd.from_envenv)te|PretypeError(ctx,sigma,te)->explain_pretype_errorctxsigmate|Notation.PrimTokenNotationError(kind,ctx,sigma,te)->explain_prim_token_notation_errorkindctxsigmate|Typeclasses_errors.TypeClassError(env,sigma,te)->explain_typeclass_errorenvsigmate|InductiveErrore->explain_inductive_errore|Primred.IncompatibleDeclarations(act,x,y)->explain_incompatible_prim_declarationsactxy|Modops.ModuleTypingErrore->explain_module_errore|Modintern.ModuleInternalizationErrore->explain_module_internalization_errore|RecursionSchemeError(env,e)->explain_recursion_scheme_errorenve|Cases.PatternMatchingError(env,sigma,e)->explain_pattern_matching_errorenvsigmae|Tacred.ReductionTacticErrore->explain_reduction_tactic_errore|Logic.RefinerError(env,sigma,e)->explain_refiner_errorenvsigmae|Nametab.GlobalizationErrorq->str"The reference"++spc()++Libnames.pr_qualidq++spc()++str"was not found"++spc()++str"in the current"++spc()++str"environment."|Tacticals.FailError(i,s)->lets=Lazy.forcesinstr"Tactic failure"++(ifPp.ismtsthenselsestr": "++s)++ifInt.equali0thenstr"."elsestr" (level "++inti++str")."|Logic_monad.TacticFailuree->vernac_interp_error_handlere|Environ.RewriteRulesNotAllowedsymb_or_rule->error_not_allowed_rewrite_rulessymb_or_rule|_->raiseUnhandledlet_=CErrors.register_handler(wrap_unhandledvernac_interp_error_handler)(* Locating errors *)letexplain_notation_not_reference=function|Notation.AmbiguousNotationAsReference_->str"Ambiguous notation."|Notation.NotationNotReference(env,sigma,ntn,ntns)->matchntnswith|[]->str"Unable to interpret "++quote(strntn)++str" as a reference."|ntns->letf(df,r)=str"Notation"++brk(1,2)++Notation_ops.pr_notation_info(Printer.pr_notation_interpretation_envenvsigma)dfrinstr"Unable to unambiguously interpret "++quote(strntn)++str" as a reference. Found:"++fnl()++v0(hov0(prlist_with_sepspcfntns))let_=CErrors.register_handler(function|Notation.NotationAsReferenceErrore->Some(explain_notation_not_referencee)|_->None)