rest-rewrite-0.4.3: Rewriting library with online termination checking
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.REST.SMT

Description

This module contains functionality for creating SMTLIB expressions and interacting with an SMT solver.

Synopsis

Documentation

checkSat :: SMTExpr Bool -> IO Bool Source #

checkSat expr launches Z3, to checks satisfiability of expr, terminating Z3 afterwards. Just a utility wrapper for checkSat'

checkSat' :: (Handle, Handle) -> SMTExpr Bool -> IO Bool Source #

checkSat' handles expr checks satisfiability of expr in an instantiated SMT solver. This is wrapped in a push / pop, so it does not change the SMT environment

getModel :: Handle -> IO () Source #

getModel instructs an instantiated SMT solver to produce its model.

parseModel :: String -> Z3Model Source #

Parses Z3's model string into a Z3Model.

killZ3 :: SolverHandle -> IO () Source #

Kills the Z3 instance by closing the standard input stream

spawnZ3 :: IO SolverHandle Source #

Instantiates a Z3 instance, returning the solver handle for interaction

smtAdd :: [SMTExpr Int] -> SMTExpr Int Source #

Returns an SMT expression that adds all elements in the list. If the list is empty, returns Const 0.

smtAnd :: SMTExpr Bool -> SMTExpr Bool -> SMTExpr Bool Source #

`smtAnd t u` returns an smt expression representing \( t \land u \).

smtGTE :: SMTExpr Int -> SMTExpr Int -> SMTExpr Bool Source #

`smtGTE t u` returns an SMT expression \( t \geqslant u \). If t == u, returns smtTrue.

withZ3 :: MonadIO m => (SolverHandle -> m b) -> m b Source #

withZ3 f instantiates a Z3 instance, runs f with that instance, and then closes the instance and returns the result

type SolverHandle = (Handle, Handle) Source #

The handle (stdIn, stdOut) used for interacting with Z3

data SMTExpr a where Source #

SMTLib expressions

Instances

Instances details
Show (SMTExpr a) Source # 
Instance details

Defined in Language.REST.SMT

Methods

showsPrec :: Int -> SMTExpr a -> ShowS #

show :: SMTExpr a -> String #

showList :: [SMTExpr a] -> ShowS #

Eq (SMTExpr a) Source # 
Instance details

Defined in Language.REST.SMT

Methods

(==) :: SMTExpr a -> SMTExpr a -> Bool #

(/=) :: SMTExpr a -> SMTExpr a -> Bool #

Ord (SMTExpr a) Source # 
Instance details

Defined in Language.REST.SMT

Methods

compare :: SMTExpr a -> SMTExpr a -> Ordering #

(<) :: SMTExpr a -> SMTExpr a -> Bool #

(<=) :: SMTExpr a -> SMTExpr a -> Bool #

(>) :: SMTExpr a -> SMTExpr a -> Bool #

(>=) :: SMTExpr a -> SMTExpr a -> Bool #

max :: SMTExpr a -> SMTExpr a -> SMTExpr a #

min :: SMTExpr a -> SMTExpr a -> SMTExpr a #

Hashable (SMTExpr a) Source # 
Instance details

Defined in Language.REST.SMT

Methods

hashWithSalt :: Int -> SMTExpr a -> Int #

hash :: SMTExpr a -> Int #

newtype SMTVar a Source #

An SMT variable

Constructors

SMTVar Text 

Instances

Instances details
Eq (SMTVar a) Source # 
Instance details

Defined in Language.REST.SMT

Methods

(==) :: SMTVar a -> SMTVar a -> Bool #

(/=) :: SMTVar a -> SMTVar a -> Bool #

Ord (SMTVar a) Source # 
Instance details

Defined in Language.REST.SMT

Methods

compare :: SMTVar a -> SMTVar a -> Ordering #

(<) :: SMTVar a -> SMTVar a -> Bool #

(<=) :: SMTVar a -> SMTVar a -> Bool #

(>) :: SMTVar a -> SMTVar a -> Bool #

(>=) :: SMTVar a -> SMTVar a -> Bool #

max :: SMTVar a -> SMTVar a -> SMTVar a #

min :: SMTVar a -> SMTVar a -> SMTVar a #

class ToSMT a b where Source #

This class allows elements of type a to be used as SMT expressions of type b

Methods

toSMT :: a -> SMTExpr b Source #

Instances

Instances details
ToSMT Int Int Source # 
Instance details

Defined in Language.REST.SMT

Methods

toSMT :: Int -> SMTExpr Int Source #

ToSMTVar a b => ToSMT a b Source # 
Instance details

Defined in Language.REST.SMT

Methods

toSMT :: a -> SMTExpr b Source #

ToSMTVar a Int => ToSMT (WQO a) Bool Source # 
Instance details

Defined in Language.REST.Internal.WQO

Methods

toSMT :: WQO a -> SMTExpr Bool Source #

ToSMTVar a Int => ToSMT (ConstraintsADT a) Bool Source # 
Instance details

Defined in Language.REST.WQOConstraints.ADT

class ToSMTVar a b | a -> b where Source #

This class allows elements of type a to be used as SMT vaiables of type b. For example, the instance ToSMTVar Op Int allows RuntimeTerm operators to be represented as Int variables.

Methods

toSMTVar :: a -> SMTVar b Source #

Instances

Instances details
ToSMTVar Op Int Source # 
Instance details

Defined in Language.REST.Op

Methods

toSMTVar :: Op -> SMTVar Int Source #

type Z3Model = Map String String Source #

A model returned by Z3 corresponding to a satisfiable set of constraints. Untyped.