Copyright | (c) Sirui Lu 2021-2023 |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | siruilu@cs.washington.edu |
Stability | Experimental |
Portability | GHC only |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Synopsis
- class Monoid symbolSet => SymbolSetOps symbolSet (typedSymbol :: Type -> Type) | symbolSet -> typedSymbol where
- emptySet :: symbolSet
- isEmptySet :: symbolSet -> Bool
- containsSymbol :: forall a. typedSymbol a -> symbolSet -> Bool
- insertSymbol :: forall a. typedSymbol a -> symbolSet -> symbolSet
- intersectionSet :: symbolSet -> symbolSet -> symbolSet
- unionSet :: symbolSet -> symbolSet -> symbolSet
- differenceSet :: symbolSet -> symbolSet -> symbolSet
- class SymbolSetOps symbolSet typedSymbol => SymbolSetRep rep symbolSet (typedSymbol :: Type -> Type) where
- buildSymbolSet :: rep -> symbolSet
- class SymbolSetOps symbolSet typedSymbol => ModelOps model symbolSet typedSymbol | model -> symbolSet typedSymbol where
- emptyModel :: model
- isEmptyModel :: model -> Bool
- modelContains :: typedSymbol a -> model -> Bool
- valueOf :: typedSymbol t -> model -> Maybe t
- insertValue :: typedSymbol t -> t -> model -> model
- exceptFor :: symbolSet -> model -> model
- exceptFor' :: typedSymbol t -> model -> model
- restrictTo :: symbolSet -> model -> model
- extendTo :: symbolSet -> model -> model
- exact :: symbolSet -> model -> model
- class ModelRep rep model | rep -> model where
- buildModel :: rep -> model
Model and symbolic set operations
class Monoid symbolSet => SymbolSetOps symbolSet (typedSymbol :: Type -> Type) | symbolSet -> typedSymbol where Source #
The operations on symbolic constant sets
Note that symbolic constants with different types are considered different.
>>>
let aBool = "a" :: TypedAnySymbol Bool
>>>
let bBool = "b" :: TypedAnySymbol Bool
>>>
let cBool = "c" :: TypedAnySymbol Bool
>>>
let aInteger = "a" :: TypedAnySymbol Integer
>>>
emptySet :: AnySymbolSet
SymbolSet {}>>>
containsSymbol aBool (buildSymbolSet aBool :: AnySymbolSet)
True>>>
containsSymbol bBool (buildSymbolSet aBool :: AnySymbolSet)
False>>>
insertSymbol aBool (buildSymbolSet aBool :: AnySymbolSet)
SymbolSet {a :: Bool}>>>
insertSymbol aInteger (buildSymbolSet aBool :: AnySymbolSet)
SymbolSet {a :: Bool, a :: Integer}>>>
let abSet = buildSymbolSet (aBool, bBool) :: AnySymbolSet
>>>
let acSet = buildSymbolSet (aBool, cBool) :: AnySymbolSet
>>>
intersectionSet abSet acSet
SymbolSet {a :: Bool}>>>
unionSet abSet acSet
SymbolSet {a :: Bool, b :: Bool, c :: Bool}>>>
differenceSet abSet acSet
SymbolSet {b :: Bool}
emptySet :: symbolSet Source #
Construct an empty set
isEmptySet :: symbolSet -> Bool Source #
Check if the set is empty
containsSymbol :: forall a. typedSymbol a -> symbolSet -> Bool Source #
Check if the set contains the given symbol
insertSymbol :: forall a. typedSymbol a -> symbolSet -> symbolSet Source #
Insert a symbol into the set
intersectionSet :: symbolSet -> symbolSet -> symbolSet Source #
Set intersection
unionSet :: symbolSet -> symbolSet -> symbolSet Source #
Set union
differenceSet :: symbolSet -> symbolSet -> symbolSet Source #
Set difference
Instances
SymbolSetOps (SymbolSet knd) (TypedSymbol knd) Source # | |
Defined in Grisette.Internal.SymPrim.Prim.Model emptySet :: SymbolSet knd Source # isEmptySet :: SymbolSet knd -> Bool Source # containsSymbol :: TypedSymbol knd a -> SymbolSet knd -> Bool Source # insertSymbol :: TypedSymbol knd a -> SymbolSet knd -> SymbolSet knd Source # intersectionSet :: SymbolSet knd -> SymbolSet knd -> SymbolSet knd Source # unionSet :: SymbolSet knd -> SymbolSet knd -> SymbolSet knd Source # differenceSet :: SymbolSet knd -> SymbolSet knd -> SymbolSet knd Source # |
class SymbolSetOps symbolSet typedSymbol => SymbolSetRep rep symbolSet (typedSymbol :: Type -> Type) where Source #
A type class for building a symbolic constant set manually from a symbolic constant set representation
>>>
buildSymbolSet ("a" :: TypedAnySymbol Bool, "b" :: TypedAnySymbol Bool) :: AnySymbolSet
SymbolSet {a :: Bool, b :: Bool}
buildSymbolSet :: rep -> symbolSet Source #
Build a symbolic constant set
Instances
class SymbolSetOps symbolSet typedSymbol => ModelOps model symbolSet typedSymbol | model -> symbolSet typedSymbol where Source #
The operations on Models.
Note that symbolic constants with different types are considered different.
>>>
let aBool = "a" :: TypedAnySymbol Bool
>>>
let bBool = "b" :: TypedAnySymbol Bool
>>>
let cBool = "c" :: TypedAnySymbol Bool
>>>
let aInteger = "a" :: TypedAnySymbol Integer
>>>
emptyModel :: Model
Model {}>>>
valueOf aBool (buildModel (aBool ::= True) :: Model)
Just True>>>
valueOf bBool (buildModel (aBool ::= True) :: Model)
Nothing>>>
insertValue bBool False (buildModel (aBool ::= True) :: Model)
Model {a -> true :: Bool, b -> false :: Bool}>>>
let abModel = buildModel (aBool ::= True, bBool ::= False) :: Model
>>>
let acSet = buildSymbolSet (aBool, cBool) :: AnySymbolSet
>>>
exceptFor acSet abModel
Model {b -> false :: Bool}>>>
restrictTo acSet abModel
Model {a -> true :: Bool}>>>
extendTo acSet abModel
Model {a -> true :: Bool, b -> false :: Bool, c -> false :: Bool}>>>
exact acSet abModel
Model {a -> true :: Bool, c -> false :: Bool}
emptyModel, isEmptyModel, modelContains, valueOf, insertValue, exceptFor, exceptFor', restrictTo, extendTo
emptyModel :: model Source #
Construct an empty model
isEmptyModel :: model -> Bool Source #
Check if the model is empty
modelContains :: typedSymbol a -> model -> Bool Source #
Check if the model contains the given symbol
valueOf :: typedSymbol t -> model -> Maybe t Source #
Extract the assigned value for a given symbolic constant
insertValue :: typedSymbol t -> t -> model -> model Source #
Insert an assignment into the model
exceptFor :: symbolSet -> model -> model Source #
Returns a model that removed all the assignments for the symbolic constants in the set
exceptFor' :: typedSymbol t -> model -> model Source #
Returns a model that removed the assignments for the symbolic constants
restrictTo :: symbolSet -> model -> model Source #
Returns a model that only keeps the assignments for the symbolic constants in the set
extendTo :: symbolSet -> model -> model Source #
Returns a model that extends the assignments for the symbolic constants in the set by assigning default values to them
exact :: symbolSet -> model -> model Source #
Returns a model that contains the assignments for exactly the symbolic constants in the set by removing assignments for the symbolic constants that are not in the set and add assignments for the missing symbolic constants by assigning default values to them.
Instances
ModelOps Model AnySymbolSet TypedAnySymbol Source # | |
Defined in Grisette.Internal.SymPrim.Prim.Model emptyModel :: Model Source # isEmptyModel :: Model -> Bool Source # modelContains :: TypedAnySymbol a -> Model -> Bool Source # valueOf :: TypedAnySymbol t -> Model -> Maybe t Source # insertValue :: TypedAnySymbol t -> t -> Model -> Model Source # exceptFor :: AnySymbolSet -> Model -> Model Source # exceptFor' :: TypedAnySymbol t -> Model -> Model Source # restrictTo :: AnySymbolSet -> Model -> Model Source # |
class ModelRep rep model | rep -> model where Source #
A type class for building a model manually from a model representation
buildModel :: rep -> model Source #
Build a model
>>>
let aBool = "a" :: TypedAnySymbol Bool
>>>
let bBool = "b" :: TypedAnySymbol Bool
>>>
buildModel (aBool ::= True, bBool ::= False) :: Model
Model {a -> true :: Bool, b -> false :: Bool}