123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102(**************************************************************************)(* This file is part of the Codex semantics library. *)(* *)(* Copyright (C) 2013-2025 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* 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, version 2.1. *)(* *)(* It 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. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file LICENSE). *)(* *)(**************************************************************************)moduleBoolean_Lattice=Lattices.QuadrivalentincludeBoolean_Latticeletname="Single_value_abstraction.Quadrivalent"moduleBoolean_Forward=structlettrue_=Trueletfalse_=Falseletnot=function|Bottom ->Bottom|True->False|False->True|Top->Top;;let(&&)ab=match(a,b)with|Bottom,_|_,Bottom->Bottom|False,_|_,False->False|True,x|x,True->x|Top,Top->Toplet(||)ab=match(a,b)with|Bottom,_|_,Bottom->Bottom|True,_|_,True->True|False,x|x,False->x|Top,Top->Topendletrefineoldernewer=matcholder,newerwith|_,Top->None|Bottom,_->None|_,Bottom->SomeBottom|True,True->None|True,False->SomeBottom|False,False->None|False,True->SomeBottom|Top,True->SomeTrue|Top,False->SomeFalsemoduleBoolean_Backward=struct(* Note: if the result is bottom it means that one of the argument
should be bottom, but as we do not know which, we cannot refine
anything. *)let(&&)a1a2res=matchreswith|Top->None,None|Bottom->None,None|True->(refinea1True),(refinea2True)|False->(matcha1,a2with|True,x->None,(refinexFalse)|x,True->(refinexFalse),None|False,_|_,False->None,None|Bottom,_|_,Bottom->None,None|Top,Top->None,None);;let(||)a1a2res=matchreswith|Top->None,None|Bottom->None,None|False->(refinea1False),(refinea2False)|True->(matcha1,a2with|False,x->None,(refinexTrue)|x,False->(refinexTrue),None|True,_|_,True->None,None|Bottom,_|_,Bottom->None,None|Top,Top->None,None);;letnotxres=letnotres=Boolean_Forward.notresinletred=Boolean_Lattice.interxnotresinifBoolean_Lattice.equalredresthenNoneelseSomeredendletrefine~older~newer=refineoldernewer