SMTLIB
ToString
format expression as SMT-LIB string
Calling Sequence
Parameters
Options
Description
Supported functions and operators
Type inference and declaration
Examples
Compatibility
ToString(expr,options)
expr
-
expression; expr to be encoded as SMT-LIB
options
(optional) options as specified below
getassignment = truefalse
Indicates whether the SMT-LIB script should include the (get-assignment) command, which instructs the SMT solver to return a list representing a satisfying assignment. Default is false.
getproof = truefalse
Indicates whether the SMT-LIB script should include the (get-proof) command, which instructs the SMT solver to produce a proof of unsatisfiability. Default is false.
getunsatcore = truefalse
Indicates whether the SMT-LIB script should include the (get-unsat-core) command, which instructs the SMT solver to produce an unsatisfiable core if the input is unsatisfiable. Default is false.
getvalue = list
Indicates that the SMT-LIB script should request a satisfying value for each of the names in this list.
logic = string or the symbol auto
The value of option logic is a string which must correspond to one of the following logic names defined by the SMT-LIB standard: "QF_UF", "QF_LIA", "QF_NIA", "QF_LRA", "QF_NRA", "LIA", and "LRA".
For an explanation of these logics, see Formats,SMTLIB.
When logic=auto, the default, the logic is inferred automatically from the input expression.
The ToString(expr) command translates the expression expr to the SMT-LIB input format, expressed as a Maple string.
The input expr must be a valid SMT Boolean expression; that is:
one of the values true or false
an equation or inequation whose left- and right-hand sides are valid SMT Boolean or algebraic expressions
an inequality whose left- and right-hand sides are valid SMT algebraic expressions
a function from the list of supported functions whose arguments are SMT Boolean or algebraic expressions
a set or Boolean combination of SMT Boolean expressions
An SMT algebraic expression is:
an integer or real constant
a sum, product, or constant integer power of SMT algebraic expressions.
The ToString command supports expressions which are expressible in the SMT-LIB language using the Core and Reals_Ints theories.
This consists of symbols and indexed names and numeric literals (integers, fractions, and floating-point numbers), and expressions formed from these using the following operators and functions:
Supported operators
+
*
^
=
<>
<=
>
>=
&+
&*
&^
&and
&iff
&implies
&nand
&nor
¬
&or
&xor
and
implies
mod
not
or
xor
Supported functions
abs
And
ceil
exists
floor
forall
if
ifelse
Implies
iquo
irem
max
min
modp
Or
piecewise
sign
trunc
Xor
As the SMT-LIB format requires each symbol to have a declared type, ToString will attempt to infer types for any unassigned names occurring in expr.
A type for a particular variable can be forced by using the assume or assuming commands to place an appropriate assumption on the variable.
Generate an SMT-LIB query testing for satisfiability of this Boolean problem.
with⁡SMTLIB:
ToString⁡axorb⇒c
(declare-fun a () Bool) (declare-fun b () Bool) (declare-fun c () Bool) (assert (=> (xor a b) c)) (check-sat) (exit)
Generate an SMT-LIB query testing for finding a satisfying assignment to a randomly generated Boolean problem.
expr≔Logic:-Random⁡x,y,z,form=CNF,clauses=6,literals=3:
ToString⁡expr,getassignment
(set-option :produce-assignments true) (declare-fun x () Bool) (declare-fun y () Bool) (declare-fun z () Bool) (assert (and (or x y z) (or x z (not y)) (or y z (not x)) (or y (not x) (not z)) (or z (not x) (not y)) (or (not x) (not y) (not z)))) (check-sat) (get-assignment) (exit)
Generate an SMT-LIB query requesting a solution for the specified variables in this Diophantine problem over quantifier-free integer linear arithmetic.
ToString⁡x+y=3,2⁢x+3⁢y=5,logic=QF_LIA,getvalue=x,y
(set-option :produce-models true) (set-logic QF_LIA) (declare-fun x () Int) (declare-fun y () Int) (assert (and (= (+ x y) 3) (= (+ (* x 2) (* y 3)) 5))) (check-sat) (get-value (x y)) (exit)
Generate an SMT-LIB query requesting a proof of solvability for the preceding Diophantine problem example.
ToString⁡x+y=3,2⁢x+3⁢y=5,logic=QF_LIA,getproof
(set-option :produce-proofs true) (set-logic QF_LIA) (declare-fun x () Int) (declare-fun y () Int) (assert (and (= (+ x y) 3) (= (+ (* x 2) (* y 3)) 5))) (check-sat) (get-proof) (exit)
Generate an SMT-LIB query requesting an unsatisfiable core (that is, a proof of unsolvability) for the specified Boolean problem.
formula≔`and`⁡`or`⁡x,y,z,`or`⁡x,y,notz,`or`⁡x,noty,z,`or`⁡x,noty,notz,`or`⁡notx,y,z,`or`⁡notx,y,notz,`or`⁡notx,noty,z,`or`⁡notx,noty,notz
formula≔xoryorzandxoryornotzandxornotyorzandxornotyornotzandnotxoryorzandnotxoryornotzandnotxandyorzandnotxandyandz
ToString⁡formula,getunsatcoreassumingboolean
(set-option :produce-unsat-cores true) (declare-fun x () Bool) (declare-fun y () Bool) (declare-fun z () Bool) (assert (and (or x y z) (or x y (not z)) (or x (not y) z) (or x (not y) (not z)) (or (not x) y z) (or (not x) y (not z)) (or (not (and x y)) z) (not (and x y z)))) (check-sat) (get-unsat-core) (exit)
Generate an SMT-LIB query testing for satisfiability of this problem over quantifier-free real arithmetic, in which the types of each variable are specified explicitly (not inferred).
ToString⁡aand2<b⇒d<3.5,logic=QF_LRAassuminga::boolean,b::integer,c::numeric
(set-logic QF_LRA) (declare-fun a () Bool) (declare-fun b () Int) (declare-fun d () Real) (assert (=> (and a (< 2 b)) (< d 3.5))) (check-sat) (exit)
The SMTLIB[ToString] command was introduced in Maple 2017.
For more information on Maple 2017 changes, see Updates in Maple 2017.
See Also
Download Help Document