{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wall -Werror #-}
module Data.SBV.Set (
empty, full, universal, singleton, fromList, complement
, insert, delete
, member, notMember, null, isEmpty, isFull, isUniversal, hasSize, isSubsetOf, isProperSubsetOf, disjoint
, union, unions, intersection, intersections, difference, (\\)
) where
import Prelude hiding (null)
import Data.Proxy (Proxy(Proxy))
import qualified Data.Set as Set
import Data.SBV.Core.Data
import Data.SBV.Core.Model ((.==), (./=))
import Data.SBV.Core.Symbolic (SetOp(..))
import qualified Data.Generics.Uniplate.Data as G
empty :: forall a. HasKind a => SSet a
empty :: forall a. HasKind a => SSet a
empty = forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k forall a b. (a -> b) -> a -> b
$ RCSet CVal -> CVal
CSet forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
RegularSet forall a. Set a
Set.empty
where k :: Kind
k = Kind -> Kind
KSet forall a b. (a -> b) -> a -> b
$ forall a. HasKind a => a -> Kind
kindOf (forall {k} (t :: k). Proxy t
Proxy @a)
full :: forall a. HasKind a => SSet a
full :: forall a. HasKind a => SSet a
full = forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ Kind -> CVal -> CV
CV Kind
k forall a b. (a -> b) -> a -> b
$ RCSet CVal -> CVal
CSet forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
ComplementSet forall a. Set a
Set.empty
where k :: Kind
k = Kind -> Kind
KSet forall a b. (a -> b) -> a -> b
$ forall a. HasKind a => a -> Kind
kindOf (forall {k} (t :: k). Proxy t
Proxy @a)
universal :: forall a. HasKind a => SSet a
universal :: forall a. HasKind a => SSet a
universal = forall a. HasKind a => SSet a
full
singleton :: forall a. (Ord a, SymVal a) => SBV a -> SSet a
singleton :: forall a. (Ord a, SymVal a) => SBV a -> SSet a
singleton = (forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SSet a
`insert` (forall a. HasKind a => SSet a
empty :: SSet a))
fromList :: forall a. (Ord a, SymVal a) => [a] -> SSet a
fromList :: forall a. (Ord a, SymVal a) => [a] -> SSet a
fromList = forall a. SymVal a => a -> SBV a
literal forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> RCSet a
RegularSet forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ord a => [a] -> Set a
Set.fromList
complement :: forall a. (Ord a, SymVal a) => SSet a -> SSet a
complement :: forall a. (Ord a, SymVal a) => SSet a -> SSet a
complement SSet a
ss
| Kind
KChar forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` forall on. Uniplate on => on -> [on]
G.universe Kind
k
= forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [[Char]] -> [Char]
unlines [ [Char]
"*** Data.SBV: Set.complement is not available for the type " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Kind
k
, [Char]
"***"
, [Char]
"*** See: https://github.com/LeventErkok/sbv/issues/601 for a discussion"
, [Char]
"*** on why SBV does not support this operation at this type."
, [Char]
"***"
, [Char]
"*** Alternative: Use sets of strings instead, though the match isn't perfect."
, [Char]
"*** If you run into this issue, please comment on the above ticket for"
, [Char]
"*** possible improvements."
]
| Just (RegularSet Set a
rs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
ComplementSet Set a
rs
| Just (ComplementSet Set a
cs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
RegularSet Set a
cs
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = Kind -> Kind
KSet (forall a. HasKind a => a -> Kind
kindOf (forall {k} (t :: k). Proxy t
Proxy @a))
r :: State -> IO SV
r State
st = do SV
svs <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
ss
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetComplement) [SV
svs]
insert :: forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SSet a
insert :: forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SSet a
insert SBV a
se SSet a
ss
| Just a
e <- forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
se, Just (RegularSet Set a
rs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
RegularSet forall a b. (a -> b) -> a -> b
$ a
e forall a. Ord a => a -> Set a -> Set a
`Set.insert` Set a
rs
| Just a
e <- forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
se, Just (ComplementSet Set a
cs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss, a
e forall a. Ord a => a -> Set a -> Bool
`Set.member` Set a
cs
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
ComplementSet forall a b. (a -> b) -> a -> b
$ a
e forall a. Ord a => a -> Set a -> Set a
`Set.delete` Set a
cs
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where ka :: Kind
ka = forall a. HasKind a => a -> Kind
kindOf (forall {k} (t :: k). Proxy t
Proxy @a)
k :: Kind
k = Kind -> Kind
KSet Kind
ka
r :: State -> IO SV
r State
st = do SV
svs <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
ss
SV
sve <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
se
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetInsert) [SV
sve, SV
svs]
delete :: forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SSet a
delete :: forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SSet a
delete SBV a
se SSet a
ss
| Just a
e <- forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
se, Just (RegularSet Set a
rs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
RegularSet forall a b. (a -> b) -> a -> b
$ a
e forall a. Ord a => a -> Set a -> Set a
`Set.delete` Set a
rs
| Just a
e <- forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
se, Just (ComplementSet Set a
cs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss, a
e forall a. Ord a => a -> Set a -> Bool
`Set.notMember` Set a
cs
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
ComplementSet forall a b. (a -> b) -> a -> b
$ a
e forall a. Ord a => a -> Set a -> Set a
`Set.insert` Set a
cs
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where ka :: Kind
ka = forall a. HasKind a => a -> Kind
kindOf (forall {k} (t :: k). Proxy t
Proxy @a)
k :: Kind
k = Kind -> Kind
KSet Kind
ka
r :: State -> IO SV
r State
st = do SV
svs <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
ss
SV
sve <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
se
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetDelete) [SV
sve, SV
svs]
member :: (Ord a, SymVal a) => SBV a -> SSet a -> SBool
member :: forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SBool
member SBV a
se SSet a
ss
| Just a
e <- forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
se, Just (RegularSet Set a
rs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ a
e forall a. Ord a => a -> Set a -> Bool
`Set.member` Set a
rs
| Just a
e <- forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
se, Just (ComplementSet Set a
cs) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
ss
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ a
e forall a. Ord a => a -> Set a -> Bool
`Set.notMember` Set a
cs
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KBool forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where r :: State -> IO SV
r State
st = do SV
svs <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
ss
SV
sve <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SBV a
se
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
KBool forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetMember) [SV
sve, SV
svs]
notMember :: (Ord a, SymVal a) => SBV a -> SSet a -> SBool
notMember :: forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SBool
notMember SBV a
se SSet a
ss = SBool -> SBool
sNot forall a b. (a -> b) -> a -> b
$ forall a. (Ord a, SymVal a) => SBV a -> SSet a -> SBool
member SBV a
se SSet a
ss
null :: HasKind a => SSet a -> SBool
null :: forall a. HasKind a => SSet a -> SBool
null = (forall a. EqSymbolic a => a -> a -> SBool
.== forall a. HasKind a => SSet a
empty)
isEmpty :: HasKind a => SSet a -> SBool
isEmpty :: forall a. HasKind a => SSet a -> SBool
isEmpty = forall a. HasKind a => SSet a -> SBool
null
isFull :: HasKind a => SSet a -> SBool
isFull :: forall a. HasKind a => SSet a -> SBool
isFull = (forall a. EqSymbolic a => a -> a -> SBool
.== forall a. HasKind a => SSet a
full)
isUniversal :: HasKind a => SSet a -> SBool
isUniversal :: forall a. HasKind a => SSet a -> SBool
isUniversal = forall a. HasKind a => SSet a -> SBool
isFull
hasSize :: (Ord a, SymVal a) => SSet a -> SInteger -> SBool
hasSize :: forall a. (Ord a, SymVal a) => SSet a -> SInteger -> SBool
hasSize SSet a
sa SInteger
si
| Just (RegularSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa
= forall a. SymVal a => a -> SBV a
literal (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Set a -> Int
Set.size Set a
a)) forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
si
| Just (ComplementSet Set a
_) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa
= SBool
sFalse
| Just Integer
i <- forall a. SymVal a => SBV a -> Maybe a
unliteral SInteger
si, Integer
i forall a. Ord a => a -> a -> Bool
< Integer
0
= SBool
sFalse
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KBool forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where r :: State -> IO SV
r State
st = do SV
sva <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sa
SV
svi <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SInteger
si
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
KBool forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetHasSize) [SV
sva, SV
svi]
isSubsetOf :: (Ord a, SymVal a) => SSet a -> SSet a -> SBool
isSubsetOf :: forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SBool
isSubsetOf SSet a
sa SSet a
sb
| Just (RegularSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa, Just (RegularSet Set a
b) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sb
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ Set a
a forall a. Ord a => Set a -> Set a -> Bool
`Set.isSubsetOf` Set a
b
| Just (ComplementSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa, Just (ComplementSet Set a
b) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sb
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ Set a
b forall a. Ord a => Set a -> Set a -> Bool
`Set.isSubsetOf` Set a
a
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
KBool forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where r :: State -> IO SV
r State
st = do SV
sva <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sa
SV
svb <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sb
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
KBool forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetSubset) [SV
sva, SV
svb]
isProperSubsetOf :: (Ord a, SymVal a) => SSet a -> SSet a -> SBool
isProperSubsetOf :: forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SBool
isProperSubsetOf SSet a
a SSet a
b = SSet a
a forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SBool
`isSubsetOf` SSet a
b SBool -> SBool -> SBool
.&& SSet a
a forall a. EqSymbolic a => a -> a -> SBool
./= SSet a
b
disjoint :: (Ord a, SymVal a) => SSet a -> SSet a -> SBool
disjoint :: forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SBool
disjoint SSet a
a SSet a
b = SSet a
a forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
`intersection` SSet a
b forall a. EqSymbolic a => a -> a -> SBool
.== forall a. HasKind a => SSet a
empty
union :: (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
union :: forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
union SSet a
sa SSet a
sb
| Just (RegularSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa, Just (RegularSet Set a
b) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sb
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
RegularSet forall a b. (a -> b) -> a -> b
$ Set a
a forall a. Ord a => Set a -> Set a -> Set a
`Set.union` Set a
b
| Just (ComplementSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa, Just (ComplementSet Set a
b) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sb
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
ComplementSet forall a b. (a -> b) -> a -> b
$ Set a
a forall a. Ord a => Set a -> Set a -> Set a
`Set.intersection` Set a
b
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = forall a. HasKind a => a -> Kind
kindOf SSet a
sa
r :: State -> IO SV
r State
st = do SV
sva <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sa
SV
svb <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sb
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetUnion) [SV
sva, SV
svb]
unions :: (Ord a, SymVal a) => [SSet a] -> SSet a
unions :: forall a. (Ord a, SymVal a) => [SSet a] -> SSet a
unions = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
union forall a. HasKind a => SSet a
empty
intersection :: (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
intersection :: forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
intersection SSet a
sa SSet a
sb
| Just (RegularSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa, Just (RegularSet Set a
b) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sb
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
RegularSet forall a b. (a -> b) -> a -> b
$ Set a
a forall a. Ord a => Set a -> Set a -> Set a
`Set.intersection` Set a
b
| Just (ComplementSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa, Just (ComplementSet Set a
b) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sb
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
ComplementSet forall a b. (a -> b) -> a -> b
$ Set a
a forall a. Ord a => Set a -> Set a -> Set a
`Set.union` Set a
b
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = forall a. HasKind a => a -> Kind
kindOf SSet a
sa
r :: State -> IO SV
r State
st = do SV
sva <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sa
SV
svb <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sb
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetIntersect) [SV
sva, SV
svb]
intersections :: (Ord a, SymVal a) => [SSet a] -> SSet a
intersections :: forall a. (Ord a, SymVal a) => [SSet a] -> SSet a
intersections = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
intersection forall a. HasKind a => SSet a
full
difference :: (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
difference :: forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
difference SSet a
sa SSet a
sb
| Just (RegularSet Set a
a) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sa, Just (RegularSet Set a
b) <- forall a. SymVal a => SBV a -> Maybe a
unliteral SSet a
sb
= forall a. SymVal a => a -> SBV a
literal forall a b. (a -> b) -> a -> b
$ forall a. Set a -> RCSet a
RegularSet forall a b. (a -> b) -> a -> b
$ Set a
a forall a. Ord a => Set a -> Set a -> Set a
`Set.difference` Set a
b
| Bool
True
= forall a. SVal -> SBV a
SBV forall a b. (a -> b) -> a -> b
$ Kind -> Either CV (Cached SV) -> SVal
SVal Kind
k forall a b. (a -> b) -> a -> b
$ forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ forall a. (State -> IO a) -> Cached a
cache State -> IO SV
r
where k :: Kind
k = forall a. HasKind a => a -> Kind
kindOf SSet a
sa
r :: State -> IO SV
r State
st = do SV
sva <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sa
SV
svb <- forall a. State -> SBV a -> IO SV
sbvToSV State
st SSet a
sb
State -> Kind -> SBVExpr -> IO SV
newExpr State
st Kind
k forall a b. (a -> b) -> a -> b
$ Op -> [SV] -> SBVExpr
SBVApp (SetOp -> Op
SetOp SetOp
SetDifference) [SV
sva, SV
svb]
infixl 9 \\
(\\) :: (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
\\ :: forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
(\\) = forall a. (Ord a, SymVal a) => SSet a -> SSet a -> SSet a
difference