123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131(************************************************************************)(* * 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) *)(************************************************************************)openSortsopenUtilopenPpopenConstropenUnivletenforce_univ_constraint(u,d,v)=matchdwith|Eq->enforce_equv|Le->enforce_lequv|Lt->enforce_leq(superu)vletsubst_univs_levelfnl=trySome(fnl)withNot_found->Noneletsubst_univs_constraintfn(u,d,vasc)cstrs=letu'=subst_univs_levelfnuinletv'=subst_univs_levelfnvinmatchu',v'with|None,None->Constraint.addccstrs|Someu,None->enforce_univ_constraint(u,d,Universe.makev)cstrs|None,Somev->enforce_univ_constraint(Universe.makeu,d,v)cstrs|Someu,Somev->enforce_univ_constraint(u,d,v)cstrsletsubst_univs_constraintssubstcsts=Constraint.fold(funccstrs->subst_univs_constraintsubstccstrs)cstsConstraint.emptyletlevel_subst_off=funl->tryletu=flinmatchUniverse.leveluwith|None->l|Somel->lwithNot_found->lletnormalize_univ_variable~find=letrecauxcur=letb=findcurinletb'=subst_univs_universeauxbinifUniverse.equalb'bthenbelseb'inauxtypeuniverse_opt_subst=Universe.toptionuniverse_mapletnormalize_univ_variable_opt_substectx=letfindl=matchUniv.LMap.findlectxwith|Someb->b|None->raiseNot_foundinnormalize_univ_variable~findletnormalize_universe_opt_substsubst=letnormlevel=normalize_univ_variable_opt_substsubstinsubst_univs_universenormlevelletnormalize_opt_substctx=letnormalize=normalize_universe_opt_substctxinUniv.LMap.mapi(funu->function|None->None|Somev->Some(normalizev))ctxletnormalize_univ_variablesctx=letctx=normalize_opt_substctxinletdef,subst=Univ.LMap.fold(funuv(def,subst)->matchvwith|None->(def,subst)|Someb->(Univ.LSet.addudef,Univ.LMap.addubsubst))ctx(Univ.LSet.empty,Univ.LMap.empty)inctx,def,substletsubst_univs_fn_puniversesf(c,uascu)=letu'=Instance.subst_fnfuinifu'==uthencuelse(c,u')letnf_evars_and_universes_opt_substfsubst=letsubst=normalize_univ_variable_opt_substsubstinletlsubst=level_subst_ofsubstinletrecauxc=matchkindcwith|Evar(evk,args)->letargs'=List.Smart.mapauxargsin(matchtryf(evk,args')withNot_found->Nonewith|None->ifargs==args'thencelsemkEvar(evk,args')|Somec->auxc)|Constpu->letpu'=subst_univs_fn_puniverseslsubstpuinifpu'==puthencelsemkConstUpu'|Indpu->letpu'=subst_univs_fn_puniverseslsubstpuinifpu'==puthencelsemkIndUpu'|Constructpu->letpu'=subst_univs_fn_puniverseslsubstpuinifpu'==puthencelsemkConstructUpu'|Sort(Typeu)->letu'=Univ.subst_univs_universesubstuinifu'==uthencelsemkSort(sort_of_univu')|Case(ci,u,pms,p,iv,t,br)->letu'=Instance.subst_fnlsubstuinifu'==uthenConstr.mapauxcelseConstr.mapaux(mkCase(ci,u',pms,p,iv,t,br))|Array(u,elems,def,ty)->letu'=Univ.Instance.subst_fnlsubstuinletelems'=CArray.Smart.mapauxelemsinletdef'=auxdefinletty'=auxtyinifu==u'&&elems==elems'&&def==def'&&ty==ty'thencelsemkArray(u',elems',def',ty')|_->Constr.mapauxcinauxletpr_universe_body=function|None->mt()|Somev->str" := "++Univ.Universe.prvletpr_universe_opt_subst=Univ.LMap.prpr_universe_body