{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module What4.Protocol.SMTLib2.Syntax
(
Command(..)
, setLogic
, setOption
, setProduceModels
, SMTInfoFlag(..)
, getInfo
, getVersion
, getName
, getErrorBehavior
, exit
, declareSort
, defineSort
, declareConst
, declareFun
, defineFun
, Symbol
, checkSat
, checkSatAssuming
, checkSatWithAssumptions
, getModel
, getValue
, push
, pop
, resetAssertions
, assert
, assertNamed
, getUnsatAssumptions
, getUnsatCore
, Logic(..)
, qf_bv
, allSupported
, Sort(..)
, boolSort
, bvSort
, intSort
, realSort
, varSort
, Term(..)
, un_app
, bin_app
, term_app
, pairwise_app
, namedTerm
, builder_list
, true
, false
, not
, implies
, and
, or
, xor
, eq
, distinct
, ite
, forall
, exists
, letBinder
, negate
, numeral
, decimal
, sub
, add
, mul
, div
, (./)
, mod
, abs
, le
, lt
, ge
, gt
, toReal
, toInt
, isInt
, concat
, extract
, bvnot
, bvand
, bvor
, bvxor
, bvneg
, bvadd
, bvsub
, bvmul
, bvudiv
, bvurem
, bvshl
, bvlshr
, bvult
, bit0
, bit1
, bvbinary
, bvdecimal
, bvhexadecimal
, bvashr
, bvslt
, bvsle
, bvule
, bvsgt
, bvsge
, bvugt
, bvuge
, bvsdiv
, bvsrem
, bvsignExtend
, bvzeroExtend
, arraySort
, arrayConst
, select
, store
) where
import qualified Data.BitVector.Sized as BV
import Data.Char (intToDigit)
import Data.Parameterized.NatRepr
import Data.String
import Data.Text (Text, cons)
import Data.Text.Lazy.Builder (Builder)
import qualified Data.Text.Lazy.Builder as Builder
import qualified Data.Text.Lazy.Builder.Int as Builder
import Numeric.Natural
import GHC.Generics (Generic)
import Data.Data (Data)
import Data.Typeable (Typeable)
import qualified Prelude
import Prelude hiding (and, or, concat, negate, div, mod, abs, not)
app_list :: Builder -> [Builder] -> Builder
app_list :: Builder -> [Builder] -> Builder
app_list Builder
o [Builder]
args = Builder
"(" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
o Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> [Builder] -> Builder
forall p. (IsString p, Semigroup p) => [p] -> p
go [Builder]
args
where go :: [p] -> p
go [] = p
")"
go (p
f:[p]
r) = p
" " p -> p -> p
forall a. Semigroup a => a -> a -> a
<> p
f p -> p -> p
forall a. Semigroup a => a -> a -> a
<> [p] -> p
go [p]
r
app :: Builder -> [Builder] -> Builder
app :: Builder -> [Builder] -> Builder
app Builder
o [] = Builder
o
app Builder
o [Builder]
args = Builder -> [Builder] -> Builder
app_list Builder
o [Builder]
args
builder_list :: [Builder] -> Builder
builder_list :: [Builder] -> Builder
builder_list [] = Builder
"()"
builder_list (Builder
h:[Builder]
l) = Builder -> [Builder] -> Builder
app_list Builder
h [Builder]
l
newtype Logic = Logic Builder
qf_bv :: Logic
qf_bv :: Logic
qf_bv = Builder -> Logic
Logic Builder
"QF_BV"
allSupported :: Logic
allSupported :: Logic
allSupported = Builder -> Logic
Logic Builder
"ALL_SUPPORTED"
type Symbol = Text
newtype Sort = Sort { Sort -> Builder
unSort :: Builder }
varSort :: Symbol -> Sort
varSort :: Symbol -> Sort
varSort = Builder -> Sort
Sort (Builder -> Sort) -> (Symbol -> Builder) -> Symbol -> Sort
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Symbol -> Builder
Builder.fromText
boolSort :: Sort
boolSort :: Sort
boolSort = Builder -> Sort
Sort Builder
"Bool"
bvSort :: Natural -> Sort
bvSort :: Natural -> Sort
bvSort Natural
w | Natural
w Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
>= Natural
1 = Builder -> Sort
Sort (Builder -> Sort) -> Builder -> Sort
forall a b. (a -> b) -> a -> b
$ Builder
"(_ BitVec " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> String -> Builder
forall a. IsString a => String -> a
fromString (Natural -> String
forall a. Show a => a -> String
show Natural
w) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
| Bool
otherwise = String -> Sort
forall a. HasCallStack => String -> a
error String
"bvSort expects a positive number."
intSort :: Sort
intSort :: Sort
intSort = Builder -> Sort
Sort Builder
"Int"
realSort :: Sort
realSort :: Sort
realSort = Builder -> Sort
Sort Builder
"Real"
arraySort :: Sort -> Sort -> Sort
arraySort :: Sort -> Sort -> Sort
arraySort (Sort Builder
i) (Sort Builder
v) = Builder -> Sort
Sort (Builder -> Sort) -> Builder -> Sort
forall a b. (a -> b) -> a -> b
$ Builder
"(Array " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
i Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
v Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
newtype Term = T { Term -> Builder
renderTerm :: Builder }
deriving (String -> Term
(String -> Term) -> IsString Term
forall a. (String -> a) -> IsString a
fromString :: String -> Term
$cfromString :: String -> Term
IsString, Semigroup Term
Term
Semigroup Term
-> Term
-> (Term -> Term -> Term)
-> ([Term] -> Term)
-> Monoid Term
[Term] -> Term
Term -> Term -> Term
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [Term] -> Term
$cmconcat :: [Term] -> Term
mappend :: Term -> Term -> Term
$cmappend :: Term -> Term -> Term
mempty :: Term
$cmempty :: Term
$cp1Monoid :: Semigroup Term
Monoid, b -> Term -> Term
NonEmpty Term -> Term
Term -> Term -> Term
(Term -> Term -> Term)
-> (NonEmpty Term -> Term)
-> (forall b. Integral b => b -> Term -> Term)
-> Semigroup Term
forall b. Integral b => b -> Term -> Term
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Term -> Term
$cstimes :: forall b. Integral b => b -> Term -> Term
sconcat :: NonEmpty Term -> Term
$csconcat :: NonEmpty Term -> Term
<> :: Term -> Term -> Term
$c<> :: Term -> Term -> Term
Semigroup)
term_app :: Builder -> [Term] -> Term
term_app :: Builder -> [Term] -> Term
term_app Builder
o [Term]
args = Builder -> Term
T (Builder -> [Builder] -> Builder
app Builder
o (Term -> Builder
renderTerm (Term -> Builder) -> [Term] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [Term]
args))
un_app :: Builder -> Term -> Term
un_app :: Builder -> Term -> Term
un_app Builder
o (T Builder
x) = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ [Builder] -> Builder
forall a. Monoid a => [a] -> a
mconcat [Builder
"(", Builder
o, Builder
" ", Builder
x, Builder
")"]
bin_app :: Builder -> Term -> Term -> Term
bin_app :: Builder -> Term -> Term -> Term
bin_app Builder
o (T Builder
x) (T Builder
y) = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ [Builder] -> Builder
forall a. Monoid a => [a] -> a
mconcat [Builder
"(", Builder
o, Builder
" ", Builder
x, Builder
" ", Builder
y, Builder
")"]
chain_app :: Builder -> [Term] -> Term
chain_app :: Builder -> [Term] -> Term
chain_app Builder
f l :: [Term]
l@(Term
_:Term
_:[Term]
_) = Builder -> [Term] -> Term
term_app Builder
f [Term]
l
chain_app Builder
f [Term]
_ = String -> Term
forall a. HasCallStack => String -> a
error (String -> Term) -> String -> Term
forall a b. (a -> b) -> a -> b
$ Builder -> String
forall a. Show a => a -> String
show Builder
f String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" expects two or more arguments."
assoc_app :: Builder -> Term -> [Term] -> Term
assoc_app :: Builder -> Term -> [Term] -> Term
assoc_app Builder
_ Term
t [] = Term
t
assoc_app Builder
f Term
t [Term]
l = Builder -> [Term] -> Term
term_app Builder
f (Term
tTerm -> [Term] -> [Term]
forall a. a -> [a] -> [a]
:[Term]
l)
namedTerm :: Term -> Text -> Term
namedTerm :: Term -> Symbol -> Term
namedTerm (T Builder
x) Symbol
nm = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Builder
"(! " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
x Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" :named " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Symbol -> Builder
Builder.fromText Symbol
nm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
true :: Term
true :: Term
true = Builder -> Term
T Builder
"true"
false :: Term
false :: Term
false = Builder -> Term
T Builder
"false"
not :: Term -> Term
not :: Term -> Term
not = Builder -> Term -> Term
un_app Builder
"not"
implies :: [Term] -> Term -> Term
implies :: [Term] -> Term -> Term
implies [] Term
t = Term
t
implies [Term]
l Term
t = Builder -> [Term] -> Term
term_app Builder
"=>" ([Term]
l [Term] -> [Term] -> [Term]
forall a. [a] -> [a] -> [a]
++ [Term
t])
and :: [Term] -> Term
and :: [Term] -> Term
and [] = Term
true
and [Term
x] = Term
x
and [Term]
l = Builder -> [Term] -> Term
term_app Builder
"and" [Term]
l
or :: [Term] -> Term
or :: [Term] -> Term
or [] = Term
true
or [Term
x] = Term
x
or [Term]
l = Builder -> [Term] -> Term
term_app Builder
"or" [Term]
l
xor :: [Term] -> Term
xor :: [Term] -> Term
xor l :: [Term]
l@(Term
_:Term
_:[Term]
_) = Builder -> [Term] -> Term
term_app Builder
"xor" [Term]
l
xor [Term]
_ = String -> Term
forall a. HasCallStack => String -> a
error String
"xor expects two or more arguments."
eq :: [Term] -> Term
eq :: [Term] -> Term
eq = Builder -> [Term] -> Term
chain_app Builder
"="
pairwise_app :: Builder -> [Term] -> Term
pairwise_app :: Builder -> [Term] -> Term
pairwise_app Builder
_ [] = Term
true
pairwise_app Builder
_ [Term
_] = Term
true
pairwise_app Builder
f l :: [Term]
l@(Term
_:Term
_:[Term]
_) = Builder -> [Term] -> Term
term_app Builder
f [Term]
l
distinct :: [Term] -> Term
distinct :: [Term] -> Term
distinct = Builder -> [Term] -> Term
pairwise_app Builder
"distinct"
ite :: Term -> Term -> Term -> Term
ite :: Term -> Term -> Term -> Term
ite Term
c Term
x Term
y = Builder -> [Term] -> Term
term_app Builder
"ite" [Term
c, Term
x, Term
y]
varBinding :: (Text,Sort) -> Builder
varBinding :: (Symbol, Sort) -> Builder
varBinding (Symbol
nm, Sort
tp) = Builder
"(" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Symbol -> Builder
Builder.fromText Symbol
nm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Sort -> Builder
unSort Sort
tp Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
forall :: [(Text, Sort)] -> Term -> Term
forall :: [(Symbol, Sort)] -> Term -> Term
forall [] Term
r = Term
r
forall [(Symbol, Sort)]
vars Term
r =
Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"forall" [[Builder] -> Builder
builder_list ((Symbol, Sort) -> Builder
varBinding ((Symbol, Sort) -> Builder) -> [(Symbol, Sort)] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Sort)]
vars), Term -> Builder
renderTerm Term
r]
exists :: [(Text, Sort)] -> Term -> Term
exists :: [(Symbol, Sort)] -> Term -> Term
exists [] Term
r = Term
r
exists [(Symbol, Sort)]
vars Term
r =
Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"exists" [[Builder] -> Builder
builder_list ((Symbol, Sort) -> Builder
varBinding ((Symbol, Sort) -> Builder) -> [(Symbol, Sort)] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Sort)]
vars), Term -> Builder
renderTerm Term
r]
letBinding :: (Text, Term) -> Builder
letBinding :: (Symbol, Term) -> Builder
letBinding (Symbol
nm, Term
t) = Builder -> [Builder] -> Builder
app_list (Symbol -> Builder
Builder.fromText Symbol
nm) [Term -> Builder
renderTerm Term
t]
letBinder :: [(Text, Term)] -> Term -> Term
letBinder :: [(Symbol, Term)] -> Term -> Term
letBinder [] Term
r = Term
r
letBinder [(Symbol, Term)]
vars Term
r =
Builder -> Term
T (Builder -> [Builder] -> Builder
app Builder
"let" [[Builder] -> Builder
builder_list ((Symbol, Term) -> Builder
letBinding ((Symbol, Term) -> Builder) -> [(Symbol, Term)] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Term)]
vars), Term -> Builder
renderTerm Term
r])
negate :: Term -> Term
negate :: Term -> Term
negate = Builder -> Term -> Term
un_app Builder
"-"
numeral :: Integer -> Term
numeral :: Integer -> Term
numeral Integer
i | Integer
i Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
0 = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Integer
i
| Bool
otherwise = Term -> Term
negate (Builder -> Term
T (Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal (Integer -> Integer
forall a. Num a => a -> a
Prelude.negate Integer
i)))
decimal :: Integer -> Term
decimal :: Integer -> Term
decimal Integer
i | Integer
i Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
0 = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Integer
i Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
".0"
| Bool
otherwise = Term -> Term
negate (Term -> Term) -> Term -> Term
forall a b. (a -> b) -> a -> b
$ Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal (Integer -> Integer
forall a. Num a => a -> a
Prelude.negate Integer
i) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
".0"
sub :: Term -> [Term] -> Term
sub :: Term -> [Term] -> Term
sub Term
x [] = Term
x
sub Term
x [Term]
l = Builder -> [Term] -> Term
term_app Builder
"-" (Term
xTerm -> [Term] -> [Term]
forall a. a -> [a] -> [a]
:[Term]
l)
add :: [Term] -> Term
add :: [Term] -> Term
add [] = Builder -> Term
T Builder
"0"
add [Term
x] = Term
x
add [Term]
l = Builder -> [Term] -> Term
term_app Builder
"+" [Term]
l
mul :: [Term] -> Term
mul :: [Term] -> Term
mul [] = Builder -> Term
T Builder
"1"
mul [Term
x] = Term
x
mul [Term]
l = Builder -> [Term] -> Term
term_app Builder
"*" [Term]
l
div :: Term -> [Term] -> Term
div :: Term -> [Term] -> Term
div Term
x [] = Term
x
div Term
x [Term]
l = Builder -> [Term] -> Term
term_app Builder
"div" (Term
xTerm -> [Term] -> [Term]
forall a. a -> [a] -> [a]
:[Term]
l)
(./) :: Term -> [Term] -> Term
Term
x ./ :: Term -> [Term] -> Term
./ [] = Term
x
Term
x ./ [Term]
l = Builder -> [Term] -> Term
term_app Builder
"/" (Term
xTerm -> [Term] -> [Term]
forall a. a -> [a] -> [a]
:[Term]
l)
mod :: Term -> Term -> Term
mod :: Term -> Term -> Term
mod = Builder -> Term -> Term -> Term
bin_app Builder
"mod"
abs :: Term -> Term
abs :: Term -> Term
abs = Builder -> Term -> Term
un_app Builder
"abs"
le :: [Term] -> Term
le :: [Term] -> Term
le = Builder -> [Term] -> Term
chain_app Builder
"<="
lt :: [Term] -> Term
lt :: [Term] -> Term
lt = Builder -> [Term] -> Term
chain_app Builder
"<"
ge :: [Term] -> Term
ge :: [Term] -> Term
ge = Builder -> [Term] -> Term
chain_app Builder
">="
gt :: [Term] -> Term
gt :: [Term] -> Term
gt = Builder -> [Term] -> Term
chain_app Builder
">"
toReal :: Term -> Term
toReal :: Term -> Term
toReal = Builder -> Term -> Term
un_app Builder
"to_real"
toInt :: Term -> Term
toInt :: Term -> Term
toInt = Builder -> Term -> Term
un_app Builder
"to_int"
isInt :: Term -> Term
isInt :: Term -> Term
isInt = Builder -> Term -> Term
un_app Builder
"is_int"
arrayConst :: Sort -> Sort -> Term -> Term
arrayConst :: Sort -> Sort -> Term -> Term
arrayConst Sort
itp Sort
rtp Term
c =
let tp :: Sort
tp = Sort -> Sort -> Sort
arraySort Sort
itp Sort
rtp
cast_app :: Builder
cast_app = [Builder] -> Builder
builder_list [ Builder
"as" , Builder
"const" , Sort -> Builder
unSort Sort
tp ]
in Builder -> [Term] -> Term
term_app Builder
cast_app [ Term
c ]
select :: Term -> Term -> Term
select :: Term -> Term -> Term
select = Builder -> Term -> Term -> Term
bin_app Builder
"select"
store :: Term -> Term -> Term -> Term
store :: Term -> Term -> Term -> Term
store Term
a Term
i Term
v = Builder -> [Term] -> Term
term_app Builder
"store" [Term
a,Term
i,Term
v]
bit0 :: Term
bit0 :: Term
bit0 = Builder -> Term
T Builder
"#b0"
bit1 :: Term
bit1 :: Term
bit1 = Builder -> Term
T Builder
"#b1"
bvbinary :: 1 <= w => NatRepr w -> BV.BV w -> Term
bvbinary :: NatRepr w -> BV w -> Term
bvbinary NatRepr w
w0 BV w
u
| Bool
otherwise = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Builder
"#b" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Natural -> Builder
go (NatRepr w -> Natural
forall (n :: Nat). NatRepr n -> Natural
natValue NatRepr w
w0)
where go :: Natural -> Builder
go :: Natural -> Builder
go Natural
0 = Builder
forall a. Monoid a => a
mempty
go Natural
w =
let i :: Natural
i = Natural
w Natural -> Natural -> Natural
forall a. Num a => a -> a -> a
- Natural
1
b :: Builder
b :: Builder
b = if Natural -> BV w -> Bool
forall (w :: Nat). Natural -> BV w -> Bool
BV.testBit' Natural
i BV w
u then Builder
"1" else Builder
"0"
in Builder
b Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Natural -> Builder
go Natural
i
bvdecimal :: 1 <= w => NatRepr w -> BV.BV w -> Term
bvdecimal :: NatRepr w -> BV w -> Term
bvdecimal NatRepr w
w BV w
u = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ [Builder] -> Builder
forall a. Monoid a => [a] -> a
mconcat [ Builder
"(_ bv"
, Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Integer
d
, Builder
" "
, Natural -> Builder
forall a. Integral a => a -> Builder
Builder.decimal (NatRepr w -> Natural
forall (n :: Nat). NatRepr n -> Natural
natValue NatRepr w
w)
, Builder
")"]
where d :: Integer
d = BV w -> Integer
forall (w :: Nat). BV w -> Integer
BV.asUnsigned BV w
u
bvhexadecimal :: 1 <= w => NatRepr w -> BV.BV w -> Term
bvhexadecimal :: NatRepr w -> BV w -> Term
bvhexadecimal NatRepr w
w0 BV w
u
| Bool
otherwise = Builder -> Term
T (Builder -> Term) -> Builder -> Term
forall a b. (a -> b) -> a -> b
$ Builder
"#x" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Natural -> Builder
go (NatRepr w -> Natural
forall (n :: Nat). NatRepr n -> Natural
natValue NatRepr w
w0)
where go :: Natural -> Builder
go :: Natural -> Builder
go Natural
0 = Builder
forall a. Monoid a => a
mempty
go Natural
w | Natural
w Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
< Natural
4 = String -> Builder
forall a. HasCallStack => String -> a
error String
"bvhexadecimal width must be a multiple of 4."
go Natural
w =
let i :: Natural
i = Natural
w Natural -> Natural -> Natural
forall a. Num a => a -> a -> a
- Natural
4
charBits :: Integer
charBits = BV 4 -> Integer
forall (w :: Nat). BV w -> Integer
BV.asUnsigned (Natural -> NatRepr 4 -> BV w -> BV 4
forall (w' :: Nat) (w :: Nat).
Natural -> NatRepr w' -> BV w -> BV w'
BV.select' Natural
i (KnownNat 4 => NatRepr 4
forall (n :: Nat). KnownNat n => NatRepr n
knownNat @4) BV w
u)
c :: Char
c :: Char
c = Int -> Char
intToDigit (Int -> Char) -> Int -> Char
forall a b. (a -> b) -> a -> b
$ Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
charBits
in Char -> Builder
Builder.singleton Char
c Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Natural -> Builder
go Natural
i
concat :: Term -> Term -> Term
concat :: Term -> Term -> Term
concat = Builder -> Term -> Term -> Term
bin_app Builder
"concat"
extract :: Natural -> Natural -> Term -> Term
Natural
i Natural
j Term
x
| Natural
i Natural -> Natural -> Bool
forall a. Ord a => a -> a -> Bool
< Natural
j = String -> Term
forall a. HasCallStack => String -> a
error (String -> Term) -> String -> Term
forall a b. (a -> b) -> a -> b
$ String
"End of extract (" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show Natural
i String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
") less than beginning (" String -> String -> String
forall a. [a] -> [a] -> [a]
++ Natural -> String
forall a. Show a => a -> String
show Natural
j String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")."
| Bool
otherwise =
let e :: Builder
e = Builder
"(_ extract " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Natural -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Natural
i Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Natural -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Natural
j Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
in Builder -> Term -> Term
un_app Builder
e Term
x
bvnot :: Term -> Term
bvnot :: Term -> Term
bvnot = Builder -> Term -> Term
un_app Builder
"bvnot"
bvand :: Term -> [Term] -> Term
bvand :: Term -> [Term] -> Term
bvand = Builder -> Term -> [Term] -> Term
assoc_app Builder
"bvand"
bvor :: Term -> [Term] -> Term
bvor :: Term -> [Term] -> Term
bvor = Builder -> Term -> [Term] -> Term
assoc_app Builder
"bvor"
bvxor :: Term -> [Term] -> Term
bvxor :: Term -> [Term] -> Term
bvxor = Builder -> Term -> [Term] -> Term
assoc_app Builder
"bvxor"
bvneg :: Term -> Term
bvneg :: Term -> Term
bvneg = Builder -> Term -> Term
un_app Builder
"bvneg"
bvadd :: Term -> [Term] -> Term
bvadd :: Term -> [Term] -> Term
bvadd = Builder -> Term -> [Term] -> Term
assoc_app Builder
"bvadd"
bvsub :: Term -> Term -> Term
bvsub :: Term -> Term -> Term
bvsub = Builder -> Term -> Term -> Term
bin_app Builder
"bvsub"
bvmul :: Term -> [Term] -> Term
bvmul :: Term -> [Term] -> Term
bvmul = Builder -> Term -> [Term] -> Term
assoc_app Builder
"bvmul"
bvudiv :: Term -> Term -> Term
bvudiv :: Term -> Term -> Term
bvudiv = Builder -> Term -> Term -> Term
bin_app Builder
"bvudiv"
bvurem :: Term -> Term -> Term
bvurem :: Term -> Term -> Term
bvurem = Builder -> Term -> Term -> Term
bin_app Builder
"bvurem"
bvshl :: Term -> Term -> Term
bvshl :: Term -> Term -> Term
bvshl = Builder -> Term -> Term -> Term
bin_app Builder
"bvshl"
bvlshr :: Term -> Term -> Term
bvlshr :: Term -> Term -> Term
bvlshr = Builder -> Term -> Term -> Term
bin_app Builder
"bvlshr"
bvult :: Term -> Term -> Term
bvult :: Term -> Term -> Term
bvult = Builder -> Term -> Term -> Term
bin_app Builder
"bvult"
bvule :: Term -> Term -> Term
bvule :: Term -> Term -> Term
bvule = Builder -> Term -> Term -> Term
bin_app Builder
"bvule"
bvsle :: Term -> Term -> Term
bvsle :: Term -> Term -> Term
bvsle = Builder -> Term -> Term -> Term
bin_app Builder
"bvsle"
bvslt :: Term -> Term -> Term
bvslt :: Term -> Term -> Term
bvslt = Builder -> Term -> Term -> Term
bin_app Builder
"bvslt"
bvuge :: Term -> Term -> Term
bvuge :: Term -> Term -> Term
bvuge = Builder -> Term -> Term -> Term
bin_app Builder
"bvuge"
bvugt :: Term -> Term -> Term
bvugt :: Term -> Term -> Term
bvugt = Builder -> Term -> Term -> Term
bin_app Builder
"bvugt"
bvsge :: Term -> Term -> Term
bvsge :: Term -> Term -> Term
bvsge = Builder -> Term -> Term -> Term
bin_app Builder
"bvsge"
bvsgt :: Term -> Term -> Term
bvsgt :: Term -> Term -> Term
bvsgt = Builder -> Term -> Term -> Term
bin_app Builder
"bvsgt"
bvashr :: Term -> Term -> Term
bvashr :: Term -> Term -> Term
bvashr = Builder -> Term -> Term -> Term
bin_app Builder
"bvashr"
bvsdiv :: Term -> Term -> Term
bvsdiv :: Term -> Term -> Term
bvsdiv = Builder -> Term -> Term -> Term
bin_app Builder
"bvsdiv"
bvsrem :: Term -> Term -> Term
bvsrem :: Term -> Term -> Term
bvsrem = Builder -> Term -> Term -> Term
bin_app Builder
"bvsrem"
bvsignExtend :: Integer -> Term -> Term
bvsignExtend :: Integer -> Term -> Term
bvsignExtend Integer
w Term
x =
let e :: Builder
e = Builder
"(_ sign_extend " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Integer
w Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
in Builder -> Term -> Term
un_app Builder
e Term
x
bvzeroExtend :: Integer -> Term -> Term
bvzeroExtend :: Integer -> Term -> Term
bvzeroExtend Integer
w Term
x =
let e :: Builder
e = Builder
"(_ zero_extend " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Integer
w Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
in Builder -> Term -> Term
un_app Builder
e Term
x
newtype Command = Cmd Builder
setLogic :: Logic -> Command
setLogic :: Logic -> Command
setLogic (Logic Builder
nm) = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder
"(set-logic " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
nm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
setOption :: Text -> Text -> Command
setOption :: Symbol -> Symbol -> Command
setOption Symbol
nm Symbol
val = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app_list Builder
"set-option" [Builder
":" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Symbol -> Builder
Builder.fromText Symbol
nm, Symbol -> Builder
Builder.fromText Symbol
val]
ppBool :: Bool -> Text
ppBool :: Bool -> Symbol
ppBool Bool
b = if Bool
b then Symbol
"true" else Symbol
"false"
setProduceModels :: Bool -> Command
setProduceModels :: Bool -> Command
setProduceModels Bool
b = Symbol -> Symbol -> Command
setOption Symbol
"produce-models" (Bool -> Symbol
ppBool Bool
b)
exit :: Command
exit :: Command
exit = Builder -> Command
Cmd Builder
"(exit)"
declareSort :: Symbol -> Integer -> Command
declareSort :: Symbol -> Integer -> Command
declareSort Symbol
v Integer
n = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"declare-sort" [Symbol -> Builder
Builder.fromText Symbol
v, String -> Builder
forall a. IsString a => String -> a
fromString (Integer -> String
forall a. Show a => a -> String
show Integer
n)]
defineSort :: Symbol
-> [Symbol]
-> Sort
-> Command
defineSort :: Symbol -> [Symbol] -> Sort -> Command
defineSort Symbol
v [Symbol]
params Sort
d =
Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"define-sort" [ Symbol -> Builder
Builder.fromText Symbol
v
, [Builder] -> Builder
builder_list (Symbol -> Builder
Builder.fromText (Symbol -> Builder) -> [Symbol] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [Symbol]
params)
, Sort -> Builder
unSort Sort
d
]
declareConst :: Text -> Sort -> Command
declareConst :: Symbol -> Sort -> Command
declareConst Symbol
v Sort
tp = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"declare-const" [Symbol -> Builder
Builder.fromText Symbol
v, Sort -> Builder
unSort Sort
tp]
declareFun :: Text -> [Sort] -> Sort -> Command
declareFun :: Symbol -> [Sort] -> Sort -> Command
declareFun Symbol
v [Sort]
argSorts Sort
retSort = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$
Builder -> [Builder] -> Builder
app Builder
"declare-fun" [ Symbol -> Builder
Builder.fromText Symbol
v
, [Builder] -> Builder
builder_list ([Builder] -> Builder) -> [Builder] -> Builder
forall a b. (a -> b) -> a -> b
$ Sort -> Builder
unSort (Sort -> Builder) -> [Sort] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [Sort]
argSorts
, Sort -> Builder
unSort Sort
retSort
]
defineFun :: Text -> [(Text,Sort)] -> Sort -> Term -> Command
defineFun :: Symbol -> [(Symbol, Sort)] -> Sort -> Term -> Command
defineFun Symbol
f [(Symbol, Sort)]
args Sort
return_type Term
e =
let resolveArg :: (Symbol, Sort) -> Builder
resolveArg (Symbol
var, Sort
tp) = Builder -> [Builder] -> Builder
app (Symbol -> Builder
Builder.fromText Symbol
var) [Sort -> Builder
unSort Sort
tp]
in Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"define-fun" [ Symbol -> Builder
Builder.fromText Symbol
f
, [Builder] -> Builder
builder_list ((Symbol, Sort) -> Builder
resolveArg ((Symbol, Sort) -> Builder) -> [(Symbol, Sort)] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Symbol, Sort)]
args)
, Sort -> Builder
unSort Sort
return_type
, Term -> Builder
renderTerm Term
e
]
assert :: Term -> Command
assert :: Term -> Command
assert Term
p = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"assert" [Term -> Builder
renderTerm Term
p]
assertNamed :: Term -> Text -> Command
assertNamed :: Term -> Symbol -> Command
assertNamed Term
p Symbol
nm =
Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"assert"
[[Builder] -> Builder
builder_list [Symbol -> Builder
Builder.fromText Symbol
"!", Term -> Builder
renderTerm Term
p, Symbol -> Builder
Builder.fromText Symbol
":named", Symbol -> Builder
Builder.fromText Symbol
nm]]
checkSat :: Command
checkSat :: Command
checkSat = Builder -> Command
Cmd Builder
"(check-sat)"
checkSatAssuming :: [Term] -> Command
checkSatAssuming :: [Term] -> Command
checkSatAssuming [Term]
l = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder
"(check-sat-assuming " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> [Builder] -> Builder
builder_list (Term -> Builder
renderTerm (Term -> Builder) -> [Term] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [Term]
l) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
checkSatWithAssumptions :: [Text] -> Command
checkSatWithAssumptions :: [Symbol] -> Command
checkSatWithAssumptions [Symbol]
nms = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"check-sat-assuming" [[Builder] -> Builder
builder_list ((Symbol -> Builder) -> [Symbol] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map Symbol -> Builder
Builder.fromText [Symbol]
nms)]
getModel :: Command
getModel :: Command
getModel = Builder -> Command
Cmd Builder
"(get-model)"
getUnsatAssumptions :: Command
getUnsatAssumptions :: Command
getUnsatAssumptions = Builder -> Command
Cmd Builder
"(get-unsat-assumptions)"
getUnsatCore :: Command
getUnsatCore :: Command
getUnsatCore = Builder -> Command
Cmd Builder
"(get-unsat-core)"
getValue :: [Term] -> Command
getValue :: [Term] -> Command
getValue [Term]
values = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"get-value" [[Builder] -> Builder
builder_list (Term -> Builder
renderTerm (Term -> Builder) -> [Term] -> [Builder]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [Term]
values)]
resetAssertions :: Command
resetAssertions :: Command
resetAssertions = Builder -> Command
Cmd Builder
"(reset-assertions)"
push :: Integer -> Command
push :: Integer -> Command
push Integer
n = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder
"(push " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Integer
n Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
pop :: Integer -> Command
pop :: Integer -> Command
pop Integer
n = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder
"(pop " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Integer -> Builder
forall a. Integral a => a -> Builder
Builder.decimal Integer
n Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
data SMTInfoFlag =
Name
| Version
| ErrorBehavior
| InfoKeyword Text
deriving (Typeable SMTInfoFlag
DataType
Constr
Typeable SMTInfoFlag
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SMTInfoFlag -> c SMTInfoFlag)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SMTInfoFlag)
-> (SMTInfoFlag -> Constr)
-> (SMTInfoFlag -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SMTInfoFlag))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SMTInfoFlag))
-> ((forall b. Data b => b -> b) -> SMTInfoFlag -> SMTInfoFlag)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r)
-> (forall u. (forall d. Data d => d -> u) -> SMTInfoFlag -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> SMTInfoFlag -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag)
-> Data SMTInfoFlag
SMTInfoFlag -> DataType
SMTInfoFlag -> Constr
(forall b. Data b => b -> b) -> SMTInfoFlag -> SMTInfoFlag
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SMTInfoFlag -> c SMTInfoFlag
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SMTInfoFlag
forall a.
Typeable a
-> (forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> SMTInfoFlag -> u
forall u. (forall d. Data d => d -> u) -> SMTInfoFlag -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r
forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SMTInfoFlag
forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SMTInfoFlag -> c SMTInfoFlag
forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SMTInfoFlag)
forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SMTInfoFlag)
$cInfoKeyword :: Constr
$cErrorBehavior :: Constr
$cVersion :: Constr
$cName :: Constr
$tSMTInfoFlag :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
$cgmapMo :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
gmapMp :: (forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
$cgmapMp :: forall (m :: Type -> Type).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
gmapM :: (forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> SMTInfoFlag -> m SMTInfoFlag
gmapQi :: Int -> (forall d. Data d => d -> u) -> SMTInfoFlag -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SMTInfoFlag -> u
gmapQ :: (forall d. Data d => d -> u) -> SMTInfoFlag -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SMTInfoFlag -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SMTInfoFlag -> r
gmapT :: (forall b. Data b => b -> b) -> SMTInfoFlag -> SMTInfoFlag
$cgmapT :: (forall b. Data b => b -> b) -> SMTInfoFlag -> SMTInfoFlag
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SMTInfoFlag)
$cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SMTInfoFlag)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SMTInfoFlag)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SMTInfoFlag)
dataTypeOf :: SMTInfoFlag -> DataType
$cdataTypeOf :: SMTInfoFlag -> DataType
toConstr :: SMTInfoFlag -> Constr
$ctoConstr :: SMTInfoFlag -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SMTInfoFlag
$cgunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SMTInfoFlag
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SMTInfoFlag -> c SMTInfoFlag
$cgfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SMTInfoFlag -> c SMTInfoFlag
$cp1Data :: Typeable SMTInfoFlag
Data, SMTInfoFlag -> SMTInfoFlag -> Bool
(SMTInfoFlag -> SMTInfoFlag -> Bool)
-> (SMTInfoFlag -> SMTInfoFlag -> Bool) -> Eq SMTInfoFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SMTInfoFlag -> SMTInfoFlag -> Bool
$c/= :: SMTInfoFlag -> SMTInfoFlag -> Bool
== :: SMTInfoFlag -> SMTInfoFlag -> Bool
$c== :: SMTInfoFlag -> SMTInfoFlag -> Bool
Eq, Eq SMTInfoFlag
Eq SMTInfoFlag
-> (SMTInfoFlag -> SMTInfoFlag -> Ordering)
-> (SMTInfoFlag -> SMTInfoFlag -> Bool)
-> (SMTInfoFlag -> SMTInfoFlag -> Bool)
-> (SMTInfoFlag -> SMTInfoFlag -> Bool)
-> (SMTInfoFlag -> SMTInfoFlag -> Bool)
-> (SMTInfoFlag -> SMTInfoFlag -> SMTInfoFlag)
-> (SMTInfoFlag -> SMTInfoFlag -> SMTInfoFlag)
-> Ord SMTInfoFlag
SMTInfoFlag -> SMTInfoFlag -> Bool
SMTInfoFlag -> SMTInfoFlag -> Ordering
SMTInfoFlag -> SMTInfoFlag -> SMTInfoFlag
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SMTInfoFlag -> SMTInfoFlag -> SMTInfoFlag
$cmin :: SMTInfoFlag -> SMTInfoFlag -> SMTInfoFlag
max :: SMTInfoFlag -> SMTInfoFlag -> SMTInfoFlag
$cmax :: SMTInfoFlag -> SMTInfoFlag -> SMTInfoFlag
>= :: SMTInfoFlag -> SMTInfoFlag -> Bool
$c>= :: SMTInfoFlag -> SMTInfoFlag -> Bool
> :: SMTInfoFlag -> SMTInfoFlag -> Bool
$c> :: SMTInfoFlag -> SMTInfoFlag -> Bool
<= :: SMTInfoFlag -> SMTInfoFlag -> Bool
$c<= :: SMTInfoFlag -> SMTInfoFlag -> Bool
< :: SMTInfoFlag -> SMTInfoFlag -> Bool
$c< :: SMTInfoFlag -> SMTInfoFlag -> Bool
compare :: SMTInfoFlag -> SMTInfoFlag -> Ordering
$ccompare :: SMTInfoFlag -> SMTInfoFlag -> Ordering
$cp1Ord :: Eq SMTInfoFlag
Ord, (forall x. SMTInfoFlag -> Rep SMTInfoFlag x)
-> (forall x. Rep SMTInfoFlag x -> SMTInfoFlag)
-> Generic SMTInfoFlag
forall x. Rep SMTInfoFlag x -> SMTInfoFlag
forall x. SMTInfoFlag -> Rep SMTInfoFlag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SMTInfoFlag x -> SMTInfoFlag
$cfrom :: forall x. SMTInfoFlag -> Rep SMTInfoFlag x
Generic, Int -> SMTInfoFlag -> String -> String
[SMTInfoFlag] -> String -> String
SMTInfoFlag -> String
(Int -> SMTInfoFlag -> String -> String)
-> (SMTInfoFlag -> String)
-> ([SMTInfoFlag] -> String -> String)
-> Show SMTInfoFlag
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [SMTInfoFlag] -> String -> String
$cshowList :: [SMTInfoFlag] -> String -> String
show :: SMTInfoFlag -> String
$cshow :: SMTInfoFlag -> String
showsPrec :: Int -> SMTInfoFlag -> String -> String
$cshowsPrec :: Int -> SMTInfoFlag -> String -> String
Show, Typeable)
flagToSExp :: SMTInfoFlag -> Text
flagToSExp :: SMTInfoFlag -> Symbol
flagToSExp = (Char -> Symbol -> Symbol
cons Char
':') (Symbol -> Symbol)
-> (SMTInfoFlag -> Symbol) -> SMTInfoFlag -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
\case
SMTInfoFlag
Name -> Symbol
"name"
SMTInfoFlag
Version -> Symbol
"version"
SMTInfoFlag
ErrorBehavior -> Symbol
"error-behavior"
InfoKeyword Symbol
s -> Symbol
s
getInfo :: SMTInfoFlag -> Command
getInfo :: SMTInfoFlag -> Command
getInfo SMTInfoFlag
flag = Builder -> Command
Cmd (Builder -> Command) -> Builder -> Command
forall a b. (a -> b) -> a -> b
$ Builder -> [Builder] -> Builder
app Builder
"get-info" [Symbol -> Builder
Builder.fromText (SMTInfoFlag -> Symbol
flagToSExp SMTInfoFlag
flag)]
getVersion :: Command
getVersion :: Command
getVersion = SMTInfoFlag -> Command
getInfo SMTInfoFlag
Version
getName :: Command
getName :: Command
getName = SMTInfoFlag -> Command
getInfo SMTInfoFlag
Name
getErrorBehavior :: Command
getErrorBehavior :: Command
getErrorBehavior = SMTInfoFlag -> Command
getInfo SMTInfoFlag
ErrorBehavior