Module Solver.SMTLIB.Internal.Interaction

This module provides a session monad to manage an interactive and incremental SMT solver session. Furthermore it includes abstractions for well-known SMT-LIB commands in Curry which are required during the interaction with an SMT solver.

Author: Jan Tikovsky, Marcellus Siegburg

Version: January 2018

Summary of exported operations:

getSess :: SMTSess SMTSession   
Get SMT session
putSess :: SMTSession -> SMTSess ()   
Set an SMT session
evalSess :: SMTSess a -> SMT a   
Evaluate multiple SMT sessions
evalSessionsImpl :: SMTSolver -> SMTOpts -> SMTSess a -> IO a   
Evaluate SMT sessions by applying given solver and options
evalSMT :: SMT a -> SMTSession -> IO a   
Evaluate an SMT action
execSMT :: SMT a -> SMTSession -> IO SMTSession   
Execute an SMT action
gets :: (SMTSession -> a) -> SMT a   
get :: SMT SMTSession   
Get SMT session
put :: SMTSession -> SMT ()   
Set SMT session
getStdin :: SMT Handle   
Get handle for stdin
getStdout :: SMT Handle   
Get handle for stdout
takeBuffer :: SMT [Command]   
Get buffered SMT commands and empty buffer
getTrace :: SMT [Command]   
Get trace of SMT commands
getGlobalCmds :: SMT [Command]   
Get global commands set in the SMT options
isIncremental :: SMT Bool   
Check if incremental SMT solving is activated
getGlobalDecls :: SMT [Command]   
Get global declarations
modify :: (SMTSession -> SMTSession) -> SMT ()   
Modify an SMT session by applying the given function
liftIOA :: IO a -> SMTSess a   
Lift an IO action directly to the SMT session monad
liftSMT :: SMT a -> SMTSess a   
Lift an SMT action to the SMT session monad
liftIO2SMT :: IO a -> SMT a   
Lift an IO action to the SMT monad
evalSession :: SMT a -> SMTSess a   
Evaluate a singe SMT session (i.e.
rsp2Msg :: CmdResponse -> SMTError   
Transform a command response to an error message
res2Msgs :: SMTResult -> [SMTError]   
Transform a result to list of error messages
declareVars :: Int -> Sort -> SMT [Term]   
Declare n fresh SMT variables of given sort
checkSat :: SMT SMTResult   
Check for syntactic errors as well as for satisfiability of the assertions
getModel :: SMT (Either [SMTError] [ModelRsp])   
Get a model for the current assertions on the solver stack
getValues :: [Term] -> SMT (Either [SMTError] [(Term,Term)])   
Get bindings for given variables for the current assertions on the solver stack
bufferGlobalDefs :: SMT ()   
Buffer global definitions in SMT session
resetSession :: SMT ()   
Reset SMT session (by resetting the SMT solver stack)
optReset :: SMT ()   
Optional reset of SMT session (in case of non-incremental solving)
optTracing :: [Command] -> SMT ()   
Optional tracing of SMT-LIB commands in the given buffer
closeSession :: SMT ()   
Close SMT session
startSession :: SMTSolver -> SMTOpts -> IO SMTSession   
Low-level SMT solver interaction Start SMT solver process and initialize fresh SMT session
termSession :: SMTSession -> IO ()   
Terminate SMT solver process
dumpSession :: SMTSession -> IO ()   
Produce dump of SMT-LIB commands used during an SMT session
bufferCmds :: [Command] -> SMT ()   
Buffer given SMT-LIB commands
sendCmds :: [Command] -> SMT ()   
Send SMT-LIB commands to SMT solver
getDelimited :: SMT String   
Get response string of an SMT solver
info :: String -> SMT ()   
Write status information to the command line when quiet option is set to False
rmvEchos :: [Command] -> [Command]   
Remove all Echo commands

Exported datatypes:


SMTSession

An SMT solver session includes

  • handles for communicating with the solver
  • a buffer for SMT-LIB commands
  • a trace of SMT-LIB commands (only required for debugging purposes)
  • SMT options
  • an index for fresh variables
  • a list of global SMT-LIB declarations

Constructors:


SMTSess

Session monad maintaining session information during multiple SMT sessions

Constructors:


SMT

SMT monad maintaining session information while performing SMT actions during a single SMT session

Constructors:


SMTResult

High-level SMT solver interaction SMT solver result

Constructors:

  • Error :: [SMTError] -> SMTResult
  • Unsat :: SMTResult
  • Unknown :: SMTResult
  • Sat :: SMTResult
  • Model :: [ModelRsp] -> SMTResult
  • Values :: [ValuationPair] -> SMTResult

Exported operations:

getSess :: SMTSess SMTSession   

Get SMT session

putSess :: SMTSession -> SMTSess ()   

Set an SMT session

evalSess :: SMTSess a -> SMT a   

Evaluate multiple SMT sessions

evalSessionsImpl :: SMTSolver -> SMTOpts -> SMTSess a -> IO a   

Evaluate SMT sessions by applying given solver and options

evalSMT :: SMT a -> SMTSession -> IO a   

Evaluate an SMT action

execSMT :: SMT a -> SMTSession -> IO SMTSession   

Execute an SMT action

gets :: (SMTSession -> a) -> SMT a   

get :: SMT SMTSession   

Get SMT session

put :: SMTSession -> SMT ()   

Set SMT session

getStdin :: SMT Handle   

Get handle for stdin

getStdout :: SMT Handle   

Get handle for stdout

takeBuffer :: SMT [Command]   

Get buffered SMT commands and empty buffer

getTrace :: SMT [Command]   

Get trace of SMT commands

getGlobalCmds :: SMT [Command]   

Get global commands set in the SMT options

isIncremental :: SMT Bool   

Check if incremental SMT solving is activated

getGlobalDecls :: SMT [Command]   

Get global declarations

modify :: (SMTSession -> SMTSession) -> SMT ()   

Modify an SMT session by applying the given function

liftIOA :: IO a -> SMTSess a   

Lift an IO action directly to the SMT session monad

liftSMT :: SMT a -> SMTSess a   

Lift an SMT action to the SMT session monad

liftIO2SMT :: IO a -> SMT a   

Lift an IO action to the SMT monad

evalSession :: SMT a -> SMTSess a   

Evaluate a singe SMT session (i.e. lift SMT action to Session monad and thread session)

rsp2Msg :: CmdResponse -> SMTError   

Transform a command response to an error message

res2Msgs :: SMTResult -> [SMTError]   

Transform a result to list of error messages

declareVars :: Int -> Sort -> SMT [Term]   

Declare n fresh SMT variables of given sort

checkSat :: SMT SMTResult   

Check for syntactic errors as well as for satisfiability of the assertions

getModel :: SMT (Either [SMTError] [ModelRsp])   

Get a model for the current assertions on the solver stack

getValues :: [Term] -> SMT (Either [SMTError] [(Term,Term)])   

Get bindings for given variables for the current assertions on the solver stack

bufferGlobalDefs :: SMT ()   

Buffer global definitions in SMT session

resetSession :: SMT ()   

Reset SMT session (by resetting the SMT solver stack)

optReset :: SMT ()   

Optional reset of SMT session (in case of non-incremental solving)

optTracing :: [Command] -> SMT ()   

Optional tracing of SMT-LIB commands in the given buffer

closeSession :: SMT ()   

Close SMT session

startSession :: SMTSolver -> SMTOpts -> IO SMTSession   

Low-level SMT solver interaction Start SMT solver process and initialize fresh SMT session

termSession :: SMTSession -> IO ()   

Terminate SMT solver process

dumpSession :: SMTSession -> IO ()   

Produce dump of SMT-LIB commands used during an SMT session

bufferCmds :: [Command] -> SMT ()   

Buffer given SMT-LIB commands

sendCmds :: [Command] -> SMT ()   

Send SMT-LIB commands to SMT solver

getDelimited :: SMT String   

Get response string of an SMT solver

info :: String -> SMT ()   

Write status information to the command line when quiet option is set to False

rmvEchos :: [Command] -> [Command]   

Remove all Echo commands