<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://cvc4.stanford.edu/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tianyi</id>
		<title>CVC4 - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://cvc4.stanford.edu/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tianyi"/>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/wiki/Special:Contributions/Tianyi"/>
		<updated>2026-04-04T12:58:13Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.4</generator>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5502</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5502"/>
				<updated>2017-01-24T21:56:47Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentative and &lt;br /&gt;
might change later.&lt;br /&gt;
&lt;br /&gt;
The basic logic is &amp;lt;code&amp;gt;QF_S&amp;lt;/code&amp;gt; consisting of quantifier-free formulas &lt;br /&gt;
over just the theory of strings, e.g.:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
A summary of the relevant syntax for strings in the SMT2, CVC, and API is below.  Note that regular expressions are not yet supported in the CVC format.  More details on these operators can be found later in this page.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse:collapse&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
! CVC language&lt;br /&gt;
! SMTLIB language&lt;br /&gt;
! C++ API&lt;br /&gt;
|-&lt;br /&gt;
| Logic string&lt;br /&gt;
| Not needed&lt;br /&gt;
| preappend &amp;quot;S&amp;quot; for strings&lt;br /&gt;
| preappend &amp;quot;S&amp;quot; for strings&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_'''S'''LIA)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''S'''LIA&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String Sort&lt;br /&gt;
| &amp;lt;code&amp;gt;STRING&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.stringType();&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String literals&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;abcdef&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;abcdef&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst( '''::CVC4::String'''(&amp;quot;abcdef&amp;quot;) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Concatenation&lt;br /&gt;
| &amp;lt;code&amp;gt;'''CONCAT'''( X1, ..., Xn )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.++''' X1 ... Xn )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_CONCAT''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Length&lt;br /&gt;
| &amp;lt;code&amp;gt;'''LENGTH'''( x )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.len''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_LENGTH''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String contains &lt;br /&gt;
| &amp;lt;code&amp;gt;'''CONTAINS'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.contains''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRCTN''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Index of&lt;br /&gt;
| &amp;lt;code&amp;gt;'''INDEXOF'''( X, Y, N )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.indexof''' X Y N)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRIDOF''', X, Y, N);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACE'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replace''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPL''', X, Y, Z);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Substring&lt;br /&gt;
| &amp;lt;code&amp;gt;'''SUBSTR'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Prefix of &lt;br /&gt;
| &amp;lt;code&amp;gt;'''PREFIXOF'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.prefixof''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_PREFIX''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Suffix of&lt;br /&gt;
| &amp;lt;code&amp;gt;'''SUFFIXOF'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.suffixof''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUFFIX''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_INTEGER'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.int''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOI''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''INTEGER_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''int.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_ITOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer (16-bit)&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_UINT16'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.u16''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOU16''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer (16-bit) to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UINT16_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''u16.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_U16TOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer (32-bit)&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_UINT32'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.u32''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOU32''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer (32-bit) to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UINT32_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''u32.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_U32TOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Character at &lt;br /&gt;
| &amp;lt;code&amp;gt;'''CHARAT'''( X, N )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.at''' X N)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_CHARAT''', X, N);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression sort&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;RegExp&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.regExpType();&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership in regular expression&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.in.re''' X R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_IN_REGEXP''', X, R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to regular expression&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.re''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_TO_REGEXP''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression concatenation&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.++''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_CONCAT''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression union&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.union''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_UNION''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.inter''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_INTER''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression Kleene star&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.*''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_STAR''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression plus&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.+''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_PLUS''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression option&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.opt''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_OPT''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
Some functions in the theory are have only experimental support currently and &lt;br /&gt;
are disabled by default (even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic:&lt;br /&gt;
To use them:&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
The solver can be run in ''finite model finding mode'' which guarantees &lt;br /&gt;
termination for satisfiable problems. &lt;br /&gt;
This mode is disabled by default. To enable it:&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
Note that in this mode the solver is much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it only as a fall back option when the default mode fails &lt;br /&gt;
to find a solution with a reasonably large timeout.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Alphabet==&lt;br /&gt;
Currently, the solver's theory is based on an alphabet consisting of the 256 &lt;br /&gt;
characters from (8-bit) Extended ASCII. &lt;br /&gt;
Since there are several versions of Extended ASCII, we allow string constants &lt;br /&gt;
to contain only ''printable US ASCII characters'', which are encoded &lt;br /&gt;
in the same way in all Extended ASCII versions.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The alphabet will change to the one prescribed by the SMT-LIB standard&lt;br /&gt;
once there is one.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences in String Constants==&lt;br /&gt;
String constants are denoted by SMT-LIB string literals consisting of sequences of printable characters delimited by double-quotes (&amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
We support escape sequences used in most programming languages &lt;br /&gt;
to represent non-printable characters. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\0&amp;lt;/code&amp;gt; … &amp;lt;code&amp;gt;\9&amp;lt;/code&amp;gt;&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\r&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\t&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\v&amp;lt;/code&amp;gt;&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;''ooo''&lt;br /&gt;
| encodes a single ASCII character where ''ooo'' consists of exactly three digits in the octal encoding of the character (from 0 to 377). For example, &amp;lt;code&amp;gt;\101&amp;lt;/code&amp;gt; represents &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;. '''Note:''' going beyond value 377 might give unexpected results. For instance, &amp;lt;code&amp;gt;\437&amp;lt;/code&amp;gt; will be translated in the two-character string &amp;lt;code&amp;gt;#7&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\x&amp;lt;/code&amp;gt;''NN''&lt;br /&gt;
| encodes a single ASCII character, where ''NN'' consists of exactly two digits in the exadecimal encoding of the character.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (&amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;) is silently ignored when it is followed by a sequence of characters not recognized as an escape sequence. For example, &amp;lt;code&amp;gt;\$ &amp;lt;/code&amp;gt;, say, is parsed as if it was just &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &lt;br /&gt;
When CVC4 outputs a string constant, a non-printable/extended ASCII character is printed in the exadecimal format &amp;lt;code&amp;gt;\x&amp;lt;/code&amp;gt;''NN'', except for the character denoted by the escape sequences &amp;lt;code&amp;gt;\a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\r&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\t&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\v&amp;lt;/code&amp;gt;, which are printed using those escape sequences.&lt;br /&gt;
&lt;br /&gt;
'''Note''': &lt;br /&gt;
These escape sequences are specific to string constants in the theory of strings. They are 'not' escape sequences in SMT-LIB 2 per se.&lt;br /&gt;
SMT-LIB 2.5 has only one escape sequence for string literals: &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;, &lt;br /&gt;
which denotes the double quotes character. &lt;br /&gt;
This means that a string literal like  &amp;lt;code&amp;gt;&amp;quot;a&amp;quot;&amp;quot;c&amp;quot;&amp;lt;/code&amp;gt; is read by the solver as the string constant consisting of the characters &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;.&lt;br /&gt;
The same constant can be entered as &amp;lt;code&amp;gt;&amp;quot;a\042c&amp;quot;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;quot;a\x22c&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Theory Signature==&lt;br /&gt;
To define a string variable, i.e., a free string constant:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
Alternatively:&lt;br /&gt;
  (declare-const x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer.&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are integers.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (Coming soon.)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. If i is negative or greater than or equal to the length of s, then (str.at s i) returns the empty string.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. If i is negative, it returns the empty string; otherwise, it returns the substring (of s) that begins at the specified index i and extends to the length j (or to the last character of s if the length of s is shorter than i + j).&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for does not occur.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is string of digits; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Extensions=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, termination is not guaranteed; however, users can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
The current version of the solver supports ASCII characters only. We might move on to UNICODE in future versions.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
==Unsat Cores==&lt;br /&gt;
The string solver supports the generation of unsatisfiable cores. &lt;br /&gt;
As with other subsolvers though, you must enable proofs at configuration time, &lt;br /&gt;
and then run CVC with &amp;quot;--dump-unsat-cores&amp;quot; flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Nestan Tsiskaridze, Cesare Tinelli, Clark Barrett, and Morgan Deters. [http://dl.acm.org/citation.cfm?id=2994123 An efficient SMT solver for string constraints]. Formal Methods in System Design. 2016. &lt;br /&gt;
* Tianyi Liang, Nestan Tsiskaridze, Andrew Reynolds, Cesare Tinelli, and Clark Barrett. [http://link.springer.com/chapter/10.1007/978-3-319-24246-0_9 A Decision Procedure for Regular Membership and Length Constraints over Unbounded Strings]. In Proceedings of the 10th International Symposium on Frontiers of Combining Systems (FroCoS'15), Wroclaw, Poland, 2015.&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5501</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5501"/>
				<updated>2017-01-24T21:55:00Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentative and &lt;br /&gt;
might change later.&lt;br /&gt;
&lt;br /&gt;
The basic logic is &amp;lt;code&amp;gt;QF_S&amp;lt;/code&amp;gt; consisting of quantifier-free formulas &lt;br /&gt;
over just the theory of strings, e.g.:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
A summary of the relevant syntax for strings in the SMT2, CVC, and API is below.  Note that regular expressions are not yet supported in the CVC format.  More details on these operators can be found later in this page.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse:collapse&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
! CVC language&lt;br /&gt;
! SMTLIB language&lt;br /&gt;
! C++ API&lt;br /&gt;
|-&lt;br /&gt;
| Logic string&lt;br /&gt;
| Not needed&lt;br /&gt;
| preappend &amp;quot;S&amp;quot; for strings&lt;br /&gt;
| preappend &amp;quot;S&amp;quot; for strings&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_'''S'''LIA)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''S'''LIA&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String Sort&lt;br /&gt;
| &amp;lt;code&amp;gt;STRING&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.stringType();&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String literals&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;abcdef&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;abcdef&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst( '''::CVC4::String'''(&amp;quot;abcdef&amp;quot;) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Concatenation&lt;br /&gt;
| &amp;lt;code&amp;gt;'''CONCAT'''( X1, ..., Xn )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.++''' X1 ... Xn )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_CONCAT''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Length&lt;br /&gt;
| &amp;lt;code&amp;gt;'''LENGTH'''( x )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.len''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_LENGTH''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String contains &lt;br /&gt;
| &amp;lt;code&amp;gt;'''CONTAINS'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.contains''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRCTN''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Index of&lt;br /&gt;
| &amp;lt;code&amp;gt;'''INDEXOF'''( X, Y, N )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.indexof''' X Y N)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRIDOF''', X, Y, N);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACE'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replace''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPL''', X, Y, Z);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Substring&lt;br /&gt;
| &amp;lt;code&amp;gt;'''SUBSTR'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Prefix of &lt;br /&gt;
| &amp;lt;code&amp;gt;'''PREFIXOF'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.prefixof''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_PREFIX''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Suffix of&lt;br /&gt;
| &amp;lt;code&amp;gt;'''SUFFIXOF'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.suffixof''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUFFIX''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_INTEGER'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.int''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOI''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''INTEGER_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''int.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_ITOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer (16-bit)&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_UINT16'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.u16''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOU16''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer (16-bit) to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UINT16_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''u16.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_U16TOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer (32-bit)&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_UINT32'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.u32''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOU32''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer (32-bit) to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UINT32_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''u32.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_U32TOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Character at &lt;br /&gt;
| &amp;lt;code&amp;gt;'''CHARAT'''( X, N )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.at''' X N)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_CHARAT''', X, N);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression sort&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;RegExp&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.regExpType();&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership in regular expression&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.in.re''' X R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_IN_REGEXP''', X, R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to regular expression&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.re''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_TO_REGEXP''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression concatenation&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.++''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_CONCAT''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression union&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.union''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_UNION''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.inter''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_INTER''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression Kleene star&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.*''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_STAR''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression plus&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.+''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_PLUS''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression option&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.opt''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_OPT''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
Some functions in the theory are have only experimental support currently and &lt;br /&gt;
are disabled by default (even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic:&lt;br /&gt;
To use them:&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
The solver can be run in ''finite model finding mode'' which guarantees &lt;br /&gt;
termination for satisfiable problems. &lt;br /&gt;
This mode is disabled by default. To enable it:&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
Note that in this mode the solver is much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it only as a fall back option when the default mode fails &lt;br /&gt;
to find a solution with a reasonably large timeout.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Alphabet==&lt;br /&gt;
Currently, the solver's theory is based on an alphabet consisting of the 256 &lt;br /&gt;
characters from (8-bit) Extended ASCII. &lt;br /&gt;
Since there are several versions of Extended ASCII, we allow string constants &lt;br /&gt;
to contain only ''printable US ASCII characters'', which are encoded &lt;br /&gt;
in the same way in all Extended ASCII versions.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The alphabet will change to the one prescribed by the SMT-LIB standard&lt;br /&gt;
once there is one.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences in String Constants==&lt;br /&gt;
String constants are denoted by SMT-LIB string literals consisting of sequences of printable characters delimited by double-quotes (&amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
We support escape sequences used in most programming languages &lt;br /&gt;
to represent non-printable characters. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\0&amp;lt;/code&amp;gt; … &amp;lt;code&amp;gt;\9&amp;lt;/code&amp;gt;&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\r&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\t&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\v&amp;lt;/code&amp;gt;&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;''ooo''&lt;br /&gt;
| encodes a single ASCII character where ''ooo'' consists of exactly three digits in the octal encoding of the character (from 0 to 377). For example, &amp;lt;code&amp;gt;\101&amp;lt;/code&amp;gt; represents &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;. '''Note:''' going beyond value 377 might give unexpected results. For instance, &amp;lt;code&amp;gt;\437&amp;lt;/code&amp;gt; will be translated in the two-character string &amp;lt;code&amp;gt;#7&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\x&amp;lt;/code&amp;gt;''NN''&lt;br /&gt;
| encodes a single ASCII character, where ''NN'' consists of exactly two digits in the exadecimal encoding of the character.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (&amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;) is silently ignored when it is followed by a sequence of characters not recognized as an escape sequence. For example, &amp;lt;code&amp;gt;\$ &amp;lt;/code&amp;gt;, say, is parsed as if it was just &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &lt;br /&gt;
When CVC4 outputs a string constant, a non-printable/extended ASCII character is printed in the exadecimal format &amp;lt;code&amp;gt;\x&amp;lt;/code&amp;gt;''NN'', except for the character denoted by the escape sequences &amp;lt;code&amp;gt;\a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\r&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\t&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\v&amp;lt;/code&amp;gt;, which are printed using those escape sequences.&lt;br /&gt;
&lt;br /&gt;
'''Note''': &lt;br /&gt;
These escape sequences are specific to string constants in the theory of strings. They are 'not' escape sequences in SMT-LIB 2 per se.&lt;br /&gt;
SMT-LIB 2.5 has only one escape sequence for string literals: &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;, &lt;br /&gt;
which denotes the double quotes character. &lt;br /&gt;
This means that a string literal like  &amp;lt;code&amp;gt;&amp;quot;a&amp;quot;&amp;quot;c&amp;quot;&amp;lt;/code&amp;gt; is read by the solver as the string constant consisting of the characters &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;.&lt;br /&gt;
The same constant can be entered as &amp;lt;code&amp;gt;&amp;quot;a\042c&amp;quot;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;quot;a\x22c&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Theory Signature==&lt;br /&gt;
To define a string variable, i.e., a free string constant:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
Alternatively:&lt;br /&gt;
  (declare-const x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer.&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are integers.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (Coming soon.)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. If i is negative or greater than or equal to the length of s, then (str.at s i) returns the empty string.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. If i is negative, it returns the empty string; otherwise, it returns the substring (of s) that begins at the specified index i and extends to the length j (or to the last character of s if the length of s is shorter than i + j).&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for does not occur.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is string of digits; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Extensions=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, termination is not guaranteed; however, users can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
The current version of the solver supports ASCII characters only. We might move on to UNICODE in future versions.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
==Unsat Cores==&lt;br /&gt;
The string solver supports the generation of unsatisfiable cores. &lt;br /&gt;
As with other subsolvers though, you must enable proofs at configuration time, &lt;br /&gt;
and then run CVC with &amp;quot;--dump-unsat-cores&amp;quot; flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Nestan Tsiskaridze, Cesare Tinelli, Clark Barrett, and Morgan Deters. An efficient SMT solver for string constraints. Formal Methods in System Design. 2016. &lt;br /&gt;
* Tianyi Liang, Nestan Tsiskaridze, Andrew Reynolds, Cesare Tinelli, and Clark Barrett. A Decision Procedure for Regular Membership and Length Constraints over Unbounded Strings. In Proceedings of the 10th International Symposium on Frontiers of Combining Systems (FroCoS'15), Wroclaw, Poland, 2015.&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5500</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5500"/>
				<updated>2017-01-24T21:53:11Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Experimental Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentative and &lt;br /&gt;
might change later.&lt;br /&gt;
&lt;br /&gt;
The basic logic is &amp;lt;code&amp;gt;QF_S&amp;lt;/code&amp;gt; consisting of quantifier-free formulas &lt;br /&gt;
over just the theory of strings, e.g.:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
A summary of the relevant syntax for strings in the SMT2, CVC, and API is below.  Note that regular expressions are not yet supported in the CVC format.  More details on these operators can be found later in this page.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;0&amp;quot; style=&amp;quot;border-collapse:collapse&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
! CVC language&lt;br /&gt;
! SMTLIB language&lt;br /&gt;
! C++ API&lt;br /&gt;
|-&lt;br /&gt;
| Logic string&lt;br /&gt;
| Not needed&lt;br /&gt;
| preappend &amp;quot;S&amp;quot; for strings&lt;br /&gt;
| preappend &amp;quot;S&amp;quot; for strings&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_'''S'''LIA)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''S'''LIA&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String Sort&lt;br /&gt;
| &amp;lt;code&amp;gt;STRING&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.stringType();&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String literals&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;abcdef&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;quot;abcdef&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst( '''::CVC4::String'''(&amp;quot;abcdef&amp;quot;) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Concatenation&lt;br /&gt;
| &amp;lt;code&amp;gt;'''CONCAT'''( X1, ..., Xn )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.++''' X1 ... Xn )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_CONCAT''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Length&lt;br /&gt;
| &amp;lt;code&amp;gt;'''LENGTH'''( x )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.len''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_LENGTH''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String contains &lt;br /&gt;
| &amp;lt;code&amp;gt;'''CONTAINS'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.contains''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRCTN''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Index of&lt;br /&gt;
| &amp;lt;code&amp;gt;'''INDEXOF'''( X, Y, N )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.indexof''' X Y N)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRIDOF''', X, Y, N);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACE'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replace''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPL''', X, Y, Z);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Substring&lt;br /&gt;
| &amp;lt;code&amp;gt;'''SUBSTR'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Prefix of &lt;br /&gt;
| &amp;lt;code&amp;gt;'''PREFIXOF'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.prefixof''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_PREFIX''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Suffix of&lt;br /&gt;
| &amp;lt;code&amp;gt;'''SUFFIXOF'''( X, Y )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.suffixof''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUFFIX''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_INTEGER'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.int''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOI''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''INTEGER_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''int.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_ITOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer (16-bit)&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_UINT16'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.u16''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOU16''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer (16-bit) to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UINT16_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''u16.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_U16TOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to Integer (32-bit)&lt;br /&gt;
| &amp;lt;code&amp;gt;'''STRING_TO_UINT32'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.u32''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STOU32''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Integer (32-bit) to String&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UINT32_TO_STRING'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''u32.to.str''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_U32TOS''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Character at &lt;br /&gt;
| &amp;lt;code&amp;gt;'''CHARAT'''( X, N )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.at''' X N)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_CHARAT''', X, N);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression sort&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;RegExp&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.regExpType();&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership in regular expression&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.in.re''' X R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_IN_REGEXP''', X, R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String to regular expression&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.to.re''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_TO_REGEXP''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression concatenation&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.++''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_CONCAT''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression union&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.union''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_UNION''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.inter''' R1 ... Rn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_INTER''', R1, ..., Rn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression Kleene star&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.*''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_STAR''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression plus&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.+''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_PLUS''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Regular expression option&lt;br /&gt;
| &amp;lt;code&amp;gt;n/a&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''re.opt''' R)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::REGEXP_OPT''', R);&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
Some functions in the theory are have only experimental support currently and &lt;br /&gt;
are disabled by default (even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic:&lt;br /&gt;
To use them:&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
The solver can be run in ''finite model finding mode'' which guarantees &lt;br /&gt;
termination for satisfiable problems. &lt;br /&gt;
This mode is disabled by default. To enable it:&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
Note that in this mode the solver is much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it only as a fall back option when the default mode fails &lt;br /&gt;
to find a solution with a reasonably large timeout.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Alphabet==&lt;br /&gt;
Currently, the solver's theory is based on an alphabet consisting of the 256 &lt;br /&gt;
characters from (8-bit) Extended ASCII. &lt;br /&gt;
Since there are several versions of Extended ASCII, we allow string constants &lt;br /&gt;
to contain only ''printable US ASCII characters'', which are encoded &lt;br /&gt;
in the same way in all Extended ASCII versions.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The alphabet will change to the one prescribed by the SMT-LIB standard&lt;br /&gt;
once there is one.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences in String Constants==&lt;br /&gt;
String constants are denoted by SMT-LIB string literals consisting of sequences of printable characters delimited by double-quotes (&amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
We support escape sequences used in most programming languages &lt;br /&gt;
to represent non-printable characters. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\0&amp;lt;/code&amp;gt; … &amp;lt;code&amp;gt;\9&amp;lt;/code&amp;gt;&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\r&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\t&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\v&amp;lt;/code&amp;gt;&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;''ooo''&lt;br /&gt;
| encodes a single ASCII character where ''ooo'' consists of exactly three digits in the octal encoding of the character (from 0 to 377). For example, &amp;lt;code&amp;gt;\101&amp;lt;/code&amp;gt; represents &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;. '''Note:''' going beyond value 377 might give unexpected results. For instance, &amp;lt;code&amp;gt;\437&amp;lt;/code&amp;gt; will be translated in the two-character string &amp;lt;code&amp;gt;#7&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;\x&amp;lt;/code&amp;gt;''NN''&lt;br /&gt;
| encodes a single ASCII character, where ''NN'' consists of exactly two digits in the exadecimal encoding of the character.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (&amp;lt;code&amp;gt;\&amp;lt;/code&amp;gt;) is silently ignored when it is followed by a sequence of characters not recognized as an escape sequence. For example, &amp;lt;code&amp;gt;\$ &amp;lt;/code&amp;gt;, say, is parsed as if it was just &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &lt;br /&gt;
When CVC4 outputs a string constant, a non-printable/extended ASCII character is printed in the exadecimal format &amp;lt;code&amp;gt;\x&amp;lt;/code&amp;gt;''NN'', except for the character denoted by the escape sequences &amp;lt;code&amp;gt;\a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\r&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\t&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;\v&amp;lt;/code&amp;gt;, which are printed using those escape sequences.&lt;br /&gt;
&lt;br /&gt;
'''Note''': &lt;br /&gt;
These escape sequences are specific to string constants in the theory of strings. They are 'not' escape sequences in SMT-LIB 2 per se.&lt;br /&gt;
SMT-LIB 2.5 has only one escape sequence for string literals: &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;, &lt;br /&gt;
which denotes the double quotes character. &lt;br /&gt;
This means that a string literal like  &amp;lt;code&amp;gt;&amp;quot;a&amp;quot;&amp;quot;c&amp;quot;&amp;lt;/code&amp;gt; is read by the solver as the string constant consisting of the characters &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;.&lt;br /&gt;
The same constant can be entered as &amp;lt;code&amp;gt;&amp;quot;a\042c&amp;quot;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;quot;a\x22c&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Theory Signature==&lt;br /&gt;
To define a string variable, i.e., a free string constant:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
Alternatively:&lt;br /&gt;
  (declare-const x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer.&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are integers.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (Coming soon.)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. If i is negative or greater than or equal to the length of s, then (str.at s i) returns the empty string.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. If i is negative, it returns the empty string; otherwise, it returns the substring (of s) that begins at the specified index i and extends to the length j (or to the last character of s if the length of s is shorter than i + j).&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for does not occur.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is string of digits; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Extensions=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, termination is not guaranteed; however, users can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
The current version of the solver supports ASCII characters only. We might move on to UNICODE in future versions.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
==Unsat Cores==&lt;br /&gt;
The string solver supports the generation of unsatisfiable cores. &lt;br /&gt;
As with other subsolvers though, you must enable proofs at configuration time, &lt;br /&gt;
and then run CVC with &amp;quot;--dump-unsat-cores&amp;quot; flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5372</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5372"/>
				<updated>2015-03-20T17:15:50Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5 [http://smt-lib.org/papers/smt-lib-reference-v2.5-draft-2.pdf draft], instead of v2.0. The major difference is the definition of escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our '''latest developing version'''.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default, even in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5371</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5371"/>
				<updated>2015-03-20T17:04:45Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is the definition of escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our '''latest developing version'''.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default, even in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5370</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5370"/>
				<updated>2015-03-20T17:04:20Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is the definition of escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default, even in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5369</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5369"/>
				<updated>2015-03-20T17:02:19Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default, even in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5368</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5368"/>
				<updated>2015-03-20T17:00:57Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5367</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5367"/>
				<updated>2015-03-20T17:00:11Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5366</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5366"/>
				<updated>2015-03-20T16:59:38Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in [http://cvc4.cs.nyu.edu/wiki/Tutorials]&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5365</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5365"/>
				<updated>2015-03-20T16:57:42Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* JAVA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5364</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5364"/>
				<updated>2015-03-20T16:56:23Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==JAVA==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5363</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5363"/>
				<updated>2015-03-20T16:54:50Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==JAVA==&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5362</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5362"/>
				<updated>2015-03-20T16:51:43Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
* C++&lt;br /&gt;
* JAVA&lt;br /&gt;
&lt;br /&gt;
=Reference=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5361</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5361"/>
				<updated>2015-03-20T16:50:02Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5360</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5360"/>
				<updated>2015-03-20T16:41:26Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Decision Procedures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT)] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of a formula with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets]]&lt;br /&gt;
&lt;br /&gt;
CVC4 has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* support for quantifiers through heuristic instantiation;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest-unstable/copying.html license]).&lt;br /&gt;
&lt;br /&gt;
=Web site=&lt;br /&gt;
&lt;br /&gt;
For more information and the latest news about CVC4, visit the [http://cvc4.cs.nyu.edu CVC4 web site].&lt;br /&gt;
&lt;br /&gt;
=Decision Procedures=&lt;br /&gt;
* Architecture&lt;br /&gt;
** See the [http://dl.acm.org/citation.cfm?id=2032319 CVC4 tool paper].&lt;br /&gt;
* Arithmetic&lt;br /&gt;
** CVC4 solves linear real arithmetic using an implementation of [http://link.springer.com/chapter/10.1007%2F11817963_11? Simplex for DPLL(T)]. For a more complete introduction see the [http://yices.csl.sri.com/sri-csl-06-01.pdf tech report].&lt;br /&gt;
** The linear arithmetic module includes heuristics from [http://eprints-phd.biblio.unitn.it/166/2/thesis.pdf Section 2.5 of Alberto Griggio's thesis] and a few currently unpublished ones.&lt;br /&gt;
** Integers are currently handled by first solving the real relaxation of the constraints, and then using a combination of [http://www.cs.wm.edu/~idillig/cav2009.pdf Cuts from Proofs] and branching to ensure integer solutions.  This approach and the equational solver  used are described in [https://es.fbk.eu/people/griggio/papers/jsat12.pdf A Practical Approach to Satisfiability Modulo Linear Integer Arithmetic].&lt;br /&gt;
** A technical report is planned to explain a number of small details and extensions including analysis to improve simplex's conflicts, handling disequalities, supporting model generation in CVC4's combination framework, heuristically propagating equalities over sharing terms, tableau row based propagation, and terminating simplex with unknown.&lt;br /&gt;
** Non-linear arithmetic support is currently rudimentary to non-existent. In CVC4 v1.0, non-linearity is handled by abstracting monomials as unique new variables.  We plan on implementing [http://cs.nyu.edu/~dejan/papers/jovanovic-ijcar2012.pdf Solving Non-Linear Arithmetic] this spring.&lt;br /&gt;
* Arrays&lt;br /&gt;
** Arrays are implemented in a manner inspired by the [http://research.microsoft.com/en-us/um/people/leonardo/files/fmcad09.pdf Generalized, efficient array decision procedures] paper with a few major modifications.&lt;br /&gt;
* Bitvectors&lt;br /&gt;
** Bitvectors is implemented primarily via a lazy schema for bitblasting. See [http://eprints-phd.biblio.unitn.it/345/ Anders Franzen's thesis chapter 3].&lt;br /&gt;
* Combination&lt;br /&gt;
** Theory combination is based on the care graph framework described in both [http://cs.nyu.edu/~dejan/papers/jovanovic-fmsd2012.pdf Being careful about theory combination] and [http://cs.nyu.edu/~dejan/papers/jovanovic-frocos2011.pdf Sharing is Caring: Combination of Theories].&lt;br /&gt;
* Datatypes&lt;br /&gt;
** CVC4 implements [http://cs.nyu.edu/acsys/pubs/BST07.ps An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** An overall description of the quantifier framework is given here [http://www.divms.uiowa.edu/~ajreynol/pres-comp12.pdf].&lt;br /&gt;
** Rewrite rules [citation?]&lt;br /&gt;
** Finite model finding is described in [http://www.divms.uiowa.edu/~ajreynol/pres-fmf12.pdf this presentation].&lt;br /&gt;
* SAT Solver&lt;br /&gt;
** The main sat solver is based on [http://minisat.se/ minisat v2.2.0].&lt;br /&gt;
** Additionally, we (optionally, and enabled by default for certain theories) use non-clausal analysis to cut down search space of minisat. For more details see the article [http://cs.nyu.edu/~kshitij/articles/cvc4-branching-heuristic.pdf A branching heuristic in CVC4].&lt;br /&gt;
* Sets&lt;br /&gt;
** Adaptation of tableau-based decision procedure described [http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.10.5176 here].&lt;br /&gt;
* Strings&lt;br /&gt;
** Original approach described in our [http://www.cs.nyu.edu/~barrett/pubs/LRT+14.pdf CAV 2014 paper: A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions]&lt;br /&gt;
* Uninterpreted functions&lt;br /&gt;
** UF (without cardinality) is handled in a manner inspired by [http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.70.1745 Simplify's tech report].&lt;br /&gt;
** UF + cardinality is described [http://www.divms.uiowa.edu/~ajreynol/pres-fmf12.pdf this presentation] and is used for finite model finding.&lt;br /&gt;
&lt;br /&gt;
=History of CVC=&lt;br /&gt;
&lt;br /&gt;
[[File:svc.gif|thumb|border|100px|The SVC logo.]]&lt;br /&gt;
[[File:cvc3_logo.jpg|thumb|border|100px|The CVC3 logo.]]&lt;br /&gt;
[[File:cvc3_night_logo.png|thumb|border|100px|The CVC3 &amp;quot;by night&amp;quot; logo, used for nightly builds and regressions.]]&lt;br /&gt;
[[File:cvc3cvc4.png|thumb|border|100px|An early CVC4 logo.]]&lt;br /&gt;
&lt;br /&gt;
The Cooperating Validity Checker series has a long history.  The&lt;br /&gt;
Stanford Validity Checker (SVC) came first in 1996, incorporating&lt;br /&gt;
theories and its own SAT solver.  Its successor, the Cooperating&lt;br /&gt;
Validity Checker (CVC), had a more optimized internal design, produced&lt;br /&gt;
proofs, used the Chaff SAT solver, and featured a number of usability&lt;br /&gt;
enhancements.  Its name comes from the cooperative nature of decision&lt;br /&gt;
procedures in Nelson-Oppen theory combination, which share amongst&lt;br /&gt;
each other equalities between shared terms.  CVC Lite, first made&lt;br /&gt;
available in 2003, was a rewrite of CVC that attempted to make CVC&lt;br /&gt;
more flexible (hence the &amp;quot;lite&amp;quot;) while extending the feature set: CVC&lt;br /&gt;
Lite supported quantifiers where its predecessors did not.  CVC3 was a&lt;br /&gt;
major overhaul of portions of CVC Lite: it added better decision&lt;br /&gt;
procedure implementations, added support for using MiniSat in the&lt;br /&gt;
core, and had generally better performance.&lt;br /&gt;
&lt;br /&gt;
[[File:cvc4-logo.png|thumb|border|100px|The CVC4 logo.]]&lt;br /&gt;
CVC4 is the new version, the fifth generation of this validity checker&lt;br /&gt;
line that is now celebrating sixteen years of heritage.  It represents&lt;br /&gt;
a complete re-evaluation of the core architecture to be both&lt;br /&gt;
performant and to serve as a cutting-edge research vehicle for the&lt;br /&gt;
next several years.  Rather than taking CVC3 and redesigning problem&lt;br /&gt;
parts, we've taken a clean-room approach, starting from scratch.&lt;br /&gt;
Before using any designs from CVC3, we have thoroughly scrutinized,&lt;br /&gt;
vetted, and updated them.  Many parts of CVC4 bear only a superficial&lt;br /&gt;
resemblance, if any, to their correspondent in CVC3.&lt;br /&gt;
&lt;br /&gt;
However, CVC4 is fundamentally similar to CVC3 and many other modern&lt;br /&gt;
SMT solvers: it is a DPLL(T) solver, with a SAT solver at its core and&lt;br /&gt;
a delegation path to different decision procedure implementations,&lt;br /&gt;
each in charge of solving formulas in some background theory.&lt;br /&gt;
&lt;br /&gt;
The re-evaluation and ground-up rewrite was necessitated, we felt, by&lt;br /&gt;
the performance characteristics of CVC3.  CVC3 has many useful&lt;br /&gt;
features, but some core aspects of the design led to high memory use,&lt;br /&gt;
and the use of heavyweight computation (where more nimble engineering&lt;br /&gt;
approaches could suffice) makes CVC3 a much slower prover than other&lt;br /&gt;
tools.  As these designs are central to CVC3, a new version was&lt;br /&gt;
preferable to a selective re-engineering, which would have ballooned&lt;br /&gt;
in short order.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5359</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5359"/>
				<updated>2015-03-20T16:38:49Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4, the stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5358</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5358"/>
				<updated>2015-03-20T16:37:35Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt; 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
Since string engine is a newly developed engine in CVC4. The stable version 1.4 is not stable for our string engine. Please use our latest developing version.&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5357</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5357"/>
				<updated>2015-03-20T16:29:17Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Unsat Core==&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5356</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5356"/>
				<updated>2015-03-20T16:28:46Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
String engine '''does''' support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5355</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5355"/>
				<updated>2015-03-20T16:28:25Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
String engine *does* support unsat core. To generate unsat cores, you must enable proofs at configure time, and&lt;br /&gt;
then run with &amp;quot;--dump-unsat-cores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Tutorials&amp;diff=5352</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Tutorials&amp;diff=5352"/>
				<updated>2015-01-14T21:40:33Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* C++ API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=CVC language=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;coming soon...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Finding these examples==&lt;br /&gt;
&lt;br /&gt;
Except where noted below, tutorial code appearing in this section is kept in the &amp;lt;code&amp;gt;examples/cvc&amp;lt;/code&amp;gt; directory of the CVC4 source distribution.  However, tutorial material on this page might be more recent than your CVC4 download.  Please refer to the [http://cvc4.cs.nyu.edu/builds/src/ most recent nightly build] for the most recent tutorial code.&lt;br /&gt;
&lt;br /&gt;
=SMT-LIB=&lt;br /&gt;
&lt;br /&gt;
We recommend [http://www.grammatech.com/resources/smt/SMTLIBTutorial.pdf David Cok's excellent tutorial on SMT-LIB].  When running examples from this tutorial, we recommend using CVC4's ''--smtlib-strict'' command line option, which enters a stricter compliance mode.&lt;br /&gt;
&lt;br /&gt;
CVC4 should be compliant with [http://www.smtlib.org/ the standard], and thus also with David Cok's tutorial, except for some unsupported functionality as noted in the [[SMT-LIB_Compliance|SMT-LIB compliance section of this wiki]].  If you find something that you believe to be nonconformant, please [http://cvc4.cs.nyu.edu/bugs/ report it as a bug].&lt;br /&gt;
&lt;br /&gt;
=C++ API=&lt;br /&gt;
* helloworld : a simple example to start off with&lt;br /&gt;
* linear_arith : real and integer linear arithmetic&lt;br /&gt;
* combination : integer and uninterpreted function example&lt;br /&gt;
* bitvectors : bit-vectors example&lt;br /&gt;
* bitvectors_and_arrays : integer and uninterpreted function example&lt;br /&gt;
* quantifiers&lt;br /&gt;
* strings : strings example&lt;br /&gt;
&lt;br /&gt;
==Finding and compiling these examples==&lt;br /&gt;
&lt;br /&gt;
Except where noted below, tutorial code appearing in this section is kept in the &amp;lt;code&amp;gt;examples/api&amp;lt;/code&amp;gt; directory of the CVC4 source distribution.  However, tutorial material on this page might be more recent than your CVC4 download.  Please refer to the [http://cvc4.cs.nyu.edu/builds/src/ most recent nightly build] for the most recent tutorial code.&lt;br /&gt;
&lt;br /&gt;
To compile everything in the &amp;lt;code&amp;gt;examples/&amp;lt;/code&amp;gt; directory, you can issue the command &amp;lt;code&amp;gt;make examples&amp;lt;/code&amp;gt; from the top-level of the source distribution.  This will first build CVC4 (if it isn't already built) and then the examples.  Some examples from the directory may not be compiled, if (for instance) you haven't built with support for Java, or if you haven't built with support for the compatibility interface; however, all native C++ API examples should be, and those are the only ones appearing in this section.&lt;br /&gt;
&lt;br /&gt;
Note that the example API code in the &amp;lt;code&amp;gt;examples/&amp;lt;/code&amp;gt; directory is intended to be compiled and linked against a CVC4 library built from the source tree.  If you try to compile them yourself, against a CVC4 library installed (for example) in &amp;lt;code&amp;gt;/usr&amp;lt;/code&amp;gt;, you may find that certain headers cannot be found.  There is an easy fix.  CVC4 #includes like the following:&lt;br /&gt;
 #include &amp;quot;expr/expr.h&amp;quot;&lt;br /&gt;
should be rewritten to this form:&lt;br /&gt;
 #include &amp;lt;cvc4/expr/expr.h&amp;gt;&lt;br /&gt;
or, most likely, you can remove all such #includes and replace with this single one:&lt;br /&gt;
 #include &amp;lt;cvc4/cvc4.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example code is not installed by &amp;lt;code&amp;gt;make install&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==helloworld==&lt;br /&gt;
To get used to CVC4, let us go through the following example line-by-line:&lt;br /&gt;
  #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
  #include &amp;lt;cvc4/cvc4.h&amp;gt;&lt;br /&gt;
  using namespace CVC4;&lt;br /&gt;
  int main() {&lt;br /&gt;
    ExprManager em;&lt;br /&gt;
    Expr helloworld = em.mkVar(&amp;quot;Hello World!&amp;quot;, em.booleanType());&lt;br /&gt;
    SmtEngine smt(&amp;amp;em);&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; helloworld &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; smt.query(helloworld) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
(The example can be found in examples/api/helloworld.cpp.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First we include the standard &amp;lt;iostream&amp;gt; library, and next we include the public interface for CVC4:&lt;br /&gt;
  #include &amp;lt;cvc4/cvc4.h&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;cvc4/cvc4.h&amp;lt;/code&amp;gt; includes definitions for all of the classes we'll need including ExprManager, Expr and SmtEngine.  All of CVC4 lives in the namespace CVC4 and to save a bit of typing let's use the namespace.  Now construct a new ExprManager named em.&lt;br /&gt;
    ExprManager em;&lt;br /&gt;
ExprManagers are in charge of constructing and managing symbolic expressions in CVC4.  We then construct the expression Expr helloworld.&lt;br /&gt;
    Expr helloworld = em.mkVar(&amp;quot;Hello World!&amp;quot;, em.booleanType());&lt;br /&gt;
helloworld is a symbolic variable with the name &amp;quot;Hello World!&amp;quot; and the type boolean. Note that we ask em to both make the variable and to get em.booleanType(). We now make the main driver for CVC4 reasoning the SmtEngine smt using em as its ExprManager.&lt;br /&gt;
  SmtEngine smt(&amp;amp;em);&lt;br /&gt;
Finally we print helloworld and query the SmtEngine if the boolean variable helloworld is valid.&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; helloworld &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; smt.query(helloworld) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
We can compile the program helloworld from helloworld.cpp by linking against &amp;lt;code&amp;gt;-lcvc4&amp;lt;/code&amp;gt;&lt;br /&gt;
 $ g++ helloworld.cpp -o helloworld -lcvc4&lt;br /&gt;
 $ ./helloworld&lt;br /&gt;
 Hello World! is invalid&lt;br /&gt;
This should all work if libcvc4 was installed using &amp;lt;code&amp;gt;make install&amp;lt;/code&amp;gt;.  If you used &amp;lt;code&amp;gt;make install&amp;lt;/code&amp;gt; to a non-standard location, look at instructions for [[Build Problems#make_install_to_a_non-standard_prefix|using non-standard prefix]]. If you insist on not-using make, look at instructions for [[Build_Problems#libcvc4_without_make_install]].&lt;br /&gt;
&lt;br /&gt;
==linear_arith==&lt;br /&gt;
With helloworld under our belt, let's try to work through the more advanced examples/api/linear_arith.cpp . In this example, we'll try to show that for &amp;lt;math&amp;gt; x \in \mathbb{Z}, y \in \mathbb{R}&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;x \geq 3 y, x \leq y, -2 &amp;lt; x &amp;lt;/math&amp;gt; then &amp;lt;math&amp;gt; \max y - x = \frac{2}{3}&amp;lt;/math&amp;gt;.&lt;br /&gt;
We can do this by first showing that these assumptions entail &amp;lt;math&amp;gt; y - x \leq \frac{2}{3}&amp;lt;/math&amp;gt;, and then showing that &amp;lt;math&amp;gt; y - x = \frac{2}{3}&amp;lt;/math&amp;gt; is consistent with the assumptions.&lt;br /&gt;
&lt;br /&gt;
We use the same basic skeleton of includes/namespaces/main as before.  We make an ExprManager and SmtEngine as before.&lt;br /&gt;
  ExprManager em;&lt;br /&gt;
  SmtEngine smt(&amp;amp;em);&lt;br /&gt;
We now set on option on the SmtEngine to enable incremental or multiple query solving, which we will take advantage of.&lt;br /&gt;
  smt.setOption(&amp;quot;incremental&amp;quot;, SExpr(&amp;quot;true&amp;quot;)); // Enable incremental solving&lt;br /&gt;
We get the Types real and integer from em, and we make x and y variables of the respective types.&lt;br /&gt;
  Type real = em.realType();&lt;br /&gt;
  Type integer = em.integerType();&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, integer);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, real);&lt;br /&gt;
We now make Exprs for the 3 Rational constants in the formulas using [[Expr#Constants|em.mkConst()]]:&lt;br /&gt;
  Expr three = em.mkConst(Rational(3));&lt;br /&gt;
  Expr neg2 = em.mkConst(Rational(-2));&lt;br /&gt;
  Expr two_thirds = em.mkConst(Rational(2,3));&lt;br /&gt;
We will now make the intermediate terms using mkExpr. &lt;br /&gt;
  Expr three_y = em.mkExpr(kind::MULT, three, y);&lt;br /&gt;
  Expr diff = em.mkExpr(kind::MINUS, y, x);&lt;br /&gt;
The first argument to mkExpr is a Kind. Kind is an enum covering all of the various expressions that CVC4 can make.  Common operators have fairly standard ALL_CAPS names, such as LEQ, MINUS, AND, BITVECTOR_NAND, and so on.  Kind's are in the namespace CVC4::kind.  For more information see [[Expr#Constants]].&lt;br /&gt;
&lt;br /&gt;
Using these intermediate terms, we make the following formulas in the same way we made terms.&lt;br /&gt;
  Expr x_geq_3y = em.mkExpr(kind::GEQ, x, three_y);&lt;br /&gt;
  Expr x_leq_y = em.mkExpr(kind::LEQ, x, y);&lt;br /&gt;
  Expr neg2_lt_x = em.mkExpr(kind::LT, neg2, x);&lt;br /&gt;
&lt;br /&gt;
We now assert the assumptions in the SmtEngine:&lt;br /&gt;
  Expr assumptions =&lt;br /&gt;
    em.mkExpr(kind::AND, x_geq_3y, x_leq_y, neg2_lt_x);&lt;br /&gt;
  smt.assertFormula(assumptions);&lt;br /&gt;
Alternatively, we could have asserted x_geq_3y, x_leq_y, and neg2_lt_x individually.  It is worth pointing out that these are asserted at decision level 0.  Modern DPLL(T) solvers are stack based. We can push the stack(), add assertions and then pop() assertions off of the stack.&lt;br /&gt;
&lt;br /&gt;
We can now prove that &amp;lt;math&amp;gt; y - x \leq \frac{2}{3}&amp;lt;/math&amp;gt;.  We first make an Expr for this literal. We now push() the SmtEngine, query the SmtEngine for the validity of the literal given the assumptions, and pop() the SmtEngine.&lt;br /&gt;
  smt.push();&lt;br /&gt;
  Expr diff_leq_two_thirds = em.mkExpr(kind::LEQ, diff, two_thirds);&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Prove that &amp;quot; &amp;lt;&amp;lt; diff_leq_two_thirds &amp;lt;&amp;lt; &amp;quot; with CVC4.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;CVC4 should report VALID.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Result from CVC4 is: &amp;quot; &amp;lt;&amp;lt; smt.query(diff_leq_two_thirds) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  smt.pop();&lt;br /&gt;
&lt;br /&gt;
It is worth noting that the push() and pop() are not strictly needed in order to not effect context level 0. This is because SmtEngine guards query(phi), checkSat(phi) with internal pushes and pops so phi does not effect the current context.  It is needed below; however, as the second lemma is proved in the following fashion:&lt;br /&gt;
  smt.push();&lt;br /&gt;
  Expr diff_is_two_thirds = em.mkExpr(kind::EQUAL, diff, two_thirds);&lt;br /&gt;
  smt.assertFormula(diff_is_two_thirds);&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Show that the asserts are consistent with &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; diff_is_two_thirds &amp;lt;&amp;lt; &amp;quot; with CVC4.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;CVC4 should report SAT.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Result from CVC4 is: &amp;quot; &amp;lt;&amp;lt; smt.checkSat(em.mkConst(true)) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  smt.pop();&lt;br /&gt;
&lt;br /&gt;
== bitvectors ==&lt;br /&gt;
&lt;br /&gt;
In this example we will prove the equivalence of three different pieces of code. The example is adapted from the book [http://www.hackersdelight.org/ A Hacker's Delight] by Henry S. Warren. The code can be found in /examples/api/bitvectors.cpp. &lt;br /&gt;
Given a variable x, that can only have one of two values: a or b, we want to assign to x a value different than the current one. For example if x was equal to a we want to assign to it b. The most straightforward implementation of this is the following:&lt;br /&gt;
&lt;br /&gt;
  if (x == a) x = b; &lt;br /&gt;
  else x = a; &lt;br /&gt;
&lt;br /&gt;
or more concise: &lt;br /&gt;
&lt;br /&gt;
  x = x == a ? b : a; // (0)&lt;br /&gt;
&lt;br /&gt;
However, the following two pieces of code provide a more efficient implementation: &lt;br /&gt;
&lt;br /&gt;
  x = a + b - x; // (1) &lt;br /&gt;
  &lt;br /&gt;
or &lt;br /&gt;
&lt;br /&gt;
  x = a ^ b ^ x; // (2)&lt;br /&gt;
&lt;br /&gt;
We will encode the problem using the theory of bit-vectors and check that the three implementations are indeed equivalent. &lt;br /&gt;
Let's analyze the code in bitvector.cpp line by line. Because we are interested in checking two different problems we will turn on incremental mode and specify the logic, to increase efficiency of solving:&lt;br /&gt;
&lt;br /&gt;
  smt.setOption(&amp;quot;incremental&amp;quot;, true); // Enable incremental solving&lt;br /&gt;
  smt.setLogic(&amp;quot;QF_BV&amp;quot;);              // Set the logic&lt;br /&gt;
&lt;br /&gt;
To make a bit-vector variable we must first make a bit-vector type. The factory method that constructs a bit-vector type requires the width of the bit-vector as an argument. In our example we will assume we are modeling a 32-bit machine:&lt;br /&gt;
&lt;br /&gt;
  // Creating a bit-vector type of width 32&lt;br /&gt;
  Type bitvector32 = em.mkBitVectorType(32);&lt;br /&gt;
&lt;br /&gt;
Creating variables and expressions follows the same pattern as in previous examples. We will first create the input variables x, a and b:&lt;br /&gt;
&lt;br /&gt;
  // Variables&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, bitvector32);&lt;br /&gt;
  Expr a = em.mkVar(&amp;quot;a&amp;quot;, bitvector32);&lt;br /&gt;
  Expr b = em.mkVar(&amp;quot;b&amp;quot;, bitvector32);&lt;br /&gt;
&lt;br /&gt;
The first assumption constraints x to be equal to either a or b:&lt;br /&gt;
&lt;br /&gt;
  // First encode the assumption that x must be equal to a or b&lt;br /&gt;
  Expr x_eq_a = em.mkExpr(kind::EQUAL, x, a); &lt;br /&gt;
  Expr x_eq_b = em.mkExpr(kind::EQUAL, x, b);&lt;br /&gt;
  Expr assumption = em.mkExpr(kind::OR, x_eq_a, x_eq_b); &lt;br /&gt;
&lt;br /&gt;
Because we will need this assumption to prove all following properties we can just assert it to the solver in the current context. &lt;br /&gt;
  // Assert the assumption&lt;br /&gt;
  smt.assertFormula(assumption); &lt;br /&gt;
&lt;br /&gt;
To model the semantics of the instructions we need to introduce a new variable for x for each program state. Here new_x will represent the value of x after executing code (0). We will use new_x_ to represent the value of x after executing code (1) first, and then after executing code (2). &lt;br /&gt;
&lt;br /&gt;
  // Introduce a new variable for the new value of x after assignment. &lt;br /&gt;
  Expr new_x = em.mkVar(&amp;quot;new_x&amp;quot;, bitvector32); // x after executing code (0) &lt;br /&gt;
  Expr new_x_ = em.mkVar(&amp;quot;new_x_&amp;quot;, bitvector32); // x after executing code (1) or (2)&lt;br /&gt;
&lt;br /&gt;
We can encode the assignment in code (0) in a straightforward manner by using a term-ITE (if-then-else) expression which captures the semantics of the C++ (cond ? val1 : val2).  &lt;br /&gt;
&lt;br /&gt;
   // new_x = x == a ? b : a; &lt;br /&gt;
  Expr ite = em.mkExpr(kind::ITE, x_eq_a, b, a); &lt;br /&gt;
  Expr assignment0 = em.mkExpr(kind::EQUAL, new_x, ite); &lt;br /&gt;
&lt;br /&gt;
  // Assert the encoding of code (0)&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Asserting &amp;quot; &amp;lt;&amp;lt; assignment0 &amp;lt;&amp;lt; &amp;quot; to CVC4 &amp;quot; &amp;lt;&amp;lt; endl; &lt;br /&gt;
  smt.assertFormula(assignment0);&lt;br /&gt;
&lt;br /&gt;
Because the assertions we have so far are the only ones that will be used in both queries we can now push a new context: &lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Pushing a new context.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  smt.push();&lt;br /&gt;
  &lt;br /&gt;
Next, we move to encoding the semantics of code (1) in a similar  manner as before: &lt;br /&gt;
&lt;br /&gt;
  // Encoding code (1)&lt;br /&gt;
  // new_x_ = a xor b xor x&lt;br /&gt;
  Expr a_xor_b_xor_x = em.mkExpr(kind::BITVECTOR_XOR, a, b, x); &lt;br /&gt;
  Expr assignment1 = em.mkExpr(kind::EQUAL, new_x_, a_xor_b_xor_x);&lt;br /&gt;
&lt;br /&gt;
  // Assert encoding to CVC4 in current context; &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Asserting &amp;quot; &amp;lt;&amp;lt; assignment1 &amp;lt;&amp;lt; &amp;quot; to CVC4 &amp;quot; &amp;lt;&amp;lt; endl; &lt;br /&gt;
  smt.assertFormula(assignment1);&lt;br /&gt;
&lt;br /&gt;
And we check that the value of x after executing code (0) is the same as that after executing code (1):&lt;br /&gt;
&lt;br /&gt;
  Expr new_x_eq_new_x_ = em.mkExpr(kind::EQUAL, new_x, new_x_);&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot; Querying: &amp;quot; &amp;lt;&amp;lt; new_x_eq_new_x_ &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot; Expect valid. &amp;quot; &amp;lt;&amp;lt; endl; &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot; CVC4: &amp;quot; &amp;lt;&amp;lt; smt.query(new_x_eq_new_x_) &amp;lt;&amp;lt; endl; &lt;br /&gt;
&lt;br /&gt;
Note that we are using smt.query(f) which checks for the validity of the formula f under the current assumptions i.e. that checking whether the current assertions imply (not f) is unsat.  &lt;br /&gt;
Now that we are done with checking the first equivalence, we can pop the context: &lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot; Popping context. &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  smt.pop();&lt;br /&gt;
&lt;br /&gt;
Note that poping the context will remove the assertion saying new_x_ = a xor b xor x.&lt;br /&gt;
&lt;br /&gt;
We follow a similar pattern to check the second equivalence:&lt;br /&gt;
&lt;br /&gt;
  // Encoding code (2)&lt;br /&gt;
  // new_x_ = a + b - x&lt;br /&gt;
  Expr a_plus_b = em.mkExpr(kind::BITVECTOR_PLUS, a, b); &lt;br /&gt;
  Expr a_plus_b_minus_x = em.mkExpr(kind::BITVECTOR_SUB, a_plus_b, x); &lt;br /&gt;
  Expr assignment2 = em.mkExpr(kind::EQUAL, new_x_, a_plus_b_minus_x);&lt;br /&gt;
  &lt;br /&gt;
  // Assert encoding to CVC4 in current context; &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Asserting &amp;quot; &amp;lt;&amp;lt; assignment2 &amp;lt;&amp;lt; &amp;quot; to CVC4 &amp;quot; &amp;lt;&amp;lt; endl; &lt;br /&gt;
  smt.assertFormula(assignment2);&lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot; Querying: &amp;quot; &amp;lt;&amp;lt; new_x_eq_new_x_ &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot; Expect valid. &amp;quot; &amp;lt;&amp;lt; endl; &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot; CVC4: &amp;quot; &amp;lt;&amp;lt; smt.query(new_x_eq_new_x_) &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
==Sets==&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;FS&amp;quot; to enable theory of sets.&lt;br /&gt;
  smt.setLogic(&amp;quot;QF_UFLIAFS&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a set type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;. It takes as argument the element type.&lt;br /&gt;
  Type integer = em.integerType();&lt;br /&gt;
  Type set = em.mkSetType(integer);&lt;br /&gt;
&lt;br /&gt;
===Union and Intersection===&lt;br /&gt;
&lt;br /&gt;
Verify union distributions over intersection. Checks the validity of (A union B) intersection C = (A intersection C) union (B intersection C) for all sets A, B, C of integers.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Expr A = em.mkVar(&amp;quot;A&amp;quot;, set);&lt;br /&gt;
    Expr B = em.mkVar(&amp;quot;B&amp;quot;, set);&lt;br /&gt;
    Expr C = em.mkVar(&amp;quot;C&amp;quot;, set);&lt;br /&gt;
&lt;br /&gt;
    Expr unionAB = em.mkExpr(kind::UNION, A, B);&lt;br /&gt;
    Expr lhs = em.mkExpr(kind::INTERSECTION, unionAB, C);&lt;br /&gt;
&lt;br /&gt;
    Expr intersectionAC = em.mkExpr(kind::INTERSECTION, A, C);&lt;br /&gt;
    Expr intersectionBC = em.mkExpr(kind::INTERSECTION, B, C);&lt;br /&gt;
    Expr rhs = em.mkExpr(kind::UNION, intersectionAC, intersectionBC);&lt;br /&gt;
&lt;br /&gt;
    Expr theorem = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; theorem &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; smt.query(theorem) &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===EmptySet constant and Subset predicate===&lt;br /&gt;
An object of CVC4::EmptySet carries its type, which should be given at construction time. Note that this is the type of the set itself (so, pass the type set of integers, not integers).&lt;br /&gt;
&lt;br /&gt;
Then, the empty set constant can be define using mkConst passing this CVC4::EmptySet object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Expr A = em.mkVar(&amp;quot;A&amp;quot;, set);&lt;br /&gt;
    Expr emptyset = em.mkConst(EmptySet(set));&lt;br /&gt;
&lt;br /&gt;
    Expr theorem = em.mkExpr(kind::SUBSET, emptyset, A);&lt;br /&gt;
&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; theorem &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; smt.query(theorem) &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Membership, singleton and producing models===&lt;br /&gt;
&lt;br /&gt;
Remember to enable models (this should be done at the start, just after creating the smt engine).&lt;br /&gt;
  smt.setOption(&amp;quot;produce-models&amp;quot;, true);&lt;br /&gt;
&lt;br /&gt;
Find an element in {1, 2} intersection {2, 3}, if there is one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    // Integer constants&lt;br /&gt;
    Expr one = em.mkConst(Rational(1));&lt;br /&gt;
    Expr two = em.mkConst(Rational(2));&lt;br /&gt;
    Expr three = em.mkConst(Rational(3));&lt;br /&gt;
&lt;br /&gt;
    // Singleton sets for each of these constants&lt;br /&gt;
    Expr singleton_one = em.mkExpr(kind::SINGLETON, one);&lt;br /&gt;
    Expr singleton_two = em.mkExpr(kind::SINGLETON, two);&lt;br /&gt;
    Expr singleton_three = em.mkExpr(kind::SINGLETON, three);&lt;br /&gt;
&lt;br /&gt;
    // Build bigger sets using union&lt;br /&gt;
    Expr one_two = em.mkExpr(kind::UNION, singleton_one, singleton_two);&lt;br /&gt;
    Expr two_three = em.mkExpr(kind::UNION, singleton_two, singleton_three);&lt;br /&gt;
&lt;br /&gt;
    Expr intersection = em.mkExpr(kind::INTERSECTION, one_two, two_three);&lt;br /&gt;
    Expr x = em.mkVar(&amp;quot;x&amp;quot;, integer);&lt;br /&gt;
    Expr e = em.mkExpr(kind::MEMBER, x, intersection);&lt;br /&gt;
&lt;br /&gt;
    Result result = smt.checkSat(e);&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; e &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
    // If the formula was satisfiable (which it should be here), get the value of x. &lt;br /&gt;
    if(result == Result::SAT) {&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;For instance, &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; &amp;quot; is a member.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
&lt;br /&gt;
The example can be found in examples/api/strings.cpp&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Java API=&lt;br /&gt;
=Parallel Solving=&lt;br /&gt;
===Obtaining===&lt;br /&gt;
* Download a statically built binary supporting parallel solving: [http://cvc4.cs.nyu.edu/cvc4-builds/portfolio-x86_64-linux-opt Optimized build]&lt;br /&gt;
* If compiling from source, specify by '''--with-portfolio''' option to the configure script. This will create an additional binary '''pcvc4''' which supports parallel solving.&lt;br /&gt;
 ./configure --with-portfolio [...]&lt;br /&gt;
&lt;br /&gt;
===Running===&lt;br /&gt;
*The '''pcvc4''' binary allows the user to run multiple instances of the solver simultaneously on the input problem. Each thread can be configured differently by prefixing each thread-specific options by '''--thread''N''='''&amp;lt;thread-specific-option&amp;gt; where ''N'' is the thread number (counting from 0). For example,&lt;br /&gt;
 pcvc4 --thread0=--decision=internal --thread0=--no-simplification --thread1=--decision=justification input.smt2&lt;br /&gt;
will run two solver threads with different decision heuristics and simplification switched off for thread0. The solver will stop as soon as one of threads has an answer.&lt;br /&gt;
&lt;br /&gt;
* The default number of threads is 2. The number of threads can be specified using '''--threads''' option. Note that any of the options specified outside all of the --thread''i''=... will be applied to all threads. For instance, in&lt;br /&gt;
 pcvc4 --threads=3 \&lt;br /&gt;
        --thread0=--random-seed=10 \&lt;br /&gt;
        --thread1=--random-seed=20 \&lt;br /&gt;
        --thread2=--random-seed=30 \&lt;br /&gt;
        --simplification=none \&lt;br /&gt;
        input.smt2&lt;br /&gt;
three threads will be run, all with simplification disabled, and different random seeds for the SAT solver.&lt;br /&gt;
&lt;br /&gt;
* We also allow sharing of ''conflict clauses'' across different threads. By default, this is disabled but may he enabled by using the '''--filter-lemma-length''' option. For example,&lt;br /&gt;
 pcvc4 --filter-lemma-length=5 ...&lt;br /&gt;
will share all lemmas having 5 or fewer literals.&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5351</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5351"/>
				<updated>2015-01-14T21:22:18Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Printable Characters==&lt;br /&gt;
A ''printable'' character is any character between 0x20 and 0x7e in the standard ASCII table.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5350</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5350"/>
				<updated>2015-01-14T21:17:54Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Escaped Character Literals for Regular Expressions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5349</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5349"/>
				<updated>2015-01-14T21:17:21Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Escaped Character Literals for Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for String Literals==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5348</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5348"/>
				<updated>2015-01-14T21:16:16Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escape sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5347</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5347"/>
				<updated>2015-01-14T20:00:53Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escape sequences for string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5346</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5346"/>
				<updated>2015-01-14T19:35:32Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escaped string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
Since the theory of strings is pretty new in CVC4, we are still working on the standards for syntax.&lt;br /&gt;
If you have some comments or suggestions about CVC4 strings, please feel feel to email me: tianyi-liang@uiowa.edu&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5345</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5345"/>
				<updated>2015-01-14T17:34:07Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Escaped Character Literals for Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escaped string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
In string literals (for the string engine) that are following the SMT-Lib v2.5 specification, it is mandatory to escape \ (by \\) and &amp;quot; (by &amp;quot;&amp;quot;) to prevent parse error.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5344</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5344"/>
				<updated>2015-01-14T17:26:49Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Escaped Character Literals for Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escaped string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \e, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \e, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5343</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5343"/>
				<updated>2015-01-11T18:13:01Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Escaped Character Literals for Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escaped string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
To be compliant with SMT-Lib, users are required to add another layer of escapes.&lt;br /&gt;
For example, in v2.0, both \t and \\t mean the tab character, and both \\\t and \\\\t mean the two characters \ and t.&lt;br /&gt;
In v2.5, only \t means the tab character, and \\t means the two characters \ and t.&lt;br /&gt;
In v2.5, both \&amp;quot;&amp;quot; and &amp;quot;&amp;quot; means the character &amp;quot;.&lt;br /&gt;
Please check the string literals section in SMT-Lib v2.5 standard for more details.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5342</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5342"/>
				<updated>2015-01-11T18:05:44Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib 2 format.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend users to switch to SMT-Lib v2.5, instead of v2.0. The major difference is for escaped string literals.'''&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5319</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5319"/>
				<updated>2014-10-22T06:39:37Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Experimental Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''Syntax below is for CVC4 version &amp;gt;= 1.4. Version 1.3 only has ''partial'' support for syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5157</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5157"/>
				<updated>2014-05-13T20:42:51Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed to be appeared natively in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5156</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5156"/>
				<updated>2014-05-13T20:41:39Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support syntax in this document.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5155</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5155"/>
				<updated>2014-05-13T19:38:46Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Escaped Character Literals for Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable/extended ASCII character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with the string literal standards in SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5154</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5154"/>
				<updated>2014-05-13T19:34:07Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
In compliance with SMT-Lib v2, only printable basic ASCII characters are allowed in string literals. Other ASCII characters '''must''' be encoded as escaped sequences.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5153</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5153"/>
				<updated>2014-05-13T02:08:04Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Experimental Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5147</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5147"/>
				<updated>2014-05-12T18:31:32Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Experimental Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5139</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5139"/>
				<updated>2014-05-12T06:48:54Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Escaped Character Literals for Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
'''Note''': Escaped character literals are for version (&amp;gt; 1.3). They are '''not''' compatible with SMT-Lib v2.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where an occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5138</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5138"/>
				<updated>2014-05-09T15:21:29Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
This string solver has a full support of '''ASCII''' characters. For arbitrary alphabets, please refer to sequence (parametrized string) theory.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where an occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5137</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5137"/>
				<updated>2014-05-06T01:13:41Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Experimental Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where an occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5136</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5136"/>
				<updated>2014-05-05T23:06:50Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Experimental Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5119</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5119"/>
				<updated>2014-04-29T20:46:59Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Experimental Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5118</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5118"/>
				<updated>2014-04-29T18:03:12Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (version &amp;gt; 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
The string s has no leading zeros, e.g. (str.to.int &amp;quot;05&amp;quot;) is equal to -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5117</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5117"/>
				<updated>2014-04-29T18:02:48Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
'''This Syntax is for the latest CVC4 (&amp;gt; version 1.3). The version 1.3 does ''NOT'' fully support string functions.'''&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
The string s has no leading zeros, e.g. (str.to.int &amp;quot;05&amp;quot;) is equal to -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5116</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5116"/>
				<updated>2014-04-29T18:02:24Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
This Syntax is for the latest CVC4 (&amp;gt; version 1.3). The version 1.3 does *NOT* fully support string functions.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
The string s has no leading zeros, e.g. (str.to.int &amp;quot;05&amp;quot;) is equal to -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5100</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5100"/>
				<updated>2014-04-11T17:09:06Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much '''slower''' than the default mode. We highly recommend you '''NOT''' using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
The string s has no leading zeros, e.g. (str.to.int &amp;quot;05&amp;quot;) is equal to -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5099</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5099"/>
				<updated>2014-04-11T17:08:40Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
The string finite model finding mode is much *slower* than the default mode. We highly recommend you *NOT* using it if it is not necessary.&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
The string s has no leading zeros, e.g. (str.to.int &amp;quot;05&amp;quot;) is equal to -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5085</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5085"/>
				<updated>2014-03-31T16:57:55Z</updated>
		
		<summary type="html">&lt;p&gt;Tianyi: /* Strings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about strings in CVC4&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document is for the SMT-Lib v2 format.&lt;br /&gt;
&lt;br /&gt;
The Theory of Strings (Quantifier-Free) logic symbol:&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
&lt;br /&gt;
The logic symbol is '''IMPORTANT''' to the Theory of String, and it has to be set up.&lt;br /&gt;
&lt;br /&gt;
If the constraints contain more theories, please add them accordingly, e.g. if it contains BitVector, the symbol should be QF_SBV.&lt;br /&gt;
&lt;br /&gt;
The Theory of Quantified Strings logic symbol:&lt;br /&gt;
  (set-logic UFSLIA)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
To use the experimental functions (disabled by default in ALL_SUPPORTED mode):&lt;br /&gt;
  (set-option :strings-exp true)&lt;br /&gt;
&lt;br /&gt;
To use finite model finding mode (false by default):&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
&lt;br /&gt;
To select the strategy of LB rule application: 0-lazy, 1-eager, 2-no (0 by default):&lt;br /&gt;
  (set-option :strings-lb 1)&lt;br /&gt;
&lt;br /&gt;
To set up string alphabet cardinality (256 by default, expert option):&lt;br /&gt;
  (set-option :strings-alphabet-card n)&lt;br /&gt;
This is a reserved option for the extension of the sequence theory.&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Strings==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| \0 … \9&lt;br /&gt;
| represents ASCII character 0 … 9, respectively&lt;br /&gt;
|-&lt;br /&gt;
| \a, \b, \f, \n, \r, \t, \v&lt;br /&gt;
| represents its corresponding ASCII character (C++ convention)&lt;br /&gt;
|-&lt;br /&gt;
| \ooo&lt;br /&gt;
| matches an ASCII character, where ooo consists of (no more than) three digits that represent the octal character code (from 0 to 377). For example, \101 represents ‘A’, while “\437” represent a string with two characters “#7”( *important* ).&lt;br /&gt;
|-&lt;br /&gt;
| \xNN&lt;br /&gt;
| matches an ASCII character, where NN is a two-digit hexadecimal character code. NN has to be exactly two hex-digits. If not, an exception will be raised.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The backslash character (\) : when followed by a character that is not recognized as an escaped character, matches that character. For example, \&amp;quot; matches a double quote(&amp;quot;).&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, a non-printable character is printed in the format \xNN, where NN matches its ASCII character, except for \a, \b, \f, \n, \r, \t, \v, which are printed directly.&lt;br /&gt;
&lt;br /&gt;
==Strings==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escaped Character Literals for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value s1 is replaced by the string s2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
The string s has no leading zeros, e.g. (str.to.int &amp;quot;05&amp;quot;) is equal to -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;/div&gt;</summary>
		<author><name>Tianyi</name></author>	</entry>

	</feed>