12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571(************************************************************************)(* * 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_declssigmapj.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_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_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?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_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_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 "++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.")letpr_relevancesigmar=letr=Evarutil.nf_relevancesigmarinmatchrwith|Sorts.Relevant->str"relevant"|Sorts.Irrelevant->str"irrelevant"|Sorts.RelevanceVarq->str"a variable "++Sorts.QVar.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(ci,_,_,_,_,_,_)=EConstr.destCasesigmacaseinstrbrk"Pattern-matching"++spc()++pr_leconstr_envenvsigmacase++strbrk" has relevance mark set to "++pr_relevancesigmaci.ci_relevance++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(r,EConstr.of_constrc)|BadRelevanceBinder(r,d)->BadRelevanceBinder(r,RelDecl.map_constr_hetEConstr.of_constrd)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 "++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|CaseOnPrivateIndind->explain_case_on_private_indenvsigmaind|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()|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~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_=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|CantApplyBadTypeExplained((t,rator,randl),error)->explain_cant_apply_bad_typeenvsigma~errortratorrandl|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_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}->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"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_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'=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)->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_universesi++str"."|TypeError(env,te)->lette=map_ptype_errorEConstr.of_constrteinexplain_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|_->raiseUnhandledlet_=CErrors.register_handler(wrap_unhandledvernac_interp_error_handler)