123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116(************************************************************************)(* * 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=|ULeofUniverse.t*Universe.t|UEqofUniverse.t*Universe.t|ULubofLevel.t*Level.t|UWeakofLevel.t*Level.tletis_trivial=function|ULe(u,v)|UEq(u,v)->Universe.equaluv|ULub(u,v)|UWeak(u,v)->Level.equaluvmoduleSet=structmoduleS=Set.Make(structtypenonrect=tletcomparexy=matchx,ywith|ULe(u,v),ULe(u',v')->leti=Universe.compareuu'inifInt.equali0thenUniverse.comparevv'elsei|UEq(u,v),UEq(u',v')->leti=Universe.compareuu'inifInt.equali0thenUniverse.comparevv'elseifUniverse.equaluv'&&Universe.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)->Universe.pru++str" <= "++Universe.prv|UEq(u,v)->Universe.pru++str" = "++Universe.prv|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||equalxyendtype'aaccumulator=Set.t->'a->'aoptiontype'aconstrained='a*Set.ttype'aconstraint_function='a->'a->Set.t->Set.tletenforce_eq_instances_univsstrictxyc=letmkuv=ifstrictthenULub(u,v)elseUEq(Universe.makeu,Universe.makev)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))axaycletto_constraints~force_weakgs=letinvalid()=raise(Invalid_argument"to_constraints: non-trivial algebraic constraint between universes")inlettrcstacc=matchcstwith|ULub(l,l')->Constraint.add(l,Eq,l')acc|UWeak(l,l')whenforce_weak->Constraint.add(l,Eq,l')acc|UWeak_->acc|ULe(l,l')->beginmatchUniverse.levell,Universe.levell'with|Somel,Somel'->Constraint.add(l,Le,l')acc|None,Some_->enforce_leqll'acc|_,None->ifUGraph.check_leqgll'thenaccelseinvalid()end|UEq(l,l')->beginmatchUniverse.levell,Universe.levell'with|Somel,Somel'->Constraint.add(l,Eq,l')acc|None,_|_,None->ifUGraph.check_eqgll'thenaccelseinvalid()endinSet.foldtrsConstraint.empty