ToString - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


SMTLIB

  

ToString

  

format expression as SMT-LIB string

 

Calling Sequence

Parameters

Options

Description

Supported functions and operators

Type inference and declaration

Examples

Compatibility

Calling Sequence

ToString(expr,options)

Parameters

expr

-

expression; expr to be encoded as SMT-LIB

options

-

(optional) options as specified below

Options

• 

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.

Description

• 

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 function from the list of supported functions whose arguments are SMT Boolean or algebraic expressions

• 

a sum, product, or constant integer power of SMT algebraic expressions.

Supported functions and operators

• 

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

&not

&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

 

Type inference and declaration

• 

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.

Examples

Generate an SMT-LIB query testing for satisfiability of this Boolean problem.

withSMTLIB&colon;

ToStringaxorbc

(declare-fun a () Bool) (declare-fun b () Bool) (declare-fun c () Bool) (assert (=> (xor a b) c)) (check-sat) (exit)

(1)

Generate an SMT-LIB query testing for finding a satisfying assignment to a randomly generated Boolean problem.

exprLogic:-Randomx&comma;y&comma;z&comma;form=CNF&comma;clauses=6&comma;literals=3&colon;

ToStringexpr&comma;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)

(2)

Generate an SMT-LIB query requesting a solution for the specified variables in this Diophantine problem over quantifier-free integer linear arithmetic.

ToStringx+y=3&comma;2x+3y=5&comma;logic=QF_LIA&comma;getvalue=x&comma;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)

(3)

Generate an SMT-LIB query requesting a proof of solvability for the preceding Diophantine problem example.

ToStringx+y=3&comma;2x+3y=5&comma;logic=QF_LIA&comma;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)

(4)

Generate an SMT-LIB query requesting an unsatisfiable core (that is, a proof of unsolvability) for the specified Boolean problem.

formula`and``or`x&comma;y&comma;z&comma;`or`x&comma;y&comma;notz&comma;`or`x&comma;noty&comma;z&comma;`or`x&comma;noty&comma;notz&comma;`or`notx&comma;y&comma;z&comma;`or`notx&comma;y&comma;notz&comma;`or`notx&comma;noty&comma;z&comma;`or`notx&comma;noty&comma;notz

formulaxoryorzandxoryornotzandxornotyorzandxornotyornotzandnotxoryorzandnotxoryornotzandnotxandyorzandnotxandyandz

(5)

ToStringformula&comma;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)

(6)

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).

ToStringaand2<bd<3.5&comma;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)

(7)

Compatibility

• 

The SMTLIB[ToString] command was introduced in Maple 2017.

• 

For more information on Maple 2017 changes, see Updates in Maple 2017.

See Also

SMTLIB