1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510(************************************************************************)(* * 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."letrecpr_disjunctionpr=function|[a]->pra|[a;b]->pra++str" or"++spc()++prb|a::l->pra++str","++spc()++pr_disjunctionprl|[]->assertfalsetypearity_error=|NonInformativeToInformative|StrongEliminationOnNonSmallType|WrongArityleterror_elim_explainkpki=letopenSortsinmatchkp,kiwith|(InType|InSet),InProp->NonInformativeToInformative|InType,InSet->StrongEliminationOnNonSmallType(* if Set impredicative *)|_->WrongArityletexplain_elim_arityenvsigmaindcokinds=letopenEConstrinletenv=make_all_name_differentenvsigmainletpi=pr_inductiveenv(fstind)inletpc=pr_leconstr_envenvsigmacinletmsg=matchokindswith|Some(pj,sorts,kp,ki)->letexplanation=error_elim_explainkpkiinletsorts=Inductiveops.sorts_belowsortsinletpki=Sorts.pr_sort_familykiinletpkp=Sorts.pr_sort_familykpinletexplanation=matchexplanationwith|NonInformativeToInformative->"proofs can be eliminated only to build proofs"|StrongEliminationOnNonSmallType->"strong elimination on non-small inductive types leads to paradoxes"|WrongArity->"wrong arity"inletppar=pr_disjunction(funs->quote(Sorts.pr_sort_familys))sortsinletppt=pr_leconstr_envenvsigma(snd(decompose_prod_assumsigmapj.uj_type))inhov0(str"the return type has sort"++spc()++ppt++spc()++str"while it"++spc()++str"should be "++ppar++str".")++fnl()++hov0(str"Elimination of an inductive object of sort "++pki++brk(1,0)++str"is not allowed on a predicate in sort "++pkp++fnl()++str"because"++spc()++strexplanation++str".")|None->str"ill-formed elimination predicate."inhov0(str"Incorrect elimination 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_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_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_annotnameSorts.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_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(n,exptyp,actualtyp)ratorrandl=letrandl=jv_nf_betaiotaevarenvsigmarandlinletactualtyp=Reductionops.nf_betaiotaenvsigmaactualtypinletenv=make_all_name_differentenvsigmainletactualtyp,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 coercible to"++brk(1,1)++exptyp++str"."letexplain_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=letevi=Evd.findsigmaevkinmatchsnd(Evd.evar_sourceevi)with|Evar_kinds.SubEvar(_,evk)->find_sourceevk|src->evi,srcinletevi,src=find_sourceevk'inletpc=matchEvd.evar_bodyeviwith|Evar_definedc->pr_leconstr_envenvsigmac|Evar_empty->assertfalseinletty'=Evd.evar_concleviinpr_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_envenveviinfnl()++str"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_inductiveenvindinifInd.CanOrd.equalci.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 "++pr_leconstr_envenvsigmac++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.pr_constraints(Termops.pr_evd_levelsigma)cst++spc()++str"(maybe a bugged tactic)."letexplain_undeclared_universeenvsigmal=strbrk"Undeclared universe: "++Termops.pr_evd_levelsigmal++spc()++str"(maybe a bugged tactic)."letexplain_disallowed_sprop()=Pp.(strbrk"SProp is disallowed because the "++str"\"Allow StrictProp\""++strbrk" flag is off.")letexplain_bad_relevanceenv=strbrk"Bad relevance (maybe a bugged tactic)."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 "++Univ.Variance.prexpected++str" but cannot be less restrictive than "++Univ.Variance.practual++str"."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_arityenvsigmaindcokinds|CaseNotInductivecj->explain_case_not_inductiveenvsigmacj|NumberBranches(cj,n)->explain_number_branchesenvsigmacjn|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|UndeclaredUniversel->explain_undeclared_universeenvsigmal|DisallowedSProp->explain_disallowed_sprop()|BadRelevance->explain_bad_relevanceenv|BadInvert->explain_bad_invertenv|BadVariance{lev;expected;actual}->explain_bad_varianceenvsigma~lev~expected~actualletpr_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)e=ifnestedthenstr"Found nested occurrences of the pattern at positions "++intpos1++strbrk" and "++pr_position(cl2,pos2)++str"."elseletppreason=matchewith|None->mt()|Some(c1,c2,e)->explain_unification_errorenvsigmac1c2(Somee)instr"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)++ppreason++str"."letpr_constraintsprintenvenvsigmaevarscstrs=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()inletevs=prlist(fun(ev,evi)->fnl()++pr_existential_key(Global.env())sigmaev++str" : "++pr_leconstr_envenv'sigma(Evd.evar_conclevi)++fnl())linh(pe++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_=matchcompwith|None->Evar.Set.memevktcs|Somecomp->Evar.Set.memevktcs&&Evar.Set.memevkcompinletundef=letm=Evar.Map.filteris_keptundefinifEvar.Map.is_emptymthenundefelseminmatchconstrwith|None->str"Unable to satisfy the following constraints:"++fnl()++pr_constraintstrueenvsigmaundefconstraints|Some(ev,k)->letcstr=letremaining=Evar.Map.removeevundefinifnot(Evar.Map.is_emptyremaining)thenstr"With the following constraints:"++fnl()++pr_constraintsfalseenvsigmaremainingconstraintselsemt()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|CannotUnifyOccurrences(b,c1,c2,e)->explain_cannot_unify_occurrencesenvsigmabc1c2e|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_inconsistencyUnivNames.(pr_with_global_universesempty_binders)incon|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}->letopenUnivinletpr_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(Int.equal(AbstractContext.sizegot)(AbstractContext.sizeexpect))thenmt()elsefnl()++str"(incompatible constraints)")|IncompatibleVariance->str"incompatible variance information"letexplain_signature_mismatchlspecwhy=str"Signature components for field "++Label.printl++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(l,spec,err)->explain_signature_mismatchlspecerr|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_bad_typeenvsigmaargtyconclty=letpm,pn=with_diffs(pr_lconstr_envenvsigmaty)(pr_leconstr_envenvsigmaconclty)instr"Refiner was given an argument"++brk(1,1)++pr_lconstr_envenvsigmaarg++spc()++str"of type"++brk(1,1)++pm++spc()++str"instead of"++brk(1,1)++pn++str"."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_lconstr_envenvsigmat++spc()++str"could not be applied to"++brk(1,1)++pr_lconstr_envenvsigmaharg++str"."letexplain_intro_needs_product()=str"Introduction tactics needs products."letexplain_non_linear_proofenvsigmac=str"Cannot refine with term"++brk(1,1)++pr_lconstr_envenvsigmac++spc()++str"because a metavariable has several occurrences."letexplain_meta_in_typeenvsigmac=str"In refiner, a meta appears in the type "++brk(1,1)++pr_leconstr_envenvsigmac++str" of another meta"letexplain_no_such_hypid=str"No such hypothesis: "++Id.printidletexplain_refiner_errorenvsigma=function|BadType(arg,ty,conclty)->explain_refiner_bad_typeenvsigmaargtyconclty|UnresolvedBindingst->explain_refiner_unresolved_bindingst|CannotApply(t,harg)->explain_refiner_cannot_applyenvsigmatharg|IntroNeedsProduct->explain_intro_needs_product()|NonLinearProofc->explain_non_linear_proofenvsigmac|MetaInTypec->explain_meta_in_typeenvsigmac|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_case_analysisenvisreckindi=str(ifisrecthen"Induction"else"Case analysis")++strbrk" on sort "++pr_sortEvd.emptykind++strbrk" is not allowed for inductive definition "++pr_inductiveenv(fsti)++str"."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'=ifInd.CanOrd.equalindind'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)->error_not_allowed_case_analysisenvisrecki|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=map_ptype_errorEConstr.of_constreinstr"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."))(** 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.Stream.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_inconsistencyUnivNames.(pr_with_global_universesempty_binders)i++str"."|TypeError(ctx,te)->lette=map_ptype_errorEConstr.of_constrteinexplain_type_errorctxEvd.emptyte|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|_->raiseUnhandledlet_=CErrors.register_handler(wrap_unhandledvernac_interp_error_handler)