1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207(************************************************************************)(* * 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) *)(************************************************************************)openCErrorsopenUtilopenNamesopenConstropenContextmoduleNamedDecl=Context.Named.DeclarationmoduleERelevance=structincludeEvd.MiniEConstr.ERelevanceletequalsigmar1r2=Sorts.relevance_equal(kindsigmar1)(kindsigmar2)letis_irrelevant=Evd.is_relevance_irrelevantletrelevant=makeRelevantletirrelevant=makeIrrelevantendmoduleESorts=structincludeEvd.MiniEConstr.ESortsletequalsigmas1s2=Sorts.equal(kindsigmas1)(kindsigmas2)letis_smallsigmas=Sorts.is_small(kindsigmas)letis_propsigmas=Sorts.is_prop(kindsigmas)letis_spropsigmas=Sorts.is_sprop(kindsigmas)letis_setsigmas=Sorts.is_set(kindsigmas)letprop=makeSorts.propletsprop=makeSorts.spropletset=makeSorts.setlettype1=makeSorts.type1letsupersigmas=make(Sorts.super(kindsigmas))letrelevance_of_sorts=letr=Sorts.relevance_of_sort(unsafe_to_sortss)inERelevance.makerletfamilysigmas=Sorts.family(kindsigmas)letqualitysigmas=Sorts.quality(kindsigmas)endmoduleEInstance=structincludeEvd.MiniEConstr.EInstanceletequalsigmai1i2=UVars.Instance.equal(kindsigmai1)(kindsigmai2)endinclude(Evd.MiniEConstr:moduletypeofEvd.MiniEConstrwithmoduleERelevance:=ERelevanceandmoduleESorts:=ESortsandmoduleEInstance:=EInstance)typetypes=ttypeconstr=ttypeexistential=tpexistentialtypecase_return=(t,ERelevance.t)pcase_returntypecase_branch=(t,ERelevance.t)pcase_branchtypecase_invert=tpcase_inverttypecase=(t,t,EInstance.t,ERelevance.t)pcasetyperec_declaration=(t,t,ERelevance.t)prec_declarationtypefixpoint=(t,t,ERelevance.t)pfixpointtypecofixpoint=(t,t,ERelevance.t)pcofixpointtypeunsafe_judgment=(constr,types)Environ.punsafe_judgmenttypeunsafe_type_judgment=(types,ESorts.t)Environ.punsafe_type_judgmenttypenamed_declaration=(constr,types,ERelevance.t)Context.Named.Declaration.pttyperel_declaration=(constr,types,ERelevance.t)Context.Rel.Declaration.pttypecompacted_declaration=(constr,types,ERelevance.t)Context.Compacted.Declaration.pttypenamed_context=(constr,types,ERelevance.t)Context.Named.pttypecompacted_context=compacted_declarationlisttyperel_context=(constr,types,ERelevance.t)Context.Rel.pttype'abinder_annot=('a,ERelevance.t)Context.pbinder_annotletannotRx=Context.make_annotxERelevance.relevantletnameRx=annotR(Namex)letanonR=annotRAnonymoustype'apuniverses='a*EInstance.tletin_punivsa=(a,EInstance.empty)letmkSProp=of_kind(Sort(ESorts.makeSorts.sprop))letmkProp=of_kind(Sort(ESorts.makeSorts.prop))letmkSet=of_kind(Sort(ESorts.makeSorts.set))letmkTypeu=of_kind(Sort(ESorts.make(Sorts.sort_of_univu)))letmkReln=of_kind(Reln)letmkVarid=of_kind(Varid)letmkMetan=of_kind(Metan)letmkEvare=of_kind(Evare)letmkSorts=of_kind(Sorts)letmkCast(b,k,t)=of_kind(Cast(b,k,t))letmkProd(na,t,u)=of_kind(Prod(na,t,u))letmkLambda(na,t,c)=of_kind(Lambda(na,t,c))letmkLetIn(na,b,t,c)=of_kind(LetIn(na,b,t,c))letmkApp(f,arg)=of_kind(App(f,arg))letmkConstUpc=of_kind(Constpc)letmkIndUpi=of_kind(Indpi)letmkConstructUpc=of_kind(Constructpc)letmkConstructUi((ind,u),i)=of_kind(Construct((ind,i),u))letmkCase(ci,u,pms,c,iv,r,p)=of_kind(Case(ci,u,pms,c,iv,r,p))letmkFixf=of_kind(Fixf)letmkCoFixf=of_kind(CoFixf)letmkProj(p,r,c)=of_kind(Proj(p,r,c))letmkArrowt1rt2=of_kind(Prod(make_annotAnonymousr,t1,t2))letmkArrowRt1t2=mkArrowt1ERelevance.relevantt2letmkInti=of_kind(Inti)letmkFloatf=of_kind(Floatf)letmkStrings=of_kind(Strings)letmkArray(u,t,def,ty)=of_kind(Array(u,t,def,ty))letmkRef(gr,u)=letopenGlobRefinmatchgrwith|ConstRefc->mkConstU(c,u)|IndRefind->mkIndU(ind,u)|ConstructRefc->mkConstructU(c,u)|VarRefx->mkVarxletmkLEvar=Evd.MiniEConstr.mkLEvarlettype1=mkSortESorts.type1letapplist(f,arg)=mkApp(f,Array.of_listarg)letapplistcfarg=mkApp(f,Array.of_listarg)letisRelsigmac=matchkindsigmacwithRel_->true|_->falseletisVarsigmac=matchkindsigmacwithVar_->true|_->falseletisIndsigmac=matchkindsigmacwithInd_->true|_->falseletisEvarsigmac=matchkindsigmacwithEvar_->true|_->falseletisMetasigmac=matchkindsigmacwithMeta_->true|_->falseletisSortsigmac=matchkindsigmacwithSort_->true|_->falseletisCastsigmac=matchkindsigmacwithCast_->true|_->falseletisAppsigmac=matchkindsigmacwithApp_->true|_->falseletisLambdasigmac=matchkindsigmacwithLambda_->true|_->falseletisLetInsigmac=matchkindsigmacwithLetIn_->true|_->falseletisProdsigmac=matchkindsigmacwithProd_->true|_->falseletisConstsigmac=matchkindsigmacwithConst_->true|_->falseletisConstructsigmac=matchkindsigmacwithConstruct_->true|_->falseletisFixsigmac=matchkindsigmacwithFix_->true|_->falseletisCoFixsigmac=matchkindsigmacwithCoFix_->true|_->falseletisCasesigmac=matchkindsigmacwithCase_->true|_->falseletisProjsigmac=matchkindsigmacwithProj_->true|_->falseletrecisTypesigmac=matchkindsigmacwith|Sorts->(matchESorts.kindsigmaswith|Sorts.Type_->true|_->false)|Cast(c,_,_)->isTypesigmac|_->falseletisVarIdsigmaidc=matchkindsigmacwithVarid'->Id.equalidid'|_->falseletisRelNsigmanc=matchkindsigmacwithReln'->Int.equalnn'|_->falseletisRefsigmac=matchkindsigmacwith|Const_|Ind_|Construct_|Var_->true|_->falseletisRefXenvsigmaxc=letopenGlobRefinmatchx,kindsigmacwith|ConstRefc,Const(c',_)->Environ.QConstant.equalenvcc'|IndRefi,Ind(i',_)->Environ.QInd.equalenvii'|ConstructRefi,Construct(i',_)->Environ.QConstruct.equalenvii'|VarRefid,Varid'->Id.equalidid'|_->falseletis_lib_refenvsigmaxc=matchCoqlib.lib_ref_optxwith|Somex->isRefXenvsigmaxc|None->falseletdestRelsigmac=matchkindsigmacwith|Relp->p|_->raiseDestKOletdestVarsigmac=matchkindsigmacwith|Varp->p|_->raiseDestKOletdestIndsigmac=matchkindsigmacwith|Indp->p|_->raiseDestKOletdestEvarsigmac=matchkindsigmacwith|Evarp->p|_->raiseDestKOletdestMetasigmac=matchkindsigmacwith|Metap->p|_->raiseDestKOletdestSortsigmac=matchkindsigmacwith|Sortp->p|_->raiseDestKOletdestCastsigmac=matchkindsigmacwith|Cast(c,k,t)->(c,k,t)|_->raiseDestKOletdestAppsigmac=matchkindsigmacwith|App(f,a)->(f,a)|_->raiseDestKOletdestLambdasigmac=matchkindsigmacwith|Lambda(na,t,c)->(na,t,c)|_->raiseDestKOletdestLetInsigmac=matchkindsigmacwith|LetIn(na,b,t,c)->(na,b,t,c)|_->raiseDestKOletdestProdsigmac=matchkindsigmacwith|Prod(na,t,c)->(na,t,c)|_->raiseDestKOletdestConstsigmac=matchkindsigmacwith|Constp->p|_->raiseDestKOletdestConstructsigmac=matchkindsigmacwith|Constructp->p|_->raiseDestKOletdestFixsigmac=matchkindsigmacwith|Fixp->p|_->raiseDestKOletdestCoFixsigmac=matchkindsigmacwith|CoFixp->p|_->raiseDestKOletdestCasesigmac=matchkindsigmacwith|Case(ci,u,pms,t,iv,c,p)->(ci,u,pms,t,iv,c,p)|_->raiseDestKOletdestProjsigmac=matchkindsigmacwith|Proj(p,r,c)->(p,r,c)|_->raiseDestKOletdestRefsigmac=letopenGlobRefinmatchkindsigmacwith|Varx->VarRefx,EInstance.empty|Const(c,u)->ConstRefc,u|Ind(ind,u)->IndRefind,u|Construct(c,u)->ConstructRefc,u|_->raiseDestKOletdecompose_appsigmac=matchkindsigmacwith|App(f,cl)->(f,cl)|_->(c,[||])letdecompose_app_listsigmac=matchkindsigmacwith|App(f,cl)->(f,Array.to_listcl)|_->(c,[])letdecompose_lambdasigmac=letreclamdec_reclc=matchkindsigmacwith|Lambda(x,t,c)->lamdec_rec((x,t)::l)c|Cast(c,_,_)->lamdec_reclc|_->l,cinlamdec_rec[]cletdecompose_lambda_declssigmac=letopenRel.Declarationinletreclamdec_reclc=matchkindsigmacwith|Lambda(x,t,c)->lamdec_rec(Context.Rel.add(LocalAssum(x,t))l)c|LetIn(x,b,t,c)->lamdec_rec(Context.Rel.add(LocalDef(x,b,t))l)c|Cast(c,_,_)->lamdec_reclc|_->l,cinlamdec_recContext.Rel.emptycletdecompose_lambda_nsigman=ifn<0thenanomalyPp.(str"decompose_lambda_n: integer parameter must be positive");letreclamdec_reclnc=ifInt.equaln0then(l,c)elsematchkindsigmacwith|Lambda(x,t,c)->lamdec_rec((x,t)::l)(n-1)c|Cast(c,_,_)->lamdec_reclnc|_->anomalyPp.(str"decompose_lambda_n: not enough abstractions")inlamdec_rec[]nletdecompose_lambda_n_assumsigmanc=letopenRel.Declarationinifn<0thenanomalyPp.(str"decompose_lambda_n_assum: integer parameter must be positive.");letreclamdec_reclnc=ifInt.equaln0thenl,celsematchkindsigmacwith|Lambda(x,t,c)->lamdec_rec(Context.Rel.add(LocalAssum(x,t))l)(n-1)c|LetIn(x,b,t,c)->lamdec_rec(Context.Rel.add(LocalDef(x,b,t))l)nc|Cast(c,_,_)->lamdec_reclnc|c->anomalyPp.(str"decompose_lambda_n_assum: not enough abstractions.")inlamdec_recContext.Rel.emptyncletdecompose_lambda_n_declssigman=letopenRel.Declarationinifn<0thenanomalyPp.(str"decompose_lambda_n_decls: integer parameter must be positive.");letreclamdec_reclnc=ifInt.equaln0thenl,celsematchkindsigmacwith|Lambda(x,t,c)->lamdec_rec(Context.Rel.add(LocalAssum(x,t))l)(n-1)c|LetIn(x,b,t,c)->lamdec_rec(Context.Rel.add(LocalDef(x,b,t))l)(n-1)c|Cast(c,_,_)->lamdec_reclnc|c->anomalyPp.(str"decompose_lambda_n_decls: not enough abstractions.")inlamdec_recContext.Rel.emptynletrecto_lambdasigmanprod=ifInt.equaln0thenprodelsematchkindsigmaprodwith|Prod(na,ty,bd)->mkLambda(na,ty,to_lambdasigma(n-1)bd)|Cast(c,_,_)->to_lambdasigmanc|_->anomalyPp.(str"Not enough products.")letdecompose_prodsigmac=letrecproddec_reclc=matchkindsigmacwith|Prod(x,t,c)->proddec_rec((x,t)::l)c|Cast(c,_,_)->proddec_reclc|_->l,cinproddec_rec[]cletdecompose_prod_nsigman=ifn<0thenanomalyPp.(str"decompose_prod_n: integer parameter must be positive");letrecproddec_reclnc=ifInt.equaln0then(l,c)elsematchkindsigmacwith|Prod(x,t,c)->proddec_rec((x,t)::l)(n-1)c|Cast(c,_,_)->proddec_reclnc|_->anomalyPp.(str"decompose_prod_n: not enough products")inproddec_rec[]nletdecompose_prod_declssigmac=letopenRel.Declarationinletrecproddec_reclc=matchkindsigmacwith|Prod(x,t,c)->proddec_rec(Context.Rel.add(LocalAssum(x,t))l)c|LetIn(x,b,t,c)->proddec_rec(Context.Rel.add(LocalDef(x,b,t))l)c|Cast(c,_,_)->proddec_reclc|_->l,cinproddec_recContext.Rel.emptycletdecompose_prod_n_declssigmanc=letopenRel.Declarationinifn<0thenanomalyPp.(str"decompose_prod_n_decls: integer parameter must be positive.");letrecprodec_reclnc=ifInt.equaln0thenl,celsematchkindsigmacwith|Prod(x,t,c)->prodec_rec(Context.Rel.add(LocalAssum(x,t))l)(n-1)c|LetIn(x,b,t,c)->prodec_rec(Context.Rel.add(LocalDef(x,b,t))l)(n-1)c|Cast(c,_,_)->prodec_reclnc|c->anomalyPp.(str"decompose_prod_n_decls: not enough assumptions.")inprodec_recContext.Rel.emptyncletprod_declssigmat=fst(decompose_prod_declssigmat)letexistential_type=Evd.existential_typeletliftnc=of_constr(Vars.liftn(unsafe_to_constrc))letof_branches:Constr.case_brancharray->case_brancharray=matchEvd.MiniEConstr.(unsafe_eq,unsafe_relevance_eq)with|Refl,Refl->funx->xletunsafe_to_branches:case_brancharray->Constr.case_brancharray=matchEvd.MiniEConstr.(unsafe_eq,unsafe_relevance_eq)with|Refl,Refl->funx->xletof_return:Constr.case_return->case_return=matchEvd.MiniEConstr.(unsafe_eq,unsafe_relevance_eq)with|Refl,Refl->funx->xletunsafe_to_return:case_return->Constr.case_return=matchEvd.MiniEConstr.(unsafe_eq,unsafe_relevance_eq)with|Refl,Refl->funx->xletof_binder_annot:'aConstr.binder_annot->'abinder_annot=matchEvd.MiniEConstr.unsafe_relevance_eqwith|Refl->funx->xletto_binder_annotsigma(x:_binder_annot):_Constr.binder_annot=letRefl=unsafe_relevance_eqinContext.map_annot_relevance_smart(ERelevance.kindsigma)xletto_rel_declsigma(d:rel_declaration):Constr.rel_declaration=letRefl=unsafe_eqinletRefl=unsafe_relevance_eqinContext.Rel.Declaration.map_constr_with_relevance(ERelevance.kindsigma)(to_constrsigma)dletto_rel_contextsigma(ctx:rel_context):Constr.rel_context=letRefl=unsafe_eqinletRefl=unsafe_relevance_eqinList.Smart.map(to_rel_declsigma)ctxletto_named_declsigma(d:named_declaration):Constr.named_declaration=letRefl=unsafe_eqinletRefl=unsafe_relevance_eqinContext.Named.Declaration.map_constr_with_relevance(ERelevance.kindsigma)(to_constrsigma)dletto_named_contextsigma(ctx:named_context):Constr.named_context=letRefl=unsafe_eqinletRefl=unsafe_relevance_eqinList.Smart.map(to_named_declsigma)ctxletmap_branchesfbr=letfc=unsafe_to_constr(f(of_constrc))inof_branches(Constr.map_branchesf(unsafe_to_branchesbr))letmap_return_predicatefp=letfc=unsafe_to_constr(f(of_constrc))inof_return(Constr.map_return_predicatef(unsafe_to_returnp))letmap_instancesigmafevkargs=letrecmapctxargs=matchctx,SList.viewargswith|[],None->SList.empty|decl::ctx,Some(Somec,rem)->letc'=fcinletrem'=mapctxreminifc'==c&&rem'==remthenargselseifConstr.isVarId(NamedDecl.get_iddecl)c'thenSList.defaultrem'elseSList.consc'rem'|decl::ctx,Some(None,rem)->letc=Constr.mkVar(NamedDecl.get_iddecl)inletc'=fcinletrem'=mapctxreminifc'==c&&rem'==remthenargselseSList.consc'rem'|[],Some_|_::_,None->assertfalseinletEvarInfoevi=Evd.findsigmaevkinletctx=Evd.evar_filtered_contexteviinmapctxargsletmapsigmafc=letfc=unsafe_to_constr(f(of_constrc))inletc=unsafe_to_constr@@whd_evarsigmacinmatchConstr.kindcwith|Evar(evk,args)->letargs'=map_instancesigmafevkargsinifargs'==argsthenof_constrcelseof_constr@@Constr.mkEvar(evk,args')|_->of_constr(Constr.mapfc)letmap_with_binderssigmagflc=letflc=unsafe_to_constr(fl(of_constrc))inletc=unsafe_to_constr@@whd_evarsigmacinmatchConstr.kindcwith|Evar(evk,args)->letargs'=map_instancesigma(func->flc)evkargsinifargs'==argsthenof_constrcelseof_constr@@Constr.mkEvar(evk,args')|_->of_constr(Constr.map_with_bindersgflc)letmap_existentialsigmaf((evk,args)asev:existential)=letfc=unsafe_to_constr(f(of_constrc))inletargs:Constr.tSList.t=matchEvd.MiniEConstr.unsafe_eqwithRefl->argsinletargs'=map_instancesigmafevkargsinifargs'==argsthenevelseletargs':tSList.t=matchEvd.MiniEConstr.unsafe_eqwithRefl->args'in(evk,args')letitersigmafc=letfc=f(of_constrc)inletc=unsafe_to_constr@@whd_evarsigmacinmatchConstr.kindcwith|Evar((evk,_)asev)->letargs=Evd.expand_existential0sigmaevinList.iter(func->fc)args|_->Constr.iterfcletexpand_caseenv_sigma(ci,u,pms,p,iv,c,bl)=letu=EInstance.unsafe_to_instanceuinletpms=unsafe_to_constr_arraypmsinletp=unsafe_to_returnpinletiv=unsafe_to_case_invertivinletc=unsafe_to_constrcinletbl=unsafe_to_branchesblinlet(ci,(p,r),iv,c,bl)=Inductive.expand_caseenv(ci,u,pms,p,iv,c,bl)inletp=of_constrpinletr=ERelevance.makerinletc=of_constrcinletiv=of_case_invertivinletbl=of_constr_arrayblin(ci,(p,r),iv,c,bl)letannotate_caseenvsigma(ci,u,pms,p,iv,c,blascase)=let(_,(p,r),_,_,bl)=expand_caseenvsigmacaseinletp=(* Too bad we need to fetch this data in the environment, should be in the
case_info instead. *)let(_,mip)=Inductive.lookup_mind_specifenvci.ci_indindecompose_lambda_n_declssigma(mip.Declarations.mind_nrealdecls+1)pinletmk_brcn=decompose_lambda_n_declssigmancinletbl=Array.map2mk_brblci.ci_cstr_ndeclsin(ci,u,pms,(p,r),iv,c,bl)letexpand_branchenv_sigmaupms(ind,i)(nas,_br)=letopenDeclarationsinletu=EInstance.unsafe_to_instanceuinletpms=unsafe_to_constr_arraypmsinlet(mib,mip)=Inductive.lookup_mind_specifenvindinletparamdecl=Vars.subst_instance_contextumib.mind_params_ctxtinletparamsubst=Vars.subst_of_rel_context_instanceparamdeclpmsinlet(ctx,_)=mip.mind_nf_lc.(i-1)inlet(ctx,_)=List.chopmip.mind_consnrealdecls.(i-1)ctxinletnas=letgen:typeab.(a,b)eq->(_,a)Context.pbinder_annotarray->(_,b)Context.pbinder_annotarray=funReflx->xingenunsafe_relevance_eqnasinletans=Inductive.instantiate_contextuparamsubstnasctxinletans:rel_context=matchEvd.MiniEConstr.(unsafe_eq,unsafe_relevance_eq)with|Refl,Refl->ansinansletcontract_caseenv_sigma(ci,(p,r),iv,c,bl)=letp=unsafe_to_constrpinletr=ERelevance.unsafe_to_relevancerinletiv=unsafe_to_case_invertivinletc=unsafe_to_constrcinletbl=unsafe_to_constr_arrayblinlet(ci,u,pms,p,iv,c,bl)=Inductive.contract_caseenv(ci,(p,r),iv,c,bl)inletu=EInstance.makeuinletpms=of_constr_arraypmsinletp=of_returnpinletiv=of_case_invertivinletc=of_constrcinletbl=of_branchesblin(ci,u,pms,p,iv,c,bl)letiter_with_full_bindersenvsigmagfnc=letopenContext.Rel.Declarationinmatchkindsigmacwith|(Rel_|Meta_|Var_|Sort_|Const_|Ind_|Construct_|Int_|Float_|String_)->()|Cast(c,_,t)->fnc;fnt|Prod(na,t,c)->fnt;f(g(LocalAssum(na,t))n)c|Lambda(na,t,c)->fnt;f(g(LocalAssum(na,t))n)c|LetIn(na,b,t,c)->fnb;fnt;f(g(LocalDef(na,b,t))n)c|App(c,l)->fnc;Array.Fun1.iterfnl|Evar((_,l)asev)->letl=Evd.expand_existentialsigmaevinList.iter(func->fnc)l|Case(ci,u,pms,p,iv,c,bl)->let(ci,_,pms,(p,_),iv,c,bl)=annotate_caseenvsigma(ci,u,pms,p,iv,c,bl)inletf_ctx(ctx,c)=f(List.fold_rightgctxn)cinArray.Fun1.iterfnpms;f_ctxp;iter_invert(fn)iv;fnc;Array.iterf_ctxbl|Proj(_,_,c)->fnc|Fix(_,(lna,tl,bl))->Array.iter(fn)tl;letn'=Array.fold_left2_i(funinnat->g(LocalAssum(na,liftit))n)nlnatlinArray.iter(fn')bl|CoFix(_,(lna,tl,bl))->Array.iter(fn)tl;letn'=Array.fold_left2_i(funinnat->g(LocalAssum(na,liftit))n)nlnatlinArray.iter(fn')bl|Array(_u,t,def,ty)->Array.Fun1.iterfnt;fndef;fntyletiter_with_binderssigmagfnc=letflc=fl(of_constrc)inletc=unsafe_to_constr@@whd_evarsigmacinmatchConstr.kindcwith|Evar((evk,_)asev)->letargs=Evd.expand_existential0sigmaevinList.iter(func->fnc)args|_->Constr.iter_with_bindersgfncletfoldsigmafaccc=letfaccc=facc(of_constrc)inletc=unsafe_to_constr@@whd_evarsigmacinmatchConstr.kindcwith|Evar((evk,_)asev)->letargs=Evd.expand_existential0sigmaevinList.fold_leftfaccargs|_->Constr.foldfacccletfold_with_binderssigmagfeaccc=letfeaccc=feacc(of_constrc)inletc=unsafe_to_constr@@whd_evarsigmacinmatchConstr.kindcwith|Evar((evk,_)asev)->letargs=Evd.expand_existential0sigmaevinList.fold_left(funaccc->feaccc)accargs|_->Constr.fold_constr_with_bindersgfeacccletcompare_genkeq_insteq_sorteq_constreq_evarsnargsc1c2=(c1==c2)||Constr.compare_head_gen_withkkeq_insteq_sorteq_constreq_evarsnargsc1c2leteq_existentialsigmaeq(evk1,args1)(evk2,args2)=ifEvar.equalevk1evk2thenletargs1=Evd.expand_existentialsigma(evk1,args1)inletargs2=Evd.expand_existentialsigma(evk2,args2)inList.equaleqargs1args2elsefalseleteq_constrsigmac1c2=letkindc=kindsigmacinleteq_inst_i1i2=EInstance.equalsigmai1i2inleteq_sortss1s2=ESorts.equalsigmas1s2inleteq_existentialeqe1e2=eq_existentialsigma(eq0)e1e2inletreceq_constrnargsc1c2=compare_genkindeq_insteq_sorts(eq_existentialeq_constr)eq_constrnargsc1c2ineq_constr0c1c2leteq_constr_nounivssigmac1c2=letkindc=kindsigmacinleteq_existentialeqe1e2=eq_existentialsigma(eq0)e1e2inletreceq_constrnargsc1c2=compare_genkind(fun___->true)(fun__->true)(eq_existentialeq_constr)eq_constrnargsc1c2ineq_constr0c1c2letcompare_constrsigmacmpc1c2=letkindc=kindsigmacinleteq_inst_i1i2=EInstance.equalsigmai1i2inleteq_sortss1s2=ESorts.equalsigmas1s2inleteq_existentialeqe1e2=eq_existentialsigma(eq0)e1e2inletcmpnargsc1c2=cmpc1c2incompare_genkindeq_insteq_sorts(eq_existentialcmp)cmp0c1c2letcmp_inductivescv_pb(mind,indasspec)nargsu1u2cstrs=letopenUnivProbleminmatchmind.Declarations.mind_variancewith|None->enforce_eq_instances_univsfalseu1u2cstrs|Somevariances->letnum_param_arity=Conversion.inductive_cumulativity_argumentsspecinifnot(Int.equalnum_param_aritynargs)thenenforce_eq_instances_univsfalseu1u2cstrselsecompare_cumulative_instancescv_pbvariancesu1u2cstrsletcmp_constructors(mind,ind,cnsasspec)nargsu1u2cstrs=letopenUnivProbleminmatchmind.Declarations.mind_variancewith|None->enforce_eq_instances_univsfalseu1u2cstrs|Some_->letnum_cnstr_args=Conversion.constructor_cumulativity_argumentsspecinifnot(Int.equalnum_cnstr_argsnargs)thenenforce_eq_instances_univsfalseu1u2cstrselseletqs1,us1=UVars.Instance.to_arrayu1andqs2,us2=UVars.Instance.to_arrayu2inletcstrs=enforce_eq_qualitiesqs1qs2cstrsinArray.fold_left2(funcstrsu1u2->UnivProblem.(Set.add(UWeak(u1,u2))cstrs))cstrsus1us2leteq_universesenvsigmacstrscv_pbrefargsll'=ifEInstance.is_emptylthen(assert(EInstance.is_emptyl');true)elseletl=EInstance.kindsigmalandl'=EInstance.kindsigmal'inletopenGlobRefinletopenUnivProbleminmatchrefargswith|Some(ConstRefc,1)whenEnviron.is_array_typeenvc->cstrs:=compare_cumulative_instancescv_pb[|UVars.Variance.Irrelevant|]ll'!cstrs;true|None|Some(ConstRef_,_)->cstrs:=enforce_eq_instances_univstruell'!cstrs;true|Some(VarRef_,_)->assertfalse(* variables don't have instances *)|Some(IndRefind,nargs)->letmind=Environ.lookup_mind(fstind)envincstrs:=cmp_inductivescv_pb(mind,sndind)nargsll'!cstrs;true|Some(ConstructRef((mi,ind),ctor),nargs)->letmind=Environ.lookup_mindmienvincstrs:=cmp_constructors(mind,ind,ctor)nargsll'!cstrs;truelettest_constr_universesenvsigmaleq?(nargs=0)mn=letopenUnivProbleminletkindc=kindsigmacinifm==nthenSomeSet.emptyelseletcstrs=refSet.emptyinletcv_pb=ifleqthenConversion.CUMULelseConversion.CONVinleteq_universesrefargsll'=eq_universesenvsigmacstrsConversion.CONVrefargsll'andleq_universesrefargsll'=eq_universesenvsigmacstrscv_pbrefargsll'inleteq_sortss1s2=lets1=ESorts.kindsigmas1inlets2=ESorts.kindsigmas2inifSorts.equals1s2thentrueelse(cstrs:=Set.add(UEq(s1,s2))!cstrs;true)inletleq_sortss1s2=lets1=ESorts.kindsigmas1inlets2=ESorts.kindsigmas2inifSorts.equals1s2thentrueelse(cstrs:=Set.add(ULe(s1,s2))!cstrs;true)inleteq_existentialeqe1e2=eq_existentialsigma(eq0)e1e2inletreceq_constr'nargsmn=compare_genkindeq_universeseq_sorts(eq_existentialeq_constr')eq_constr'nargsmninletres=ifleqthenletreccompare_leqnargsmn=Constr.compare_head_gen_leq_withkindkindleq_universesleq_sorts(eq_existentialeq_constr')eq_constr'leq_constr'nargsmnandleq_constr'nargsmn=m==n||compare_leqnargsmnincompare_leqnargsmnelseConstr.compare_head_gen_withkindkindeq_universeseq_sorts(eq_existentialeq_constr')eq_constr'nargsmninifresthenSome!cstrselseNoneleteq_constr_universesenvsigma?nargsmn=test_constr_universesenvsigmafalse?nargsmnletleq_constr_universesenvsigma?nargsmn=test_constr_universesenvsigmatrue?nargsmnletcompare_head_gen_projenvsigmaequeqseqeveqc'nargsmn=letkindc=kindsigmacinmatchkindm,kindnwith|Proj(p,_,c),App(f,args)|App(f,args),Proj(p,_,c)->(matchkindfwith|Const(p',u)whenEnviron.QConstant.equalenv(Projection.constantp)p'->letnpars=Projection.nparspinifArray.lengthargs==npars+1theneqc'0cargs.(npars)elsefalse|_->false)|_->Constr.compare_head_gen_withkindkindequeqseqeveqc'nargsmnleteq_constr_universes_projenvsigmamn=letopenUnivProbleminifm==nthenSomeSet.emptyelseletcstrs=refSet.emptyinleteq_universesrefll'=eq_universesenvsigmacstrsConversion.CONVrefll'inleteq_sortss1s2=lets1=ESorts.kindsigmas1inlets2=ESorts.kindsigmas2inifSorts.equals1s2thentrueelse(cstrs:=Set.add(UEq(s1,s2))!cstrs;true)inleteq_existentialeqe1e2=eq_existentialsigma(eq0)e1e2inletreceq_constr'nargsmn=m==n||compare_head_gen_projenvsigmaeq_universeseq_sorts(eq_existentialeq_constr')eq_constr'nargsmninletres=eq_constr'0mninifresthenSome!cstrselseNoneletadd_universes_of_instancesigma(qs,us)u=letu=EInstance.kindsigmauinletqs',us'=UVars.Instance.levelsuinletqs=Sorts.Quality.(Set.fold(funqqs->matchqwith|QVarq->Sorts.QVar.Set.addqqs|QConstant_->qs)qs'qs)inqs,Univ.Level.Set.unionusus'letfold_annot_relevancefaccna=faccna.Context.binder_relevanceletfold_case_under_context_relevancefacc(nas,_)=Array.fold_left(fold_annot_relevancef)accnasletfold_rec_declaration_relevancefacc(nas,_,_)=Array.fold_left(fold_annot_relevancef)accnasletfold_constr_relevancesigmafaccc=matchkindsigmacwith|Rel_|Var_|Meta_|Evar_|Sort_|Cast_|App_|Const_|Ind_|Construct_|Proj_|Int_|Float_|String_|Array_->acc|Prod(na,_,_)|Lambda(na,_,_)|LetIn(na,_,_,_)->fold_annot_relevancefaccna|Case(_,_u,_params,(ret,r),_iv,_v,brs)->letacc=faccrinletacc=fold_case_under_context_relevancefaccretinletacc=CArray.fold_left(fold_case_under_context_relevancef)accbrsinacc|Fix(_,data)|CoFix(_,data)->fold_rec_declaration_relevancefaccdataletadd_relevancesigma(qs,usasv)r=letopenSortsin(* NB this normalizes above_prop to Relevant which makes it disappear *)matchERelevance.kindsigmarwith|Irrelevant|Relevant->v|RelevanceVarq->QVar.Set.addqqs,usletuniverses_of_constrsigmac=letopenUnivinletrecauxsc=lets=fold_constr_relevancesigma(add_relevancesigma)scinmatchkindsigmacwith|Const(_,u)|Ind(_,u)|Construct(_,u)->add_universes_of_instancesigmasu|Sortu->beginmatchESorts.kindsigmauwith|Typeu->Util.on_snd(Level.Set.foldLevel.Set.add(Universe.levelsu))s|QSort(q,u)->letqs,us=sinSorts.QVar.Set.addqqs,Level.Set.unionus(Universe.levelsu)|SProp|Prop|Set->send|Evar(k,args)->letconcl=Evd.evar_concl(Evd.find_undefinedsigmak)infoldsigmaaux(auxsconcl)c|Array(u,_,_,_)->lets=add_universes_of_instancesigmasuinfoldsigmaauxsc|Case(_,u,_,_,_,_,_)->lets=add_universes_of_instancesigmasuinfoldsigmaauxsc|_->foldsigmaauxscinaux(Sorts.QVar.Set.empty,Level.Set.empty)copenContextopenEnvironletcast_list:typeab.(a,b)eq->alist->blist=funReflx->xletcast_vect:typeab.(a,b)eq->aarray->barray=funReflx->xletcast_rel_decl:typeabcd.(a,b)eq->(c,d)eq->(a,a,c)Rel.Declaration.pt->(b,b,d)Rel.Declaration.pt=funReflReflx->xletcast_rel_context:typeabcd.(a,b)eq->(c,d)eq->(a,a,c)Rel.pt->(b,b,d)Rel.pt=funReflReflx->xletcast_rec_decl:typeabcd.(a,b)eq->(c,d)eq->(a,a,c)Constr.prec_declaration->(b,b,d)Constr.prec_declaration=funReflReflx->xletcast_named_decl:typeabcd.(a,b)eq->(c,d)eq->(a,a,c)Named.Declaration.pt->(b,b,d)Named.Declaration.pt=funReflReflx->xletcast_named_context:typeabcd.(a,b)eq->(c,d)eq->(a,a,c)Named.pt->(b,b,d)Named.pt=funReflReflx->xmoduleVars=structexceptionLocalOccurletto_constr=unsafe_to_constrletto_rel_decl=unsafe_to_rel_decltypeinstance=tarraytypeinstance_list=tlisttypesubstl=tlist(** Operations that commute with evar-normalization *)letlift=liftletliftnnmc=of_constr(Vars.liftnnm(to_constrc))letsubstnlsubstnc=of_constr(Vars.substnl(cast_listunsafe_eqsubst)n(to_constrc))letsubstlsubstc=of_constr(Vars.substl(cast_listunsafe_eqsubst)(to_constrc))letsubst1cr=of_constr(Vars.subst1(to_constrc)(to_constrr))letsubstnl_declsubstnd=of_rel_decl(Vars.substnl_decl(cast_listunsafe_eqsubst)n(to_rel_decld))letsubstl_declsubstd=of_rel_decl(Vars.substl_decl(cast_listunsafe_eqsubst)(to_rel_decld))letsubst1_declcd=of_rel_decl(Vars.subst1_decl(to_constrc)(to_rel_decld))typesubstituend=Vars.substituendletmake_substituendc=Vars.make_substituend(unsafe_to_constrc)letlift_substituendns=of_constr(Vars.lift_substituendns)letreplace_vars=replace_vars(* (subst_var str t) substitute (Var str) by (Rel 1) in t *)letsubst_varsigmastrt=replace_varssigma[(str,mkRel1)]t(* (subst_vars [id1;...;idn] t) substitute (Var idj) by (Rel j) in t *)letsubstn_varssigmapvarsc=let_,subst=List.fold_left(fun(n,l)var->((n+1),(var,mkReln)::l))(p,[])varsinreplace_varssigma(List.revsubst)cletsubst_varssigmasubstc=substn_varssigma1substcletsubst_univs_level_constrsubstc=of_constr(Vars.subst_univs_level_constrsubst(to_constrc))letsubst_instance_contextsubstctx=letsubst=EInstance.unsafe_to_instancesubstincast_rel_context(symunsafe_eq)(symunsafe_relevance_eq)(Vars.subst_instance_contextsubst(cast_rel_contextunsafe_equnsafe_relevance_eqctx))letsubst_instance_constrsubstc=letsubst=EInstance.unsafe_to_instancesubstinof_constr(Vars.subst_instance_constrsubst(to_constrc))letsubst_instance_relevancesubstr=letsubst=EInstance.unsafe_to_instancesubstinletr=ERelevance.unsafe_to_relevancerinletr=UVars.subst_instance_relevancesubstrinERelevance.maker(** Operations that dot NOT commute with evar-normalization *)letnoccurnsigmanterm=letrecoccur_recnc=matchkindsigmacwith|Relm->ifInt.equalmnthenraiseLocalOccur|Evar(_,l)->SList.Skip.iter(func->occur_recnc)l|_->iter_with_binderssigmasuccoccur_recncintryoccur_recnterm;truewithLocalOccur->falseletnoccur_betweensigmanmterm=letrecoccur_recnc=matchkindsigmacwith|Relp->ifn<=p&&p<n+mthenraiseLocalOccur|Evar(_,l)->SList.Skip.iter(func->occur_recnc)l|_->iter_with_binderssigmasuccoccur_recncintryoccur_recnterm;truewithLocalOccur->falseletclosednsigmanc=letrecclosed_recnc=matchkindsigmacwith|Relm->ifm>nthenraiseLocalOccur|Evar(_,l)->SList.Skip.iter(func->closed_recnc)l|_->iter_with_binderssigmasuccclosed_recncintryclosed_recnc;truewithLocalOccur->falseletclosed0sigmac=closednsigma0cletsubst_of_rel_context_instancectxsubst=cast_list(symunsafe_eq)(Vars.subst_of_rel_context_instance(cast_rel_contextunsafe_equnsafe_relevance_eqctx)(cast_vectunsafe_eqsubst))letsubst_of_rel_context_instance_listctxsubst=cast_list(symunsafe_eq)(Vars.subst_of_rel_context_instance_list(cast_rel_contextunsafe_equnsafe_relevance_eqctx)(cast_listunsafe_eqsubst))letliftn_rel_contextnkctx=cast_rel_context(symunsafe_eq)(symunsafe_relevance_eq)(Vars.liftn_rel_contextnk(cast_rel_contextunsafe_equnsafe_relevance_eqctx))letlift_rel_contextnctx=cast_rel_context(symunsafe_eq)(symunsafe_relevance_eq)(Vars.lift_rel_contextn(cast_rel_contextunsafe_equnsafe_relevance_eqctx))letsubstnl_rel_contextsubstnctx=cast_rel_context(symunsafe_eq)(symunsafe_relevance_eq)(Vars.substnl_rel_context(cast_listunsafe_eqsubst)n(cast_rel_contextunsafe_equnsafe_relevance_eqctx))letsubstl_rel_contextsubstctx=cast_rel_context(symunsafe_eq)(symunsafe_relevance_eq)(Vars.substl_rel_context(cast_listunsafe_eqsubst)(cast_rel_contextunsafe_equnsafe_relevance_eqctx))letsmash_rel_contextctx=cast_rel_context(symunsafe_eq)(symunsafe_relevance_eq)(Vars.smash_rel_context(cast_rel_contextunsafe_equnsafe_relevance_eqctx))letesubst:(int->'a->t)->'aEsubst.subs->t->t=matchunsafe_eqwith|Refl->Vars.esubstend(* Constructs either [forall x:t, c] or [let x:=b:t in c] *)letmkProd_or_LetIndeclc=letopenContext.Rel.Declarationinmatchdeclwith|LocalAssum(na,t)->mkProd(na,t,c)|LocalDef(na,b,t)->mkLetIn(na,b,t,c)(* Constructs either [forall x:t, c] or [c] in which [x] is replaced by [b] *)letmkProd_wo_LetIndeclc=letopenContext.Rel.Declarationinmatchdeclwith|LocalAssum(na,t)->mkProd(na,t,c)|LocalDef(_,b,_)->Vars.subst1bcletmkLambda_or_LetIndeclc=letopenContext.Rel.Declarationinmatchdeclwith|LocalAssum(na,t)->mkLambda(na,t,c)|LocalDef(na,b,t)->mkLetIn(na,b,t,c)letmkLambda_wo_LetIndeclc=letopenContext.Rel.Declarationinmatchdeclwith|LocalAssum(na,t)->mkLambda(na,t,c)|LocalDef(_,b,_)->Vars.subst1bcletmkNamedProdsigmaidtypc=mkProd(map_annotName.mk_nameid,typ,Vars.subst_varsigmaid.binder_namec)letmkNamedLambdasigmaidtypc=mkLambda(map_annotName.mk_nameid,typ,Vars.subst_varsigmaid.binder_namec)letmkNamedLetInsigmaidc1tc2=mkLetIn(map_annotName.mk_nameid,c1,t,Vars.subst_varsigmaid.binder_namec2)letmkNamedProd_or_LetInsigmadeclc=letopenContext.Named.Declarationinmatchdeclwith|LocalAssum(id,t)->mkNamedProdsigmaidtc|LocalDef(id,b,t)->mkNamedLetInsigmaidbtcletmkNamedLambda_or_LetInsigmadeclc=letopenContext.Named.Declarationinmatchdeclwith|LocalAssum(id,t)->mkNamedLambdasigmaidtc|LocalDef(id,b,t)->mkNamedLetInsigmaidbtcletmkNamedProd_wo_LetInsigmadeclc=letopenContext.Named.Declarationinmatchdeclwith|LocalAssum(id,t)->mkNamedProdsigmaidtc|LocalDef(id,b,t)->Vars.subst1bcletit_mkProdinit=List.fold_left(func(n,t)->mkProd(n,t,c))initletit_mkLambdainit=List.fold_left(func(n,t)->mkLambda(n,t,c))initletcompose_lamlb=it_mkLambdablletit_mkProd_or_LetIntctx=List.fold_left(funcd->mkProd_or_LetIndc)tctxletit_mkLambda_or_LetIntctx=List.fold_left(funcd->mkLambda_or_LetIndc)tctxletit_mkProd_wo_LetIntctx=List.fold_left(funcd->mkProd_wo_LetIndc)tctxletit_mkLambda_wo_LetIntctx=List.fold_left(funcd->mkLambda_wo_LetIndc)tctxletit_mkNamedProd_or_LetInsigmatctx=List.fold_left(funcd->mkNamedProd_or_LetInsigmadc)tctxletit_mkNamedLambda_or_LetInsigmatctx=List.fold_left(funcd->mkNamedLambda_or_LetInsigmadc)tctxletit_mkNamedProd_wo_LetInsigmatctx=List.fold_left(funcd->mkNamedProd_wo_LetInsigmadc)tctxletrecisAritysigmac=matchkindsigmacwith|Prod(_,_,c)->isAritysigmac|LetIn(_,_,_,c)->isAritysigmac|Cast(c,_,_)->isAritysigmac|Sort_->true|_->falsetypearity=rel_context*ESorts.tletmkArity(ctx,s)=it_mkProd_or_LetIn(mkSorts)ctxletdestAritysigma=letopenContext.Rel.Declarationinletrecprodec_reclc=matchkindsigmacwith|Prod(x,t,c)->prodec_rec(LocalAssum(x,t)::l)c|LetIn(x,b,t,c)->prodec_rec(LocalDef(x,b,t)::l)c|Cast(c,_,_)->prodec_reclc|Sorts->l,s|_->anomaly~label:"destArity"(Pp.str"not an arity.")inprodec_rec[]letpush_relde=push_rel(cast_rel_declunsafe_equnsafe_relevance_eqd)eletpush_rel_contextde=push_rel_context(cast_rel_contextunsafe_equnsafe_relevance_eqd)eletpush_rec_typesde=push_rec_types(cast_rec_declunsafe_equnsafe_relevance_eqd)eletpush_namedde=push_named(cast_named_declunsafe_equnsafe_relevance_eqd)eletpush_named_contextde=push_named_context(cast_named_contextunsafe_equnsafe_relevance_eqd)eletpush_named_context_valde=push_named_context_val(cast_named_declunsafe_equnsafe_relevance_eqd)eletrel_contexte=cast_rel_context(symunsafe_eq)(symunsafe_relevance_eq)(rel_contexte)letnamed_contexte=cast_named_context(symunsafe_eq)(symunsafe_relevance_eq)(named_contexte)letval_of_named_contexte=val_of_named_context(cast_named_contextunsafe_equnsafe_relevance_eqe)letnamed_context_of_vale=cast_named_context(symunsafe_eq)(symunsafe_relevance_eq)(named_context_of_vale)letof_existential:Constr.existential->existential=letgen:typeab.(a,b)eq->'c*bSList.t->'c*aSList.t=funReflx->xingenunsafe_eqletlookup_relie=cast_rel_decl(symunsafe_eq)(symunsafe_relevance_eq)(lookup_relie)letlookup_namedne=cast_named_decl(symunsafe_eq)(symunsafe_relevance_eq)(lookup_namedne)letlookup_named_valne=cast_named_decl(symunsafe_eq)(symunsafe_relevance_eq)(lookup_named_ctxtne)letmap_rel_context_in_envfenvsign=letrecauxenvacc=function|d::sign->aux(push_reldenv)(Context.Rel.Declaration.map_constr(fenv)d::acc)sign|[]->accinauxenv[](List.revsign)letmatch_named_context_val:named_context_val->(named_declaration*named_context_val)option=matchunsafe_eq,unsafe_relevance_eqwith|Refl,Refl->match_named_context_valletidentity_subst_val:named_context_val->tSList.t=functx->SList.defaultn(List.lengthctx.Environ.env_named_ctx)SList.emptyletfresh_global?loc?rigid?namesenvsigmareference=let(evd,t)=Evd.fresh_global?loc?rigid?namesenvsigmareferenceinevd,tletis_global=isRefX(** Kind of type *)typekind_of_type=|SortTypeofESorts.t|CastTypeoftypes*t|ProdTypeofName.tbinder_annot*t*t|LetInTypeofName.tbinder_annot*t*t*t|AtomicTypeoft*tarrayletkind_of_typesigmat=matchkindsigmatwith|Sorts->SortTypes|Cast(c,_,t)->CastType(c,t)|Prod(na,t,c)->ProdType(na,t,c)|LetIn(na,b,t,c)->LetInType(na,b,t,c)|App(c,l)->AtomicType(c,l)|(Rel_|Meta_|Var_|Evar_|Const_|Proj_|Case_|Fix_|CoFix_|Ind_)->AtomicType(t,[||])|(Lambda_|Construct_|Int_|Float_|String_|Array_)->failwith"Not a type"moduleUnsafe=structletto_relevance=ERelevance.unsafe_to_relevanceletto_sorts=ESorts.unsafe_to_sortsletto_instance=EInstance.unsafe_to_instanceletto_constr=unsafe_to_constrletto_constr_array=unsafe_to_constr_arrayletto_binder_annot:'abinder_annot->'aConstr.binder_annot=matchunsafe_relevance_eqwithRefl->funx->xletto_rel_decl=unsafe_to_rel_declletto_named_decl=unsafe_to_named_declletto_named_context=letgen:typeabcd.(a,b)eq->(c,d)eq->(a,a,c)Context.Named.pt->(b,b,d)Context.Named.pt=funReflReflx->xingenunsafe_equnsafe_relevance_eqletto_rel_context=letgen:typeabcd.(a,b)eq->(c,d)eq->(a,a,c)Context.Rel.pt->(b,b,d)Context.Rel.pt=funReflReflx->xingenunsafe_equnsafe_relevance_eqletto_case_invert=unsafe_to_case_invertleteq=unsafe_eqletrelevance_eq=unsafe_relevance_eqendmoduleUnsafeMonomorphic=structletmkConstc=of_kind(Const(in_punivsc))letmkIndi=of_kind(Ind(in_punivsi))letmkConstructc=of_kind(Construct(in_punivsc))end(* deprecated *)letdecompose_lambda_assum=decompose_lambda_declsletdecompose_prod_assum=decompose_prod_declsletdecompose_prod_n_assum=decompose_prod_n_declsletprod_assum=prod_declsletdecompose_lam=decompose_lambdaletdecompose_lam_n_assum=decompose_lambda_n_assumletdecompose_lam_n_decls=decompose_lambda_n_declsletdecompose_lam_assum=decompose_lambda_assumincludeUnsafeMonomorphic