grisette-0.9.0.0: Symbolic evaluation as a library
Copyright(c) Sirui Lu 2021-2023
LicenseBSD-3-Clause (see the LICENSE file)
Maintainersiruilu@cs.washington.edu
StabilityExperimental
PortabilityGHC only
Safe HaskellTrustworthy
LanguageHaskell2010

Grisette.Internal.Core.Data.Class.ModelOps

Description

 
Synopsis

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}

Methods

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

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}

Methods

buildSymbolSet :: rep -> symbolSet Source #

Build a symbolic constant set

Instances

Instances details
SymbolSetRep (SomeTypedSymbol knd) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep [SomeTypedSymbol knd] (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep [TypedSymbol knd t] (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: [TypedSymbol knd t] -> SymbolSet knd Source #

SymbolSetRep (TypedSymbol knd t) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

SymbolSetRep (TypedSymbol knd a, TypedSymbol knd b) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: (TypedSymbol knd a, TypedSymbol knd b) -> SymbolSet knd Source #

SymbolSetRep (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c) -> SymbolSet knd Source #

SymbolSetRep (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d) -> SymbolSet knd Source #

SymbolSetRep (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e) -> SymbolSet knd Source #

SymbolSetRep (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e, TypedSymbol knd f) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e, TypedSymbol knd f) -> SymbolSet knd Source #

SymbolSetRep (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e, TypedSymbol knd f, TypedSymbol knd g) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e, TypedSymbol knd f, TypedSymbol knd g) -> SymbolSet knd Source #

SymbolSetRep (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e, TypedSymbol knd f, TypedSymbol knd g, TypedSymbol knd h) (SymbolSet knd) (TypedSymbol knd) Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildSymbolSet :: (TypedSymbol knd a, TypedSymbol knd b, TypedSymbol knd c, TypedSymbol knd d, TypedSymbol knd e, TypedSymbol knd f, TypedSymbol knd g, TypedSymbol knd h) -> SymbolSet knd Source #

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}

Methods

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.

class ModelRep rep model | rep -> model where Source #

A type class for building a model manually from a model representation

Methods

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}

Instances

Instances details
ModelRep (ModelValuePair t) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

ModelRep (ModelSymPair ct st) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.ModelRep

Methods

buildModel :: ModelSymPair ct st -> Model Source #

(ModelRep a Model, ModelRep b Model) => ModelRep (a, b) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model) => ModelRep (a, b, c) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model) => ModelRep (a, b, c, d) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model) => ModelRep (a, b, c, d, e) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model, ModelRep f Model) => ModelRep (a, b, c, d, e, f) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e, f) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model, ModelRep f Model, ModelRep g Model) => ModelRep (a, b, c, d, e, f, g) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e, f, g) -> Model Source #

(ModelRep a Model, ModelRep b Model, ModelRep c Model, ModelRep d Model, ModelRep e Model, ModelRep f Model, ModelRep g Model, ModelRep h Model) => ModelRep (a, b, c, d, e, f, g, h) Model Source # 
Instance details

Defined in Grisette.Internal.SymPrim.Prim.Model

Methods

buildModel :: (a, b, c, d, e, f, g, h) -> Model Source #