123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101(************************************************************************)(* * 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) *)(************************************************************************)openUnivtypet=|ULeofSorts.t*Sorts.t|UEqofSorts.t*Sorts.t|ULubofLevel.t*Level.t|UWeakofLevel.t*Level.tletis_trivial=function|ULe(u,v)|UEq(u,v)->Sorts.equaluv|ULub(u,v)|UWeak(u,v)->Level.equaluvletforce=function|ULe_|UEq_|UWeak_ascst->cst|ULub(u,v)->UEq(Sorts.sort_of_univ@@Universe.makeu,Sorts.sort_of_univ@@Universe.makev)letcheck_eq_levelguv=UGraph.check_eq_levelguvletcheckg=function|ULe(u,v)->UGraph.check_leq_sortguv|UEq(u,v)->UGraph.check_eq_sortguv|ULub(u,v)->check_eq_levelguv|UWeak_->truemoduleSet=structmoduleS=Set.Make(structtypenonrect=tletcomparexy=matchx,ywith|ULe(u,v),ULe(u',v')->leti=Sorts.compareuu'inifInt.equali0thenSorts.comparevv'elsei|UEq(u,v),UEq(u',v')->leti=Sorts.compareuu'inifInt.equali0thenSorts.comparevv'elseifSorts.equaluv'&&Sorts.equalvu'then0elsei|ULub(u,v),ULub(u',v')|UWeak(u,v),UWeak(u',v')->leti=Level.compareuu'inifInt.equali0thenLevel.comparevv'elseifLevel.equaluv'&&Level.equalvu'then0elsei|ULe_,_->-1|_,ULe_->1|UEq_,_->-1|_,UEq_->1|ULub_,_->-1|_,ULub_->1end)includeSletaddcsts=ifis_trivialcstthenselseaddcstsletpr_one=letopenPpinfunction|ULe(u,v)->Sorts.debug_printu++str" <= "++Sorts.debug_printv|UEq(u,v)->Sorts.debug_printu++str" = "++Sorts.debug_printv|ULub(u,v)->Level.pru++str" /\\ "++Level.prv|UWeak(u,v)->Level.pru++str" ~ "++Level.prvletprc=letopenPpinfold(funcstpp_std->pp_std++pr_onecst++fnl())c(str"")letequalxy=x==y||equalxyletforces=mapforcesletcheckgs=for_all(checkg)sendtype'aconstraint_function='a->'a->Set.t->Set.tletenforce_eq_instances_univsstrictxyc=letmkUu=Sorts.sort_of_univ@@Universe.makeuinletmkuv=ifstrictthenULub(u,v)elseUEq(mkUu,mkUv)inletax=Instance.to_arrayxanday=Instance.to_arrayyinifArray.lengthax!=Array.lengthaythenCErrors.anomalyPp.(str"Invalid argument: enforce_eq_instances_univs called with"++str" instances of different lengths.");CArray.fold_right2(funxy->Set.add(mkxy))axayc