<?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=Ajreynol</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=Ajreynol"/>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/wiki/Special:Contributions/Ajreynol"/>
		<updated>2026-04-05T21:34:32Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.4</generator>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5746</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5746"/>
				<updated>2019-08-13T14:47:25Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Semantics==&lt;br /&gt;
&lt;br /&gt;
The semantics of most of the above operators (e.g. set union, intersection, difference) are straightforward. The semantics for the universe set and complement are more subtle and is explained in the following.&lt;br /&gt;
&lt;br /&gt;
The universe set (as univset (Set T)) is *not* interpreted as the set containing all elements of type T. Instead it may be interpreted as any set such that all sets of type (Set T) are interpreted as subsets of it. In other words, it is the union of the interpretation of all (finite) sets in our input. For example:&lt;br /&gt;
  (declare-fun x () (Set Int))&lt;br /&gt;
  (declare-fun y () (Set Int))&lt;br /&gt;
  (declare-fun z () (Set Int))&lt;br /&gt;
  (assert (member 0 x))&lt;br /&gt;
  (assert (member 1 y))&lt;br /&gt;
  (assert (= z (as univset (Set Int))))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
Here, a possible model is:&lt;br /&gt;
  (define-fun x () (singleton 0))&lt;br /&gt;
  (define-fun y () (singleton 1))&lt;br /&gt;
  (define-fun z () (union (singleton 1) (singleton 0)))&lt;br /&gt;
Notice that the universe set in this example is interpreted the same as z, and is such that all sets in this example (x, y, and z) are subsets of it.&lt;br /&gt;
&lt;br /&gt;
The set complement operator for (Set T) is interpreted relative to the interpretation of the universe set for (Set T), and not relative to the set of all elements of type T.  That is, for all sets X of type (Set T), the complement operator is such that: &lt;br /&gt;
  (complement X) = (setminus (as univset (Set T)) X)&lt;br /&gt;
holds in all models.&lt;br /&gt;
&lt;br /&gt;
The motivation for these semantics is to ensure that the universe set for type T and applications of set complement can always be interpreted as a finite set in (quantifier-free) inputs, even if the cardinality of T is infinite. Above, notice that we were able to find a model for the universe set of type (Set Int) that contained two elements only.&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/master/test/regress/regress0/rels/rel_join_1_1.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/master/test/regress/regress0/rels/relations-ops.smt2 SMT language example]&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
For more details, see our CADE 2017 paper on an extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5745</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5745"/>
				<updated>2019-08-13T14:38:42Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Semantics==&lt;br /&gt;
&lt;br /&gt;
The semantics of most of the above operators (e.g. set union, intersection, difference) are straightforward. The semantics for the universe set and complement are more subtle and is explained in the following.&lt;br /&gt;
&lt;br /&gt;
The universe set (as univset (Set T)) is *not* interpreted as the set containing all elements of type T. Instead it may be interpreted as any set such that all sets of type (Set T) are interpreted as subsets of it. In other words, it is the union of the interpretation of all (finite) sets in our input. For example:&lt;br /&gt;
  (declare-fun x () (Set Int))&lt;br /&gt;
  (declare-fun y () (Set Int))&lt;br /&gt;
  (declare-fun z () (Set Int))&lt;br /&gt;
  (assert (member 0 x))&lt;br /&gt;
  (assert (member 1 y))&lt;br /&gt;
  (assert (= z (as univset (Set Int))))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
Here, a possible model is:&lt;br /&gt;
  (define-fun x () (singleton 0))&lt;br /&gt;
  (define-fun y () (singleton 1))&lt;br /&gt;
  (define-fun z () (union (singleton 1) (singleton 0)))&lt;br /&gt;
Notice that the universe set in this example is interpreted the same as z, and is such that all sets in this example (x, y, and z) are subsets of it.&lt;br /&gt;
&lt;br /&gt;
The set complement operator for (Set T) is interpreted relative to the interpretation of the universe set for (Set T), and not relative to the set of all elements of type T.  That is, for all sets X of type (Set T), the complement operator is such that: &lt;br /&gt;
  (complement X) = (setminus (as univset (Set T)) X)&lt;br /&gt;
holds in all models.&lt;br /&gt;
&lt;br /&gt;
The motivation for these semantics is to ensure that the universe set for type T and applications of set complement can always be interpreted as a finite set in (quantifier-free) inputs, even if the cardinality of T is infinite. Above, notice that we were able to find a model for the universe set of type (Set Int) that contained two elements only.&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/master/test/regress/regress0/rels/rel_join_1_1.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/master/test/regress/regress0/rels/relations-ops.smt2 SMT language example]&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5744</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5744"/>
				<updated>2019-03-12T19:36:40Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Semantics==&lt;br /&gt;
&lt;br /&gt;
The semantics of most of the above operators (e.g. set union, intersection, difference) are straightforward. The semantics for the universe set and complement are more subtle and is explained in the following.&lt;br /&gt;
&lt;br /&gt;
The universe set (as univset (Set T)) is *not* interpreted as the set containing all elements of type T. Instead it may be interpreted as any set such that all sets of type (Set T) are interpreted as subsets of it. In other words, it is the union of the interpretation of all (finite) sets in our input. For example:&lt;br /&gt;
  (declare-fun x () (Set Int))&lt;br /&gt;
  (declare-fun y () (Set Int))&lt;br /&gt;
  (declare-fun z () (Set Int))&lt;br /&gt;
  (assert (member 0 x))&lt;br /&gt;
  (assert (member 1 y))&lt;br /&gt;
  (assert (= z (as univset (Set Int))))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
Here, a possible model is:&lt;br /&gt;
  (define-fun x () (singleton 0))&lt;br /&gt;
  (define-fun y () (singleton 1))&lt;br /&gt;
  (define-fun z () (union (singleton 1) (singleton 0)))&lt;br /&gt;
Notice that the universe set in this example is interpreted the same as z, and is such that all sets in this example (x, y, and z) are subsets of it.&lt;br /&gt;
&lt;br /&gt;
The set complement operator for (Set T) is interpreted relative to the interpretation of the universe set for (Set T), and not relative to the set of all elements of type T.  That is, for all sets X of type (Set T), the complement operator is such that: &lt;br /&gt;
  (complement X) = (setminus (as univset (Set T)) X)&lt;br /&gt;
holds in all models.&lt;br /&gt;
&lt;br /&gt;
The motivation for these semantics is to ensure that the universe set for type T and applications of set complement can always be interpreted as a finite set in (quantifier-free) inputs, even if the cardinality of T is infinite. Above, notice that we were able to find a model for the universe set of type (Set Int) that contained two elements only.&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5743</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5743"/>
				<updated>2019-03-12T19:34:59Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Semantics==&lt;br /&gt;
&lt;br /&gt;
Most of the above operators (e.g. set union, intersection, difference) have semantics that are straightforward. The semantics for the universe set is more subtle and is explained in the following.&lt;br /&gt;
&lt;br /&gt;
The universe set (as univset (Set T)) is *not* interpreted as the set containing all elements of type T. Instead it is defined as any set such that all sets of type (Set T) are interpreted as subsets of it. For example:&lt;br /&gt;
  (declare-fun x () (Set Int))&lt;br /&gt;
  (declare-fun y () (Set Int))&lt;br /&gt;
  (declare-fun z () (Set Int))&lt;br /&gt;
  (assert (member 0 x))&lt;br /&gt;
  (assert (member 1 y))&lt;br /&gt;
  (assert (= z (as univset (Set Int))))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
Here, a possible model is:&lt;br /&gt;
  (define-fun x () (singleton 0))&lt;br /&gt;
  (define-fun y () (singleton 1))&lt;br /&gt;
  (define-fun z () (union (singleton 1) (singleton 0)))&lt;br /&gt;
Notice that the universe set in this example is interpreted the same as z, and is such that all sets in this example (x, y, and z) are subsets of it.&lt;br /&gt;
&lt;br /&gt;
The set complement operator for (Set T) is interpreted relative to the interpretation of the universe set for (Set T), and not relative to the set of all elements of type T.  That is, for all sets X of type (Set T), the complement operator is such that: &lt;br /&gt;
  (complement X) = (setminus (as univset (Set T)) X)&lt;br /&gt;
holds in all models.&lt;br /&gt;
&lt;br /&gt;
The motivation for these semantics is to ensure that the universe set for type T and applications of set complement can always be interpreted as a finite set in (quantifier-free) inputs, even if the cardinality of T is infinite. Above, notice that we were able to find a model for the universe set of type (Set Int) that contained two elements only.&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5742</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5742"/>
				<updated>2019-03-12T19:34:06Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Semantics==&lt;br /&gt;
&lt;br /&gt;
Most of the above operators (e.g. set union, intersection, difference) have semantics that are straightforward. The semantics for the universe set is more subtle and is explained in the following.&lt;br /&gt;
&lt;br /&gt;
The universe set (as univset (Set T)) is *not* interpreted as the set containing all elements of type T. Instead it is defined as any set such that all sets of type (Set T) are interpreted as subsets of it. For example:&lt;br /&gt;
  (declare-fun x () (Set Int))&lt;br /&gt;
  (declare-fun y () (Set Int))&lt;br /&gt;
  (declare-fun z () (Set Int))&lt;br /&gt;
  (assert (member 0 x))&lt;br /&gt;
  (assert (member 1 y))&lt;br /&gt;
  (assert (= z (as univset (Set Int))))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
Here, a possible model is:&lt;br /&gt;
  (define-fun x () (singleton 0))&lt;br /&gt;
  (define-fun y () (singleton 1))&lt;br /&gt;
  (define-fun z () (uniont (singleton 1) (singleton 0)))&lt;br /&gt;
Notice that the universe set in this example is interpreted the same as z, and is such that all sets in this example (x, y, and z) are subsets of it.&lt;br /&gt;
&lt;br /&gt;
The set complement operator for (Set T) is interpreted relative to the interpretation of the universe set for (Set T), and not relative to the set of all elements of type T.  That is, for all sets X of type (Set T), the complement operator is such that: &lt;br /&gt;
  (complement X) = (setminus (as univset (Set T)) X)&lt;br /&gt;
holds in all models.&lt;br /&gt;
&lt;br /&gt;
The motivation for these semantics is to ensure that the universe set for type T and applications of set complement can always be interpreted as a finite set in (quantifier-free) inputs, even if the cardinality of T is infinite.&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5741</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5741"/>
				<updated>2019-03-12T19:28:32Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Semantics==&lt;br /&gt;
&lt;br /&gt;
Most of the above operators (e.g. set union, intersection, difference) have semantics that are straightforward. The semantics for the universe set is more subtle and is explained in the following.&lt;br /&gt;
&lt;br /&gt;
The universe set (as univset (Set T)) is not &lt;br /&gt;
&lt;br /&gt;
For all sets X of type (Set T), the complement operator is such that: &lt;br /&gt;
  (complement X) = (setminus (as univset (Set T)) X)&lt;br /&gt;
holds in all models.&lt;br /&gt;
&lt;br /&gt;
The motivation for these semantics is to ensure that the universe set and applications of set complement can always be interpreted as a finite set in (quantifier-free) inputs.&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5735</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5735"/>
				<updated>2018-12-11T18:35:47Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Extended Functions */&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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==Regular Expression Memberships==&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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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;
=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.stanford.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;
=References=&lt;br /&gt;
* Andrew Reynolds, Maverick Woo, Clark Barrett, David Brumley, Tianyi Liang, Cesare Tinelli. [http://homepage.divms.uiowa.edu/~ajreynol/cav17a.pdf Scaling Up DPLL(T) String Solvers Using Context-Dependent Simplification]. CAV 2017.&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5734</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5734"/>
				<updated>2018-12-11T18:34:01Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==Regular Expression Memberships==&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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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;
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;
=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.stanford.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;
=References=&lt;br /&gt;
* Andrew Reynolds, Maverick Woo, Clark Barrett, David Brumley, Tianyi Liang, Cesare Tinelli. [http://homepage.divms.uiowa.edu/~ajreynol/cav17a.pdf Scaling Up DPLL(T) String Solvers Using Context-Dependent Simplification]. CAV 2017.&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5733</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5733"/>
				<updated>2018-12-11T18:31:58Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==Regular Expression Memberships==&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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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;
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;
=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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5732</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5732"/>
				<updated>2018-12-11T18:31:22Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==Regular Expression Memberships==&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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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;
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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5731</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5731"/>
				<updated>2018-12-11T18:30:58Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Extended Functions */&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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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;
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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5730</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5730"/>
				<updated>2018-12-11T18:30:36Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Theory Signature */&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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5729</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5729"/>
				<updated>2018-12-11T18:29:50Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5728</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5728"/>
				<updated>2018-12-11T18:29:34Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Options */&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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
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'', i.e. those with numerical value between 0x20 and 0x7e &lt;br /&gt;
in the standard US ASCII encoding. &lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5727</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5727"/>
				<updated>2018-12-11T18:28:01Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Options */&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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
By default, the strings solver uses the standard ASCII alphabet, which has cardinality 256.&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;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5726</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5726"/>
				<updated>2018-12-11T18:27:28Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Options */&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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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;
By default, the strings solver uses the standard ASCII alphabet, which has cardinality 256.&lt;br /&gt;
To limit the alphabet of the strings solver to the 128 printable ASCII characters, use:&lt;br /&gt;
  (set-option :--strings-print-ascii)&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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5725</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5725"/>
				<updated>2018-12-11T18:24:03Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Syntax */&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;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5] or greater, &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;
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 arbitrary 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 (although one is in development http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml), &lt;br /&gt;
the logic and operator names described below are tentative and 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;
For string applications that require reasoning about length, the logic should be extended to also include linear integer arithmetic:&lt;br /&gt;
  (set-logic QF_SLIA)&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;
| Replace&lt;br /&gt;
| &amp;lt;code&amp;gt;'''REPLACEALL'''( X, Y, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.replaceall''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_STRREPLALL''', 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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
We refer to all functions apart from string length and string concatenation as ''extended functions'' in the following.&lt;br /&gt;
&lt;br /&gt;
==Options==&lt;br /&gt;
The extended functions in the theory are disabled by default,&lt;br /&gt;
even in the &amp;lt;code&amp;gt;ALL_SUPPORTED&amp;lt;/code&amp;gt; logic. To enable them, use:&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 where all strings are interpreted with small lengths.&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 can be much '''slower''' than in default mode, &lt;br /&gt;
so we recommend it 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 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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Separation_Logic&amp;diff=5724</id>
		<title>Separation Logic</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Separation_Logic&amp;diff=5724"/>
				<updated>2018-08-02T16:59:34Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 supports a syntax for separation logic as an extension of the *.smt2 language.&lt;br /&gt;
&lt;br /&gt;
=Signature=&lt;br /&gt;
&lt;br /&gt;
Given a (decidable) base theory T, CVC4 has a [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf decision procedure] for quantifier-free &amp;lt;math&amp;gt;SL(T)_{Loc,Data}&amp;lt;/math&amp;gt; formulas, where &amp;quot;Loc&amp;quot; and &amp;quot;Data&amp;quot; are any sort belonging to T.&lt;br /&gt;
A &amp;lt;math&amp;gt;SL(T)_{Loc,Data}&amp;lt;/math&amp;gt; formula is one from the following grammar:&lt;br /&gt;
  F : L | (emp t u) | (pto t u) | (sep F1 ... Fn) | (wand F1 F2) | ~F1 | F1 op ... op Fn&lt;br /&gt;
where &amp;quot;op&amp;quot; is any classical Boolean connective, t and u are terms built from symbols in the signature of T of sort Loc and Data respectively, and L is a T-literal.&lt;br /&gt;
The operator &amp;quot;emp&amp;quot; denotes the empty heap constraint, the operator &amp;quot;pto&amp;quot; denotes the points-to predicate,&lt;br /&gt;
the operator &amp;quot;sep&amp;quot; denotes separation start and is variadic, and the operator &amp;quot;wand&amp;quot; denote magic wand.&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
A satisfiability relation &amp;lt;math&amp;gt;I,h \models_{SL} \varphi&amp;lt;/math&amp;gt; is defined for &amp;lt;math&amp;gt;SL(T)_{Loc,Data}&amp;lt;/math&amp;gt; formulas &amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt;,&lt;br /&gt;
where I is an interpretation, and h is a heap. The semantics of separation logic operators are as follows:&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;
| &amp;lt;math&amp;gt;I,h \models_{SL} &amp;lt;/math&amp;gt; L&lt;br /&gt;
| Iff &lt;br /&gt;
| &amp;lt;math&amp;gt;I \models&amp;lt;/math&amp;gt; L, if L is a T-literal&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;I,h \models_{SL}&amp;lt;/math&amp;gt; (emp &amp;lt;math&amp;gt;t \ u&amp;lt;/math&amp;gt;)&lt;br /&gt;
| Iff &lt;br /&gt;
| &amp;lt;math&amp;gt;h = \emptyset&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;I,h \models_{SL}&amp;lt;/math&amp;gt; (pto &amp;lt;math&amp;gt;t \ u&amp;lt;/math&amp;gt;)&lt;br /&gt;
| Iff &lt;br /&gt;
| &amp;lt;math&amp;gt;h = \{(t^I,u^I)\} \text{ and } t^I\not=nil^I&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;I,h \models_{SL} &amp;lt;/math&amp;gt; (sep &amp;lt;math&amp;gt;\phi_1 \ldots \phi_n&amp;lt;/math&amp;gt;)&lt;br /&gt;
| Iff &lt;br /&gt;
| there exist heaps &amp;lt;math&amp;gt;h_1,\ldots,h_n&amp;lt;/math&amp;gt; s.t. &amp;lt;math&amp;gt;h=h_1\uplus \ldots \uplus h_n&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;I,h_i \models_{SL} \phi_i, i = 1,\ldots,n&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;I,h \models_{SL}&amp;lt;/math&amp;gt; (wand &amp;lt;math&amp;gt;\phi_1 \ \phi_2&amp;lt;/math&amp;gt;)&lt;br /&gt;
| Iff &lt;br /&gt;
| for all heaps &amp;lt;math&amp;gt;h'&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;h'\#h&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;I,h' \models_{SL} \phi_1&amp;lt;/math&amp;gt; then &amp;lt;math&amp;gt;I,h'\uplus h \models_{SL} \phi_2&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;h_1 \uplus \ldots \uplus h_n&amp;lt;/math&amp;gt; denotes the disjoint union of heaps &amp;lt;math&amp;gt;h_1, \ldots, h_n&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;h'\#h&amp;lt;/math&amp;gt; denotes that heaps h' and h are disjoint, and &amp;lt;math&amp;gt;nil&amp;lt;/math&amp;gt; is a distinguished variable of sort Loc.&lt;br /&gt;
All classical Boolean connectives are interpreted as expected.&lt;br /&gt;
Note that the arguments of &amp;quot;emp&amp;quot; are used to denote the type of the heap and have no meaning otherwise.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
Separation logic in CVC4 requires the &amp;quot;all supported&amp;quot; logic:&lt;br /&gt;
  (set-logic QF_ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
The syntax for the operators of separation logic is summarized in the following table:&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;
| Empty heap&lt;br /&gt;
| &amp;lt;code&amp;gt;N/A&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(_ '''emp''' T1 T2)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SEP_EMP''', X, Y);&amp;lt;/code&amp;gt; where X and Y are of type T1 and T2.&lt;br /&gt;
|-&lt;br /&gt;
| Points-to&lt;br /&gt;
| &amp;lt;code&amp;gt;N/A&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''pto''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SEP_PTO''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Separation star&lt;br /&gt;
| &amp;lt;code&amp;gt;N/A&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''sep''' C1 ... Cn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SEP_STAR''', C1, ..., Cn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Magic wand&lt;br /&gt;
| &amp;lt;code&amp;gt;N/A&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''wand''' C1 C2)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SEP_WAND''', C1, C2);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Nil element&lt;br /&gt;
| &amp;lt;code&amp;gt;N/A&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''as nil''' T)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkUniqueVar(T,'''kind::SEP_NIL''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
The following input on heaps Int -&amp;gt; Int is unsatisfiable:&lt;br /&gt;
  (set-logic QF_ALL_SUPPORTED)&lt;br /&gt;
  (set-info :status unsat)&lt;br /&gt;
  (declare-const x Int)&lt;br /&gt;
  (declare-const a Int)&lt;br /&gt;
  (declare-const b Int)&lt;br /&gt;
  (assert (and (pto x a) (pto x b)))&lt;br /&gt;
  (assert (not (= a b)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
The following input on heaps U -&amp;gt; Int is satisfiable. Notice that the formula (not (emp x 0)) is satisfied by heaps U -&amp;gt; Int (the types of x and 0 respectively) whose domain is non-empty.&lt;br /&gt;
  (set-logic QF_ALL_SUPPORTED)&lt;br /&gt;
  (set-info :status unsat)&lt;br /&gt;
  (declare-sort U 0)&lt;br /&gt;
  (declare-const x U)&lt;br /&gt;
  (declare-const a Int)&lt;br /&gt;
  (assert (and (not (_ emp Int U)) (pto x a))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
The following input on heaps Int -&amp;gt; Node is satisfiable, where Node denotes a user-defined inductive [[Datatypes|datatype]]:&lt;br /&gt;
  (set-logic QF_ALL_SUPPORTED)&lt;br /&gt;
  (set-info :status sat)&lt;br /&gt;
  (declare-const x Int)&lt;br /&gt;
  (declare-const y Int)&lt;br /&gt;
  (declare-const z Int)&lt;br /&gt;
  (declare-datatypes () ((Node (node (data Int) (left Int) (right Int)))))&lt;br /&gt;
  (assert (pto x (node 0 y z)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Given a separation logic input, &lt;br /&gt;
the sorts Loc and Data are inferred by CVC4, and must be consistent across all predicates occurring in an input.  CVC4 does not accept an input such as:&lt;br /&gt;
  (set-logic QF_ALL_SUPPORTED)&lt;br /&gt;
  (declare-sort U 0)&lt;br /&gt;
  (declare-const x U)&lt;br /&gt;
  (assert (and (pto x 0) (pto 1 2)))&lt;br /&gt;
since the sorts of the first arguments of the points-to predicates do not agree.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5722</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5722"/>
				<updated>2018-05-08T18:51:20Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Syntax/API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;br /&gt;
&lt;br /&gt;
=Syntax/API=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' fst:'''INT''', snd:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;fst&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;snd&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkRecordType'''(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''f1(t)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-}&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5721</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5721"/>
				<updated>2018-05-08T18:51:02Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Syntax/API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;br /&gt;
&lt;br /&gt;
=Syntax/API=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' fst:'''INT''', snd:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;fst&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;snd&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkRecordType'''(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''f1(t)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-}&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5720</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5720"/>
				<updated>2018-05-08T13:57:04Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &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.stanford.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;
* [[Datatypes|tuples]]&lt;br /&gt;
* [[Datatypes|records]]&lt;br /&gt;
* user-defined inductive [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets and relations]]&lt;br /&gt;
* [[Separation Logic|separation logic]]&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://cvc4.cs.stanford.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 [https://github.com/CVC4/CVC4/blob/master/COPYING 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.stanford.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;
** A heuristic approach non-linear arithmetic is supported based on this paper [https://es-static.fbk.eu/people/griggio/papers/tacas17.pdf].&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://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
** This procedure has been extended to incorporate coinductive datatypes [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf].&lt;br /&gt;
** The datatypes decision procedure is optimized via the use of shared selectors, described in this paper [http://homepage.divms.uiowa.edu/~ajreynol/ijcar18.pdf].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** E-matching and conflict-based quantifier instantiation [http://homepage.cs.uiowa.edu/~ajreynol/fmcad14.pdf].&lt;br /&gt;
** Finite model finding [http://homepage.cs.uiowa.edu/~ajreynol/thesis.pdf].&lt;br /&gt;
** Enumerative instantiation, as described in [http://homepage.divms.uiowa.edu/~ajreynol/tacas18.pdf].&lt;br /&gt;
** Techniques for finding counterexamples for conjectures in the presence of recursive functions [http://homepage.cs.uiowa.edu/~ajreynol/ijcar16a.pdf].&lt;br /&gt;
** Automated induction for datatypes [http://homepage.cs.uiowa.edu/~ajreynol/vmcai15.pdf].&lt;br /&gt;
** A decision procedure for quantified linear integer and real arithmetic [http://homepage.divms.uiowa.edu/~ajreynol/fmsd17-instla.pdf].&lt;br /&gt;
** A dedicated approach for quantified bit-vectors based on invertibility conditions, as described in [http://homepage.divms.uiowa.edu/~ajreynol/cav18.pdf].&lt;br /&gt;
** Support for syntax-guided synthesis, as described in [http://homepage.cs.uiowa.edu/~ajreynol/cav15a.pdf].&lt;br /&gt;
* Relations&lt;br /&gt;
** An extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&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;
* Separation Logic&lt;br /&gt;
** A decision procedure for a fragment quantifier-free separation logic containing negation, separation star and magic wand is implemented and can be composed with other decision procedures supported by CVC4.  For details see [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf A Decision Procedure for Separation Logic in SMT].&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.stanford.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;
** Decision procedure for regular memberships with length [http://homepage.cs.uiowa.edu/~ajreynol/frocos15.pdf].&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5719</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5719"/>
				<updated>2018-05-08T13:56:43Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &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.stanford.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|datatypes]]&lt;br /&gt;
* [[records|datatypes]]&lt;br /&gt;
* user-defined inductive [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets and relations]]&lt;br /&gt;
* [[Separation Logic|separation logic]]&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://cvc4.cs.stanford.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 [https://github.com/CVC4/CVC4/blob/master/COPYING 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.stanford.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;
** A heuristic approach non-linear arithmetic is supported based on this paper [https://es-static.fbk.eu/people/griggio/papers/tacas17.pdf].&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://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
** This procedure has been extended to incorporate coinductive datatypes [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf].&lt;br /&gt;
** The datatypes decision procedure is optimized via the use of shared selectors, described in this paper [http://homepage.divms.uiowa.edu/~ajreynol/ijcar18.pdf].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** E-matching and conflict-based quantifier instantiation [http://homepage.cs.uiowa.edu/~ajreynol/fmcad14.pdf].&lt;br /&gt;
** Finite model finding [http://homepage.cs.uiowa.edu/~ajreynol/thesis.pdf].&lt;br /&gt;
** Enumerative instantiation, as described in [http://homepage.divms.uiowa.edu/~ajreynol/tacas18.pdf].&lt;br /&gt;
** Techniques for finding counterexamples for conjectures in the presence of recursive functions [http://homepage.cs.uiowa.edu/~ajreynol/ijcar16a.pdf].&lt;br /&gt;
** Automated induction for datatypes [http://homepage.cs.uiowa.edu/~ajreynol/vmcai15.pdf].&lt;br /&gt;
** A decision procedure for quantified linear integer and real arithmetic [http://homepage.divms.uiowa.edu/~ajreynol/fmsd17-instla.pdf].&lt;br /&gt;
** A dedicated approach for quantified bit-vectors based on invertibility conditions, as described in [http://homepage.divms.uiowa.edu/~ajreynol/cav18.pdf].&lt;br /&gt;
** Support for syntax-guided synthesis, as described in [http://homepage.cs.uiowa.edu/~ajreynol/cav15a.pdf].&lt;br /&gt;
* Relations&lt;br /&gt;
** An extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&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;
* Separation Logic&lt;br /&gt;
** A decision procedure for a fragment quantifier-free separation logic containing negation, separation star and magic wand is implemented and can be composed with other decision procedures supported by CVC4.  For details see [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf A Decision Procedure for Separation Logic in SMT].&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.stanford.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;
** Decision procedure for regular memberships with length [http://homepage.cs.uiowa.edu/~ajreynol/frocos15.pdf].&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5718</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5718"/>
				<updated>2018-05-08T13:56:15Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5717</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5717"/>
				<updated>2018-05-08T13:55:27Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Syntax/API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;br /&gt;
&lt;br /&gt;
=Syntax/API=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' fst:'''INT''', snd:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;fst&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;snd&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkRecordType'''(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''f1(t)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-}&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5716</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5716"/>
				<updated>2018-05-08T13:54:04Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;br /&gt;
&lt;br /&gt;
=Syntax/API=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt;Type&amp;gt; types;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;types.push_back(em.mkIntegerType());&amp;lt;/code&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkTupleType'''( types );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_SELECTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' fst:'''INT''', snd:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;fst&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;snd&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkRecordType'''(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''f1(t)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-}&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5715</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5715"/>
				<updated>2018-05-08T13:48:49Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;br /&gt;
&lt;br /&gt;
=Syntax/API=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' f1:'''INT''', f2:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;f1&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;f2&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkRecordType'''(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-}&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5714</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5714"/>
				<updated>2018-05-08T13:48:15Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Syntax/API=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' f1:'''INT''', f2:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;f1&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;f2&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkRecordType'''(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-}&lt;br /&gt;
&lt;br /&gt;
=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5713</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5713"/>
				<updated>2018-05-08T13:47:29Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Syntax=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' f1:'''INT''', f2:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;f1&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;vec.push_back(std::pair&amp;lt;std::string, Type&amp;gt;(&amp;quot;f2&amp;quot;,em.integerType());&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.'''mkRecordType'''(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-}&lt;br /&gt;
&lt;br /&gt;
=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5712</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5712"/>
				<updated>2018-05-08T13:45:51Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Syntax=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' f1:'''INT''', f2:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkRecordType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5711</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5711"/>
				<updated>2018-05-08T13:44:59Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' f1:'''INT''', f2:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkRecordType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5710</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5710"/>
				<updated>2018-05-08T13:44:22Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''DT''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''DT'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record Sort&lt;br /&gt;
| [# f1:&amp;lt;Sort_1&amp;gt;, ..., fn:&amp;lt;Sort_n&amp;gt; #]&lt;br /&gt;
| n/a&lt;br /&gt;
| CVC4::ExprManager::mkRecordType(const Record&amp;amp; r)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[#''' f1:'''INT''', f2:'''INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkRecordType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(# f1 := t1, ..., fn := tn #)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Record selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| n/a&lt;br /&gt;
| &amp;lt;code&amp;gt;std::vector&amp;lt; std::pair&amp;lt;std::string, Type&amp;gt; &amp;gt; vec;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;...&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Record r(vec);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;DatatypeType tt = em.mkRecordType(r);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5709</id>
		<title>Datatypes</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Datatypes&amp;diff=5709"/>
				<updated>2018-05-01T20:01:49Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Logic=&lt;br /&gt;
To enable CVC4's decision procedure for datatypes, include &amp;quot;DT&amp;quot; in the logic:&lt;br /&gt;
  (set-logic QF_UFDT)&lt;br /&gt;
Alternatively, use the &amp;quot;ALL_SUPPORTED&amp;quot; logic:&lt;br /&gt;
  (set-logic ALL_SUPPORTED)&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
CVC4 supports the following syntax for declaring mutually recursive blocks of datatypes in *.smt2 input files in the smt lib 2.6 format:&lt;br /&gt;
  (declare-datatypes ((D1 n1)...(Dk nk)) &lt;br /&gt;
    (((C1 (S1 T1)....(Si Ti))...(Cj .... ))&lt;br /&gt;
     ...&lt;br /&gt;
     ((....) ... (....)))&lt;br /&gt;
&lt;br /&gt;
where D1...Dk are datatype types, C1...Cj are the constructors for datatype D1, S1....Si are the selectors (or &amp;quot;destructors&amp;quot;) of constructor C1, and each T1...Ti is a previously declared type or one of D1...k. The symbols U1...Un are type parameters (fresh symbols).  The numbers n1...nk denote the number of type parameters for the datatype, where 0 is used for non-parametric datatypes.&lt;br /&gt;
&lt;br /&gt;
In addition to declaring symbols for constructors and selectors, the above command also adds tester (or &amp;quot;discriminator&amp;quot;) indexed symbols of the form (_ is C) for each constructor C, which are unary predicates which evaluate to true iff their argument has top-symbol C.&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports datatypes in its native format [http://cvc4.cs.nyu.edu/wiki/CVC4%27s_native_language#Inductive_Data_Types].&lt;br /&gt;
&lt;br /&gt;
=Semantics=&lt;br /&gt;
&lt;br /&gt;
The decision procedure for inductive datatypes can be found [http://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf here].&lt;br /&gt;
&lt;br /&gt;
=Example Declarations=&lt;br /&gt;
An enumeration:&lt;br /&gt;
  (declare-datatypes ((Color 0)) &lt;br /&gt;
    (((Red) (Black))))&lt;br /&gt;
&lt;br /&gt;
A List of Int with &amp;quot;cons&amp;quot; and &amp;quot;nil&amp;quot; as constructors:&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
&lt;br /&gt;
A parametric List of T's:&lt;br /&gt;
  (declare-datatypes ((list 1)) &lt;br /&gt;
    ((par (T) ((cons (head T) (tail (list T))) (nil)))))&lt;br /&gt;
&lt;br /&gt;
Mutual recursion:&lt;br /&gt;
  (declare-datatypes ((list 0) (tree 0)) &lt;br /&gt;
    (((cons (head tree) (tail list)) (nil))&lt;br /&gt;
     ((node (data Int) (children list)))))&lt;br /&gt;
&lt;br /&gt;
A (non-recursive) record type:&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((list 0)) &lt;br /&gt;
    (((cons (head Int) (tail list)) (nil))))&lt;br /&gt;
  (declare-fun a () list)&lt;br /&gt;
  (declare-fun b () list)&lt;br /&gt;
  (assert (and (= (tail a) b) (not ((_ is nil) b)) (&amp;gt; (head b) 0)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
  (declare-datatypes ((record 0))&lt;br /&gt;
    (((rec (fname String) (lname String) (id Int)))))&lt;br /&gt;
  (declare-const x record)&lt;br /&gt;
  (assert (and (= (fname x) &amp;quot;John&amp;quot;) (= (lname x) &amp;quot;Smith&amp;quot;)))&lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=Parametric Datatypes=&lt;br /&gt;
&lt;br /&gt;
Instances of parametric datatypes must have their arguments instantiated with concrete types. For instance, in the example:&lt;br /&gt;
  (declare-datatypes ((list 1)) ((par (T) (cons (head T) (tail (list T))) (nil))))&lt;br /&gt;
&lt;br /&gt;
To declare a list of Int, use the command:&lt;br /&gt;
  (declare-fun f () (list Int))&lt;br /&gt;
&lt;br /&gt;
Use of constructors that are ambiguously typed must be cast to a concrete type, for instance all occurrences of &amp;quot;nil&amp;quot; for the above datatype must be cast with the syntax:&lt;br /&gt;
  (as nil (list Int))&lt;br /&gt;
&lt;br /&gt;
=Tuples=&lt;br /&gt;
&lt;br /&gt;
Tuples are a particular instance of an inductive datatype. CVC4 supports special syntax for tuples as an extension of the SMT-LIB version 2 format. For example:&lt;br /&gt;
  (declare-fun t () (Tuple Int Int))&lt;br /&gt;
  (assert (= ((_ tupSel 0) t) 3))&lt;br /&gt;
  (assert (not (= t (mkTuple 3 4))))&lt;br /&gt;
&lt;br /&gt;
=Codatatypes=&lt;br /&gt;
&lt;br /&gt;
CVC4 also supports co-inductive datatypes, as described [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf here].  The syntax for declaring mutually recursive coinductive datatype blocks is identical to inductive datatypes, except that &amp;quot;declare-datatypes&amp;quot; is replaced by &amp;quot;declare-codatatypes&amp;quot;.  For example, the following declares the type denote streams of Int:&lt;br /&gt;
  (declare-codatatypes ((stream 0)) &lt;br /&gt;
    (((cons (head Int) (tail stream)))))&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5708</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5708"/>
				<updated>2018-05-01T19:58:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* 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.stanford.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 [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets and relations]]&lt;br /&gt;
* [[Separation Logic|separation logic]]&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://cvc4.cs.stanford.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 [https://github.com/CVC4/CVC4/blob/master/COPYING 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.stanford.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;
** A heuristic approach non-linear arithmetic is supported based on this paper [https://es-static.fbk.eu/people/griggio/papers/tacas17.pdf].&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://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
** This procedure has been extended to incorporate coinductive datatypes [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf].&lt;br /&gt;
** The datatypes decision procedure is optimized via the use of shared selectors, described in this paper [http://homepage.divms.uiowa.edu/~ajreynol/ijcar18.pdf].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** E-matching and conflict-based quantifier instantiation [http://homepage.cs.uiowa.edu/~ajreynol/fmcad14.pdf].&lt;br /&gt;
** Finite model finding [http://homepage.cs.uiowa.edu/~ajreynol/thesis.pdf].&lt;br /&gt;
** Enumerative instantiation, as described in [http://homepage.divms.uiowa.edu/~ajreynol/tacas18.pdf].&lt;br /&gt;
** Techniques for finding counterexamples for conjectures in the presence of recursive functions [http://homepage.cs.uiowa.edu/~ajreynol/ijcar16a.pdf].&lt;br /&gt;
** Automated induction for datatypes [http://homepage.cs.uiowa.edu/~ajreynol/vmcai15.pdf].&lt;br /&gt;
** A decision procedure for quantified linear integer and real arithmetic [http://homepage.divms.uiowa.edu/~ajreynol/fmsd17-instla.pdf].&lt;br /&gt;
** A dedicated approach for quantified bit-vectors based on invertibility conditions, as described in [http://homepage.divms.uiowa.edu/~ajreynol/cav18.pdf].&lt;br /&gt;
** Support for syntax-guided synthesis, as described in [http://homepage.cs.uiowa.edu/~ajreynol/cav15a.pdf].&lt;br /&gt;
* Relations&lt;br /&gt;
** An extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&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;
* Separation Logic&lt;br /&gt;
** A decision procedure for a fragment quantifier-free separation logic containing negation, separation star and magic wand is implemented and can be composed with other decision procedures supported by CVC4.  For details see [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf A Decision Procedure for Separation Logic in SMT].&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.stanford.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;
** Decision procedure for regular memberships with length [http://homepage.cs.uiowa.edu/~ajreynol/frocos15.pdf].&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5707</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5707"/>
				<updated>2018-05-01T19:57:58Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* 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.stanford.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 [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets and relations]]&lt;br /&gt;
* [[Separation Logic|separation logic]]&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://cvc4.cs.stanford.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 [https://github.com/CVC4/CVC4/blob/master/COPYING 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.stanford.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;
** A heuristic approach non-linear arithmetic is supported based on this paper [https://es-static.fbk.eu/people/griggio/papers/tacas17.pdf].&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://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
** This procedure has been extended to incorporate coinductive datatypes [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf].&lt;br /&gt;
** The datatypes decision procedure is optimized via the use of shared selectors, described in this paper [http://homepage.divms.uiowa.edu/~ajreynol/ijcar18.pdf].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** E-matching and conflict-based quantifier instantiation [http://homepage.cs.uiowa.edu/~ajreynol/fmcad14.pdf].&lt;br /&gt;
** Finite model finding [http://homepage.cs.uiowa.edu/~ajreynol/thesis.pdf].&lt;br /&gt;
** Enumerative instantiation, as described in [http://homepage.divms.uiowa.edu/~ajreynol/tacas18.pdf].&lt;br /&gt;
** Techniques for finding counterexamples for conjectures in the presence of recursive functions [http://homepage.cs.uiowa.edu/~ajreynol/ijcar16a.pdf].&lt;br /&gt;
** Automated induction for datatypes [http://homepage.cs.uiowa.edu/~ajreynol/vmcai15.pdf].&lt;br /&gt;
** A decision procedure for quantified linear integer and real arithmetic [http://homepage.divms.uiowa.edu/~ajreynol/fmsd17-instla.pdf].&lt;br /&gt;
** Support for syntax-guided synthesis, as described in [http://homepage.cs.uiowa.edu/~ajreynol/cav15a.pdf].&lt;br /&gt;
* Relations&lt;br /&gt;
** An extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&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;
* Separation Logic&lt;br /&gt;
** A decision procedure for a fragment quantifier-free separation logic containing negation, separation star and magic wand is implemented and can be composed with other decision procedures supported by CVC4.  For details see [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf A Decision Procedure for Separation Logic in SMT].&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.stanford.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;
** Decision procedure for regular memberships with length [http://homepage.cs.uiowa.edu/~ajreynol/frocos15.pdf].&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5706</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5706"/>
				<updated>2018-05-01T19:56:58Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* 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.stanford.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 [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets and relations]]&lt;br /&gt;
* [[Separation Logic|separation logic]]&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://cvc4.cs.stanford.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 [https://github.com/CVC4/CVC4/blob/master/COPYING 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.stanford.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;
** A heuristic approach non-linear arithmetic is supported based on this paper [https://es-static.fbk.eu/people/griggio/papers/tacas17.pdf].&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://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
** This procedure has been extended to incorporate coinductive datatypes [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** E-matching and conflict-based quantifier instantiation [http://homepage.cs.uiowa.edu/~ajreynol/fmcad14.pdf].&lt;br /&gt;
** Finite model finding [http://homepage.cs.uiowa.edu/~ajreynol/thesis.pdf].&lt;br /&gt;
** Enumerative instantiation, as described in [http://homepage.divms.uiowa.edu/~ajreynol/tacas18.pdf].&lt;br /&gt;
** Techniques for finding counterexamples for conjectures in the presence of recursive functions [http://homepage.cs.uiowa.edu/~ajreynol/ijcar16a.pdf].&lt;br /&gt;
** Automated induction for datatypes [http://homepage.cs.uiowa.edu/~ajreynol/vmcai15.pdf].&lt;br /&gt;
** A decision procedure for quantified linear integer and real arithmetic [http://homepage.divms.uiowa.edu/~ajreynol/fmsd17-instla.pdf].&lt;br /&gt;
** Support for syntax-guided synthesis, as described in [http://homepage.cs.uiowa.edu/~ajreynol/cav15a.pdf].&lt;br /&gt;
* Relations&lt;br /&gt;
** An extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&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;
* Separation Logic&lt;br /&gt;
** A decision procedure for a fragment quantifier-free separation logic containing negation, separation star and magic wand is implemented and can be composed with other decision procedures supported by CVC4.  For details see [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf A Decision Procedure for Separation Logic in SMT].&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.stanford.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;
** Decision procedure for regular memberships with length [http://homepage.cs.uiowa.edu/~ajreynol/frocos15.pdf].&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5705</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5705"/>
				<updated>2018-05-01T19:54:00Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* 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.stanford.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 [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets and relations]]&lt;br /&gt;
* [[Separation Logic|separation logic]]&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://cvc4.cs.stanford.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 [https://github.com/CVC4/CVC4/blob/master/COPYING 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.stanford.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://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
** This procedure has been extended to incorporate coinductive datatypes [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** E-matching and conflict-based quantifier instantiation [http://homepage.cs.uiowa.edu/~ajreynol/fmcad14.pdf].&lt;br /&gt;
** Finite model finding [http://homepage.cs.uiowa.edu/~ajreynol/thesis.pdf].&lt;br /&gt;
** Enumerative instantiation, as described in [http://homepage.divms.uiowa.edu/~ajreynol/tacas18.pdf].&lt;br /&gt;
** Techniques for finding counterexamples for conjectures in the presence of recursive functions [http://homepage.cs.uiowa.edu/~ajreynol/ijcar16a.pdf].&lt;br /&gt;
** Automated induction for datatypes [http://homepage.cs.uiowa.edu/~ajreynol/vmcai15.pdf].&lt;br /&gt;
** A decision procedure for quantified linear integer and real arithmetic [http://homepage.divms.uiowa.edu/~ajreynol/fmsd17-instla.pdf].&lt;br /&gt;
** Support for syntax-guided synthesis, as described in [http://homepage.cs.uiowa.edu/~ajreynol/cav15a.pdf].&lt;br /&gt;
* Relations&lt;br /&gt;
** An extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&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;
* Separation Logic&lt;br /&gt;
** A decision procedure for a fragment quantifier-free separation logic containing negation, separation star and magic wand is implemented and can be composed with other decision procedures supported by CVC4.  For details see [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf A Decision Procedure for Separation Logic in SMT].&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.stanford.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;
** Decision procedure for regular memberships with length [http://homepage.cs.uiowa.edu/~ajreynol/frocos15.pdf].&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5704</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5704"/>
				<updated>2018-05-01T19:52:08Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* 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.stanford.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 [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets and relations]]&lt;br /&gt;
* [[Separation Logic|separation logic]]&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://cvc4.cs.stanford.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 [https://github.com/CVC4/CVC4/blob/master/COPYING 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.stanford.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://homepage.cs.uiowa.edu/~tinelli/papers/BarST-JSAT-07.pdf An Abstract Decision Procedure for a Theory of Inductive Data Types].&lt;br /&gt;
** This procedure has been extended to incorporate coinductive datatypes [http://homepage.cs.uiowa.edu/~ajreynol/cade15.pdf].&lt;br /&gt;
* Quantifiers&lt;br /&gt;
** E-matching and conflict-based quantifier instantiation [http://homepage.cs.uiowa.edu/~ajreynol/fmcad14.pdf].&lt;br /&gt;
** Finite model finding [http://homepage.cs.uiowa.edu/~ajreynol/thesis.pdf].&lt;br /&gt;
** Techniques for finding counterexamples for conjectures in the presence of recursive functions [http://homepage.cs.uiowa.edu/~ajreynol/ijcar16a.pdf].&lt;br /&gt;
** Automated induction for datatypes [http://homepage.cs.uiowa.edu/~ajreynol/vmcai15.pdf].&lt;br /&gt;
** A decision procedure for quantified linear arithmetic with one alternation [http://homepage.cs.uiowa.edu/~ajreynol/report-inst-la15.pdf].&lt;br /&gt;
** Support for syntax-guided synthesis, as described in [http://homepage.cs.uiowa.edu/~ajreynol/cav15a.pdf].&lt;br /&gt;
* Relations&lt;br /&gt;
** An extension of the decision procedure for sets, as described in [http://homepage.cs.uiowa.edu/~tinelli/papers/MenEtAl-CADE-17.pdf].&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;
* Separation Logic&lt;br /&gt;
** A decision procedure for a fragment quantifier-free separation logic containing negation, separation star and magic wand is implemented and can be composed with other decision procedures supported by CVC4.  For details see [http://homepage.divms.uiowa.edu/~ajreynol/atva16.pdf A Decision Procedure for Separation Logic in SMT].&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.stanford.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;
** Decision procedure for regular memberships with length [http://homepage.cs.uiowa.edu/~ajreynol/frocos15.pdf].&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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5703</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5703"/>
				<updated>2018-05-01T19:46:34Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;t: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun t () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(t1, ..., tn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' t1, ..., tn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, t1, ..., tn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''t.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' t)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType tt = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = tt.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, t);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5702</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5702"/>
				<updated>2018-05-01T19:45:15Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(X1, ..., Xn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType t = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = t.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple selector&lt;br /&gt;
| &amp;lt;code&amp;gt;'''X.i'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''(_ tupSel i)''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType t = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = t.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr s = dt[0][i].getSelector();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', s, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5701</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5701"/>
				<updated>2018-04-25T18:50:02Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: &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;
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, Z )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''str.substr''' X Y Z)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::STRING_SUBSTR''', X, Y, Z);&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;
==Extended Functions==&lt;br /&gt;
Following functions are available when using the --strings-exp option. &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.stanford.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;
=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>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5700</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5700"/>
				<updated>2018-04-25T17:52:10Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkTupleType'''( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(X1, ..., Xn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType t = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = t.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.'''mkTupleType'''( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5699</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5699"/>
				<updated>2018-04-25T17:51:21Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(X1, ..., Xn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType t = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = t.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5698</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5698"/>
				<updated>2018-04-25T17:50:26Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(X1, ..., Xn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType t = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = t.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5697</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5697"/>
				<updated>2018-04-25T17:48:36Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;'''(X1, ..., Xn)'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''mkTuple''' X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType t = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = t.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TRANSPOSE''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::TCLOSURE''', X);  &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::JOIN''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; em.mkExpr('''kind::PRODUCT''', X); &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5696</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5696"/>
				<updated>2018-04-25T17:46:48Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;(X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(mkTuple X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;DatatypeType t = em.mkTupleType(types);&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;const Datatype&amp;amp; dt = t.getDatatype();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;Expr c = dt[0].getConstructor();&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', c, X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5695</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5695"/>
				<updated>2018-04-25T17:45:04Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;(X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(mkTuple X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;A;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;B;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;c;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5694</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5694"/>
				<updated>2018-04-25T17:42:17Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Set (Tuple Int Int))''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () '''(Tuple Int Int)''') &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;(X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(mkTuple X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5693</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5693"/>
				<updated>2018-04-25T17:41:24Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| '''(Set (Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;))'''&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () ('''Set''' ('''Tuple''' Int Int))) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [&amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;]&lt;br /&gt;
| '''(Tuple &amp;lt;Sort_1&amp;gt;, ..., &amp;lt;Sort_n&amp;gt;)'''&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; types)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () ('''Tuple''' Int Int)) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;(X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(mkTuple X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5692</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5692"/>
				<updated>2018-04-25T17:38:01Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [ElementSort_1, ..., ElementSort_n]&lt;br /&gt;
| (Set (Tuple ElementSort_1, ..., ElementSort_n))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () (Set (Tuple Int Int))) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [ElementSort_1, ..., ElementSort_n]&lt;br /&gt;
| (Tuple ElementSort_1, ..., ElementSort_n)&lt;br /&gt;
| CVC4::ExprManager::mkTupleType(std::vector&amp;lt;CVC4::Type&amp;gt;&amp;amp; elementTypes)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () (Tuple Int Int)) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;(X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(mkTuple X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5691</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5691"/>
				<updated>2018-04-25T17:35:54Z</updated>
		
		<summary type="html">&lt;p&gt;Ajreynol: /* Finite Relations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Finite Sets=&lt;br /&gt;
&lt;br /&gt;
As of July 2014 (CVC4 v1.4), we include support for theory of finite sets. The simplest way to get a sense of the syntax is to look at an example:&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/cvc-sample.cvc CVC language example]&lt;br /&gt;
* [https://github.com/CVC4/CVC4/blob/1.4/test/regress/regress0/sets/sets-sample.smt2 SMT language example]&lt;br /&gt;
*  API example: [[Tutorials#Sets|tutorial]], [https://github.com/CVC4/CVC4/blob/1.4/examples/api/sets.cpp source code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For reference, below is a short summary of the sorts, constants, functions and predicates.&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;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
| append &amp;quot;FS&amp;quot; for finite sets&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;(set-logic QF_UFLIA'''FS''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_UFLIA'''FS'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF &amp;lt;Element Sort&amp;gt;&lt;br /&gt;
| (Set &amp;lt;Element Sort&amp;gt;) &lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF INT''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(declare-fun X () '''(Set Int)''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.'''mkSetType'''( em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Union&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''union''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::UNION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Intersection&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''intersection''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INTERSECTION''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Set subtraction&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''setminus''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SETMINUS''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Membership&lt;br /&gt;
| &amp;lt;code&amp;gt;x '''&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''member''' x X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::MEMBER''', x, X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subset&lt;br /&gt;
| &amp;lt;code&amp;gt;X '''&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;''' Y&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''subset''' X Y)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SUBSET''', X, Y);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Empty set&lt;br /&gt;
| {} :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as emptyset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| CVC4::EmptySet(CVC4::SetType setType)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{}''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''emptyset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkConst('''EmptySet'''(em.mkSetType(em.integerType())));&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Singleton set&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''singleton''' 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::SINGLETON''', oneExpr);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cardinality&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;CARD&amp;lt;/nowiki&amp;gt;'''( X )&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''card''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::CARD''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Insert/finite sets&lt;br /&gt;
| &amp;lt;code&amp;gt;'''{1, 2, 3, 4}'''&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''insert''' 1 2 3 (singleton 4))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::INSERT''', c1, c2, c3, sgl4);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Complement&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;~&amp;lt;/nowiki&amp;gt;''' X&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;('''complement''' X)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::COMPLEMENT''', X);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Universe set&lt;br /&gt;
| UNIVERSE :: &amp;lt;Type Ascription&amp;gt;&lt;br /&gt;
| (as univset &amp;lt;Type Ascription&amp;gt;)&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| &amp;lt;code&amp;gt;'''UNIVERSE''' :: SET OF INT&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(as '''univset''' (Set Int))&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkNullaryOperator(em.mkSetType(em.integerType()),'''kind::UNIVERSE_SET''');&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operator precedence for CVC language:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;–&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IS_IN&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, &amp;lt;code&amp;gt;A - B | A &amp;amp; C &amp;lt;= D&amp;lt;/code&amp;gt; is read as &amp;lt;code&amp;gt;( A - ( B | (A &amp;amp; C) ) ) &amp;lt;= D&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Finite Relations=&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;
| &amp;lt;code&amp;gt;(set-logic QF_'''ALL''')&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;smt.setLogic(&amp;quot;QF_'''ALL'''&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Relation Sort&lt;br /&gt;
| SET OF [ElementSort_1, ..., ElementSort_n]&lt;br /&gt;
| (Set (Tuple ElementSort_1, ..., ElementSort_n))&lt;br /&gt;
| CVC4::ExprManager::mkSetType(CVC4::Type elementType)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''SET OF [INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () (Set (Tuple Int Int))) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkSetType( em.mkTupleType( em.integerType(), em.integerType() ) );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple Sort&lt;br /&gt;
| [ElementSort_1, ..., ElementSort_n]&lt;br /&gt;
| (Tuple ElementSort_1, ..., ElementSort_n)&lt;br /&gt;
| --&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| &amp;lt;code&amp;gt;X: '''[INT, INT]''';&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; (declare-fun X () (Tuple Int Int)) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkTupleType( em.integerType(), em.integerType() );&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Tuple constructor&lt;br /&gt;
| &amp;lt;code&amp;gt;(X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;(mkTuple X1, ..., Xn)&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;em.mkExpr('''kind::APPLY_CONSTRUCTOR''', X1, ..., Xn);&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transpose&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TRANSPOSE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''transpose''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Transitive Closure&lt;br /&gt;
| &amp;lt;code&amp;gt;'''&amp;lt;nowiki&amp;gt;TCLOSURE&amp;lt;/nowiki&amp;gt;'''(X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''tclosure''' X) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Join&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;JOIN&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''join''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Product&lt;br /&gt;
| &amp;lt;code&amp;gt; X '''&amp;lt;nowiki&amp;gt;PRODUCT&amp;lt;/nowiki&amp;gt;''' Y &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; ('''product''' X Y) &amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt; -- &amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
Note: Currently, we only support encoding relational constraints in CVC4 native language. Support for SMT-LIB language is coming soon.&lt;/div&gt;</summary>
		<author><name>Ajreynol</name></author>	</entry>

	</feed>