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

Online Help

All Products    Maple    MapleSim


Connectivity

 

SMTLIB

URL

YAML

SMTLIB

The SMTLIB package provides support for converting Maple expressions to input in the SMT-LIB language format.

SMT-LIB is an interface language frequently used by programs designed to solve SMT (Satisfiability Modulo Theories) problems.

 

The SMTLIB[ToString] command converts a Maple expression into SMT-LIB input which can then be fed as input into an SMT solver program. By default, the generated SMT-LIB script performs a simple satisfiability query.

Example 1: Generate an SMT-LIB script testing whether a logical formula has a satisfying assignment (that is, an assignment of values making the formula true).

expr  Importexample/3sat.cnf,base=datadir,variables=V1,V2,V3

exprV1orV3ornotV2andV2orV3ornotV1andV3ornotV1ornotV2

(1.1)

withSMTLIB

ToString

(1.2)

ToString expr 

(set-logic QF_UF) (declare-fun V1 () Bool) (declare-fun V2 () Bool) (declare-fun V3 () Bool) (assert (and (or V1 V3 (not V2)) (or V2 V3 (not V1)) (or V3 (not V1) (not V2)))) (check-sat) (exit)

(1.3)

If an explicit satisfying assignment is desired, we can optionally generate a script requesting the SMT solver to produce one (here, a set of values for V1, V2, V3 for which the formula is true).

ToString expr, getvalue=V1,V2,V3

(set-option :produce-models true) (set-logic QF_UF) (declare-fun V1 () Bool) (declare-fun V2 () Bool) (declare-fun V3 () Bool) (assert (and (or V1 V3 (not V2)) (or V2 V3 (not V1)) (or V3 (not V1) (not V2)))) (check-sat) (get-value (V1 V2 V3)) (exit)

(1.4)

In addition to Boolean-valued variables, SMT-LIB variables may also be numeric. The generated SMT-LIB requests a nontrivial solution in positive integers to the equation w3+x3=y3+z3. (When such a solution exists, the integer w3+x3 is known as a taxicab number, the smallest of which is 1729.)

ToString w3+x3=y3+z3, w>0,x>0,y>0,z>0,wy,wz,getvalue=w,x,y,z

(set-option :produce-models true) (set-logic QF_NIA) (declare-fun w () Int) (declare-fun x () Int) (declare-fun y () Int) (declare-fun z () Int) (assert (and (= (+ (* w w w) (* x x x)) (+ (* y y y) (* z z z))) (distinct w y) (distinct w z) (< 0 w) (< 0 x) (< 0 y) (< 0 z))) (check-sat) (get-value (w x y z)) (exit)

(1.5)

URL

The existing URL package has been extended with three new commands: URL[Delete], URL[Head], and URL[Put]. These correspond directly to the HTTP (Hypertext Transfer Protocol) commands DELETE, HEAD, and PUT, respectively.

The inclusion of Delete, Head, and Put in the URL package, along with the existing URL[Get] and URL[Post], enables Maple code to make use of REST (REpresentational State Transfer) web interfaces. These interfaces offer access and manipulation of online resources by use of a uniform set of stateless operations based on HTTP.

Example: The Head command issues an HTTP HEAD request. This requests a response from the server identical to that of a GET request, but without the body of the response. Among many other uses, this command may be used to confirm that a remote server is online and accepting requests.

withURL

Construct&comma;Delete&comma;Escape&comma;Get&comma;Head&comma;Parse&comma;Post&comma;Put&comma;Unescape

(2.1)

Head http://www.maplesoft.com/&comma;output&equals;headers&comma;content&comma;code

tableDate=Mon, 23 Jan 2017 22:17:11 GMT&comma;X-Powered-By=ASP.NET&comma;X-AspNet-Version=2.0.50727&comma;Cache-Control=private&comma;Content-Length=53676&comma;Content-Type=text/html; charset=utf-8&comma;Set-Cookie=ASP.NET_SessionId=b0eexnvcsrscup45x14dftid; path=/; HttpOnly&comma;Server=Microsoft-IIS/8.5,,200

(2.2)

YAML

The new YAML package allows import and export of files and strings in the YAML format, a lightweight file format for exchanging structured data.
The commands YAML[ParseFile] and YAML[ParseString] parse YAML files and strings, respectively, to Maple expressions. The inverse operation, conversion of Maple structures to YAML, is provided by YAML[ToString].

The general-purpose commands Import and Export have also been extended to support YAML.


Example: Import YAML data encoding the mailing address of Maplesoft headquarters.

yamlFile  FileTools:-JoinPathexample/address.yaml&comma; base&equals;datadir

T  YAML:-ParseFile yamlFile 

Ttableaddress=tablecity=Waterloo&comma;country=Canada&comma;province=ON&comma;streetAddress=615 Kumpf Drive&comma;postalCode=N2V 1K8&comma;companyName=Maplesoft&comma;phoneNumbers=tabletype=local&comma;number=+1 (519) 747-2373&comma;tabletype=toll-free&comma;number=+1 (800) 267-6583&comma;tabletype=fax&comma;number=+1 (519) 747-5284&comma;founded=1988

(3.1)

TcompanyName

Maplesoft

(3.2)

Taddresscity&comma; Taddresscountry

Waterloo,Canada

(3.3)