12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485(****************************************************************************)(* *)(* This file is part of MOPSA, a Modular Open Platform for Static Analysis. *)(* *)(* Copyright (C) 2017-2019 The MOPSA Project. *)(* *)(* This program is free software: you can redistribute it and/or modify *)(* it under the terms of the GNU Lesser General Public License as published *)(* by the Free Software Foundation, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)(* *)(****************************************************************************)(** Reduction operator for intervals and powersets. *)openMopsaopenSig.Reduction.ValuemoduleReduction=structletname="universal.numeric.reductions.intervals_powerset"letdebugfmt=Debug.debug~channel:namefmtmoduleI=Values.Intervals.Integer.ValuemoduleP=Values.Powersets.Standard.ValuemoduleB=ItvUtils.IntItv.B(* Reduce an interval and a powerset *)letof_interval(a:I.t):P.t=matchawith|BOT->P.bottom|Nb(B.Finitel,B.Finiteh)->P.of_boundslh|_->P.topletto_interval(x:P.t):I.t=matchxwith|TOP->I.top|Nts->ifP.Set.is_emptysthenBOTelseNb(B.Finite(P.Set.min_elts),B.Finite(P.Set.max_elts))letreduce_pair(x:P.t)(i:I.t):P.t*I.t=ifP.is_topxthenof_intervali,ielsematchiwith|BOT->P.bottom,BOT|Nb(B.Finitel,B.Finiteh)->letxx=P.Powerset.filter(funa->a>=l&&a<=h)xinxx,to_intervalxx|Nb(B.MINF,B.Finiteh)->letxx=P.Powerset.filter(funa->a<=h)xinxx,to_intervalxx|Nb(B.Finitel,B.PINF)->letxx=P.Powerset.filter(funa->a>=l)xinxx,to_intervalxx|_->x,to_intervalxletreduce(man:'avalue_reduction_man)(v:'a):'a=leti=man.getI.idvandp=man.getP.idvinletp',i'=reduce_pairpiinman.setI.idi'v|>man.setP.idp'endlet()=register_value_reduction(moduleReduction)