Module Curry2SMT

A tool to translate FlatCurry operations into SMT assertions.

Author: Michael Hanus

Version: May 2021

Summary of exported operations:

funcs2SMT :: Options -> IORef VState -> [(String,String)] -> IO (Command,[AFuncDecl TypeExpr],[((String,String),Bool)])  Non-deterministic 
Translates a list of operations specified by their qualified name (together with all operations on which these operation depend on) into an SMT string that axiomatizes their semantics.
fun2SMT :: AFuncDecl TypeExpr -> ([String],FunSig,Term)  Deterministic 
exp2SMT :: AExpr TypeExpr -> Term  Deterministic 
patternTest :: APattern TypeExpr -> Term -> Term  Deterministic 
constructorTest :: Bool -> (String,String) -> Term -> TypeExpr -> Term  Deterministic 
Translates a constructor name and a term into an SMT formula implementing a test on the term for this constructor.
selectors :: (String,String) -> [String]  Deterministic 
Computes the SMT selector names for a given constructor.
polytype2sort :: TypeExpr -> Sort  Deterministic 
Translates a FlatCurry type expression into a corresponding SMT sort.
polytype2psort :: TypeExpr -> Sort  Deterministic 
Translates a FlatCurry type expression into a parametric SMT sort.
type2sort :: [(String,String)] -> Bool -> Bool -> TypeExpr -> Sort  Deterministic 
Translates a FlatCurry type expression into a corresponding SMT sort.
tcons2SMT :: (String,String) -> String  Deterministic 
Translates a FlatCurry type constructor name into SMT.
tdecl2SMT :: TypeDecl -> Command  Deterministic 
Translates a type declaration into an SMT datatype declaration.
genSelName :: (String,String) -> Int -> String  Deterministic 
Generates the name of the i-th selector for a given constructor.
preludeSort2SMT :: String -> [Command]  Deterministic 
Translates a prelude sort (with SMT name) into an SMT datatype declaration, if necessary.
pairType :: [Command]  Deterministic 
maybeType :: [Command]  Deterministic 
eitherType :: [Command]  Deterministic 
orderingType :: [Command]  Deterministic 
unitType :: [Command]  Deterministic 
dictType :: [Command]  Deterministic 
cons2SMT :: Bool -> Bool -> (String,String) -> TypeExpr -> QIdent  Deterministic 
Translates a qualifed name with given result type into an SMT identifier.
pat2SMT :: APattern TypeExpr -> Term  Deterministic 
Translates a pattern into an SMT expression.
lit2SMT :: Literal -> Term  Deterministic 
Translates a literal into an SMT expression.
transOpName :: (String,String) -> String  Deterministic 
Translates a qualified FlatCurry name into an SMT string.
encodeSpecialChars :: String -> String  Deterministic 
Encode special characters in strings
decodeSpecialChars :: String -> String  Deterministic 
Translates urlencoded string into equivalent ASCII string.
untransOpName :: String -> Maybe (String,String)  Deterministic 
Translates a (translated) SMT string back into qualified FlatCurry name.

Exported operations:

funcs2SMT :: Options -> IORef VState -> [(String,String)] -> IO (Command,[AFuncDecl TypeExpr],[((String,String),Bool)])  Non-deterministic 

Translates a list of operations specified by their qualified name (together with all operations on which these operation depend on) into an SMT string that axiomatizes their semantics. Non-deterministic operations are axiomatized by the "planned choice" translation (see module FlatCurry.Typed.NonDet2Det). In order to call them correctly, a list of qualified operation names together with their non-determinism status (True means non-deterministic) is also returned.

fun2SMT :: AFuncDecl TypeExpr -> ([String],FunSig,Term)  Deterministic 

exp2SMT :: AExpr TypeExpr -> Term  Deterministic 

constructorTest :: Bool -> (String,String) -> Term -> TypeExpr -> Term  Deterministic 

Translates a constructor name and a term into an SMT formula implementing a test on the term for this constructor. If the first argument is true, parametric sorts are used (i.e., we translate a polymorphic function), otherwise type variables are translated into the sort TVar.

Further infos:
  • partially defined

selectors :: (String,String) -> [String]  Deterministic 

Computes the SMT selector names for a given constructor.

Further infos:
  • partially defined

polytype2sort :: TypeExpr -> Sort  Deterministic 

Translates a FlatCurry type expression into a corresponding SMT sort. Polymorphic type variables are translated into the sort TVar. The types TVar and Func are defined in the SMT prelude which is always loaded.

polytype2psort :: TypeExpr -> Sort  Deterministic 

Translates a FlatCurry type expression into a parametric SMT sort. Thus, a polymorphic type variable i is translated into the sort TVari. These type variables are later processed by the SMT translator.

type2sort :: [(String,String)] -> Bool -> Bool -> TypeExpr -> Sort  Deterministic 

Translates a FlatCurry type expression into a corresponding SMT sort. If the first argument is null, then type variables are translated into the sort TVar. If the second argument is true, the type variable index is appended (TVari) in order to generate a polymorphic sort (which will later be translated by the SMT translator). If the first argument is not null, we are in the translation of the types of selector operations and the first argument contains the currently defined data types. In this case, type variables are translated into Ti, but further nesting of the defined data types are not allowed (since this is not supported by SMT). The types TVar and Func are defined in the SMT prelude which is always loaded.

tcons2SMT :: (String,String) -> String  Deterministic 

Translates a FlatCurry type constructor name into SMT.

Further infos:
  • partially defined

tdecl2SMT :: TypeDecl -> Command  Deterministic 

Translates a type declaration into an SMT datatype declaration.

genSelName :: (String,String) -> Int -> String  Deterministic 

Generates the name of the i-th selector for a given constructor.

Further infos:
  • partially defined

preludeSort2SMT :: String -> [Command]  Deterministic 

Translates a prelude sort (with SMT name) into an SMT datatype declaration, if necessary.

Further infos:
  • partially defined

pairType :: [Command]  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

maybeType :: [Command]  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

eitherType :: [Command]  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

orderingType :: [Command]  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

unitType :: [Command]  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

dictType :: [Command]  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

cons2SMT :: Bool -> Bool -> (String,String) -> TypeExpr -> QIdent  Deterministic 

Translates a qualifed name with given result type into an SMT identifier. If the first argument is true and the result type is not a base type, the type is attached via (as ...) to resolve overloading problems in SMT. If the second argument is true, parametric sorts are used (i.e., we translate a polymorphic function), otherwise type variables are translated into the sort TVar.

pat2SMT :: APattern TypeExpr -> Term  Deterministic 

Translates a pattern into an SMT expression.

Further infos:
  • partially defined

lit2SMT :: Literal -> Term  Deterministic 

Translates a literal into an SMT expression. We represent character as ints.

transOpName :: (String,String) -> String  Deterministic 

Translates a qualified FlatCurry name into an SMT string.

encodeSpecialChars :: String -> String  Deterministic 

Encode special characters in strings

decodeSpecialChars :: String -> String  Deterministic 

Translates urlencoded string into equivalent ASCII string.

Further infos:
  • partially defined

untransOpName :: String -> Maybe (String,String)  Deterministic 

Translates a (translated) SMT string back into qualified FlatCurry name. Returns Nothing if it was not a qualified name.

Further infos:
  • partially defined