1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859(**********************************************************************)(* *)(* LASCAr *)(* *)(* Copyright (c) 2017-present, Jocelyn SEROT. All rights reserved. *)(* *)(* This source code is licensed under the license found in the *)(* LICENSE file in the root directory of this source tree. *)(* *)(**********************************************************************)(* module type OrderedType = sig *)(* include Set.OrderedType *)(* val to_string: t -> string *)(* (\* include Stringable with type t := t *\) *)(* end *)moduletypeS=sigincludeSet.SmoduleElt:OrderedTypeExt.Twithtypet=eltvalmap:(elt->elt)->t->tvalpower:t->tlistvalextract:t->elt*tvalto_string:t->stringendmoduleMake(E:OrderedTypeExt.T)=structmoduleS=Set.Make(E)moduleElt=EincludeSletmapfs=S.fold(funes->S.add(fe)s)sS.emptyletextracts=lete=S.choosesine,S.removeesletrecpowers=ifS.is_emptysthen[S.empty]elselete,s'=extractsinletss=powers'inss@(List.map(funs->addes)ss)letto_strings="{"^ListExt.to_stringE.to_string","(S.elementss)^"}"end(* module Pair (E1: OrderedType.T) (E2: OrderedType.T) = *)(* struct *)(* type t = E1.t * E2.t *)(* let compare = compare *)(* let to_string (x,y) = E1.to_string x ^ "," ^ E2.to_string y *)(* end *)moduleProduct(S1:S)(S2:S)=struct(* module R = Make(Pair(S1.Elt)(S2.Elt)) *)moduleR=Make(OrderedTypeExt.Pair(S1.Elt)(S2.Elt))includeRletproducts1s2=letfxyt=R.add(x,y)tinletgxt=S2.fold(fx)s2tinS1.foldgs1R.emptyend