Copyright | (c) Alexandre Joannou 2020-2021 |
---|---|
License | MIT |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
This module provides basic pretty printing utilities for SMT code generation
Synopsis
- showAtBase :: (Integral a, Show a) => a -> a -> Doc
- showHex :: (Integral a, Show a) => a -> Doc
- showBin :: (Integral a, Show a) => a -> Doc
- psep :: [Doc] -> Doc
- plist :: [(Doc, Doc)] -> Doc
- applyOp :: Doc -> [Doc] -> Doc
- bvHexLit :: Integer -> Doc
- bvBinLit :: Integer -> Doc
- bvSlice :: Int -> Int -> Doc -> Doc
- bvSortStr :: Int -> String
- bvSort :: Int -> Doc
- int2bv :: Int -> Integer -> Doc
- bvIsFalse :: Doc -> Doc
- bvIsTrue :: Doc -> Doc
- bv2Bool :: Doc -> Doc
- bool2bv :: Doc -> Doc
- qualify :: Doc -> Doc -> Doc
- parBind :: [String] -> Doc -> Doc
- forallBind :: [(Doc, Doc)] -> Doc -> Doc
- existsBind :: [(Doc, Doc)] -> Doc -> Doc
- matchBind :: Doc -> [(Doc, Doc)] -> Doc
- letBind :: [(Doc, Doc)] -> Doc -> Doc
- nestLetBind :: [[(Doc, Doc)]] -> Doc -> Doc
- declareDataTypes :: [(String, [String], [(String, [String])])] -> Doc
- declareDataType :: String -> [String] -> [(String, [(String, String)])] -> Doc
- defineFun :: Doc -> [(Doc, Doc)] -> Doc -> Doc -> Doc
- defineFunRec :: Doc -> [(Doc, Doc)] -> Doc -> Doc -> Doc
- defineFunsRec :: [(String, [(String, String)], String, Doc)] -> Doc
general numerical helpers
showAtBase :: (Integral a, Show a) => a -> a -> Doc Source #
pretty print an Integral
in a given base
formatting helpers
plist :: [(Doc, Doc)] -> Doc Source #
pretty print a whitespace separated list of parenthesised pairs of Doc
s
in parentheses
applyOp :: Doc -> [Doc] -> Doc Source #
pretty print the application of an operator to a list of arguments
bvSlice :: Int -> Int -> Doc -> Doc Source #
extract the bitslice from lo
to hi
from the bv
SMT BitVec
bvSortStr :: Int -> String Source #
return a string representing the BitVec SMT sort of the given width n
int2bv :: Int -> Integer -> Doc Source #
cast the Int sorted SMT value n
to a (BitVec w
) sorted SMT value
SMT binders and qualifiers
qualify :: Doc -> Doc -> Doc Source #
wrap the SMT expression expr
in the "as" qualifier with the given sort
parBind :: [String] -> Doc -> Doc Source #
wrap the SMT parametric expression expr
in the "par" sort parameter
binder with the pars
list of sort parameters
forallBind :: [(Doc, Doc)] -> Doc -> Doc Source #
wrap an SMT expression in the "forall" universal quantifier with the provided list of pairs of (variable name, sort)
existsBind :: [(Doc, Doc)] -> Doc -> Doc Source #
wrap an SMT expression in the "exists" existential quantifier with the provided list of pairs of (variable name, sort)
matchBind :: Doc -> [(Doc, Doc)] -> Doc Source #
wrap an SMT expression in the "match" binder, pattern matching the SMT expression against each of the patterns provided in the argument list of pairs of (pattern, expression)
letBind :: [(Doc, Doc)] -> Doc -> Doc Source #
wrap an SMT expression in the "let" binder with the provided list of pairs of (variable name, sort)
nestLetBind :: [[(Doc, Doc)]] -> Doc -> Doc Source #
wrap an SMT expression in a sequence of nested "let" binders, each introducing one of the variables provided by the argument list of pairs of (variable name, sort), in the provided order
SMT datatype declarations
declareDataTypes :: [(String, [String], [(String, [String])])] -> Doc Source #
pretty print the declaration of the datatypes provided in the argument list of triples each representing a single datatype: its name, a potentially empty list of parameters, and a non empty list of constructors consisting of a name and a potentially empty list of fields
declareDataType :: String -> [String] -> [(String, [(String, String)])] -> Doc Source #
pretty print the declaration of a single datatype given its name, a potentially empty list of parameters, and a non empty list of constructors consisting of a name and a potentially empty list of fields
SMT function definitions
defineFun :: Doc -> [(Doc, Doc)] -> Doc -> Doc -> Doc Source #
pretty print the definition of a function given its name, a potentially empty list of arguments, a return type and a function body
defineFunRec :: Doc -> [(Doc, Doc)] -> Doc -> Doc -> Doc Source #
pretty print the definition of a recursive function given its name, a potentially empty list of arguments, a return type and a function body
defineFunsRec :: [(String, [(String, String)], String, Doc)] -> Doc Source #
pretty print the definition of the potentially mutually recursive functions provided in the argument list of triples each representing a single potentially recursive function: its name, a potentially empty list of arguments, a return type and a function body