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

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5689</id>
		<title>Sets</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Sets&amp;diff=5689"/>
				<updated>2018-04-24T21:56:41Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: &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;
| --&lt;br /&gt;
| --&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| --&lt;br /&gt;
| --&lt;br /&gt;
|-&lt;br /&gt;
| Sort&lt;br /&gt;
| SET OF [ElementSort_1, ..., ElementSort_n]&lt;br /&gt;
|  (Set (Tuple ElementSort_1, ..., ElementSort_n))&lt;br /&gt;
| --&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; -- &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>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5688</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5688"/>
				<updated>2018-04-24T21:55:35Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: &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;
* 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>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Registration&amp;diff=5554</id>
		<title>User Registration</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Registration&amp;diff=5554"/>
				<updated>2017-06-07T20:44:26Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To register as a new user, please contact a member of the Stanford team, especially:&lt;br /&gt;
&lt;br /&gt;
* [http://theory.stanford.edu/~barrett/ Clark Barrett]&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=5400</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=5400"/>
				<updated>2015-11-01T18:06:09Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Global symbol definitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN;&lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y);&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 EmptyTupleType: TYPE = []; % this is a unit type&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL];&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q: BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[#Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.  Note that the empty tuple can be created with &amp;lt;math&amp;gt;(\ )&amp;lt;/math&amp;gt;; however, a single-element tuple cannot be directly created, as &amp;lt;math&amp;gt;(\ \_\ )&amp;lt;/math&amp;gt; is interpreted as a parenthesized (non-tuple) expression.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from assertion (stack) level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current assertion level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt;]] -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== PUSH and POPTO ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4's context can be understood as being stratified in ''assertion levels''&lt;br /&gt;
which are added and removed in a LIFO fashion.&lt;br /&gt;
The system starts at assertion level 0 and every execution of the PUSH command creates a new assertion level after the current one.&lt;br /&gt;
Each formula added to the context either by the user, via an ASSERT command, or internally by the system&lt;br /&gt;
is added to the most recent assertion level.&lt;br /&gt;
Executing POPTO n removes from the context the most recent n assertion levels and all the formulas in them.&lt;br /&gt;
So, for instance, POP 1 has the effect of retracting all formulas in the current assertion level (and removing that level).&lt;br /&gt;
Note that formulas at assertion level 0 cannot be retracted.&lt;br /&gt;
&lt;br /&gt;
Note: Symbol declarations are always added at assertion level zero. So they are not affected by POPTO commands.&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=5399</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=5399"/>
				<updated>2015-11-01T17:55:13Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Terms and Formulas */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN;&lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y);&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 EmptyTupleType: TYPE = []; % this is a unit type&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL];&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q: BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.  Note that the empty tuple can be created with &amp;lt;math&amp;gt;(\ )&amp;lt;/math&amp;gt;; however, a single-element tuple cannot be directly created, as &amp;lt;math&amp;gt;(\ \_\ )&amp;lt;/math&amp;gt; is interpreted as a parenthesized (non-tuple) expression.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from assertion (stack) level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current assertion level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt;]] -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== PUSH and POPTO ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4's context can be understood as being stratified in ''assertion levels''&lt;br /&gt;
which are added and removed in a LIFO fashion.&lt;br /&gt;
The system starts at assertion level 0 and every execution of the PUSH command creates a new assertion level after the current one.&lt;br /&gt;
Each formula added to the context either by the user, via an ASSERT command, or internally by the system&lt;br /&gt;
is added to the most recent assertion level.&lt;br /&gt;
Executing POPTO n removes from the context the most recent n assertion levels and all the formulas in them.&lt;br /&gt;
So, for instance, POP 1 has the effect of retracting all formulas in the current assertion level (and removing that level).&lt;br /&gt;
Note that formulas at assertion level 0 cannot be retracted.&lt;br /&gt;
&lt;br /&gt;
Note: Symbol declarations are always added at assertion level zero. So they are not affected by POPTO commands.&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5387</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5387"/>
				<updated>2015-06-09T23:26:57Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Extension */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentive 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 quanfier-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;
If the formulas contain sybols from theories, please add them accordingly, &lt;br /&gt;
e.g., if the formulas contain symbols from the BitVector theory, &lt;br /&gt;
the logic symbol should be &amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic consisting of the full (quantified) theory strings is &lt;br /&gt;
&amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
&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;
==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 a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (Coming soon.)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extensions=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, termination is not guaranteed; however, users can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
The current version of the solver supports ASCII characters only. We might move on to UNICODE in future versions.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5386</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5386"/>
				<updated>2015-06-09T23:26:20Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Limitation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentive 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 quanfier-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;
If the formulas contain sybols from theories, please add them accordingly, &lt;br /&gt;
e.g., if the formulas contain symbols from the BitVector theory, &lt;br /&gt;
the logic symbol should be &amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic consisting of the full (quantified) theory strings is &lt;br /&gt;
&amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
&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;
==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 a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (Coming soon.)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitations=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, termination is not guaranteed; however, users can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
The current version of the solver supports ASCII characters only. We might move on to UNICODE in future versions.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5385</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5385"/>
				<updated>2015-06-09T22:02:00Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Escape Sequences for String Literals */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentive 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 quanfier-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;
If the formulas contain sybols from theories, please add them accordingly, &lt;br /&gt;
e.g., if the formulas contain symbols from the BitVector theory, &lt;br /&gt;
the logic symbol should be &amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic consisting of the full (quantified) theory strings is &lt;br /&gt;
&amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
&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;
==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 a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (Coming soon.)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5384</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5384"/>
				<updated>2015-06-09T22:00:34Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Escape Sequences for Regular Expressions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentive 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 quanfier-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;
If the formulas contain sybols from theories, please add them accordingly, &lt;br /&gt;
e.g., if the formulas contain symbols from the BitVector theory, &lt;br /&gt;
the logic symbol should be &amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic consisting of the full (quantified) theory strings is &lt;br /&gt;
&amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
&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;
==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 for String Literals==&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;
&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 a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (Coming soon.)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5383</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5383"/>
				<updated>2015-06-09T21:59:30Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* 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;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentive 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 quanfier-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;
If the formulas contain sybols from theories, please add them accordingly, &lt;br /&gt;
e.g., if the formulas contain symbols from the BitVector theory, &lt;br /&gt;
the logic symbol should be &amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic consisting of the full (quantified) theory strings is &lt;br /&gt;
&amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
&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;
==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 for String Literals==&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;
&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 a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5382</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5382"/>
				<updated>2015-06-09T21:49:40Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentive 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 quanfier-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;
If the formulas contain sybols from theories, please add them accordingly, &lt;br /&gt;
e.g., if the formulas contain symbols from the BitVector theory, &lt;br /&gt;
the logic symbol should be &amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic consisting of the full (quantified) theory strings is &lt;br /&gt;
&amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
&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;
==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 for String Literals==&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;
&lt;br /&gt;
==Theory Signature==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5381</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Strings&amp;diff=5381"/>
				<updated>2015-06-09T21:42:49Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: Revised section on string constants to be consistent with SMT-LIB 2.5, CVC4 front end might need to be revised accordingly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes support for the theory of strings in CVC4.&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
This document focuses on input written in SMT-LIB 2 format. &lt;br /&gt;
A frontend for CVC4's native syntax is not available yet.&lt;br /&gt;
&lt;br /&gt;
'''We highly recommend that users use SMT-LIB [http://smt-lib.org/language.shtml Version 2.5], &lt;br /&gt;
instead of Version 2.0.''' &lt;br /&gt;
The major difference is in the definition of escape sequences for string literals.&lt;br /&gt;
&lt;br /&gt;
'''The syntax below is for CVC4 version &amp;gt; 1.4.''' Version 1.3 has only&lt;br /&gt;
''partial'' support for syntax in this document.&lt;br /&gt;
&lt;br /&gt;
Since the string (sub)solver is still relatively new, the current stable version &lt;br /&gt;
of CVC4 (1.4) does not provide the latest version of that solver.  &lt;br /&gt;
Please use our latest Development version instead.&lt;br /&gt;
&lt;br /&gt;
Currently, the string solver supports string constants over a set of characters&lt;br /&gt;
limited to the printable ASCII characters. Other characters ''must'' be encoded &lt;br /&gt;
with escape sequences. &lt;br /&gt;
For arbitry alphabets, we plan to provide later a separate solver &lt;br /&gt;
for a theory of parametric sequences.&lt;br /&gt;
&lt;br /&gt;
To use the string solver it is important to declare initially &lt;br /&gt;
(using the &amp;lt;code&amp;gt;set-logic&amp;lt;/code&amp;gt; command) an SMT-LIB logic that includes strings.&lt;br /&gt;
Since the SMT-LIB standard does not have an official theory of strings and &lt;br /&gt;
related logics yet, the logic names described below are tentive 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 quanfier-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;
If the formulas contain sybols from theories, please add them accordingly, &lt;br /&gt;
e.g., if the formulas contain symbols from the BitVector theory, &lt;br /&gt;
the logic symbol should be &amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The logic consisting of the full (quantified) theory strings is &lt;br /&gt;
&amp;lt;code&amp;gt;QF_SBV&amp;lt;/code&amp;gt;:&lt;br /&gt;
  (set-logic S)&lt;br /&gt;
&lt;br /&gt;
&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;
==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 for String Literals==&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 the 377 value 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;
When 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 that is not recognized as an escape sequence. For example, &amp;lt;quote&amp;gt;\$ &amp;lt;/quote&amp;gt;, say, is parsed as if it was just &amp;lt;quote&amp;gt;$&amp;lt;/quote&amp;gt;.&lt;br /&gt;
 &lt;br /&gt;
In CVC4 string literal output, 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. &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;
&lt;br /&gt;
==Theory Signature==&lt;br /&gt;
To define a string variable:&lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
&lt;br /&gt;
String Concatenation:&lt;br /&gt;
  (str.++ s1 s2 ... sn)&lt;br /&gt;
where s1, s2, ..., and sn are string terms. String concatenation takes at least 2 arguments.&lt;br /&gt;
&lt;br /&gt;
String Length:&lt;br /&gt;
  (str.len s)&lt;br /&gt;
where s is a string term.&lt;br /&gt;
&lt;br /&gt;
Character in String:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is a natural number. (see partial functions)&lt;br /&gt;
The index is starting from 0.&lt;br /&gt;
&lt;br /&gt;
Sub-String:&lt;br /&gt;
  (str.substr s i j )&lt;br /&gt;
where s is a string term, i and j are natural numbers. (see partial functions)&lt;br /&gt;
&lt;br /&gt;
==Escape Sequences for Regular Expressions==&lt;br /&gt;
Currently, it is for CVC format only. (coming soon)&lt;br /&gt;
&lt;br /&gt;
==Symbolic Regular Expression==&lt;br /&gt;
Membership Constraint:&lt;br /&gt;
  (str.in.re s r)&lt;br /&gt;
where s is a string term and r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
String to Regular Expression Conversion:&lt;br /&gt;
  (str.to.re s)&lt;br /&gt;
where s is a string term. The statement turns a regular expression that only contains a string s.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Concatenation:&lt;br /&gt;
  (re.++ r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Alternation:&lt;br /&gt;
  (re.union r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.or is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Intersection:&lt;br /&gt;
  (re.inter r_1 r_2 ... r_n)&lt;br /&gt;
where r_1, r_2, ..., r_n are regular expressions. re.itr is for releases before March, 2014.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Star:&lt;br /&gt;
  (re.* r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Kleene-Cross:&lt;br /&gt;
  (re.+ r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Option:&lt;br /&gt;
  (re.opt r)&lt;br /&gt;
where r is a regular expression.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Range:&lt;br /&gt;
  (re.range s t)&lt;br /&gt;
where s, t are single characters in double quotes, e.g. &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;.&lt;br /&gt;
It returns a regular expression that contains any character between s and t.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop:&lt;br /&gt;
  (re.loop r l u)&lt;br /&gt;
where r is a regular expression, l is a non-negative constant integer, and u is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r and at most u repetitions of r.&lt;br /&gt;
If l &amp;gt;= u, it returns exactly l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
Regular Expression Loop-2:&lt;br /&gt;
  (re.loop r l)&lt;br /&gt;
where r is a regular expression, and l is a non-negative constant integer.&lt;br /&gt;
It returns a regular expression that contains at least l repetitions of r.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Empty Regular Expression:&lt;br /&gt;
  re.nostr&lt;br /&gt;
&lt;br /&gt;
The Regular Expression that contains all characters:&lt;br /&gt;
  re.allchar&lt;br /&gt;
&lt;br /&gt;
==Experimental Mode==&lt;br /&gt;
Following functions are under the --strings-exp option. They are under active refinement. Once they are stable, we will move them to the default mode. Please let us know when you have some suggestions.&lt;br /&gt;
&lt;br /&gt;
String Char-At:&lt;br /&gt;
  (str.at s i)&lt;br /&gt;
where s is a string term and i is an integer term. i is the position. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Sub-string:&lt;br /&gt;
  (str.substr s i j)&lt;br /&gt;
where s is a string term and i, j are integer terms. i is the starting position, and j is the offset. See partial functions section.&lt;br /&gt;
&lt;br /&gt;
String Contain:&lt;br /&gt;
  (str.contains s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s contains the string t.&lt;br /&gt;
This function determines whether the string t can be found within the string s, returning true or false as appropriate.&lt;br /&gt;
&lt;br /&gt;
String IndexOf:&lt;br /&gt;
 (str.indexof s t i)&lt;br /&gt;
where s is a string, t is a non-empty string and i is a non-negative integer.&lt;br /&gt;
This function returns the position of the first occurrence of the specified value t in the string s after the index i.&lt;br /&gt;
It returns -1 if the value to search for never occurs.&lt;br /&gt;
&lt;br /&gt;
String Replacement:&lt;br /&gt;
 (str.replace s t1 t2)&lt;br /&gt;
where s, t1 and t2 are string terms, t1 is non-empty.&lt;br /&gt;
This function searches the string s for the specified value t1, and returns a new string where the first occurrence of the specified value t1 is replaced by the string t2.&lt;br /&gt;
&lt;br /&gt;
String PrefixOf:&lt;br /&gt;
 (str.prefixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a prefix of the string t.&lt;br /&gt;
&lt;br /&gt;
String SuffixOf:&lt;br /&gt;
 (str.suffixof s t)&lt;br /&gt;
where s and t are string terms. It returns true if the string s is a suffix of the string t.&lt;br /&gt;
&lt;br /&gt;
String To Integer Conversion:&lt;br /&gt;
 (str.to.int s)&lt;br /&gt;
where s is a string term. It returns the corresponding natural number if s is valid; otherwise, it returns -1.&lt;br /&gt;
&lt;br /&gt;
Integer To String Conversion:&lt;br /&gt;
 (int.to.str i)&lt;br /&gt;
where i is an integer term. It returns the corresponding string if i is a natural number; otherwise, it returns an empty string.&lt;br /&gt;
&lt;br /&gt;
=Partial Functions=&lt;br /&gt;
By the definition of partial functions in [http://www.smtlib.org/ SMT-Lib Document], the following constraint is satisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 10) &amp;quot;b&amp;quot;))&lt;br /&gt;
However, the following constraints are unsatisfiable:&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (= (str.substr &amp;quot;a&amp;quot; 2 1) &amp;quot;c&amp;quot;))&lt;br /&gt;
To achieve a desirable goal, it requires users to guard proper conditions. For example,&lt;br /&gt;
  (assert (= (str.at x j) &amp;quot;b&amp;quot;))&lt;br /&gt;
  (assert (&amp;gt; j 0))&lt;br /&gt;
  (assert (&amp;gt; (str.len x) j))&lt;br /&gt;
&lt;br /&gt;
=Extension=&lt;br /&gt;
Together with other engine in CVC4, we can extend new functionality in the theory of strings. For example,&lt;br /&gt;
  (define-fun fun1 ((?x String) (?s String)) Bool&lt;br /&gt;
    (or (= ?x ?s)&lt;br /&gt;
        (&amp;gt; (str.len ?x) (str.len ?s))&lt;br /&gt;
     ))&lt;br /&gt;
Quantifiers over bounded Integers (with strings in the body) are supported in the experimental mode; however, quantifiers over strings are still under development.&lt;br /&gt;
&lt;br /&gt;
=Limitation=&lt;br /&gt;
The decidability of this theory is unknown.&lt;br /&gt;
For satisfiable problems (without extensions), our solver is sound, complete and terminating in the FMF mode (although the FMF mode will be slower than the default mode in general). For unsatisfiable problems, the termination is not guaranteed; however, user can tune the options for termination.&lt;br /&gt;
&lt;br /&gt;
Current version supports ASCII characters only. We will move on to UNICODE in the future version.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
Find an assignment for x, where x.&amp;quot;ab&amp;quot;=&amp;quot;ba&amp;quot;.x and the length of x equals to 7.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot;) (str.++ &amp;quot;ba&amp;quot; x)))&lt;br /&gt;
  (assert (= (str.len x) 7))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x and y are distinct and their lengths are equal.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (=  x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find assignments for x and y, where x.y != y.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (assert (not (= (str.++ x y) (str.++ y x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x, y and z, where x.&amp;quot;ab&amp;quot;.y=y.&amp;quot;ba&amp;quot;.z and z=x.y and x.&amp;quot;a&amp;quot;!=&amp;quot;a&amp;quot;.x.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  (declare-fun z () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert (= (str.++ x &amp;quot;ab&amp;quot; y) (str.++ y &amp;quot;ba&amp;quot; z)))&lt;br /&gt;
  (assert (= z (str.++ x y)))&lt;br /&gt;
  (assert (not (= (str.++ x &amp;quot;a&amp;quot;) (str.++ &amp;quot;a&amp;quot; x))))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
Find a model for x and y, where both x and y are in the RegEx (a*b)* and they are different but have the same length.&lt;br /&gt;
  (set-logic QF_S)&lt;br /&gt;
  (set-option :strings-fmf true)&lt;br /&gt;
  &lt;br /&gt;
  (declare-fun x () String)&lt;br /&gt;
  (declare-fun y () String)&lt;br /&gt;
  &lt;br /&gt;
  (assert&lt;br /&gt;
    (str.in.re x&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  (assert (str.in.re y&lt;br /&gt;
       (re.* (re.++ (re.* (str.to.re &amp;quot;a&amp;quot;) ) (str.to.re &amp;quot;b&amp;quot;) ))))&lt;br /&gt;
  &lt;br /&gt;
  (assert (not (= x y)))&lt;br /&gt;
  (assert (= (str.len x) (str.len y)))&lt;br /&gt;
  &lt;br /&gt;
  (check-sat)&lt;br /&gt;
&lt;br /&gt;
=API=&lt;br /&gt;
More details can be found in the [http://cvc4.cs.nyu.edu/wiki/Tutorials Tutorials].&lt;br /&gt;
&lt;br /&gt;
==C++==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/strings.cpp examples/api/strings.cpp].&lt;br /&gt;
&lt;br /&gt;
If setting the logic, use &amp;quot;S&amp;quot; to enable theory of strings.&lt;br /&gt;
  smt.setLogic(&amp;quot;S&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
To create a string type, call &amp;lt;code&amp;gt;mkSetType&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;ExprManager&amp;lt;/code&amp;gt;.&lt;br /&gt;
  Type string = em.stringType();&lt;br /&gt;
&lt;br /&gt;
Make some string literals:&lt;br /&gt;
  // std::string&lt;br /&gt;
  std::string std_str_ab(&amp;quot;ab&amp;quot;);&lt;br /&gt;
  // CVC4::String&lt;br /&gt;
  CVC4::String cvc4_str_ab(std_str_ab);&lt;br /&gt;
  CVC4::String cvc4_str_abc(&amp;quot;abc&amp;quot;);&lt;br /&gt;
  // String constants&lt;br /&gt;
  Expr ab = em.mkConst(cvc4_str_ab);&lt;br /&gt;
  Expr abc = em.mkConst(CVC4::String(&amp;quot;abc&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
Make some string variables:&lt;br /&gt;
  Expr x = em.mkVar(&amp;quot;x&amp;quot;, string);&lt;br /&gt;
  Expr y = em.mkVar(&amp;quot;y&amp;quot;, string);&lt;br /&gt;
  Expr z = em.mkVar(&amp;quot;z&amp;quot;, string);&lt;br /&gt;
&lt;br /&gt;
Make some string constraints:&lt;br /&gt;
  // String concatenation: x.ab.y&lt;br /&gt;
  Expr lhs = em.mkExpr(kind::STRING_CONCAT, x, ab, y);&lt;br /&gt;
  // String concatenation: abc.z&lt;br /&gt;
  Expr rhs = em.mkExpr(kind::STRING_CONCAT, abc, z);&lt;br /&gt;
  // x.ab.y = abc.z&lt;br /&gt;
  Expr formula1 = em.mkExpr(kind::EQUAL, lhs, rhs);&lt;br /&gt;
  // Length of y: |y|&lt;br /&gt;
  Expr leny = em.mkExpr(kind::STRING_LENGTH, y);&lt;br /&gt;
  // |y| &amp;gt;= 0&lt;br /&gt;
  Expr formula2 = em.mkExpr(kind::GEQ, leny, em.mkConst(Rational(0)));&lt;br /&gt;
  // Regular expression: (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr r = em.mkExpr(kind::REGEXP_UNION,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_CONCAT,&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;ab&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::REGEXP_STAR,&lt;br /&gt;
  em.mkExpr(kind::REGEXP_RANGE, em.mkConst(String(&amp;quot;c&amp;quot;)), em.mkConst(String(&amp;quot;e&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;f&amp;quot;)))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;g&amp;quot;))),&lt;br /&gt;
  em.mkExpr(kind::STRING_TO_REGEXP, em.mkConst(String(&amp;quot;h&amp;quot;))));&lt;br /&gt;
  // String variables&lt;br /&gt;
  Expr s1 = em.mkVar(&amp;quot;s1&amp;quot;, string);&lt;br /&gt;
  Expr s2 = em.mkVar(&amp;quot;s2&amp;quot;, string);&lt;br /&gt;
  // String concatenation: s1.s2&lt;br /&gt;
  Expr s = em.mkExpr(kind::STRING_CONCAT, s1, s2);&lt;br /&gt;
  // s1.s2 in (ab[c-e]*f)|g|h&lt;br /&gt;
  Expr formula3 = em.mkExpr(kind::STRING_IN_REGEXP, s, r);&lt;br /&gt;
&lt;br /&gt;
Make a query:&lt;br /&gt;
  Expr q = em.mkExpr(kind::AND,&lt;br /&gt;
    formula1,&lt;br /&gt;
    formula2,&lt;br /&gt;
    formula3);&lt;br /&gt;
&lt;br /&gt;
Check the result:&lt;br /&gt;
  Result result = smt.checkSat(q);&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;CVC4 reports: &amp;quot; &amp;lt;&amp;lt; q &amp;lt;&amp;lt; &amp;quot; is &amp;quot; &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &amp;quot;.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  if(result == Result::SAT) {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; x = &amp;quot; &amp;lt;&amp;lt; smt.getValue(x) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot; s1.s2 = &amp;quot; &amp;lt;&amp;lt; smt.getValue(s) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
The example can be found in [https://github.com/CVC4/CVC4/blob/master/examples/api/java/Strings.java examples/api/java/Strings.java].&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
* Tianyi Liang, Andrew Reynolds, Cesare Tinelli, Clark Barrett and Morgan Deters. [http://link.springer.com/chapter/10.1007%2F978-3-319-08867-9_43 A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].In Proceedings of the 26th International Conference on Computer Aided Verification (CAV'14), Vienna, Austria, 2014.&lt;br /&gt;
* Tianyi Liang. [http://ir.uiowa.edu/etd/1478/ Automated reasoning over string constraints]. PhD Dissertation, Department of Computer Science, The University of Iowa, Dec 2014.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

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

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

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4517</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4517"/>
				<updated>2013-02-13T05:54:12Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Tuple Types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN;&lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y);&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL];&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from assertion (stack) level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current assertion level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt;]] -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== PUSH and POPTO ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4's context can be understood as being stratified in ''assertion levels''&lt;br /&gt;
which are added and removed in a LIFO fashion.&lt;br /&gt;
The system starts at assertion level 0 and every execution of the PUSH command creates a new assertion level after the current one.&lt;br /&gt;
Each formula added to the context either by the user, via an ASSERT command, or internally by the system&lt;br /&gt;
is added to the most recent assertion level.&lt;br /&gt;
Executing POPTO n removes from the context the most recent n assertion levels and all the formulas in them.&lt;br /&gt;
So, for instance, POP 1 has the effect of retracting all formulas in the current assertion level (and removing that level).&lt;br /&gt;
Note that formulas at assertion level 0 cannot be retracted.&lt;br /&gt;
&lt;br /&gt;
Note: Symbol declarations are always added at assertion level zero. So they are not affected by POPTO commands.&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4516</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4516"/>
				<updated>2013-02-13T05:52:01Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* The BOOLEAN Type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN;&lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y);&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from assertion (stack) level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current assertion level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt;]] -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== PUSH and POPTO ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4's context can be understood as being stratified in ''assertion levels''&lt;br /&gt;
which are added and removed in a LIFO fashion.&lt;br /&gt;
The system starts at assertion level 0 and every execution of the PUSH command creates a new assertion level after the current one.&lt;br /&gt;
Each formula added to the context either by the user, via an ASSERT command, or internally by the system&lt;br /&gt;
is added to the most recent assertion level.&lt;br /&gt;
Executing POPTO n removes from the context the most recent n assertion levels and all the formulas in them.&lt;br /&gt;
So, for instance, POP 1 has the effect of retracting all formulas in the current assertion level (and removing that level).&lt;br /&gt;
Note that formulas at assertion level 0 cannot be retracted.&lt;br /&gt;
&lt;br /&gt;
Note: Symbol declarations are always added at assertion level zero. So they are not affected by POPTO commands.&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4060</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4060"/>
				<updated>2012-12-03T22:28:11Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN; &lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y)&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from assertion (stack) level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current assertion level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt;]] -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== PUSH and POPTO ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4's context can be understood as being stratified in ''assertion levels''&lt;br /&gt;
which are added and removed in a LIFO fashion.&lt;br /&gt;
The system starts at assertion level 0 and every execution of the PUSH command creates a new assertion level after the current one.&lt;br /&gt;
Each formula added to the context either by the user, via an ASSERT command, or internally by the system&lt;br /&gt;
is added to the most recent assertion level.&lt;br /&gt;
Executing POPTO n removes from the context the most recent n assertion levels and all the formulas in them.&lt;br /&gt;
So, for instance, POP 1 has the effect of retracting all formulas in the current assertion level (and removing that level).&lt;br /&gt;
Note that formulas at assertion level 0 cannot be retracted.&lt;br /&gt;
&lt;br /&gt;
Note: Symbol declarations are always added at assertion level zero. So they are not affected by POPTO commands.&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4059</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4059"/>
				<updated>2012-12-03T22:27:14Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN; &lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y)&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* [[#PUSH and POPTO|&amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt;]] -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== PUSH and POPTO ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4's context can be understood as being stratified in ''assertion levels''&lt;br /&gt;
which are added and removed in a LIFO fashion.&lt;br /&gt;
The system starts at assertion level 0 and every execution of the PUSH command creates a new assertion level after the current one.&lt;br /&gt;
Each formula added to the context either by the user, via an ASSERT command, or internally by the system&lt;br /&gt;
is added to the most recent assertion level.&lt;br /&gt;
Executing POPTO n removes from the context the most recent n assertion levels and all the formulas in them.&lt;br /&gt;
So, for instance, POP 1 has the effect of retracting all formulas in the current assertion level (and removing that level).&lt;br /&gt;
Note that formulas at assertion level 0 cannot be retracted.&lt;br /&gt;
&lt;br /&gt;
Note: Symbol declarations are always added at assertion level zero. So they are not affected by POPTO commands.&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4058</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4058"/>
				<updated>2012-12-03T21:42:29Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* POPTO */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN; &lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y)&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== PUSH and POPTO ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4's context can be understood as being stratified in ''assertion levels''&lt;br /&gt;
which are added and removed in a LIFO fashion.&lt;br /&gt;
The system starts at assertion level 0 and every execution of the PUSH command creates a new assertion level after the current one.&lt;br /&gt;
Each formula added to the context either by the user, via an ASSERT command, or internally by the system&lt;br /&gt;
is added to the most recent assertion level.&lt;br /&gt;
Executing POPTO n removes from the context the most recent n assertion levels and all the formulas in them.&lt;br /&gt;
So, for instance, POP 1 has the effect of retracting all formulas in the current assertion level (and removing that level).&lt;br /&gt;
Note that formulas at assertion level 0 cannot be retracted.&lt;br /&gt;
&lt;br /&gt;
Note: Symbol declarations are always added at assertion level zero. So they are not affected by POPTO commands.&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4055</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4055"/>
				<updated>2012-12-03T21:21:38Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* The BOOLEAN Type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN; &lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y)&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT y = f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4054</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4054"/>
				<updated>2012-12-03T21:21:02Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* The BOOLEAN Type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN; &lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y)&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % The argument of f can be a formula ...&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % ... even a quantified one&lt;br /&gt;
 ASSERT f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4053</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4053"/>
				<updated>2012-12-03T21:20:38Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* The BOOLEAN Type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN; &lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y)&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % the argument of f can be a formula&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % Even a quantified one&lt;br /&gt;
 ASSERT f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4052</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4052"/>
				<updated>2012-12-03T21:19:41Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: Added example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &lt;br /&gt;
 % Boolean constants&lt;br /&gt;
 a, b: BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % REAL constants&lt;br /&gt;
 x,y: REAL&lt;br /&gt;
 &lt;br /&gt;
 % Boolean-valued function, can be used as a predicate symbol&lt;br /&gt;
 p: REAL -&amp;gt; BOOLEAN; &lt;br /&gt;
 ASSERT  a =&amp;gt; p(x - y)&lt;br /&gt;
 &lt;br /&gt;
 % Real-valued function with Boolean argument&lt;br /&gt;
 f: BOOLEAN -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % the argument of f can be formula&lt;br /&gt;
 ASSERT f(a OR b) &amp;gt; 0.3  OR  p(x);&lt;br /&gt;
 &lt;br /&gt;
 % Even a quantified one&lt;br /&gt;
 ASSERT f(FORALL (r: REAL): r &amp;lt; r + 1);&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are modeled by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided into the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4011</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4011"/>
				<updated>2012-11-30T23:19:02Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Local symbol definitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = s \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4010</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4010"/>
				<updated>2012-11-30T23:15:39Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Parametric Data Types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4009</id>
		<title>CVC4's native language</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4009"/>
				<updated>2012-11-30T23:14:58Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= CVC4 native input language =&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=4008</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=4008"/>
				<updated>2012-11-30T23:13:45Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* CVC4's input languages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This manual includes information on installing and using CVC4. It is a work in progress. &lt;br /&gt;
&lt;br /&gt;
=Getting CVC4=&lt;br /&gt;
&lt;br /&gt;
Both pre-compiled binaries and the source code for CVC4 are available for download from [http://cvc4.cs.nyu.edu/builds/ http://cvc4.cs.nyu.edu/builds/]. &lt;br /&gt;
&lt;br /&gt;
==Getting CVC4 binaries==&lt;br /&gt;
The most recent binaries can be downloaded from our Nightly Builds pages: &lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/debian/unstable Debian] packages&lt;br /&gt;
&lt;br /&gt;
To install CVC4 on an Ubuntu Machine follow the instructions below. First add the CVC4 respository to /etc/apt/source.list by inserting the following two lines at the end of the file:&lt;br /&gt;
  # CVC4 repository&lt;br /&gt;
  deb http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
  deb-src http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
&lt;br /&gt;
To run CVC4 as a binary you only need the first line but to use the library API you will also need the source package. &lt;br /&gt;
Make sure to update the respository list by running:&lt;br /&gt;
&lt;br /&gt;
  sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
Now you can simply install CVC4 as you would any other piece of sofware using the command:&lt;br /&gt;
  sudo apt-get install cvc4&lt;br /&gt;
&lt;br /&gt;
If you want to use CVC4 as a library also install the following packages: libcvc4-dev, and libcvc4-parser-dev.&lt;br /&gt;
&lt;br /&gt;
==Building CVC4 from source==&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/src/ Sources are available] from the same site as the binaries. The source-code is also available in the [http://cvc4.cs.nyu.edu/builds/src/ CVC4 source repository] which is currently hosted by [http://cims.nyu.edu/ CIMS] and therefore requires a CIMS account. Please contact a member of the development team for access. &lt;br /&gt;
&lt;br /&gt;
To build CVC4 from source the following steps are required. After downloading the source files first install antlr by running the following script in the CVC4 contrib directory:&lt;br /&gt;
    cd contrib&lt;br /&gt;
    ./get-antlr-3.4&lt;br /&gt;
&lt;br /&gt;
The next step is to configure CVC4:&lt;br /&gt;
    cd ..&lt;br /&gt;
    ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
&lt;br /&gt;
And then finally compile it:&lt;br /&gt;
    make&lt;br /&gt;
    make check   [recommended]&lt;br /&gt;
    make install [optional]&lt;br /&gt;
&lt;br /&gt;
For a comprehensive list of dependencies and more detailed build instructions see [[Building CVC4 from source]].&lt;br /&gt;
&lt;br /&gt;
=Using the CVC4 binary=&lt;br /&gt;
&lt;br /&gt;
Once installed, the CVC4 driver binary (&amp;quot;cvc4&amp;quot;) can be executed to directly enter into interactive mode:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then enter commands into CVC4 interactively:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;incremental&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;produce-models&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; TRANSFORM 25*25;&lt;br /&gt;
 625&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example shows two useful options, ''incremental'' and ''produce-models.''&lt;br /&gt;
&lt;br /&gt;
* The ''incremental'' option allows you to issue multiple QUERY (or CHECKSAT) commands, and allows the use of the PUSH and POP commands.  Without this option, CVC4 optimizes itself for a single QUERY or CHECKSAT command (though you may issue any number of ASSERT commands).  The ''incremental'' option may also be given by passing the ''-i'' command line option to CVC4.&lt;br /&gt;
* The ''produce-models'' option allows you to query the model (here, with the COUNTERMODEL command) after an &amp;quot;invalid&amp;quot; QUERY (or &amp;quot;satisfiable&amp;quot; CHECK-SAT).  Without it, CVC4 doesn't do the bookkeeping necessary to support model generation.  The ''produce-models'' option may also be given by passing the ''-m'' command line option to CVC4.&lt;br /&gt;
&lt;br /&gt;
So, if you invoke CVC4 with ''-im'', you don't need to pass those options at all:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -im&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, CVC4 operates in [[#CVC4's native input language|CVC-language mode]].  If you enter something that looks like SMT-LIB, it will suggest that you use the &amp;quot;''--lang smt''&amp;quot; command-line option for SMT-LIB mode:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (declare-fun x () Int)&lt;br /&gt;
 Parse Error: &amp;lt;shell&amp;gt;:1.7: In CVC4 presentation language mode, but SMT-LIB format detected.  Use --lang smt for SMT-LIB support.&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verbosity==&lt;br /&gt;
&lt;br /&gt;
CVC4 has various levels of verbosity.  By default, CVC4 is pretty quiet, only reporting serious warnings and notices.  If you're curious about what it's doing, you can pass CVC4 the ''-v'' option:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -v file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
For even more verbosity, you can pass CVC4 an ''additional'' ''-v'':&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -vv file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
 expanding definitions...&lt;br /&gt;
 constraining subtypes...&lt;br /&gt;
 applying substitutions...&lt;br /&gt;
 simplifying assertions...&lt;br /&gt;
 doing static learning...&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
Internally, verbosity is just an integer value.  It starts at 0, and with every ''-v'' on the command line it is incremented; with every ''-q'', decremented.  It can also be set directly.  From CVC language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;verbosity&amp;quot; 2;&lt;br /&gt;
&lt;br /&gt;
Or from SMT-LIB language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (set-option :verbosity 2)&lt;br /&gt;
&lt;br /&gt;
==Getting statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with the ''--statistics'' command line option.&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 --statistics foo.smt2&lt;br /&gt;
 sat&lt;br /&gt;
 sat::decisions, 0&lt;br /&gt;
 sat::propagations, 3&lt;br /&gt;
 sat::starts, 1&lt;br /&gt;
 theory::uf::TheoryUF::functionTermsCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::mergesCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::termsCount, 6&lt;br /&gt;
 theory&amp;lt;THEORY_UF&amp;gt;::propagations, 1 &lt;br /&gt;
 driver::filename, foo.smt2&lt;br /&gt;
 driver::sat/unsat, sat&lt;br /&gt;
 driver::totalTime, 0.02015373&lt;br /&gt;
 ''[many others]''&lt;br /&gt;
&lt;br /&gt;
Many statistics name-value pairs follow, one comma-separated pair per line.&lt;br /&gt;
&lt;br /&gt;
==Exit status==&lt;br /&gt;
&lt;br /&gt;
The exit status of CVC4 depends on the ''last'' QUERY or CHECK-SAT.  If you wish to call CVC4 from a program (e.g., a shell script) and care only about the satisfiability or validity of a single formula, you can pass the ''-q'' option (as described [[#Verbosity|above, under verbosity]]) and check the exit code.  With ''-q'', CVC4 should not produce any output unless it encounters a fatal error.&lt;br /&gt;
&lt;br /&gt;
QUERY asks a validity question, and CHECK-SAT a satisfiability question, and these are dual problems; hence the terminology is different, but really &amp;quot;sat&amp;quot; and &amp;quot;invalid&amp;quot; are the same internally, as are &amp;quot;unsat&amp;quot; and &amp;quot;valid&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Solver's last result&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Exit code&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''sat''' or '''invalid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unsat''' or '''valid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unknown'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;could be for any reason: time limit exceeded, no memory, incompleteness..&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;''no result''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no query or check-sat command issued&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;parse errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0 (in interactive mode)&amp;lt;br/&amp;gt;1 (otherwise)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;other errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1 (usually)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, and others, can produce different exit codes.  In interactive mode, parse errors are ignored and the next line read; so in interactive mode, you may see an exit code of 0 even in the presence of such an error.&lt;br /&gt;
&lt;br /&gt;
In SMT-LIB mode, an SMT-LIB command script that sets its status via &amp;quot;set-info :status&amp;quot; also affects the exit code.  So, for instance, the following SMT-LIB script returns an exit code of 10 even though it contains no &amp;quot;check-sat&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 (set-logic QF_UF)&lt;br /&gt;
 (set-info :status sat)&lt;br /&gt;
 (exit)&lt;br /&gt;
&lt;br /&gt;
Without the &amp;quot;set-info,&amp;quot; it would have returned an exit code of 0.&lt;br /&gt;
&lt;br /&gt;
=CVC4's input languages=&lt;br /&gt;
&lt;br /&gt;
When not used in interactive mode, CVC4 can read its input from an external file. It accepts the following input languages: &lt;br /&gt;
&lt;br /&gt;
* [[CVC4's native language | CVC4's native language]]&lt;br /&gt;
* SMT-LIB 2.0  (see [http://www.grammatech.com/resources/smt/SMTLIBTutorial.pdf David Cok's SMT-LIB tutorial])&lt;br /&gt;
* SMT-LIB 1.0&lt;br /&gt;
&lt;br /&gt;
CVC4 tries to automatically recognize the input language based on the file's extension: .cvc for CVC4's native language, .smt2 for SMT-LIB 2.0 and .smt for SMT-LIB 1.0. If the file extension does not match one of the previously mentioned ones you can specify the input language via the command line flag --lang. To see all language options type:&lt;br /&gt;
 $ cvc4 --lang help&lt;br /&gt;
&lt;br /&gt;
Every effort has been made to make CVC4 compliant with the SMT-LIB 2.0&lt;br /&gt;
standard (http://smtlib.org/).  However, when parsing SMT-LIB input,&lt;br /&gt;
certain default settings don't match what is stated in the official&lt;br /&gt;
standard.  To make CVC4 adhere more strictly to the standard, use the&lt;br /&gt;
&amp;quot;--smtlib&amp;quot; command-line option.  Even with this setting, CVC4 is&lt;br /&gt;
somewhat lenient; some non-conforming input may still be parsed and&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
==Using CVC4 from Java==&lt;br /&gt;
==The compatibility interface==&lt;br /&gt;
&lt;br /&gt;
=Upgrading from CVC3 to CVC4=&lt;br /&gt;
&lt;br /&gt;
==Features not supported by CVC4 (yet)==&lt;br /&gt;
&lt;br /&gt;
===Type Correctness Conditions (TCCs)===&lt;br /&gt;
&lt;br /&gt;
Type Correctness Conditions (TCCs), and the checking of such, are not&lt;br /&gt;
supported by CVC4 1.0.  Thus, a function defined only on integers can be&lt;br /&gt;
applied to REAL (as INT is a subtype of REAL), and CVC4 will not complain,&lt;br /&gt;
but may produce strange results.  For example:&lt;br /&gt;
&lt;br /&gt;
  f : INT -&amp;gt; INT;&lt;br /&gt;
  ASSERT f(1/3) = 0;&lt;br /&gt;
  ASSERT f(2/3) = 1;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  COUNTEREXAMPLE;&lt;br /&gt;
  % f : (INT) -&amp;gt; INT = LAMBDA(x1:INT) : 0;&lt;br /&gt;
&lt;br /&gt;
CVC3 can be used to produce TCCs for this input (with the +dump-tcc option).&lt;br /&gt;
The TCC can be checked by CVC3 or another solver.  (CVC3 can also check&lt;br /&gt;
TCCs while solving with +tcc.)&lt;br /&gt;
&lt;br /&gt;
==If you were using the text interfaces of CVC3==&lt;br /&gt;
&lt;br /&gt;
The native language of all solvers in the CVC family, referred to as the&lt;br /&gt;
&amp;quot;presentation language,&amp;quot; has undergone some revisions for CVC4.  The&lt;br /&gt;
most notable is that CVC4 does _not_ add counterexample assertions to&lt;br /&gt;
the current assertion set after a SAT/INVALID result.  For example:&lt;br /&gt;
&lt;br /&gt;
  x, y : INT;&lt;br /&gt;
  ASSERT x = 1 OR x = 2;&lt;br /&gt;
  ASSERT y = 1 OR y = 2;&lt;br /&gt;
  ASSERT x /= y;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  QUERY x = 1;&lt;br /&gt;
  % invalid&lt;br /&gt;
  QUERY x = 2;&lt;br /&gt;
  % invalid&lt;br /&gt;
&lt;br /&gt;
Here, CVC4 responds &amp;quot;invalid&amp;quot; to the second and third queries, because&lt;br /&gt;
each has a counterexample (x=2 is a counterexample to the first, and&lt;br /&gt;
x=1 is a counterexample to the second).  However, CVC3 will respond&lt;br /&gt;
with &amp;quot;valid&amp;quot; to one of these two, as the first query (the CHECKSAT)&lt;br /&gt;
had the side-effect of locking CVC3 into one of the two cases; the&lt;br /&gt;
later queries are effectively querying the counterexample that was&lt;br /&gt;
found by the first.  CVC4 removes this side-effect of the CHECKSAT and&lt;br /&gt;
QUERY commands.&lt;br /&gt;
&lt;br /&gt;
CVC4 supports rational literals (of type REAL) in decimal; CVC3 did not&lt;br /&gt;
support decimals.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not have support for the IS_INTEGER predicate.&lt;br /&gt;
&lt;br /&gt;
==If you were using the library (&amp;quot;in-memory&amp;quot;) interface of CVC3==&lt;br /&gt;
===If you were using CVC3 from C===&lt;br /&gt;
===If you were using CVC3 from Java===&lt;br /&gt;
&lt;br /&gt;
=Advanced features=&lt;br /&gt;
&lt;br /&gt;
This section describes some features of CVC4 of interest to developers and advanced users. &lt;br /&gt;
&lt;br /&gt;
==Resource limits==&lt;br /&gt;
&lt;br /&gt;
CVC4 can be made to self-timeout after a given number of milliseconds.&lt;br /&gt;
Use the --tlimit command line option to limit the entire run of&lt;br /&gt;
CVC4, or use --tlimit-per to limit each individual query separately.&lt;br /&gt;
Preprocessing time is not counted by the time limit, so for some large&lt;br /&gt;
inputs which require aggressive preprocessing, you may notice that&lt;br /&gt;
--tlimit does not work very well.  If you suspect this might be the&lt;br /&gt;
case, you can use &amp;quot;-vv&amp;quot; (double verbosity) to see what CVC4 is doing.&lt;br /&gt;
&lt;br /&gt;
Time-limited runs are not deterministic; two consecutive runs with the&lt;br /&gt;
same time limit might produce different results (i.e., one may time out&lt;br /&gt;
and responds with &amp;quot;unknown&amp;quot;, while the other completes and provides an&lt;br /&gt;
answer).  To ensure that results are reproducible, use --rlimit or&lt;br /&gt;
--rlimit-per.  These options take a &amp;quot;resource count&amp;quot; (presently, based on&lt;br /&gt;
the number of SAT conflicts) that limits the search time.  A word of&lt;br /&gt;
caution, though: there is no guarantee that runs of different versions of&lt;br /&gt;
CVC4 or of different builds of CVC4 (e.g., two CVC4 binaries with different&lt;br /&gt;
features enabled, or for different architectures) will interpret the resource&lt;br /&gt;
count in the same manner.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not presently have a way to limit its memory use; you may opt&lt;br /&gt;
to run it from a shell after using &amp;quot;ulimit&amp;quot; to limit the size of the&lt;br /&gt;
heap.&lt;br /&gt;
&lt;br /&gt;
==Dumping API calls or preprocessed output==&lt;br /&gt;
&lt;br /&gt;
[to do]&lt;br /&gt;
&lt;br /&gt;
==Changing the output language==&lt;br /&gt;
&lt;br /&gt;
[to do]&lt;br /&gt;
&lt;br /&gt;
==Proof support==&lt;br /&gt;
&lt;br /&gt;
CVC4 1.0 has limited support for proofs, and they are disabled by default.&lt;br /&gt;
(Run the configure script with --enable-proof to enable proofs).  Proofs&lt;br /&gt;
are exported in LFSC format and are limited to the propositional backbone&lt;br /&gt;
of the discovered proof (theory lemmas are stated without proof in this&lt;br /&gt;
release).&lt;br /&gt;
&lt;br /&gt;
==Parallel solving==&lt;br /&gt;
&lt;br /&gt;
The most recent binaries with support for parallel solving can be downloaded from our Nightly Builds pages:&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/cvc4-builds/portfolio-x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/cvc4-builds/portfolio-x86_64-linux-dbg/ Debug] binaries (statically linked) &lt;br /&gt;
&lt;br /&gt;
If enabled at configure-time (./configure --with-portfolio), a second&lt;br /&gt;
CVC4 binary will be produced (&amp;quot;pcvc4&amp;quot;).  This binary has support for&lt;br /&gt;
running multiple instances of CVC4 in different threads.  Use --threads=N&lt;br /&gt;
to specify the number of threads, and use --thread0=&amp;quot;options for thread 0&amp;quot;&lt;br /&gt;
--thread1=&amp;quot;options for thread 1&amp;quot;, etc., to specify a configuration for the&lt;br /&gt;
threads.  Lemmas are *not* shared between the threads by default; to adjust&lt;br /&gt;
this, use the --filter-lemma-length=N option to share lemmas of N literals&lt;br /&gt;
(or smaller).  (Some lemmas are ineligible for sharing because they include&lt;br /&gt;
literals that are &amp;quot;local&amp;quot; to one thread.)&lt;br /&gt;
&lt;br /&gt;
Currently, the portfolio **does not work** with the theory of inductive&lt;br /&gt;
datatypes. This limitation will be addressed in a future release.&lt;br /&gt;
&lt;br /&gt;
See more details and examples in the [[Tutorials#Parallel_Solving|tutorial]].&lt;br /&gt;
&lt;br /&gt;
==Emacs support==&lt;br /&gt;
&lt;br /&gt;
For a suggestion of editing CVC4 source code with emacs, see the file&lt;br /&gt;
contrib/editing-with-emacs.  For a CVC language mode (the native input&lt;br /&gt;
language for CVC4), see contrib/cvc-mode.el.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Related_Links&amp;diff=3918</id>
		<title>Related Links</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Related_Links&amp;diff=3918"/>
				<updated>2012-11-26T05:42:36Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: Replaced individual links to SMT workshops with link to the workshop's website.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Satisfiability Modulo Theories (SMT)==&lt;br /&gt;
* [http://www.smtlib.org/ SMT-LIB Initiative]&lt;br /&gt;
* [http://www.smtcomp.org/ SMT-COMP Competition]&lt;br /&gt;
* [http://www.smtexec.org/ SMT-EXEC Service]&lt;br /&gt;
* [http://smt-workshop.org/ SMT Workshop Series]&lt;br /&gt;
* PDPAR Workshops: [http://www.loria.fr/~ranise/pdpar03/ 2003] [http://www.loria.fr/~ranise/pdpar04/ 2004] [http://www.ai.dist.unige.it/pdpar05/ 2005] [http://dit.unitn.it/~rseba/pdpar06/ 2006]&lt;br /&gt;
&lt;br /&gt;
==CVC4's Predecessors==&lt;br /&gt;
* [http://verify.stanford.edu/SVC/ SVC]&lt;br /&gt;
* [http://verify.stanford.edu/CVC/ CVC]&lt;br /&gt;
* [http://www.cs.nyu.edu/acsys/cvcl/ CVC Lite]&lt;br /&gt;
* [http://www.cs.nyu.edu/acsys/cvc3/ CVC3]&lt;br /&gt;
&lt;br /&gt;
==Other==&lt;br /&gt;
* [http://www.cs.nyu.edu/acsys NYU Analysis of Computer Systems Group]&lt;br /&gt;
* [http://clc.cs.uiowa.edu/ University of Iowa Computational Logic Center]&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3917</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3917"/>
				<updated>2012-11-26T04:38:44Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Parametric Data Types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This manual includes lots of information about how to use CVC4.&lt;br /&gt;
&lt;br /&gt;
It is a work in-progress.&lt;br /&gt;
&lt;br /&gt;
= What is CVC4? =&lt;br /&gt;
&lt;br /&gt;
CVC4 is the last of a long line of SMT solvers that started with SVC and includes CVC, CVC-Lite and CVC3.&lt;br /&gt;
Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories. &lt;br /&gt;
The current built-in theories are the theories of:&lt;br /&gt;
&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols,&lt;br /&gt;
* real and integer linear arithmetic (with some support for non-linear arithmetic),&lt;br /&gt;
* bit vectors,&lt;br /&gt;
* arrays,&lt;br /&gt;
* tuples,&lt;br /&gt;
* records,&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 checks whether a given formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is valid in the built-in theories under a given set &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; of assumptions, a ''context''. &lt;br /&gt;
More precisely, it checks whether&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma\models_T \phi&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
that is, whether &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a logical consequence in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; of the set of formulas &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the union of CVC4's built-in theories.&lt;br /&gt;
&lt;br /&gt;
Roughly speaking, when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a universal formula and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is a set of existential formulas (i.e., when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; contain at most universal, respectively existential, quantifiers), CVC4 is a decision procedure: &lt;br /&gt;
it is guaranteed (modulo bugs and memory limits) to return a correct &amp;quot;valid&amp;quot; or &amp;quot;invalid&amp;quot; answer eventually. &lt;br /&gt;
In all other cases, CVC4 is deductively sound but incomplete: &lt;br /&gt;
it will never say that an invalid formula is valid,&lt;br /&gt;
but it may either never return or give up and return &amp;quot;unknown&amp;quot; for some formulas.&lt;br /&gt;
&lt;br /&gt;
Currently, when CVC4 returns &amp;quot;valid&amp;quot; for a query formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; under a context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;&lt;br /&gt;
it provides no evidence to back its claim.&lt;br /&gt;
Future versions will also return a ''proof certificate'', &lt;br /&gt;
a formal proof that &amp;lt;math&amp;gt;\Gamma'\models_T \phi&amp;lt;/math&amp;gt; for some subset &amp;lt;math&amp;gt;\Gamma'&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When CVC4 returns &amp;quot;invalid&amp;quot; it can return &lt;br /&gt;
both a ''counter-example'' to &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;'s validity under the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and a ''counter-model''. &lt;br /&gt;
Both a counter-example and a counter-model are a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of additional formulas consistent with &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but entailing the negation of &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
Formally:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \not\models_T \mathit{false}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \models_T \lnot \phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference is that a counter-model is given as a set of equations providing a concrete assignment of values for the free symbols in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; &lt;br /&gt;
(see the section on [[#CVC4's native input language|CVC4's native input language]] for more details).&lt;br /&gt;
&lt;br /&gt;
=Obtaining and compiling CVC4=&lt;br /&gt;
&lt;br /&gt;
CVC4 is distributed in the following ways:&lt;br /&gt;
* [[#Obtaining_binary_packages|Binary packages]]&lt;br /&gt;
* [[#Obtaining_source_packages|Source packages]]&lt;br /&gt;
* [[#Source_repository|Source repository checkout]]&lt;br /&gt;
&lt;br /&gt;
==Obtaining binary packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/ Binary packages are available] for CVC4.&lt;br /&gt;
Nightly builds:&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/debian/unstable Debian] packages&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
&lt;br /&gt;
==Obtaining source packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/src/ Sources are available] from the same site as the binaries.&lt;br /&gt;
&lt;br /&gt;
==Source repository==&lt;br /&gt;
The [http://cvc4.cs.nyu.edu/builds/src/ CVC4 source repository] is currently hosted by [http://cims.nyu.edu/ CIMS] and requires a CIMS account. Please contact a member of the development team for access. Please see the additional instructions for [[#Building_CVC4 from_a_repository_checkout]] here.&lt;br /&gt;
&lt;br /&gt;
==Building from source==&lt;br /&gt;
&lt;br /&gt;
===Quick-start instructions===&lt;br /&gt;
To compile from a source package:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
    cd contrib&lt;br /&gt;
    ./get-antlr-3.4&lt;br /&gt;
    cd ..&lt;br /&gt;
    ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
    make&lt;br /&gt;
    make check   [recommended]&lt;br /&gt;
    make install [optional]&lt;br /&gt;
&lt;br /&gt;
(To build from a repository checkout, see [[#Building_CVC4_from_a_repository_checkout|below]].)&lt;br /&gt;
&lt;br /&gt;
===Common make Options===&lt;br /&gt;
* &amp;quot;''make install''&amp;quot; will install into the &amp;quot;--prefix&amp;quot; option you gave to&lt;br /&gt;
the configure script (''/usr/local'' by default).&lt;br /&gt;
    ./configure --prefix=~/install_targets/cvc4 ...&lt;br /&gt;
    make install&lt;br /&gt;
* '''You should run &amp;quot;''make check''&amp;quot;''' before installation to ensure that CVC4 has been&lt;br /&gt;
built correctly.  In particular, GCC version 4.5.1 seems to have a&lt;br /&gt;
bug in the optimizer that results in incorrect behavior (and wrong&lt;br /&gt;
results) in many builds.  This is a known problem for Minisat, and&lt;br /&gt;
since Minisat is at the core of CVC4, a problem for CVC4.  &amp;quot;''make check''&amp;quot;&lt;br /&gt;
easily detects this problem (by showing a number of FAILed test cases).&lt;br /&gt;
It is ok if the unit tests aren't run as part of &amp;quot;''make check''&amp;quot;, but all&lt;br /&gt;
system tests and regression tests should pass without incident.&lt;br /&gt;
* To build API documentation, use &amp;quot;''make doc''&amp;quot;.  Documentation is produced&lt;br /&gt;
under ''builds/doc/'' but is not installed by &amp;quot;''make install''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Examples and tutorials are not installed with &amp;quot;''make install''.&amp;quot;  See [[#Examples_and_tutorials_are_not_built_or_installed|below]].&lt;br /&gt;
&lt;br /&gt;
For more information about the build system itself (probably not&lt;br /&gt;
necessary for casual users), see the [[#Appendix:_Build_architecture|Appendix]] at the bottom of this&lt;br /&gt;
file.&lt;br /&gt;
&lt;br /&gt;
===Common configure Options===&lt;br /&gt;
*'''--prefix=PREFIX''' install architecture-independent files in PREFIX (by default /usr/local)&lt;br /&gt;
*'''--with-build={production,debug,default,competition}''' &lt;br /&gt;
*'''--with-antlr-dir=PATH'''&lt;br /&gt;
*'''--with-cln'''/'''--with-gmp''' selects the numbers package to use by default ([[#Optional requirements]])&lt;br /&gt;
*'''--enable-static-binary''' build a fully statically-linked binary. (This is recommended for Mac OS X users that want to be able to use gdb.)&lt;br /&gt;
*'''ANTLR=PATH''' location of the antlr3 script&lt;br /&gt;
*'''--with-boost=DIR''' installation location of the boost libraries (most users will not need this)&lt;br /&gt;
&lt;br /&gt;
See '''./configure --help''' for more.&lt;br /&gt;
&lt;br /&gt;
===Build dependencies===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are required to run CVC4. Versions&lt;br /&gt;
given are minimum versions; more recent versions should be compatible.&lt;br /&gt;
&lt;br /&gt;
*'''GNU C and C++''' (gcc and g++), reasonably recent versions&lt;br /&gt;
*'''GNU Make'''&lt;br /&gt;
*'''GNU Bash'''&lt;br /&gt;
*'''GMP v4.2''' (GNU Multi-Precision arithmetic library)&lt;br /&gt;
*'''libantlr3c v3.2 or v3.4''' (ANTLR parser generator C support library)&lt;br /&gt;
*'''The Boost C++ base libraries'''&lt;br /&gt;
*'''MacPorts'''   [highly recommended if on a Mac; see [[#MacPorts]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hardest to obtain and install is the libantlr3c requirement, and&lt;br /&gt;
is explained [[#Installing libantlr3c: ANTLR parser generator C support library|next]].&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;make&amp;quot; is non-GNU on your system, make sure to invoke &amp;quot;gmake&amp;quot; (or&lt;br /&gt;
whatever GNU Make is installed as).  If your usual shell is not Bash,&lt;br /&gt;
the configure script should auto-correct this.  If it does not, you'll&lt;br /&gt;
see strange shell syntax errors, and you may need to explicitly set&lt;br /&gt;
SHELL or CONFIG_SHELL to the location of bash on your system.&lt;br /&gt;
&lt;br /&gt;
====Installing libantlr3c: ANTLR parser generator C support library====&lt;br /&gt;
&lt;br /&gt;
For libantlr3c, you can use the convenience script in&lt;br /&gt;
''contrib/get-antlr-3.4'' in the source distribution---this will download, patch, compile and install&lt;br /&gt;
libantlr3c into your cvc4 directory as ''cvc4/antlr-3.4/''.&lt;br /&gt;
  cd contrib&lt;br /&gt;
  ./get-antlr-3.4&lt;br /&gt;
&lt;br /&gt;
CVC4 must be configured with the antlr library installation directory, '''--with-antlr-dir''', and an antlr executable script file, '''ANTLR'''.  If libantlr3c was installed via get-antlr-3.4, the following configure line should suffice for CVC44&lt;br /&gt;
  ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
&lt;br /&gt;
For 64 bit machines, libantlr3c needs to be configured with 64 bit explicitly&lt;br /&gt;
  ./configure --enable-64bit ...&lt;br /&gt;
The get-antlr-3.4 script makes a guess at whether the machine is 64 bit and adds the appropriate flag.&lt;br /&gt;
To force the script to compile 32 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86&amp;quot; ./get-antlr3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr3.4&lt;br /&gt;
&lt;br /&gt;
For a longer discussion, instructions for manual installation, and more in depth troubleshooting, see [[Developer's Guide#ANTLR3]].&lt;br /&gt;
&lt;br /&gt;
====MacPorts====&lt;br /&gt;
&lt;br /&gt;
On a Mac, it is '''highly''' recommended that you use MacPorts (see&lt;br /&gt;
http://www.macports.org/).  Doing so is easy.  Then, simply run the&lt;br /&gt;
script ''contrib/mac-build'', which installs a few ports from the MacPorts&lt;br /&gt;
repository, then compiles and installs antlr3c using the ''get-antlr-3.4''&lt;br /&gt;
script.  The mac-build script should set you up&lt;br /&gt;
with all requirements, and will tell you how to configure CVC4 when it&lt;br /&gt;
completes successfully.&lt;br /&gt;
&lt;br /&gt;
====Installing the Boost C++ base libraries====&lt;br /&gt;
&lt;br /&gt;
A Boost package is available on most Linux distributions; check yours&lt;br /&gt;
for a package named something like libboost-dev or boost-devel.  There&lt;br /&gt;
are a number of additional Boost packages in some distributions, but&lt;br /&gt;
this &amp;quot;basic&amp;quot; one should be sufficient for building CVC4.&lt;br /&gt;
&lt;br /&gt;
Should you want to install Boost manually, or to learn more about the&lt;br /&gt;
Boost project, please visit http://www.boost.org/.&lt;br /&gt;
&lt;br /&gt;
===Optional requirements===&lt;br /&gt;
&lt;br /&gt;
None of these is required, but can improve CVC4 as described below:&lt;br /&gt;
&lt;br /&gt;
*'''Optional: SWIG 2.0.x''' (Simplified Wrapper and Interface Generator)&lt;br /&gt;
*'''Optional: CLN v1.3 or newer''' (Class Library for Numbers)&lt;br /&gt;
*'''Optional: CUDD v2.4.2 or newer''' (Colorado University Decision Diagram package)&lt;br /&gt;
*'''Optional: GNU Readline library''' (for an improved interactive experience)&lt;br /&gt;
*'''Optional: The Boost C++ threading library''' (libboost_thread)&lt;br /&gt;
*'''Optional: CxxTest unit testing framework'''&lt;br /&gt;
&lt;br /&gt;
SWIG is necessary to build the Java API (and of course a JDK is&lt;br /&gt;
necessary, too).  SWIG 1.x won't work; you'll need 2.0, and the more&lt;br /&gt;
recent the better.  On Mac, we've seen SWIG segfault when generating&lt;br /&gt;
CVC4 language bindings; version 2.0.8 or higher is recommended to&lt;br /&gt;
avoid this.  See [[#Language_bindings|Language bindings]] below for build instructions.&lt;br /&gt;
&lt;br /&gt;
CLN is an alternative multiprecision arithmetic package that can offer&lt;br /&gt;
better performance and memory footprint than GMP.  CLN is covered by&lt;br /&gt;
the GNU General Public License, version 3; so if you choose to use&lt;br /&gt;
CVC4 with CLN support, you are licensing CVC4 under that same license.&lt;br /&gt;
(Usually CVC4's license is more permissive than GPL is; see the file&lt;br /&gt;
COPYING in the CVC4 source distribution for details.)  Please visit&lt;br /&gt;
http://www.ginac.de/CLN/ for more details about CLN.&lt;br /&gt;
&lt;br /&gt;
CUDD is a decision diagram package that changes the behavior of the&lt;br /&gt;
CVC4 arithmetic solver in some cases; it may or may not improve the&lt;br /&gt;
arithmetic solver's performance.  See [[#Building_with_CUDD_(optional)|below]] for instructions on&lt;br /&gt;
obtaining and building CUDD.&lt;br /&gt;
&lt;br /&gt;
The GNU Readline library is optionally used to provide command&lt;br /&gt;
editing, tab completion, and history functionality at the CVC prompt&lt;br /&gt;
(when running in interactive mode).  Check your distribution for a&lt;br /&gt;
package named &amp;quot;libreadline-dev&amp;quot; or &amp;quot;readline-devel&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
The Boost C++ threading library (often packaged independently of the&lt;br /&gt;
Boost base library) is needed to run CVC4 in &amp;quot;portfolio&amp;quot;&lt;br /&gt;
(multithreaded) mode.  Check your distribution for a package named&lt;br /&gt;
&amp;quot;libboost-thread-dev&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
CxxTest is necessary to run CVC4's unit tests (included with the&lt;br /&gt;
distribution).  Running these is not really required for users of&lt;br /&gt;
CVC4; &amp;quot;make check&amp;quot; will skip unit tests if CxxTest isn't available,&lt;br /&gt;
and go on to run the extensive system- and regression-tests in the&lt;br /&gt;
source tree.  However, if you're interested, you can download CxxTest&lt;br /&gt;
at http://cxxtest.com/ .&lt;br /&gt;
&lt;br /&gt;
====Building with CUDD (optional)====&lt;br /&gt;
&lt;br /&gt;
CUDD, if desired, must be installed delicately.  The CVC4 configure&lt;br /&gt;
script attempts to auto-detect the locations and names of CUDD headers&lt;br /&gt;
and libraries the way that the Fedora RPMs install them, the way that&lt;br /&gt;
our NYU-provided Debian packages install them, and the way they exist&lt;br /&gt;
when you download and build the CUDD sources directly.  If you install&lt;br /&gt;
from Fedora RPMs or our Debian packages, the process should be&lt;br /&gt;
completely automatic, since the libraries and headers are installed in&lt;br /&gt;
a standard location.  If you download the sources yourself, you need&lt;br /&gt;
to build them in a special way.  Fortunately, the&lt;br /&gt;
&amp;quot;contrib/build-cudd-2.4.2-with-libtool.sh&amp;quot; script in the CVC4 source&lt;br /&gt;
tree does exactly what you need: it patches the CUDD makefiles to use&lt;br /&gt;
libtool, builds the libtool libraries, then reverses the patch to&lt;br /&gt;
leave the makefiles as they were.  Once you run this script on an&lt;br /&gt;
unpacked CUDD 2.4.2 source distribution, then CVC4's configure script&lt;br /&gt;
should pick up the libraries if you provide&lt;br /&gt;
--with-cudd-dir=/PATH/TO/CUDD/SOURCES.&lt;br /&gt;
&lt;br /&gt;
If you want to force linking to CUDD, provide --with-cudd to the&lt;br /&gt;
configure script; this makes it a hard requirement rather than an&lt;br /&gt;
optional add-on.&lt;br /&gt;
&lt;br /&gt;
The NYU-provided Debian packaging of CUDD 2.4.2 and CUDD 2.5.0 are&lt;br /&gt;
here (along with the CVC4 Debian packages):&lt;br /&gt;
&lt;br /&gt;
  deb http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
&lt;br /&gt;
On Debian (and Debian-derived distributions like Ubuntu), you only&lt;br /&gt;
need to drop that one line in your /etc/apt/sources.list file, then install with your favorite package manager.&lt;br /&gt;
&lt;br /&gt;
The Debian source package &amp;quot;cudd&amp;quot;, available from the same repository,&lt;br /&gt;
includes a diff of all changes made to cudd makefiles.&lt;br /&gt;
&lt;br /&gt;
===Language bindings===&lt;br /&gt;
&lt;br /&gt;
There are several options available for using CVC4 from the API.&lt;br /&gt;
&lt;br /&gt;
First, CVC4 offers a complete and flexible API for manipulating&lt;br /&gt;
expressions, maintaining a stack of assertions, and checking&lt;br /&gt;
satisfiability, and related things.  The C++ libraries (libcvc4.so and&lt;br /&gt;
libcvc4parser.so) and required headers are installed normally via a&lt;br /&gt;
&amp;quot;make install&amp;quot;.  This API is also available from Java (via CVC4.jar&lt;br /&gt;
and libcvc4jni.so) by configuring with --enable-language-bindings=java.&lt;br /&gt;
You'll also need SWIG 2.0 installed (and you might need to help&lt;br /&gt;
configure find it if you installed it in a nonstandard place with&lt;br /&gt;
--with-swig-dir=/path/to/swig/installation).  You may also need to&lt;br /&gt;
give the configure script the path to your Java headers (in&lt;br /&gt;
particular, jni.h).  You might do so with (for example):&lt;br /&gt;
&lt;br /&gt;
  ./configure --enable-language-bindings=java \&lt;br /&gt;
      JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-openjdk-amd64/include&lt;br /&gt;
&lt;br /&gt;
There is also a &amp;quot;C++ compatibility API&amp;quot; (''#include &amp;lt;cvc4/cvc3_compat.h&amp;gt;''&lt;br /&gt;
and link against libcvc4compat.so) that attempts to maintain&lt;br /&gt;
source-level backwards-compatibility with the CVC3 C++ API.  The&lt;br /&gt;
compatibility library is built by default, and&lt;br /&gt;
''--enable-language-bindings=java'' enables the Java compatibility library&lt;br /&gt;
(CVC4compat.jar and libcvc4compatjni.so).&lt;br /&gt;
''--enable-language-bindings=c'' enables the C compatibility library&lt;br /&gt;
(''#include &amp;lt;cvc4/bindings/compat/c/c_interface.h&amp;gt;'' and link against&lt;br /&gt;
libcvc4bindings_c_compat.so), and if you want both C and Java&lt;br /&gt;
bindings, use ''--enable-language-bindings=c,java''.  These compatibility&lt;br /&gt;
language bindings do NOT require SWIG.&lt;br /&gt;
&lt;br /&gt;
The ''examples/'' directory in the source distribution includes some basic examples (the &amp;quot;simple vc&amp;quot;&lt;br /&gt;
and &amp;quot;simple vc compat&amp;quot; family of examples) of all these interfaces.&lt;br /&gt;
&lt;br /&gt;
In principle, since we use SWIG to generate the native Java API, we&lt;br /&gt;
could support other languages as well.  However, using CVC4 from other&lt;br /&gt;
languages is not supported, nor expected to work, at this time.  If&lt;br /&gt;
you're interested in helping to develop, maintain, and test a language&lt;br /&gt;
binding, please contact us via the users' mailing list at&lt;br /&gt;
cvc-users@cs.nyu.edu.&lt;br /&gt;
&lt;br /&gt;
===Building CVC4 from a repository checkout===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are additionally required to build&lt;br /&gt;
CVC4 from from a repository checkout rather than from a prepared&lt;br /&gt;
source tarball.&lt;br /&gt;
&lt;br /&gt;
*'''Automake v1.11'''&lt;br /&gt;
*'''Autoconf v2.61'''&lt;br /&gt;
*'''Libtool v2.2'''&lt;br /&gt;
*'''ANTLR3 v3.2 or v3.4'''&lt;br /&gt;
*'''Java Development Kit''' ([http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 required for ANTLR3])&lt;br /&gt;
&lt;br /&gt;
First, use &amp;quot;''./autogen.sh''&amp;quot; to create the configure script.  Then&lt;br /&gt;
proceed as normal for any distribution tarball.  The parsers are&lt;br /&gt;
pre-generated for the tarballs, but don't exist in the repository; hence the extra ANTLR3 and JDK requirements to&lt;br /&gt;
generate the source code for the parsers, when building from the&lt;br /&gt;
repository.&lt;br /&gt;
&lt;br /&gt;
===Examples and tutorials are not built or installed===&lt;br /&gt;
&lt;br /&gt;
Examples are not built by &amp;quot;''make''&amp;quot; or &amp;quot;''make install''&amp;quot;.  See&lt;br /&gt;
''examples/README'' in the source distribution for information on what to find in the ''examples/''&lt;br /&gt;
directory, as well as information about building and installing them.&lt;br /&gt;
&lt;br /&gt;
===Appendix: Build architecture===&lt;br /&gt;
&lt;br /&gt;
The build system is generated by automake, libtool, and autoconf.  It&lt;br /&gt;
is somewhat nonstandard, though, which (for one thing) requires that&lt;br /&gt;
GNU Make be used.  If you ./configure in the top-level source&lt;br /&gt;
directory, the objects will actually all appear in&lt;br /&gt;
builds/${arch}/${build_id}.  This is to allow multiple, separate&lt;br /&gt;
builds in the same place (e.g., an assertions-enabled debugging build&lt;br /&gt;
alongside a production build), without changing directories at the&lt;br /&gt;
shell.  The &amp;quot;current&amp;quot; build is maintained, and you can still use&lt;br /&gt;
(e.g.) &amp;quot;make -C src/main&amp;quot; to rebuild objects in just one subdirectory.&lt;br /&gt;
&lt;br /&gt;
You can also create your own build directory inside or outside of the&lt;br /&gt;
source tree and configure from there.  All objects will then be built&lt;br /&gt;
in that directory, and you'll ultimately find the &amp;quot;cvc4&amp;quot; binary in&lt;br /&gt;
src/main/, and the libraries under src/ and src/parser/.&lt;br /&gt;
&lt;br /&gt;
=Using the CVC4 binary=&lt;br /&gt;
&lt;br /&gt;
The CVC4 driver binary (&amp;quot;cvc4&amp;quot;), once installed, can be executed directly to enter into interactive mode:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then enter commands into CVC4 interactively:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;incremental&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;produce-models&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; TRANSFORM 25*25;&lt;br /&gt;
 625&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example shows two useful options, ''incremental'' and ''produce-models.''&lt;br /&gt;
&lt;br /&gt;
* The ''incremental'' option allows you to issue multiple QUERY (or CHECKSAT) commands, and allows the use of the PUSH and POP commands.  Without this option, CVC4 optimizes itself for a single QUERY or CHECKSAT command (though you may issue any number of ASSERT commands).  The ''incremental'' option may also be given by passing the ''-i'' command line option to CVC4.&lt;br /&gt;
* The ''produce-models'' option allows you to query the model (here, with the COUNTERMODEL command) after an &amp;quot;invalid&amp;quot; QUERY (or &amp;quot;satisfiable&amp;quot; CHECK-SAT).  Without it, CVC4 doesn't do the bookkeeping necessary to support model generation.  The ''produce-models'' option may also be given by passing the ''-m'' command line option to CVC4.&lt;br /&gt;
&lt;br /&gt;
So, if you invoke CVC4 with ''-im'', you don't need to pass those options at all:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -im&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, CVC4 operates in [[#CVC4's native input language|CVC-language mode]].  If you enter something that looks like SMT-LIB, it will suggest that you use the &amp;quot;''--lang smt''&amp;quot; command-line option for SMT-LIB mode:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (declare-fun x () Int)&lt;br /&gt;
 Parse Error: &amp;lt;shell&amp;gt;:1.7: In CVC4 presentation language mode, but SMT-LIB format detected.  Use --lang smt for SMT-LIB support.&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verbosity==&lt;br /&gt;
&lt;br /&gt;
CVC4 has various levels of verbosity.  By default, CVC4 is pretty quiet, only reporting serious warnings and notices.  If you're curious about what it's doing, you can pass CVC4 the ''-v'' option:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -v file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
For even more verbosity, you can pass CVC4 an ''additional'' ''-v'':&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -vv file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
 expanding definitions...&lt;br /&gt;
 constraining subtypes...&lt;br /&gt;
 applying substitutions...&lt;br /&gt;
 simplifying assertions...&lt;br /&gt;
 doing static learning...&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
Internally, verbosity is just an integer value.  It starts at 0, and with every ''-v'' on the command line it is incremented; with every ''-q'', decremented.  It can also be set directly.  From CVC language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;verbosity&amp;quot; 2;&lt;br /&gt;
&lt;br /&gt;
Or from SMT-LIB language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (set-option :verbosity 2)&lt;br /&gt;
&lt;br /&gt;
==Getting statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with the ''--statistics'' command line option.&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 --statistics foo.smt2&lt;br /&gt;
 sat&lt;br /&gt;
 sat::decisions, 0&lt;br /&gt;
 sat::propagations, 3&lt;br /&gt;
 sat::starts, 1&lt;br /&gt;
 theory::uf::TheoryUF::functionTermsCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::mergesCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::termsCount, 6&lt;br /&gt;
 theory&amp;lt;THEORY_UF&amp;gt;::propagations, 1 &lt;br /&gt;
 driver::filename, foo.smt2&lt;br /&gt;
 driver::sat/unsat, sat&lt;br /&gt;
 driver::totalTime, 0.02015373&lt;br /&gt;
 ''[many others]''&lt;br /&gt;
&lt;br /&gt;
Many statistics name-value pairs follow, one comma-separated pair per line.&lt;br /&gt;
&lt;br /&gt;
==Exit status==&lt;br /&gt;
&lt;br /&gt;
The exit status of CVC4 depends on the ''last'' QUERY or CHECK-SAT.  If you wish to call CVC4 from a program (e.g., a shell script) and care only about the satisfiability or validity of a single formula, you can pass the ''-q'' option (as described [[#Verbosity|above, under verbosity]]) and check the exit code.  With ''-q'', CVC4 should not produce any output unless it encounters a fatal error.&lt;br /&gt;
&lt;br /&gt;
QUERY asks a validity question, and CHECK-SAT a satisfiability question, and these are dual problems; hence the terminology is different, but really &amp;quot;sat&amp;quot; and &amp;quot;invalid&amp;quot; are the same internally, as are &amp;quot;unsat&amp;quot; and &amp;quot;valid&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Solver's last result&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Exit code&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''sat''' or '''invalid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unsat''' or '''valid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unknown'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;could be for any reason: time limit exceeded, no memory, incompleteness..&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;''no result''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no query or check-sat command issued&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;parse errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0 (in interactive mode)&amp;lt;br/&amp;gt;1 (otherwise)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;other errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1 (usually)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, and others, can produce different exit codes.  In interactive mode, parse errors are ignored and the next line read; so in interactive mode, you may see an exit code of 0 even in the presence of such an error.&lt;br /&gt;
&lt;br /&gt;
In SMT-LIB mode, an SMT-LIB command script that sets its status via &amp;quot;set-info :status&amp;quot; also affects the exit code.  So, for instance, the following SMT-LIB script returns an exit code of 10 even though it contains no &amp;quot;check-sat&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 (set-logic QF_UF)&lt;br /&gt;
 (set-info :status sat)&lt;br /&gt;
 (exit)&lt;br /&gt;
&lt;br /&gt;
Without the &amp;quot;set-info,&amp;quot; it would have returned an exit code of 0.&lt;br /&gt;
&lt;br /&gt;
=CVC4's native input language=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}  \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1[X_{1,1}, \ldots, X_{1,p_1}] &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2[X_{2,1}, \ldots, X_{2,p_2}] &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n[X_{n,1}, \ldots, X_{n,p_n}] &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by the type variables &amp;lt;math&amp;gt;X_{i,1}, \ldots, X_{i,p_i}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=CVC4's support for the SMT-LIB language=&lt;br /&gt;
&lt;br /&gt;
==SMT-LIB compliance==&lt;br /&gt;
&lt;br /&gt;
Every effort has been made to make CVC4 compliant with the SMT-LIB 2.0&lt;br /&gt;
standard (http://smtlib.org/).  However, when parsing SMT-LIB input,&lt;br /&gt;
certain default settings don't match what is stated in the official&lt;br /&gt;
standard.  To make CVC4 adhere more strictly to the standard, use the&lt;br /&gt;
&amp;quot;--smtlib&amp;quot; command-line option.  Even with this setting, CVC4 is&lt;br /&gt;
somewhat lenient; some non-conforming input may still be parsed and&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
==Using CVC4 from Java==&lt;br /&gt;
==The compatibility interface==&lt;br /&gt;
&lt;br /&gt;
=Upgrading from CVC3 to CVC4=&lt;br /&gt;
&lt;br /&gt;
==Features not supported by CVC4 (yet)==&lt;br /&gt;
&lt;br /&gt;
===Type Correctness Conditions (TCCs)===&lt;br /&gt;
&lt;br /&gt;
Type Correctness Conditions (TCCs), and the checking of such, are not&lt;br /&gt;
supported by CVC4 1.0.  Thus, a function defined only on integers can be&lt;br /&gt;
applied to REAL (as INT is a subtype of REAL), and CVC4 will not complain,&lt;br /&gt;
but may produce strange results.  For example:&lt;br /&gt;
&lt;br /&gt;
  f : INT -&amp;gt; INT;&lt;br /&gt;
  ASSERT f(1/3) = 0;&lt;br /&gt;
  ASSERT f(2/3) = 1;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  COUNTEREXAMPLE;&lt;br /&gt;
  % f : (INT) -&amp;gt; INT = LAMBDA(x1:INT) : 0;&lt;br /&gt;
&lt;br /&gt;
CVC3 can be used to produce TCCs for this input (with the +dump-tcc option).&lt;br /&gt;
The TCC can be checked by CVC3 or another solver.  (CVC3 can also check&lt;br /&gt;
TCCs while solving with +tcc.)&lt;br /&gt;
&lt;br /&gt;
==If you were using the text interfaces of CVC3==&lt;br /&gt;
&lt;br /&gt;
The native language of all solvers in the CVC family, referred to as the&lt;br /&gt;
&amp;quot;presentation language,&amp;quot; has undergone some revisions for CVC4.  The&lt;br /&gt;
most notable is that CVC4 does _not_ add counterexample assertions to&lt;br /&gt;
the current assertion set after a SAT/INVALID result.  For example:&lt;br /&gt;
&lt;br /&gt;
  x, y : INT;&lt;br /&gt;
  ASSERT x = 1 OR x = 2;&lt;br /&gt;
  ASSERT y = 1 OR y = 2;&lt;br /&gt;
  ASSERT x /= y;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  QUERY x = 1;&lt;br /&gt;
  % invalid&lt;br /&gt;
  QUERY x = 2;&lt;br /&gt;
  % invalid&lt;br /&gt;
&lt;br /&gt;
Here, CVC4 responds &amp;quot;invalid&amp;quot; to the second and third queries, because&lt;br /&gt;
each has a counterexample (x=2 is a counterexample to the first, and&lt;br /&gt;
x=1 is a counterexample to the second).  However, CVC3 will respond&lt;br /&gt;
with &amp;quot;valid&amp;quot; to one of these two, as the first query (the CHECKSAT)&lt;br /&gt;
had the side-effect of locking CVC3 into one of the two cases; the&lt;br /&gt;
later queries are effectively querying the counterexample that was&lt;br /&gt;
found by the first.  CVC4 removes this side-effect of the CHECKSAT and&lt;br /&gt;
QUERY commands.&lt;br /&gt;
&lt;br /&gt;
CVC4 supports rational literals (of type REAL) in decimal; CVC3 did not&lt;br /&gt;
support decimals.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not have support for the IS_INTEGER predicate.&lt;br /&gt;
&lt;br /&gt;
==If you were using the library (&amp;quot;in-memory&amp;quot;) interface of CVC3==&lt;br /&gt;
===If you were using CVC3 from C===&lt;br /&gt;
===If you were using CVC3 from Java===&lt;br /&gt;
&lt;br /&gt;
=Useful command-line options=&lt;br /&gt;
&lt;br /&gt;
==Statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with&lt;br /&gt;
the --statistics command line option.&lt;br /&gt;
&lt;br /&gt;
==Time and resource limits==&lt;br /&gt;
&lt;br /&gt;
CVC4 can be made to self-timeout after a given number of milliseconds.&lt;br /&gt;
Use the --tlimit command line option to limit the entire run of&lt;br /&gt;
CVC4, or use --tlimit-per to limit each individual query separately.&lt;br /&gt;
Preprocessing time is not counted by the time limit, so for some large&lt;br /&gt;
inputs which require aggressive preprocessing, you may notice that&lt;br /&gt;
--tlimit does not work very well.  If you suspect this might be the&lt;br /&gt;
case, you can use &amp;quot;-vv&amp;quot; (double verbosity) to see what CVC4 is doing.&lt;br /&gt;
&lt;br /&gt;
Time-limited runs are not deterministic; two consecutive runs with the&lt;br /&gt;
same time limit might produce different results (i.e., one may time out&lt;br /&gt;
and responds with &amp;quot;unknown&amp;quot;, while the other completes and provides an&lt;br /&gt;
answer).  To ensure that results are reproducible, use --rlimit or&lt;br /&gt;
--rlimit-per.  These options take a &amp;quot;resource count&amp;quot; (presently, based on&lt;br /&gt;
the number of SAT conflicts) that limits the search time.  A word of&lt;br /&gt;
caution, though: there is no guarantee that runs of different versions of&lt;br /&gt;
CVC4 or of different builds of CVC4 (e.g., two CVC4 binaries with different&lt;br /&gt;
features enabled, or for different architectures) will interpret the resource&lt;br /&gt;
count in the same manner.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not presently have a way to limit its memory use; you may opt&lt;br /&gt;
to run it from a shell after using &amp;quot;ulimit&amp;quot; to limit the size of the&lt;br /&gt;
heap.&lt;br /&gt;
&lt;br /&gt;
=Dumping API calls or preprocessed output=&lt;br /&gt;
&lt;br /&gt;
=Changing the output language=&lt;br /&gt;
&lt;br /&gt;
=Proof support=&lt;br /&gt;
&lt;br /&gt;
CVC4 1.0 has limited support for proofs, and they are disabled by default.&lt;br /&gt;
(Run the configure script with --enable-proof to enable proofs).  Proofs&lt;br /&gt;
are exported in LFSC format and are limited to the propositional backbone&lt;br /&gt;
of the discovered proof (theory lemmas are stated without proof in this&lt;br /&gt;
release).&lt;br /&gt;
&lt;br /&gt;
=Portfolio solving=&lt;br /&gt;
&lt;br /&gt;
If enabled at configure-time (./configure --with-portfolio), a second&lt;br /&gt;
CVC4 binary will be produced (&amp;quot;pcvc4&amp;quot;).  This binary has support for&lt;br /&gt;
running multiple instances of CVC4 in different threads.  Use --threads=N&lt;br /&gt;
to specify the number of threads, and use --thread0=&amp;quot;options for thread 0&amp;quot;&lt;br /&gt;
--thread1=&amp;quot;options for thread 1&amp;quot;, etc., to specify a configuration for the&lt;br /&gt;
threads.  Lemmas are *not* shared between the threads by default; to adjust&lt;br /&gt;
this, use the --filter-lemma-length=N option to share lemmas of N literals&lt;br /&gt;
(or smaller).  (Some lemmas are ineligible for sharing because they include&lt;br /&gt;
literals that are &amp;quot;local&amp;quot; to one thread.)&lt;br /&gt;
&lt;br /&gt;
Currently, the portfolio **does not work** with quantifiers or with&lt;br /&gt;
the theory of inductive datatypes.  These limitations will be addressed&lt;br /&gt;
in a future release.&lt;br /&gt;
&lt;br /&gt;
=Emacs support=&lt;br /&gt;
&lt;br /&gt;
For a suggestion of editing CVC4 source code with emacs, see the file&lt;br /&gt;
contrib/editing-with-emacs.  For a CVC language mode (the native input&lt;br /&gt;
language for CVC4), see contrib/cvc-mode.el.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3916</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3916"/>
				<updated>2012-11-26T04:31:25Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Arithmetic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This manual includes lots of information about how to use CVC4.&lt;br /&gt;
&lt;br /&gt;
It is a work in-progress.&lt;br /&gt;
&lt;br /&gt;
= What is CVC4? =&lt;br /&gt;
&lt;br /&gt;
CVC4 is the last of a long line of SMT solvers that started with SVC and includes CVC, CVC-Lite and CVC3.&lt;br /&gt;
Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories. &lt;br /&gt;
The current built-in theories are the theories of:&lt;br /&gt;
&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols,&lt;br /&gt;
* real and integer linear arithmetic (with some support for non-linear arithmetic),&lt;br /&gt;
* bit vectors,&lt;br /&gt;
* arrays,&lt;br /&gt;
* tuples,&lt;br /&gt;
* records,&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 checks whether a given formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is valid in the built-in theories under a given set &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; of assumptions, a ''context''. &lt;br /&gt;
More precisely, it checks whether&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma\models_T \phi&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
that is, whether &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a logical consequence in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; of the set of formulas &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the union of CVC4's built-in theories.&lt;br /&gt;
&lt;br /&gt;
Roughly speaking, when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a universal formula and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is a set of existential formulas (i.e., when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; contain at most universal, respectively existential, quantifiers), CVC4 is a decision procedure: &lt;br /&gt;
it is guaranteed (modulo bugs and memory limits) to return a correct &amp;quot;valid&amp;quot; or &amp;quot;invalid&amp;quot; answer eventually. &lt;br /&gt;
In all other cases, CVC4 is deductively sound but incomplete: &lt;br /&gt;
it will never say that an invalid formula is valid,&lt;br /&gt;
but it may either never return or give up and return &amp;quot;unknown&amp;quot; for some formulas.&lt;br /&gt;
&lt;br /&gt;
Currently, when CVC4 returns &amp;quot;valid&amp;quot; for a query formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; under a context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;&lt;br /&gt;
it provides no evidence to back its claim.&lt;br /&gt;
Future versions will also return a ''proof certificate'', &lt;br /&gt;
a formal proof that &amp;lt;math&amp;gt;\Gamma'\models_T \phi&amp;lt;/math&amp;gt; for some subset &amp;lt;math&amp;gt;\Gamma'&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When CVC4 returns &amp;quot;invalid&amp;quot; it can return &lt;br /&gt;
both a ''counter-example'' to &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;'s validity under the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and a ''counter-model''. &lt;br /&gt;
Both a counter-example and a counter-model are a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of additional formulas consistent with &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but entailing the negation of &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
Formally:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \not\models_T \mathit{false}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \models_T \lnot \phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference is that a counter-model is given as a set of equations providing a concrete assignment of values for the free symbols in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; &lt;br /&gt;
(see the section on [[#CVC4's native input language|CVC4's native input language]] for more details).&lt;br /&gt;
&lt;br /&gt;
=Obtaining and compiling CVC4=&lt;br /&gt;
&lt;br /&gt;
CVC4 is distributed in the following ways:&lt;br /&gt;
* [[#Obtaining_binary_packages|Binary packages]]&lt;br /&gt;
* [[#Obtaining_source_packages|Source packages]]&lt;br /&gt;
* [[#Source_repository|Source repository checkout]]&lt;br /&gt;
&lt;br /&gt;
==Obtaining binary packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/ Binary packages are available] for CVC4.&lt;br /&gt;
Nightly builds:&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/debian/unstable Debian] packages&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
&lt;br /&gt;
==Obtaining source packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/src/ Sources are available] from the same site as the binaries.&lt;br /&gt;
&lt;br /&gt;
==Source repository==&lt;br /&gt;
The [http://cvc4.cs.nyu.edu/builds/src/ CVC4 source repository] is currently hosted by [http://cims.nyu.edu/ CIMS] and requires a CIMS account. Please contact a member of the development team for access. Please see the additional instructions for [[#Building_CVC4 from_a_repository_checkout]] here.&lt;br /&gt;
&lt;br /&gt;
==Building from source==&lt;br /&gt;
&lt;br /&gt;
===Quick-start instructions===&lt;br /&gt;
To compile from a source package:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
    cd contrib&lt;br /&gt;
    ./get-antlr-3.4&lt;br /&gt;
    cd ..&lt;br /&gt;
    ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
    make&lt;br /&gt;
    make check   [recommended]&lt;br /&gt;
    make install [optional]&lt;br /&gt;
&lt;br /&gt;
(To build from a repository checkout, see [[#Building_CVC4_from_a_repository_checkout|below]].)&lt;br /&gt;
&lt;br /&gt;
===Common make Options===&lt;br /&gt;
* &amp;quot;''make install''&amp;quot; will install into the &amp;quot;--prefix&amp;quot; option you gave to&lt;br /&gt;
the configure script (''/usr/local'' by default).&lt;br /&gt;
    ./configure --prefix=~/install_targets/cvc4 ...&lt;br /&gt;
    make install&lt;br /&gt;
* '''You should run &amp;quot;''make check''&amp;quot;''' before installation to ensure that CVC4 has been&lt;br /&gt;
built correctly.  In particular, GCC version 4.5.1 seems to have a&lt;br /&gt;
bug in the optimizer that results in incorrect behavior (and wrong&lt;br /&gt;
results) in many builds.  This is a known problem for Minisat, and&lt;br /&gt;
since Minisat is at the core of CVC4, a problem for CVC4.  &amp;quot;''make check''&amp;quot;&lt;br /&gt;
easily detects this problem (by showing a number of FAILed test cases).&lt;br /&gt;
It is ok if the unit tests aren't run as part of &amp;quot;''make check''&amp;quot;, but all&lt;br /&gt;
system tests and regression tests should pass without incident.&lt;br /&gt;
* To build API documentation, use &amp;quot;''make doc''&amp;quot;.  Documentation is produced&lt;br /&gt;
under ''builds/doc/'' but is not installed by &amp;quot;''make install''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Examples and tutorials are not installed with &amp;quot;''make install''.&amp;quot;  See [[#Examples_and_tutorials_are_not_built_or_installed|below]].&lt;br /&gt;
&lt;br /&gt;
For more information about the build system itself (probably not&lt;br /&gt;
necessary for casual users), see the [[#Appendix:_Build_architecture|Appendix]] at the bottom of this&lt;br /&gt;
file.&lt;br /&gt;
&lt;br /&gt;
===Common configure Options===&lt;br /&gt;
*'''--prefix=PREFIX''' install architecture-independent files in PREFIX (by default /usr/local)&lt;br /&gt;
*'''--with-build={production,debug,default,competition}''' &lt;br /&gt;
*'''--with-antlr-dir=PATH'''&lt;br /&gt;
*'''--with-cln'''/'''--with-gmp''' selects the numbers package to use by default ([[#Optional requirements]])&lt;br /&gt;
*'''--enable-static-binary''' build a fully statically-linked binary. (This is recommended for Mac OS X users that want to be able to use gdb.)&lt;br /&gt;
*'''ANTLR=PATH''' location of the antlr3 script&lt;br /&gt;
*'''--with-boost=DIR''' installation location of the boost libraries (most users will not need this)&lt;br /&gt;
&lt;br /&gt;
See '''./configure --help''' for more.&lt;br /&gt;
&lt;br /&gt;
===Build dependencies===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are required to run CVC4. Versions&lt;br /&gt;
given are minimum versions; more recent versions should be compatible.&lt;br /&gt;
&lt;br /&gt;
*'''GNU C and C++''' (gcc and g++), reasonably recent versions&lt;br /&gt;
*'''GNU Make'''&lt;br /&gt;
*'''GNU Bash'''&lt;br /&gt;
*'''GMP v4.2''' (GNU Multi-Precision arithmetic library)&lt;br /&gt;
*'''libantlr3c v3.2 or v3.4''' (ANTLR parser generator C support library)&lt;br /&gt;
*'''The Boost C++ base libraries'''&lt;br /&gt;
*'''MacPorts'''   [highly recommended if on a Mac; see [[#MacPorts]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hardest to obtain and install is the libantlr3c requirement, and&lt;br /&gt;
is explained [[#Installing libantlr3c: ANTLR parser generator C support library|next]].&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;make&amp;quot; is non-GNU on your system, make sure to invoke &amp;quot;gmake&amp;quot; (or&lt;br /&gt;
whatever GNU Make is installed as).  If your usual shell is not Bash,&lt;br /&gt;
the configure script should auto-correct this.  If it does not, you'll&lt;br /&gt;
see strange shell syntax errors, and you may need to explicitly set&lt;br /&gt;
SHELL or CONFIG_SHELL to the location of bash on your system.&lt;br /&gt;
&lt;br /&gt;
====Installing libantlr3c: ANTLR parser generator C support library====&lt;br /&gt;
&lt;br /&gt;
For libantlr3c, you can use the convenience script in&lt;br /&gt;
''contrib/get-antlr-3.4'' in the source distribution---this will download, patch, compile and install&lt;br /&gt;
libantlr3c into your cvc4 directory as ''cvc4/antlr-3.4/''.&lt;br /&gt;
  cd contrib&lt;br /&gt;
  ./get-antlr-3.4&lt;br /&gt;
&lt;br /&gt;
CVC4 must be configured with the antlr library installation directory, '''--with-antlr-dir''', and an antlr executable script file, '''ANTLR'''.  If libantlr3c was installed via get-antlr-3.4, the following configure line should suffice for CVC44&lt;br /&gt;
  ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
&lt;br /&gt;
For 64 bit machines, libantlr3c needs to be configured with 64 bit explicitly&lt;br /&gt;
  ./configure --enable-64bit ...&lt;br /&gt;
The get-antlr-3.4 script makes a guess at whether the machine is 64 bit and adds the appropriate flag.&lt;br /&gt;
To force the script to compile 32 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86&amp;quot; ./get-antlr3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr3.4&lt;br /&gt;
&lt;br /&gt;
For a longer discussion, instructions for manual installation, and more in depth troubleshooting, see [[Developer's Guide#ANTLR3]].&lt;br /&gt;
&lt;br /&gt;
====MacPorts====&lt;br /&gt;
&lt;br /&gt;
On a Mac, it is '''highly''' recommended that you use MacPorts (see&lt;br /&gt;
http://www.macports.org/).  Doing so is easy.  Then, simply run the&lt;br /&gt;
script ''contrib/mac-build'', which installs a few ports from the MacPorts&lt;br /&gt;
repository, then compiles and installs antlr3c using the ''get-antlr-3.4''&lt;br /&gt;
script.  The mac-build script should set you up&lt;br /&gt;
with all requirements, and will tell you how to configure CVC4 when it&lt;br /&gt;
completes successfully.&lt;br /&gt;
&lt;br /&gt;
====Installing the Boost C++ base libraries====&lt;br /&gt;
&lt;br /&gt;
A Boost package is available on most Linux distributions; check yours&lt;br /&gt;
for a package named something like libboost-dev or boost-devel.  There&lt;br /&gt;
are a number of additional Boost packages in some distributions, but&lt;br /&gt;
this &amp;quot;basic&amp;quot; one should be sufficient for building CVC4.&lt;br /&gt;
&lt;br /&gt;
Should you want to install Boost manually, or to learn more about the&lt;br /&gt;
Boost project, please visit http://www.boost.org/.&lt;br /&gt;
&lt;br /&gt;
===Optional requirements===&lt;br /&gt;
&lt;br /&gt;
None of these is required, but can improve CVC4 as described below:&lt;br /&gt;
&lt;br /&gt;
*'''Optional: SWIG 2.0.x''' (Simplified Wrapper and Interface Generator)&lt;br /&gt;
*'''Optional: CLN v1.3 or newer''' (Class Library for Numbers)&lt;br /&gt;
*'''Optional: CUDD v2.4.2 or newer''' (Colorado University Decision Diagram package)&lt;br /&gt;
*'''Optional: GNU Readline library''' (for an improved interactive experience)&lt;br /&gt;
*'''Optional: The Boost C++ threading library''' (libboost_thread)&lt;br /&gt;
*'''Optional: CxxTest unit testing framework'''&lt;br /&gt;
&lt;br /&gt;
SWIG is necessary to build the Java API (and of course a JDK is&lt;br /&gt;
necessary, too).  SWIG 1.x won't work; you'll need 2.0, and the more&lt;br /&gt;
recent the better.  On Mac, we've seen SWIG segfault when generating&lt;br /&gt;
CVC4 language bindings; version 2.0.8 or higher is recommended to&lt;br /&gt;
avoid this.  See [[#Language_bindings|Language bindings]] below for build instructions.&lt;br /&gt;
&lt;br /&gt;
CLN is an alternative multiprecision arithmetic package that can offer&lt;br /&gt;
better performance and memory footprint than GMP.  CLN is covered by&lt;br /&gt;
the GNU General Public License, version 3; so if you choose to use&lt;br /&gt;
CVC4 with CLN support, you are licensing CVC4 under that same license.&lt;br /&gt;
(Usually CVC4's license is more permissive than GPL is; see the file&lt;br /&gt;
COPYING in the CVC4 source distribution for details.)  Please visit&lt;br /&gt;
http://www.ginac.de/CLN/ for more details about CLN.&lt;br /&gt;
&lt;br /&gt;
CUDD is a decision diagram package that changes the behavior of the&lt;br /&gt;
CVC4 arithmetic solver in some cases; it may or may not improve the&lt;br /&gt;
arithmetic solver's performance.  See [[#Building_with_CUDD_(optional)|below]] for instructions on&lt;br /&gt;
obtaining and building CUDD.&lt;br /&gt;
&lt;br /&gt;
The GNU Readline library is optionally used to provide command&lt;br /&gt;
editing, tab completion, and history functionality at the CVC prompt&lt;br /&gt;
(when running in interactive mode).  Check your distribution for a&lt;br /&gt;
package named &amp;quot;libreadline-dev&amp;quot; or &amp;quot;readline-devel&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
The Boost C++ threading library (often packaged independently of the&lt;br /&gt;
Boost base library) is needed to run CVC4 in &amp;quot;portfolio&amp;quot;&lt;br /&gt;
(multithreaded) mode.  Check your distribution for a package named&lt;br /&gt;
&amp;quot;libboost-thread-dev&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
CxxTest is necessary to run CVC4's unit tests (included with the&lt;br /&gt;
distribution).  Running these is not really required for users of&lt;br /&gt;
CVC4; &amp;quot;make check&amp;quot; will skip unit tests if CxxTest isn't available,&lt;br /&gt;
and go on to run the extensive system- and regression-tests in the&lt;br /&gt;
source tree.  However, if you're interested, you can download CxxTest&lt;br /&gt;
at http://cxxtest.com/ .&lt;br /&gt;
&lt;br /&gt;
====Building with CUDD (optional)====&lt;br /&gt;
&lt;br /&gt;
CUDD, if desired, must be installed delicately.  The CVC4 configure&lt;br /&gt;
script attempts to auto-detect the locations and names of CUDD headers&lt;br /&gt;
and libraries the way that the Fedora RPMs install them, the way that&lt;br /&gt;
our NYU-provided Debian packages install them, and the way they exist&lt;br /&gt;
when you download and build the CUDD sources directly.  If you install&lt;br /&gt;
from Fedora RPMs or our Debian packages, the process should be&lt;br /&gt;
completely automatic, since the libraries and headers are installed in&lt;br /&gt;
a standard location.  If you download the sources yourself, you need&lt;br /&gt;
to build them in a special way.  Fortunately, the&lt;br /&gt;
&amp;quot;contrib/build-cudd-2.4.2-with-libtool.sh&amp;quot; script in the CVC4 source&lt;br /&gt;
tree does exactly what you need: it patches the CUDD makefiles to use&lt;br /&gt;
libtool, builds the libtool libraries, then reverses the patch to&lt;br /&gt;
leave the makefiles as they were.  Once you run this script on an&lt;br /&gt;
unpacked CUDD 2.4.2 source distribution, then CVC4's configure script&lt;br /&gt;
should pick up the libraries if you provide&lt;br /&gt;
--with-cudd-dir=/PATH/TO/CUDD/SOURCES.&lt;br /&gt;
&lt;br /&gt;
If you want to force linking to CUDD, provide --with-cudd to the&lt;br /&gt;
configure script; this makes it a hard requirement rather than an&lt;br /&gt;
optional add-on.&lt;br /&gt;
&lt;br /&gt;
The NYU-provided Debian packaging of CUDD 2.4.2 and CUDD 2.5.0 are&lt;br /&gt;
here (along with the CVC4 Debian packages):&lt;br /&gt;
&lt;br /&gt;
  deb http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
&lt;br /&gt;
On Debian (and Debian-derived distributions like Ubuntu), you only&lt;br /&gt;
need to drop that one line in your /etc/apt/sources.list file, then install with your favorite package manager.&lt;br /&gt;
&lt;br /&gt;
The Debian source package &amp;quot;cudd&amp;quot;, available from the same repository,&lt;br /&gt;
includes a diff of all changes made to cudd makefiles.&lt;br /&gt;
&lt;br /&gt;
===Language bindings===&lt;br /&gt;
&lt;br /&gt;
There are several options available for using CVC4 from the API.&lt;br /&gt;
&lt;br /&gt;
First, CVC4 offers a complete and flexible API for manipulating&lt;br /&gt;
expressions, maintaining a stack of assertions, and checking&lt;br /&gt;
satisfiability, and related things.  The C++ libraries (libcvc4.so and&lt;br /&gt;
libcvc4parser.so) and required headers are installed normally via a&lt;br /&gt;
&amp;quot;make install&amp;quot;.  This API is also available from Java (via CVC4.jar&lt;br /&gt;
and libcvc4jni.so) by configuring with --enable-language-bindings=java.&lt;br /&gt;
You'll also need SWIG 2.0 installed (and you might need to help&lt;br /&gt;
configure find it if you installed it in a nonstandard place with&lt;br /&gt;
--with-swig-dir=/path/to/swig/installation).  You may also need to&lt;br /&gt;
give the configure script the path to your Java headers (in&lt;br /&gt;
particular, jni.h).  You might do so with (for example):&lt;br /&gt;
&lt;br /&gt;
  ./configure --enable-language-bindings=java \&lt;br /&gt;
      JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-openjdk-amd64/include&lt;br /&gt;
&lt;br /&gt;
There is also a &amp;quot;C++ compatibility API&amp;quot; (''#include &amp;lt;cvc4/cvc3_compat.h&amp;gt;''&lt;br /&gt;
and link against libcvc4compat.so) that attempts to maintain&lt;br /&gt;
source-level backwards-compatibility with the CVC3 C++ API.  The&lt;br /&gt;
compatibility library is built by default, and&lt;br /&gt;
''--enable-language-bindings=java'' enables the Java compatibility library&lt;br /&gt;
(CVC4compat.jar and libcvc4compatjni.so).&lt;br /&gt;
''--enable-language-bindings=c'' enables the C compatibility library&lt;br /&gt;
(''#include &amp;lt;cvc4/bindings/compat/c/c_interface.h&amp;gt;'' and link against&lt;br /&gt;
libcvc4bindings_c_compat.so), and if you want both C and Java&lt;br /&gt;
bindings, use ''--enable-language-bindings=c,java''.  These compatibility&lt;br /&gt;
language bindings do NOT require SWIG.&lt;br /&gt;
&lt;br /&gt;
The ''examples/'' directory in the source distribution includes some basic examples (the &amp;quot;simple vc&amp;quot;&lt;br /&gt;
and &amp;quot;simple vc compat&amp;quot; family of examples) of all these interfaces.&lt;br /&gt;
&lt;br /&gt;
In principle, since we use SWIG to generate the native Java API, we&lt;br /&gt;
could support other languages as well.  However, using CVC4 from other&lt;br /&gt;
languages is not supported, nor expected to work, at this time.  If&lt;br /&gt;
you're interested in helping to develop, maintain, and test a language&lt;br /&gt;
binding, please contact us via the users' mailing list at&lt;br /&gt;
cvc-users@cs.nyu.edu.&lt;br /&gt;
&lt;br /&gt;
===Building CVC4 from a repository checkout===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are additionally required to build&lt;br /&gt;
CVC4 from from a repository checkout rather than from a prepared&lt;br /&gt;
source tarball.&lt;br /&gt;
&lt;br /&gt;
*'''Automake v1.11'''&lt;br /&gt;
*'''Autoconf v2.61'''&lt;br /&gt;
*'''Libtool v2.2'''&lt;br /&gt;
*'''ANTLR3 v3.2 or v3.4'''&lt;br /&gt;
*'''Java Development Kit''' ([http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 required for ANTLR3])&lt;br /&gt;
&lt;br /&gt;
First, use &amp;quot;''./autogen.sh''&amp;quot; to create the configure script.  Then&lt;br /&gt;
proceed as normal for any distribution tarball.  The parsers are&lt;br /&gt;
pre-generated for the tarballs, but don't exist in the repository; hence the extra ANTLR3 and JDK requirements to&lt;br /&gt;
generate the source code for the parsers, when building from the&lt;br /&gt;
repository.&lt;br /&gt;
&lt;br /&gt;
===Examples and tutorials are not built or installed===&lt;br /&gt;
&lt;br /&gt;
Examples are not built by &amp;quot;''make''&amp;quot; or &amp;quot;''make install''&amp;quot;.  See&lt;br /&gt;
''examples/README'' in the source distribution for information on what to find in the ''examples/''&lt;br /&gt;
directory, as well as information about building and installing them.&lt;br /&gt;
&lt;br /&gt;
===Appendix: Build architecture===&lt;br /&gt;
&lt;br /&gt;
The build system is generated by automake, libtool, and autoconf.  It&lt;br /&gt;
is somewhat nonstandard, though, which (for one thing) requires that&lt;br /&gt;
GNU Make be used.  If you ./configure in the top-level source&lt;br /&gt;
directory, the objects will actually all appear in&lt;br /&gt;
builds/${arch}/${build_id}.  This is to allow multiple, separate&lt;br /&gt;
builds in the same place (e.g., an assertions-enabled debugging build&lt;br /&gt;
alongside a production build), without changing directories at the&lt;br /&gt;
shell.  The &amp;quot;current&amp;quot; build is maintained, and you can still use&lt;br /&gt;
(e.g.) &amp;quot;make -C src/main&amp;quot; to rebuild objects in just one subdirectory.&lt;br /&gt;
&lt;br /&gt;
You can also create your own build directory inside or outside of the&lt;br /&gt;
source tree and configure from there.  All objects will then be built&lt;br /&gt;
in that directory, and you'll ultimately find the &amp;quot;cvc4&amp;quot; binary in&lt;br /&gt;
src/main/, and the libraries under src/ and src/parser/.&lt;br /&gt;
&lt;br /&gt;
=Using the CVC4 binary=&lt;br /&gt;
&lt;br /&gt;
The CVC4 driver binary (&amp;quot;cvc4&amp;quot;), once installed, can be executed directly to enter into interactive mode:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then enter commands into CVC4 interactively:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;incremental&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;produce-models&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; TRANSFORM 25*25;&lt;br /&gt;
 625&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example shows two useful options, ''incremental'' and ''produce-models.''&lt;br /&gt;
&lt;br /&gt;
* The ''incremental'' option allows you to issue multiple QUERY (or CHECKSAT) commands, and allows the use of the PUSH and POP commands.  Without this option, CVC4 optimizes itself for a single QUERY or CHECKSAT command (though you may issue any number of ASSERT commands).  The ''incremental'' option may also be given by passing the ''-i'' command line option to CVC4.&lt;br /&gt;
* The ''produce-models'' option allows you to query the model (here, with the COUNTERMODEL command) after an &amp;quot;invalid&amp;quot; QUERY (or &amp;quot;satisfiable&amp;quot; CHECK-SAT).  Without it, CVC4 doesn't do the bookkeeping necessary to support model generation.  The ''produce-models'' option may also be given by passing the ''-m'' command line option to CVC4.&lt;br /&gt;
&lt;br /&gt;
So, if you invoke CVC4 with ''-im'', you don't need to pass those options at all:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -im&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, CVC4 operates in [[#CVC4's native input language|CVC-language mode]].  If you enter something that looks like SMT-LIB, it will suggest that you use the &amp;quot;''--lang smt''&amp;quot; command-line option for SMT-LIB mode:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (declare-fun x () Int)&lt;br /&gt;
 Parse Error: &amp;lt;shell&amp;gt;:1.7: In CVC4 presentation language mode, but SMT-LIB format detected.  Use --lang smt for SMT-LIB support.&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verbosity==&lt;br /&gt;
&lt;br /&gt;
CVC4 has various levels of verbosity.  By default, CVC4 is pretty quiet, only reporting serious warnings and notices.  If you're curious about what it's doing, you can pass CVC4 the ''-v'' option:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -v file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
For even more verbosity, you can pass CVC4 an ''additional'' ''-v'':&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -vv file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
 expanding definitions...&lt;br /&gt;
 constraining subtypes...&lt;br /&gt;
 applying substitutions...&lt;br /&gt;
 simplifying assertions...&lt;br /&gt;
 doing static learning...&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
Internally, verbosity is just an integer value.  It starts at 0, and with every ''-v'' on the command line it is incremented; with every ''-q'', decremented.  It can also be set directly.  From CVC language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;verbosity&amp;quot; 2;&lt;br /&gt;
&lt;br /&gt;
Or from SMT-LIB language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (set-option :verbosity 2)&lt;br /&gt;
&lt;br /&gt;
==Getting statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with the ''--statistics'' command line option.&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 --statistics foo.smt2&lt;br /&gt;
 sat&lt;br /&gt;
 sat::decisions, 0&lt;br /&gt;
 sat::propagations, 3&lt;br /&gt;
 sat::starts, 1&lt;br /&gt;
 theory::uf::TheoryUF::functionTermsCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::mergesCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::termsCount, 6&lt;br /&gt;
 theory&amp;lt;THEORY_UF&amp;gt;::propagations, 1 &lt;br /&gt;
 driver::filename, foo.smt2&lt;br /&gt;
 driver::sat/unsat, sat&lt;br /&gt;
 driver::totalTime, 0.02015373&lt;br /&gt;
 ''[many others]''&lt;br /&gt;
&lt;br /&gt;
Many statistics name-value pairs follow, one comma-separated pair per line.&lt;br /&gt;
&lt;br /&gt;
==Exit status==&lt;br /&gt;
&lt;br /&gt;
The exit status of CVC4 depends on the ''last'' QUERY or CHECK-SAT.  If you wish to call CVC4 from a program (e.g., a shell script) and care only about the satisfiability or validity of a single formula, you can pass the ''-q'' option (as described [[#Verbosity|above, under verbosity]]) and check the exit code.  With ''-q'', CVC4 should not produce any output unless it encounters a fatal error.&lt;br /&gt;
&lt;br /&gt;
QUERY asks a validity question, and CHECK-SAT a satisfiability question, and these are dual problems; hence the terminology is different, but really &amp;quot;sat&amp;quot; and &amp;quot;invalid&amp;quot; are the same internally, as are &amp;quot;unsat&amp;quot; and &amp;quot;valid&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Solver's last result&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Exit code&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''sat''' or '''invalid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unsat''' or '''valid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unknown'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;could be for any reason: time limit exceeded, no memory, incompleteness..&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;''no result''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no query or check-sat command issued&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;parse errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0 (in interactive mode)&amp;lt;br/&amp;gt;1 (otherwise)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;other errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1 (usually)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, and others, can produce different exit codes.  In interactive mode, parse errors are ignored and the next line read; so in interactive mode, you may see an exit code of 0 even in the presence of such an error.&lt;br /&gt;
&lt;br /&gt;
In SMT-LIB mode, an SMT-LIB command script that sets its status via &amp;quot;set-info :status&amp;quot; also affects the exit code.  So, for instance, the following SMT-LIB script returns an exit code of 10 even though it contains no &amp;quot;check-sat&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 (set-logic QF_UF)&lt;br /&gt;
 (set-info :status sat)&lt;br /&gt;
 (exit)&lt;br /&gt;
&lt;br /&gt;
Without the &amp;quot;set-info,&amp;quot; it would have returned an exit code of 0.&lt;br /&gt;
&lt;br /&gt;
=CVC4's native input language=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}\ [X_1, \ldots, X_p] \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt; are type variables,&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by some of the variables &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format,&lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=CVC4's support for the SMT-LIB language=&lt;br /&gt;
&lt;br /&gt;
==SMT-LIB compliance==&lt;br /&gt;
&lt;br /&gt;
Every effort has been made to make CVC4 compliant with the SMT-LIB 2.0&lt;br /&gt;
standard (http://smtlib.org/).  However, when parsing SMT-LIB input,&lt;br /&gt;
certain default settings don't match what is stated in the official&lt;br /&gt;
standard.  To make CVC4 adhere more strictly to the standard, use the&lt;br /&gt;
&amp;quot;--smtlib&amp;quot; command-line option.  Even with this setting, CVC4 is&lt;br /&gt;
somewhat lenient; some non-conforming input may still be parsed and&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
==Using CVC4 from Java==&lt;br /&gt;
==The compatibility interface==&lt;br /&gt;
&lt;br /&gt;
=Upgrading from CVC3 to CVC4=&lt;br /&gt;
&lt;br /&gt;
==Features not supported by CVC4 (yet)==&lt;br /&gt;
&lt;br /&gt;
===Type Correctness Conditions (TCCs)===&lt;br /&gt;
&lt;br /&gt;
Type Correctness Conditions (TCCs), and the checking of such, are not&lt;br /&gt;
supported by CVC4 1.0.  Thus, a function defined only on integers can be&lt;br /&gt;
applied to REAL (as INT is a subtype of REAL), and CVC4 will not complain,&lt;br /&gt;
but may produce strange results.  For example:&lt;br /&gt;
&lt;br /&gt;
  f : INT -&amp;gt; INT;&lt;br /&gt;
  ASSERT f(1/3) = 0;&lt;br /&gt;
  ASSERT f(2/3) = 1;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  COUNTEREXAMPLE;&lt;br /&gt;
  % f : (INT) -&amp;gt; INT = LAMBDA(x1:INT) : 0;&lt;br /&gt;
&lt;br /&gt;
CVC3 can be used to produce TCCs for this input (with the +dump-tcc option).&lt;br /&gt;
The TCC can be checked by CVC3 or another solver.  (CVC3 can also check&lt;br /&gt;
TCCs while solving with +tcc.)&lt;br /&gt;
&lt;br /&gt;
==If you were using the text interfaces of CVC3==&lt;br /&gt;
&lt;br /&gt;
The native language of all solvers in the CVC family, referred to as the&lt;br /&gt;
&amp;quot;presentation language,&amp;quot; has undergone some revisions for CVC4.  The&lt;br /&gt;
most notable is that CVC4 does _not_ add counterexample assertions to&lt;br /&gt;
the current assertion set after a SAT/INVALID result.  For example:&lt;br /&gt;
&lt;br /&gt;
  x, y : INT;&lt;br /&gt;
  ASSERT x = 1 OR x = 2;&lt;br /&gt;
  ASSERT y = 1 OR y = 2;&lt;br /&gt;
  ASSERT x /= y;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  QUERY x = 1;&lt;br /&gt;
  % invalid&lt;br /&gt;
  QUERY x = 2;&lt;br /&gt;
  % invalid&lt;br /&gt;
&lt;br /&gt;
Here, CVC4 responds &amp;quot;invalid&amp;quot; to the second and third queries, because&lt;br /&gt;
each has a counterexample (x=2 is a counterexample to the first, and&lt;br /&gt;
x=1 is a counterexample to the second).  However, CVC3 will respond&lt;br /&gt;
with &amp;quot;valid&amp;quot; to one of these two, as the first query (the CHECKSAT)&lt;br /&gt;
had the side-effect of locking CVC3 into one of the two cases; the&lt;br /&gt;
later queries are effectively querying the counterexample that was&lt;br /&gt;
found by the first.  CVC4 removes this side-effect of the CHECKSAT and&lt;br /&gt;
QUERY commands.&lt;br /&gt;
&lt;br /&gt;
CVC4 supports rational literals (of type REAL) in decimal; CVC3 did not&lt;br /&gt;
support decimals.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not have support for the IS_INTEGER predicate.&lt;br /&gt;
&lt;br /&gt;
==If you were using the library (&amp;quot;in-memory&amp;quot;) interface of CVC3==&lt;br /&gt;
===If you were using CVC3 from C===&lt;br /&gt;
===If you were using CVC3 from Java===&lt;br /&gt;
&lt;br /&gt;
=Useful command-line options=&lt;br /&gt;
&lt;br /&gt;
==Statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with&lt;br /&gt;
the --statistics command line option.&lt;br /&gt;
&lt;br /&gt;
==Time and resource limits==&lt;br /&gt;
&lt;br /&gt;
CVC4 can be made to self-timeout after a given number of milliseconds.&lt;br /&gt;
Use the --tlimit command line option to limit the entire run of&lt;br /&gt;
CVC4, or use --tlimit-per to limit each individual query separately.&lt;br /&gt;
Preprocessing time is not counted by the time limit, so for some large&lt;br /&gt;
inputs which require aggressive preprocessing, you may notice that&lt;br /&gt;
--tlimit does not work very well.  If you suspect this might be the&lt;br /&gt;
case, you can use &amp;quot;-vv&amp;quot; (double verbosity) to see what CVC4 is doing.&lt;br /&gt;
&lt;br /&gt;
Time-limited runs are not deterministic; two consecutive runs with the&lt;br /&gt;
same time limit might produce different results (i.e., one may time out&lt;br /&gt;
and responds with &amp;quot;unknown&amp;quot;, while the other completes and provides an&lt;br /&gt;
answer).  To ensure that results are reproducible, use --rlimit or&lt;br /&gt;
--rlimit-per.  These options take a &amp;quot;resource count&amp;quot; (presently, based on&lt;br /&gt;
the number of SAT conflicts) that limits the search time.  A word of&lt;br /&gt;
caution, though: there is no guarantee that runs of different versions of&lt;br /&gt;
CVC4 or of different builds of CVC4 (e.g., two CVC4 binaries with different&lt;br /&gt;
features enabled, or for different architectures) will interpret the resource&lt;br /&gt;
count in the same manner.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not presently have a way to limit its memory use; you may opt&lt;br /&gt;
to run it from a shell after using &amp;quot;ulimit&amp;quot; to limit the size of the&lt;br /&gt;
heap.&lt;br /&gt;
&lt;br /&gt;
=Dumping API calls or preprocessed output=&lt;br /&gt;
&lt;br /&gt;
=Changing the output language=&lt;br /&gt;
&lt;br /&gt;
=Proof support=&lt;br /&gt;
&lt;br /&gt;
CVC4 1.0 has limited support for proofs, and they are disabled by default.&lt;br /&gt;
(Run the configure script with --enable-proof to enable proofs).  Proofs&lt;br /&gt;
are exported in LFSC format and are limited to the propositional backbone&lt;br /&gt;
of the discovered proof (theory lemmas are stated without proof in this&lt;br /&gt;
release).&lt;br /&gt;
&lt;br /&gt;
=Portfolio solving=&lt;br /&gt;
&lt;br /&gt;
If enabled at configure-time (./configure --with-portfolio), a second&lt;br /&gt;
CVC4 binary will be produced (&amp;quot;pcvc4&amp;quot;).  This binary has support for&lt;br /&gt;
running multiple instances of CVC4 in different threads.  Use --threads=N&lt;br /&gt;
to specify the number of threads, and use --thread0=&amp;quot;options for thread 0&amp;quot;&lt;br /&gt;
--thread1=&amp;quot;options for thread 1&amp;quot;, etc., to specify a configuration for the&lt;br /&gt;
threads.  Lemmas are *not* shared between the threads by default; to adjust&lt;br /&gt;
this, use the --filter-lemma-length=N option to share lemmas of N literals&lt;br /&gt;
(or smaller).  (Some lemmas are ineligible for sharing because they include&lt;br /&gt;
literals that are &amp;quot;local&amp;quot; to one thread.)&lt;br /&gt;
&lt;br /&gt;
Currently, the portfolio **does not work** with quantifiers or with&lt;br /&gt;
the theory of inductive datatypes.  These limitations will be addressed&lt;br /&gt;
in a future release.&lt;br /&gt;
&lt;br /&gt;
=Emacs support=&lt;br /&gt;
&lt;br /&gt;
For a suggestion of editing CVC4 source code with emacs, see the file&lt;br /&gt;
contrib/editing-with-emacs.  For a CVC language mode (the native input&lt;br /&gt;
language for CVC4), see contrib/cvc-mode.el.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3915</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3915"/>
				<updated>2012-11-26T04:30:35Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Arithmetic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This manual includes lots of information about how to use CVC4.&lt;br /&gt;
&lt;br /&gt;
It is a work in-progress.&lt;br /&gt;
&lt;br /&gt;
= What is CVC4? =&lt;br /&gt;
&lt;br /&gt;
CVC4 is the last of a long line of SMT solvers that started with SVC and includes CVC, CVC-Lite and CVC3.&lt;br /&gt;
Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories. &lt;br /&gt;
The current built-in theories are the theories of:&lt;br /&gt;
&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols,&lt;br /&gt;
* real and integer linear arithmetic (with some support for non-linear arithmetic),&lt;br /&gt;
* bit vectors,&lt;br /&gt;
* arrays,&lt;br /&gt;
* tuples,&lt;br /&gt;
* records,&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 checks whether a given formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is valid in the built-in theories under a given set &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; of assumptions, a ''context''. &lt;br /&gt;
More precisely, it checks whether&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma\models_T \phi&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
that is, whether &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a logical consequence in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; of the set of formulas &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the union of CVC4's built-in theories.&lt;br /&gt;
&lt;br /&gt;
Roughly speaking, when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a universal formula and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is a set of existential formulas (i.e., when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; contain at most universal, respectively existential, quantifiers), CVC4 is a decision procedure: &lt;br /&gt;
it is guaranteed (modulo bugs and memory limits) to return a correct &amp;quot;valid&amp;quot; or &amp;quot;invalid&amp;quot; answer eventually. &lt;br /&gt;
In all other cases, CVC4 is deductively sound but incomplete: &lt;br /&gt;
it will never say that an invalid formula is valid,&lt;br /&gt;
but it may either never return or give up and return &amp;quot;unknown&amp;quot; for some formulas.&lt;br /&gt;
&lt;br /&gt;
Currently, when CVC4 returns &amp;quot;valid&amp;quot; for a query formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; under a context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;&lt;br /&gt;
it provides no evidence to back its claim.&lt;br /&gt;
Future versions will also return a ''proof certificate'', &lt;br /&gt;
a formal proof that &amp;lt;math&amp;gt;\Gamma'\models_T \phi&amp;lt;/math&amp;gt; for some subset &amp;lt;math&amp;gt;\Gamma'&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When CVC4 returns &amp;quot;invalid&amp;quot; it can return &lt;br /&gt;
both a ''counter-example'' to &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;'s validity under the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and a ''counter-model''. &lt;br /&gt;
Both a counter-example and a counter-model are a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of additional formulas consistent with &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but entailing the negation of &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
Formally:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \not\models_T \mathit{false}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \models_T \lnot \phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference is that a counter-model is given as a set of equations providing a concrete assignment of values for the free symbols in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; &lt;br /&gt;
(see the section on [[#CVC4's native input language|CVC4's native input language]] for more details).&lt;br /&gt;
&lt;br /&gt;
=Obtaining and compiling CVC4=&lt;br /&gt;
&lt;br /&gt;
CVC4 is distributed in the following ways:&lt;br /&gt;
* [[#Obtaining_binary_packages|Binary packages]]&lt;br /&gt;
* [[#Obtaining_source_packages|Source packages]]&lt;br /&gt;
* [[#Source_repository|Source repository checkout]]&lt;br /&gt;
&lt;br /&gt;
==Obtaining binary packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/ Binary packages are available] for CVC4.&lt;br /&gt;
Nightly builds:&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/debian/unstable Debian] packages&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
&lt;br /&gt;
==Obtaining source packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/src/ Sources are available] from the same site as the binaries.&lt;br /&gt;
&lt;br /&gt;
==Source repository==&lt;br /&gt;
The [http://cvc4.cs.nyu.edu/builds/src/ CVC4 source repository] is currently hosted by [http://cims.nyu.edu/ CIMS] and requires a CIMS account. Please contact a member of the development team for access. Please see the additional instructions for [[#Building_CVC4 from_a_repository_checkout]] here.&lt;br /&gt;
&lt;br /&gt;
==Building from source==&lt;br /&gt;
&lt;br /&gt;
===Quick-start instructions===&lt;br /&gt;
To compile from a source package:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
    cd contrib&lt;br /&gt;
    ./get-antlr-3.4&lt;br /&gt;
    cd ..&lt;br /&gt;
    ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
    make&lt;br /&gt;
    make check   [recommended]&lt;br /&gt;
    make install [optional]&lt;br /&gt;
&lt;br /&gt;
(To build from a repository checkout, see [[#Building_CVC4_from_a_repository_checkout|below]].)&lt;br /&gt;
&lt;br /&gt;
===Common make Options===&lt;br /&gt;
* &amp;quot;''make install''&amp;quot; will install into the &amp;quot;--prefix&amp;quot; option you gave to&lt;br /&gt;
the configure script (''/usr/local'' by default).&lt;br /&gt;
    ./configure --prefix=~/install_targets/cvc4 ...&lt;br /&gt;
    make install&lt;br /&gt;
* '''You should run &amp;quot;''make check''&amp;quot;''' before installation to ensure that CVC4 has been&lt;br /&gt;
built correctly.  In particular, GCC version 4.5.1 seems to have a&lt;br /&gt;
bug in the optimizer that results in incorrect behavior (and wrong&lt;br /&gt;
results) in many builds.  This is a known problem for Minisat, and&lt;br /&gt;
since Minisat is at the core of CVC4, a problem for CVC4.  &amp;quot;''make check''&amp;quot;&lt;br /&gt;
easily detects this problem (by showing a number of FAILed test cases).&lt;br /&gt;
It is ok if the unit tests aren't run as part of &amp;quot;''make check''&amp;quot;, but all&lt;br /&gt;
system tests and regression tests should pass without incident.&lt;br /&gt;
* To build API documentation, use &amp;quot;''make doc''&amp;quot;.  Documentation is produced&lt;br /&gt;
under ''builds/doc/'' but is not installed by &amp;quot;''make install''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Examples and tutorials are not installed with &amp;quot;''make install''.&amp;quot;  See [[#Examples_and_tutorials_are_not_built_or_installed|below]].&lt;br /&gt;
&lt;br /&gt;
For more information about the build system itself (probably not&lt;br /&gt;
necessary for casual users), see the [[#Appendix:_Build_architecture|Appendix]] at the bottom of this&lt;br /&gt;
file.&lt;br /&gt;
&lt;br /&gt;
===Common configure Options===&lt;br /&gt;
*'''--prefix=PREFIX''' install architecture-independent files in PREFIX (by default /usr/local)&lt;br /&gt;
*'''--with-build={production,debug,default,competition}''' &lt;br /&gt;
*'''--with-antlr-dir=PATH'''&lt;br /&gt;
*'''--with-cln'''/'''--with-gmp''' selects the numbers package to use by default ([[#Optional requirements]])&lt;br /&gt;
*'''--enable-static-binary''' build a fully statically-linked binary. (This is recommended for Mac OS X users that want to be able to use gdb.)&lt;br /&gt;
*'''ANTLR=PATH''' location of the antlr3 script&lt;br /&gt;
*'''--with-boost=DIR''' installation location of the boost libraries (most users will not need this)&lt;br /&gt;
&lt;br /&gt;
See '''./configure --help''' for more.&lt;br /&gt;
&lt;br /&gt;
===Build dependencies===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are required to run CVC4. Versions&lt;br /&gt;
given are minimum versions; more recent versions should be compatible.&lt;br /&gt;
&lt;br /&gt;
*'''GNU C and C++''' (gcc and g++), reasonably recent versions&lt;br /&gt;
*'''GNU Make'''&lt;br /&gt;
*'''GNU Bash'''&lt;br /&gt;
*'''GMP v4.2''' (GNU Multi-Precision arithmetic library)&lt;br /&gt;
*'''libantlr3c v3.2 or v3.4''' (ANTLR parser generator C support library)&lt;br /&gt;
*'''The Boost C++ base libraries'''&lt;br /&gt;
*'''MacPorts'''   [highly recommended if on a Mac; see [[#MacPorts]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hardest to obtain and install is the libantlr3c requirement, and&lt;br /&gt;
is explained [[#Installing libantlr3c: ANTLR parser generator C support library|next]].&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;make&amp;quot; is non-GNU on your system, make sure to invoke &amp;quot;gmake&amp;quot; (or&lt;br /&gt;
whatever GNU Make is installed as).  If your usual shell is not Bash,&lt;br /&gt;
the configure script should auto-correct this.  If it does not, you'll&lt;br /&gt;
see strange shell syntax errors, and you may need to explicitly set&lt;br /&gt;
SHELL or CONFIG_SHELL to the location of bash on your system.&lt;br /&gt;
&lt;br /&gt;
====Installing libantlr3c: ANTLR parser generator C support library====&lt;br /&gt;
&lt;br /&gt;
For libantlr3c, you can use the convenience script in&lt;br /&gt;
''contrib/get-antlr-3.4'' in the source distribution---this will download, patch, compile and install&lt;br /&gt;
libantlr3c into your cvc4 directory as ''cvc4/antlr-3.4/''.&lt;br /&gt;
  cd contrib&lt;br /&gt;
  ./get-antlr-3.4&lt;br /&gt;
&lt;br /&gt;
CVC4 must be configured with the antlr library installation directory, '''--with-antlr-dir''', and an antlr executable script file, '''ANTLR'''.  If libantlr3c was installed via get-antlr-3.4, the following configure line should suffice for CVC44&lt;br /&gt;
  ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
&lt;br /&gt;
For 64 bit machines, libantlr3c needs to be configured with 64 bit explicitly&lt;br /&gt;
  ./configure --enable-64bit ...&lt;br /&gt;
The get-antlr-3.4 script makes a guess at whether the machine is 64 bit and adds the appropriate flag.&lt;br /&gt;
To force the script to compile 32 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86&amp;quot; ./get-antlr3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr3.4&lt;br /&gt;
&lt;br /&gt;
For a longer discussion, instructions for manual installation, and more in depth troubleshooting, see [[Developer's Guide#ANTLR3]].&lt;br /&gt;
&lt;br /&gt;
====MacPorts====&lt;br /&gt;
&lt;br /&gt;
On a Mac, it is '''highly''' recommended that you use MacPorts (see&lt;br /&gt;
http://www.macports.org/).  Doing so is easy.  Then, simply run the&lt;br /&gt;
script ''contrib/mac-build'', which installs a few ports from the MacPorts&lt;br /&gt;
repository, then compiles and installs antlr3c using the ''get-antlr-3.4''&lt;br /&gt;
script.  The mac-build script should set you up&lt;br /&gt;
with all requirements, and will tell you how to configure CVC4 when it&lt;br /&gt;
completes successfully.&lt;br /&gt;
&lt;br /&gt;
====Installing the Boost C++ base libraries====&lt;br /&gt;
&lt;br /&gt;
A Boost package is available on most Linux distributions; check yours&lt;br /&gt;
for a package named something like libboost-dev or boost-devel.  There&lt;br /&gt;
are a number of additional Boost packages in some distributions, but&lt;br /&gt;
this &amp;quot;basic&amp;quot; one should be sufficient for building CVC4.&lt;br /&gt;
&lt;br /&gt;
Should you want to install Boost manually, or to learn more about the&lt;br /&gt;
Boost project, please visit http://www.boost.org/.&lt;br /&gt;
&lt;br /&gt;
===Optional requirements===&lt;br /&gt;
&lt;br /&gt;
None of these is required, but can improve CVC4 as described below:&lt;br /&gt;
&lt;br /&gt;
*'''Optional: SWIG 2.0.x''' (Simplified Wrapper and Interface Generator)&lt;br /&gt;
*'''Optional: CLN v1.3 or newer''' (Class Library for Numbers)&lt;br /&gt;
*'''Optional: CUDD v2.4.2 or newer''' (Colorado University Decision Diagram package)&lt;br /&gt;
*'''Optional: GNU Readline library''' (for an improved interactive experience)&lt;br /&gt;
*'''Optional: The Boost C++ threading library''' (libboost_thread)&lt;br /&gt;
*'''Optional: CxxTest unit testing framework'''&lt;br /&gt;
&lt;br /&gt;
SWIG is necessary to build the Java API (and of course a JDK is&lt;br /&gt;
necessary, too).  SWIG 1.x won't work; you'll need 2.0, and the more&lt;br /&gt;
recent the better.  On Mac, we've seen SWIG segfault when generating&lt;br /&gt;
CVC4 language bindings; version 2.0.8 or higher is recommended to&lt;br /&gt;
avoid this.  See [[#Language_bindings|Language bindings]] below for build instructions.&lt;br /&gt;
&lt;br /&gt;
CLN is an alternative multiprecision arithmetic package that can offer&lt;br /&gt;
better performance and memory footprint than GMP.  CLN is covered by&lt;br /&gt;
the GNU General Public License, version 3; so if you choose to use&lt;br /&gt;
CVC4 with CLN support, you are licensing CVC4 under that same license.&lt;br /&gt;
(Usually CVC4's license is more permissive than GPL is; see the file&lt;br /&gt;
COPYING in the CVC4 source distribution for details.)  Please visit&lt;br /&gt;
http://www.ginac.de/CLN/ for more details about CLN.&lt;br /&gt;
&lt;br /&gt;
CUDD is a decision diagram package that changes the behavior of the&lt;br /&gt;
CVC4 arithmetic solver in some cases; it may or may not improve the&lt;br /&gt;
arithmetic solver's performance.  See [[#Building_with_CUDD_(optional)|below]] for instructions on&lt;br /&gt;
obtaining and building CUDD.&lt;br /&gt;
&lt;br /&gt;
The GNU Readline library is optionally used to provide command&lt;br /&gt;
editing, tab completion, and history functionality at the CVC prompt&lt;br /&gt;
(when running in interactive mode).  Check your distribution for a&lt;br /&gt;
package named &amp;quot;libreadline-dev&amp;quot; or &amp;quot;readline-devel&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
The Boost C++ threading library (often packaged independently of the&lt;br /&gt;
Boost base library) is needed to run CVC4 in &amp;quot;portfolio&amp;quot;&lt;br /&gt;
(multithreaded) mode.  Check your distribution for a package named&lt;br /&gt;
&amp;quot;libboost-thread-dev&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
CxxTest is necessary to run CVC4's unit tests (included with the&lt;br /&gt;
distribution).  Running these is not really required for users of&lt;br /&gt;
CVC4; &amp;quot;make check&amp;quot; will skip unit tests if CxxTest isn't available,&lt;br /&gt;
and go on to run the extensive system- and regression-tests in the&lt;br /&gt;
source tree.  However, if you're interested, you can download CxxTest&lt;br /&gt;
at http://cxxtest.com/ .&lt;br /&gt;
&lt;br /&gt;
====Building with CUDD (optional)====&lt;br /&gt;
&lt;br /&gt;
CUDD, if desired, must be installed delicately.  The CVC4 configure&lt;br /&gt;
script attempts to auto-detect the locations and names of CUDD headers&lt;br /&gt;
and libraries the way that the Fedora RPMs install them, the way that&lt;br /&gt;
our NYU-provided Debian packages install them, and the way they exist&lt;br /&gt;
when you download and build the CUDD sources directly.  If you install&lt;br /&gt;
from Fedora RPMs or our Debian packages, the process should be&lt;br /&gt;
completely automatic, since the libraries and headers are installed in&lt;br /&gt;
a standard location.  If you download the sources yourself, you need&lt;br /&gt;
to build them in a special way.  Fortunately, the&lt;br /&gt;
&amp;quot;contrib/build-cudd-2.4.2-with-libtool.sh&amp;quot; script in the CVC4 source&lt;br /&gt;
tree does exactly what you need: it patches the CUDD makefiles to use&lt;br /&gt;
libtool, builds the libtool libraries, then reverses the patch to&lt;br /&gt;
leave the makefiles as they were.  Once you run this script on an&lt;br /&gt;
unpacked CUDD 2.4.2 source distribution, then CVC4's configure script&lt;br /&gt;
should pick up the libraries if you provide&lt;br /&gt;
--with-cudd-dir=/PATH/TO/CUDD/SOURCES.&lt;br /&gt;
&lt;br /&gt;
If you want to force linking to CUDD, provide --with-cudd to the&lt;br /&gt;
configure script; this makes it a hard requirement rather than an&lt;br /&gt;
optional add-on.&lt;br /&gt;
&lt;br /&gt;
The NYU-provided Debian packaging of CUDD 2.4.2 and CUDD 2.5.0 are&lt;br /&gt;
here (along with the CVC4 Debian packages):&lt;br /&gt;
&lt;br /&gt;
  deb http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
&lt;br /&gt;
On Debian (and Debian-derived distributions like Ubuntu), you only&lt;br /&gt;
need to drop that one line in your /etc/apt/sources.list file, then install with your favorite package manager.&lt;br /&gt;
&lt;br /&gt;
The Debian source package &amp;quot;cudd&amp;quot;, available from the same repository,&lt;br /&gt;
includes a diff of all changes made to cudd makefiles.&lt;br /&gt;
&lt;br /&gt;
===Language bindings===&lt;br /&gt;
&lt;br /&gt;
There are several options available for using CVC4 from the API.&lt;br /&gt;
&lt;br /&gt;
First, CVC4 offers a complete and flexible API for manipulating&lt;br /&gt;
expressions, maintaining a stack of assertions, and checking&lt;br /&gt;
satisfiability, and related things.  The C++ libraries (libcvc4.so and&lt;br /&gt;
libcvc4parser.so) and required headers are installed normally via a&lt;br /&gt;
&amp;quot;make install&amp;quot;.  This API is also available from Java (via CVC4.jar&lt;br /&gt;
and libcvc4jni.so) by configuring with --enable-language-bindings=java.&lt;br /&gt;
You'll also need SWIG 2.0 installed (and you might need to help&lt;br /&gt;
configure find it if you installed it in a nonstandard place with&lt;br /&gt;
--with-swig-dir=/path/to/swig/installation).  You may also need to&lt;br /&gt;
give the configure script the path to your Java headers (in&lt;br /&gt;
particular, jni.h).  You might do so with (for example):&lt;br /&gt;
&lt;br /&gt;
  ./configure --enable-language-bindings=java \&lt;br /&gt;
      JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-openjdk-amd64/include&lt;br /&gt;
&lt;br /&gt;
There is also a &amp;quot;C++ compatibility API&amp;quot; (''#include &amp;lt;cvc4/cvc3_compat.h&amp;gt;''&lt;br /&gt;
and link against libcvc4compat.so) that attempts to maintain&lt;br /&gt;
source-level backwards-compatibility with the CVC3 C++ API.  The&lt;br /&gt;
compatibility library is built by default, and&lt;br /&gt;
''--enable-language-bindings=java'' enables the Java compatibility library&lt;br /&gt;
(CVC4compat.jar and libcvc4compatjni.so).&lt;br /&gt;
''--enable-language-bindings=c'' enables the C compatibility library&lt;br /&gt;
(''#include &amp;lt;cvc4/bindings/compat/c/c_interface.h&amp;gt;'' and link against&lt;br /&gt;
libcvc4bindings_c_compat.so), and if you want both C and Java&lt;br /&gt;
bindings, use ''--enable-language-bindings=c,java''.  These compatibility&lt;br /&gt;
language bindings do NOT require SWIG.&lt;br /&gt;
&lt;br /&gt;
The ''examples/'' directory in the source distribution includes some basic examples (the &amp;quot;simple vc&amp;quot;&lt;br /&gt;
and &amp;quot;simple vc compat&amp;quot; family of examples) of all these interfaces.&lt;br /&gt;
&lt;br /&gt;
In principle, since we use SWIG to generate the native Java API, we&lt;br /&gt;
could support other languages as well.  However, using CVC4 from other&lt;br /&gt;
languages is not supported, nor expected to work, at this time.  If&lt;br /&gt;
you're interested in helping to develop, maintain, and test a language&lt;br /&gt;
binding, please contact us via the users' mailing list at&lt;br /&gt;
cvc-users@cs.nyu.edu.&lt;br /&gt;
&lt;br /&gt;
===Building CVC4 from a repository checkout===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are additionally required to build&lt;br /&gt;
CVC4 from from a repository checkout rather than from a prepared&lt;br /&gt;
source tarball.&lt;br /&gt;
&lt;br /&gt;
*'''Automake v1.11'''&lt;br /&gt;
*'''Autoconf v2.61'''&lt;br /&gt;
*'''Libtool v2.2'''&lt;br /&gt;
*'''ANTLR3 v3.2 or v3.4'''&lt;br /&gt;
*'''Java Development Kit''' ([http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 required for ANTLR3])&lt;br /&gt;
&lt;br /&gt;
First, use &amp;quot;''./autogen.sh''&amp;quot; to create the configure script.  Then&lt;br /&gt;
proceed as normal for any distribution tarball.  The parsers are&lt;br /&gt;
pre-generated for the tarballs, but don't exist in the repository; hence the extra ANTLR3 and JDK requirements to&lt;br /&gt;
generate the source code for the parsers, when building from the&lt;br /&gt;
repository.&lt;br /&gt;
&lt;br /&gt;
===Examples and tutorials are not built or installed===&lt;br /&gt;
&lt;br /&gt;
Examples are not built by &amp;quot;''make''&amp;quot; or &amp;quot;''make install''&amp;quot;.  See&lt;br /&gt;
''examples/README'' in the source distribution for information on what to find in the ''examples/''&lt;br /&gt;
directory, as well as information about building and installing them.&lt;br /&gt;
&lt;br /&gt;
===Appendix: Build architecture===&lt;br /&gt;
&lt;br /&gt;
The build system is generated by automake, libtool, and autoconf.  It&lt;br /&gt;
is somewhat nonstandard, though, which (for one thing) requires that&lt;br /&gt;
GNU Make be used.  If you ./configure in the top-level source&lt;br /&gt;
directory, the objects will actually all appear in&lt;br /&gt;
builds/${arch}/${build_id}.  This is to allow multiple, separate&lt;br /&gt;
builds in the same place (e.g., an assertions-enabled debugging build&lt;br /&gt;
alongside a production build), without changing directories at the&lt;br /&gt;
shell.  The &amp;quot;current&amp;quot; build is maintained, and you can still use&lt;br /&gt;
(e.g.) &amp;quot;make -C src/main&amp;quot; to rebuild objects in just one subdirectory.&lt;br /&gt;
&lt;br /&gt;
You can also create your own build directory inside or outside of the&lt;br /&gt;
source tree and configure from there.  All objects will then be built&lt;br /&gt;
in that directory, and you'll ultimately find the &amp;quot;cvc4&amp;quot; binary in&lt;br /&gt;
src/main/, and the libraries under src/ and src/parser/.&lt;br /&gt;
&lt;br /&gt;
=Using the CVC4 binary=&lt;br /&gt;
&lt;br /&gt;
The CVC4 driver binary (&amp;quot;cvc4&amp;quot;), once installed, can be executed directly to enter into interactive mode:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then enter commands into CVC4 interactively:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;incremental&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;produce-models&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; TRANSFORM 25*25;&lt;br /&gt;
 625&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example shows two useful options, ''incremental'' and ''produce-models.''&lt;br /&gt;
&lt;br /&gt;
* The ''incremental'' option allows you to issue multiple QUERY (or CHECKSAT) commands, and allows the use of the PUSH and POP commands.  Without this option, CVC4 optimizes itself for a single QUERY or CHECKSAT command (though you may issue any number of ASSERT commands).  The ''incremental'' option may also be given by passing the ''-i'' command line option to CVC4.&lt;br /&gt;
* The ''produce-models'' option allows you to query the model (here, with the COUNTERMODEL command) after an &amp;quot;invalid&amp;quot; QUERY (or &amp;quot;satisfiable&amp;quot; CHECK-SAT).  Without it, CVC4 doesn't do the bookkeeping necessary to support model generation.  The ''produce-models'' option may also be given by passing the ''-m'' command line option to CVC4.&lt;br /&gt;
&lt;br /&gt;
So, if you invoke CVC4 with ''-im'', you don't need to pass those options at all:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -im&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, CVC4 operates in [[#CVC4's native input language|CVC-language mode]].  If you enter something that looks like SMT-LIB, it will suggest that you use the &amp;quot;''--lang smt''&amp;quot; command-line option for SMT-LIB mode:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (declare-fun x () Int)&lt;br /&gt;
 Parse Error: &amp;lt;shell&amp;gt;:1.7: In CVC4 presentation language mode, but SMT-LIB format detected.  Use --lang smt for SMT-LIB support.&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verbosity==&lt;br /&gt;
&lt;br /&gt;
CVC4 has various levels of verbosity.  By default, CVC4 is pretty quiet, only reporting serious warnings and notices.  If you're curious about what it's doing, you can pass CVC4 the ''-v'' option:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -v file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
For even more verbosity, you can pass CVC4 an ''additional'' ''-v'':&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -vv file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
 expanding definitions...&lt;br /&gt;
 constraining subtypes...&lt;br /&gt;
 applying substitutions...&lt;br /&gt;
 simplifying assertions...&lt;br /&gt;
 doing static learning...&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
Internally, verbosity is just an integer value.  It starts at 0, and with every ''-v'' on the command line it is incremented; with every ''-q'', decremented.  It can also be set directly.  From CVC language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;verbosity&amp;quot; 2;&lt;br /&gt;
&lt;br /&gt;
Or from SMT-LIB language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (set-option :verbosity 2)&lt;br /&gt;
&lt;br /&gt;
==Getting statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with the ''--statistics'' command line option.&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 --statistics foo.smt2&lt;br /&gt;
 sat&lt;br /&gt;
 sat::decisions, 0&lt;br /&gt;
 sat::propagations, 3&lt;br /&gt;
 sat::starts, 1&lt;br /&gt;
 theory::uf::TheoryUF::functionTermsCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::mergesCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::termsCount, 6&lt;br /&gt;
 theory&amp;lt;THEORY_UF&amp;gt;::propagations, 1 &lt;br /&gt;
 driver::filename, foo.smt2&lt;br /&gt;
 driver::sat/unsat, sat&lt;br /&gt;
 driver::totalTime, 0.02015373&lt;br /&gt;
 ''[many others]''&lt;br /&gt;
&lt;br /&gt;
Many statistics name-value pairs follow, one comma-separated pair per line.&lt;br /&gt;
&lt;br /&gt;
==Exit status==&lt;br /&gt;
&lt;br /&gt;
The exit status of CVC4 depends on the ''last'' QUERY or CHECK-SAT.  If you wish to call CVC4 from a program (e.g., a shell script) and care only about the satisfiability or validity of a single formula, you can pass the ''-q'' option (as described [[#Verbosity|above, under verbosity]]) and check the exit code.  With ''-q'', CVC4 should not produce any output unless it encounters a fatal error.&lt;br /&gt;
&lt;br /&gt;
QUERY asks a validity question, and CHECK-SAT a satisfiability question, and these are dual problems; hence the terminology is different, but really &amp;quot;sat&amp;quot; and &amp;quot;invalid&amp;quot; are the same internally, as are &amp;quot;unsat&amp;quot; and &amp;quot;valid&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Solver's last result&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Exit code&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''sat''' or '''invalid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unsat''' or '''valid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unknown'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;could be for any reason: time limit exceeded, no memory, incompleteness..&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;''no result''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no query or check-sat command issued&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;parse errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0 (in interactive mode)&amp;lt;br/&amp;gt;1 (otherwise)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;other errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1 (usually)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, and others, can produce different exit codes.  In interactive mode, parse errors are ignored and the next line read; so in interactive mode, you may see an exit code of 0 even in the presence of such an error.&lt;br /&gt;
&lt;br /&gt;
In SMT-LIB mode, an SMT-LIB command script that sets its status via &amp;quot;set-info :status&amp;quot; also affects the exit code.  So, for instance, the following SMT-LIB script returns an exit code of 10 even though it contains no &amp;quot;check-sat&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 (set-logic QF_UF)&lt;br /&gt;
 (set-info :status sat)&lt;br /&gt;
 (exit)&lt;br /&gt;
&lt;br /&gt;
Without the &amp;quot;set-info,&amp;quot; it would have returned an exit code of 0.&lt;br /&gt;
&lt;br /&gt;
=CVC4's native input language=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}\ [X_1, \ldots, X_p] \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt; are type variables,&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by some of the variables &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so an expression such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format: &lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 is cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=CVC4's support for the SMT-LIB language=&lt;br /&gt;
&lt;br /&gt;
==SMT-LIB compliance==&lt;br /&gt;
&lt;br /&gt;
Every effort has been made to make CVC4 compliant with the SMT-LIB 2.0&lt;br /&gt;
standard (http://smtlib.org/).  However, when parsing SMT-LIB input,&lt;br /&gt;
certain default settings don't match what is stated in the official&lt;br /&gt;
standard.  To make CVC4 adhere more strictly to the standard, use the&lt;br /&gt;
&amp;quot;--smtlib&amp;quot; command-line option.  Even with this setting, CVC4 is&lt;br /&gt;
somewhat lenient; some non-conforming input may still be parsed and&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
==Using CVC4 from Java==&lt;br /&gt;
==The compatibility interface==&lt;br /&gt;
&lt;br /&gt;
=Upgrading from CVC3 to CVC4=&lt;br /&gt;
&lt;br /&gt;
==Features not supported by CVC4 (yet)==&lt;br /&gt;
&lt;br /&gt;
===Type Correctness Conditions (TCCs)===&lt;br /&gt;
&lt;br /&gt;
Type Correctness Conditions (TCCs), and the checking of such, are not&lt;br /&gt;
supported by CVC4 1.0.  Thus, a function defined only on integers can be&lt;br /&gt;
applied to REAL (as INT is a subtype of REAL), and CVC4 will not complain,&lt;br /&gt;
but may produce strange results.  For example:&lt;br /&gt;
&lt;br /&gt;
  f : INT -&amp;gt; INT;&lt;br /&gt;
  ASSERT f(1/3) = 0;&lt;br /&gt;
  ASSERT f(2/3) = 1;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  COUNTEREXAMPLE;&lt;br /&gt;
  % f : (INT) -&amp;gt; INT = LAMBDA(x1:INT) : 0;&lt;br /&gt;
&lt;br /&gt;
CVC3 can be used to produce TCCs for this input (with the +dump-tcc option).&lt;br /&gt;
The TCC can be checked by CVC3 or another solver.  (CVC3 can also check&lt;br /&gt;
TCCs while solving with +tcc.)&lt;br /&gt;
&lt;br /&gt;
==If you were using the text interfaces of CVC3==&lt;br /&gt;
&lt;br /&gt;
The native language of all solvers in the CVC family, referred to as the&lt;br /&gt;
&amp;quot;presentation language,&amp;quot; has undergone some revisions for CVC4.  The&lt;br /&gt;
most notable is that CVC4 does _not_ add counterexample assertions to&lt;br /&gt;
the current assertion set after a SAT/INVALID result.  For example:&lt;br /&gt;
&lt;br /&gt;
  x, y : INT;&lt;br /&gt;
  ASSERT x = 1 OR x = 2;&lt;br /&gt;
  ASSERT y = 1 OR y = 2;&lt;br /&gt;
  ASSERT x /= y;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  QUERY x = 1;&lt;br /&gt;
  % invalid&lt;br /&gt;
  QUERY x = 2;&lt;br /&gt;
  % invalid&lt;br /&gt;
&lt;br /&gt;
Here, CVC4 responds &amp;quot;invalid&amp;quot; to the second and third queries, because&lt;br /&gt;
each has a counterexample (x=2 is a counterexample to the first, and&lt;br /&gt;
x=1 is a counterexample to the second).  However, CVC3 will respond&lt;br /&gt;
with &amp;quot;valid&amp;quot; to one of these two, as the first query (the CHECKSAT)&lt;br /&gt;
had the side-effect of locking CVC3 into one of the two cases; the&lt;br /&gt;
later queries are effectively querying the counterexample that was&lt;br /&gt;
found by the first.  CVC4 removes this side-effect of the CHECKSAT and&lt;br /&gt;
QUERY commands.&lt;br /&gt;
&lt;br /&gt;
CVC4 supports rational literals (of type REAL) in decimal; CVC3 did not&lt;br /&gt;
support decimals.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not have support for the IS_INTEGER predicate.&lt;br /&gt;
&lt;br /&gt;
==If you were using the library (&amp;quot;in-memory&amp;quot;) interface of CVC3==&lt;br /&gt;
===If you were using CVC3 from C===&lt;br /&gt;
===If you were using CVC3 from Java===&lt;br /&gt;
&lt;br /&gt;
=Useful command-line options=&lt;br /&gt;
&lt;br /&gt;
==Statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with&lt;br /&gt;
the --statistics command line option.&lt;br /&gt;
&lt;br /&gt;
==Time and resource limits==&lt;br /&gt;
&lt;br /&gt;
CVC4 can be made to self-timeout after a given number of milliseconds.&lt;br /&gt;
Use the --tlimit command line option to limit the entire run of&lt;br /&gt;
CVC4, or use --tlimit-per to limit each individual query separately.&lt;br /&gt;
Preprocessing time is not counted by the time limit, so for some large&lt;br /&gt;
inputs which require aggressive preprocessing, you may notice that&lt;br /&gt;
--tlimit does not work very well.  If you suspect this might be the&lt;br /&gt;
case, you can use &amp;quot;-vv&amp;quot; (double verbosity) to see what CVC4 is doing.&lt;br /&gt;
&lt;br /&gt;
Time-limited runs are not deterministic; two consecutive runs with the&lt;br /&gt;
same time limit might produce different results (i.e., one may time out&lt;br /&gt;
and responds with &amp;quot;unknown&amp;quot;, while the other completes and provides an&lt;br /&gt;
answer).  To ensure that results are reproducible, use --rlimit or&lt;br /&gt;
--rlimit-per.  These options take a &amp;quot;resource count&amp;quot; (presently, based on&lt;br /&gt;
the number of SAT conflicts) that limits the search time.  A word of&lt;br /&gt;
caution, though: there is no guarantee that runs of different versions of&lt;br /&gt;
CVC4 or of different builds of CVC4 (e.g., two CVC4 binaries with different&lt;br /&gt;
features enabled, or for different architectures) will interpret the resource&lt;br /&gt;
count in the same manner.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not presently have a way to limit its memory use; you may opt&lt;br /&gt;
to run it from a shell after using &amp;quot;ulimit&amp;quot; to limit the size of the&lt;br /&gt;
heap.&lt;br /&gt;
&lt;br /&gt;
=Dumping API calls or preprocessed output=&lt;br /&gt;
&lt;br /&gt;
=Changing the output language=&lt;br /&gt;
&lt;br /&gt;
=Proof support=&lt;br /&gt;
&lt;br /&gt;
CVC4 1.0 has limited support for proofs, and they are disabled by default.&lt;br /&gt;
(Run the configure script with --enable-proof to enable proofs).  Proofs&lt;br /&gt;
are exported in LFSC format and are limited to the propositional backbone&lt;br /&gt;
of the discovered proof (theory lemmas are stated without proof in this&lt;br /&gt;
release).&lt;br /&gt;
&lt;br /&gt;
=Portfolio solving=&lt;br /&gt;
&lt;br /&gt;
If enabled at configure-time (./configure --with-portfolio), a second&lt;br /&gt;
CVC4 binary will be produced (&amp;quot;pcvc4&amp;quot;).  This binary has support for&lt;br /&gt;
running multiple instances of CVC4 in different threads.  Use --threads=N&lt;br /&gt;
to specify the number of threads, and use --thread0=&amp;quot;options for thread 0&amp;quot;&lt;br /&gt;
--thread1=&amp;quot;options for thread 1&amp;quot;, etc., to specify a configuration for the&lt;br /&gt;
threads.  Lemmas are *not* shared between the threads by default; to adjust&lt;br /&gt;
this, use the --filter-lemma-length=N option to share lemmas of N literals&lt;br /&gt;
(or smaller).  (Some lemmas are ineligible for sharing because they include&lt;br /&gt;
literals that are &amp;quot;local&amp;quot; to one thread.)&lt;br /&gt;
&lt;br /&gt;
Currently, the portfolio **does not work** with quantifiers or with&lt;br /&gt;
the theory of inductive datatypes.  These limitations will be addressed&lt;br /&gt;
in a future release.&lt;br /&gt;
&lt;br /&gt;
=Emacs support=&lt;br /&gt;
&lt;br /&gt;
For a suggestion of editing CVC4 source code with emacs, see the file&lt;br /&gt;
contrib/editing-with-emacs.  For a CVC language mode (the native input&lt;br /&gt;
language for CVC4), see contrib/cvc-mode.el.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3914</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3914"/>
				<updated>2012-11-26T04:30:12Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Arithmetic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This manual includes lots of information about how to use CVC4.&lt;br /&gt;
&lt;br /&gt;
It is a work in-progress.&lt;br /&gt;
&lt;br /&gt;
= What is CVC4? =&lt;br /&gt;
&lt;br /&gt;
CVC4 is the last of a long line of SMT solvers that started with SVC and includes CVC, CVC-Lite and CVC3.&lt;br /&gt;
Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories. &lt;br /&gt;
The current built-in theories are the theories of:&lt;br /&gt;
&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols,&lt;br /&gt;
* real and integer linear arithmetic (with some support for non-linear arithmetic),&lt;br /&gt;
* bit vectors,&lt;br /&gt;
* arrays,&lt;br /&gt;
* tuples,&lt;br /&gt;
* records,&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 checks whether a given formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is valid in the built-in theories under a given set &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; of assumptions, a ''context''. &lt;br /&gt;
More precisely, it checks whether&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma\models_T \phi&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
that is, whether &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a logical consequence in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; of the set of formulas &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the union of CVC4's built-in theories.&lt;br /&gt;
&lt;br /&gt;
Roughly speaking, when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a universal formula and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is a set of existential formulas (i.e., when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; contain at most universal, respectively existential, quantifiers), CVC4 is a decision procedure: &lt;br /&gt;
it is guaranteed (modulo bugs and memory limits) to return a correct &amp;quot;valid&amp;quot; or &amp;quot;invalid&amp;quot; answer eventually. &lt;br /&gt;
In all other cases, CVC4 is deductively sound but incomplete: &lt;br /&gt;
it will never say that an invalid formula is valid,&lt;br /&gt;
but it may either never return or give up and return &amp;quot;unknown&amp;quot; for some formulas.&lt;br /&gt;
&lt;br /&gt;
Currently, when CVC4 returns &amp;quot;valid&amp;quot; for a query formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; under a context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;&lt;br /&gt;
it provides no evidence to back its claim.&lt;br /&gt;
Future versions will also return a ''proof certificate'', &lt;br /&gt;
a formal proof that &amp;lt;math&amp;gt;\Gamma'\models_T \phi&amp;lt;/math&amp;gt; for some subset &amp;lt;math&amp;gt;\Gamma'&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When CVC4 returns &amp;quot;invalid&amp;quot; it can return &lt;br /&gt;
both a ''counter-example'' to &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;'s validity under the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and a ''counter-model''. &lt;br /&gt;
Both a counter-example and a counter-model are a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of additional formulas consistent with &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but entailing the negation of &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
Formally:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \not\models_T \mathit{false}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \models_T \lnot \phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference is that a counter-model is given as a set of equations providing a concrete assignment of values for the free symbols in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; &lt;br /&gt;
(see the section on [[#CVC4's native input language|CVC4's native input language]] for more details).&lt;br /&gt;
&lt;br /&gt;
=Obtaining and compiling CVC4=&lt;br /&gt;
&lt;br /&gt;
CVC4 is distributed in the following ways:&lt;br /&gt;
* [[#Obtaining_binary_packages|Binary packages]]&lt;br /&gt;
* [[#Obtaining_source_packages|Source packages]]&lt;br /&gt;
* [[#Source_repository|Source repository checkout]]&lt;br /&gt;
&lt;br /&gt;
==Obtaining binary packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/ Binary packages are available] for CVC4.&lt;br /&gt;
Nightly builds:&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/debian/unstable Debian] packages&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
&lt;br /&gt;
==Obtaining source packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/src/ Sources are available] from the same site as the binaries.&lt;br /&gt;
&lt;br /&gt;
==Source repository==&lt;br /&gt;
The [http://cvc4.cs.nyu.edu/builds/src/ CVC4 source repository] is currently hosted by [http://cims.nyu.edu/ CIMS] and requires a CIMS account. Please contact a member of the development team for access. Please see the additional instructions for [[#Building_CVC4 from_a_repository_checkout]] here.&lt;br /&gt;
&lt;br /&gt;
==Building from source==&lt;br /&gt;
&lt;br /&gt;
===Quick-start instructions===&lt;br /&gt;
To compile from a source package:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
    cd contrib&lt;br /&gt;
    ./get-antlr-3.4&lt;br /&gt;
    cd ..&lt;br /&gt;
    ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
    make&lt;br /&gt;
    make check   [recommended]&lt;br /&gt;
    make install [optional]&lt;br /&gt;
&lt;br /&gt;
(To build from a repository checkout, see [[#Building_CVC4_from_a_repository_checkout|below]].)&lt;br /&gt;
&lt;br /&gt;
===Common make Options===&lt;br /&gt;
* &amp;quot;''make install''&amp;quot; will install into the &amp;quot;--prefix&amp;quot; option you gave to&lt;br /&gt;
the configure script (''/usr/local'' by default).&lt;br /&gt;
    ./configure --prefix=~/install_targets/cvc4 ...&lt;br /&gt;
    make install&lt;br /&gt;
* '''You should run &amp;quot;''make check''&amp;quot;''' before installation to ensure that CVC4 has been&lt;br /&gt;
built correctly.  In particular, GCC version 4.5.1 seems to have a&lt;br /&gt;
bug in the optimizer that results in incorrect behavior (and wrong&lt;br /&gt;
results) in many builds.  This is a known problem for Minisat, and&lt;br /&gt;
since Minisat is at the core of CVC4, a problem for CVC4.  &amp;quot;''make check''&amp;quot;&lt;br /&gt;
easily detects this problem (by showing a number of FAILed test cases).&lt;br /&gt;
It is ok if the unit tests aren't run as part of &amp;quot;''make check''&amp;quot;, but all&lt;br /&gt;
system tests and regression tests should pass without incident.&lt;br /&gt;
* To build API documentation, use &amp;quot;''make doc''&amp;quot;.  Documentation is produced&lt;br /&gt;
under ''builds/doc/'' but is not installed by &amp;quot;''make install''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Examples and tutorials are not installed with &amp;quot;''make install''.&amp;quot;  See [[#Examples_and_tutorials_are_not_built_or_installed|below]].&lt;br /&gt;
&lt;br /&gt;
For more information about the build system itself (probably not&lt;br /&gt;
necessary for casual users), see the [[#Appendix:_Build_architecture|Appendix]] at the bottom of this&lt;br /&gt;
file.&lt;br /&gt;
&lt;br /&gt;
===Common configure Options===&lt;br /&gt;
*'''--prefix=PREFIX''' install architecture-independent files in PREFIX (by default /usr/local)&lt;br /&gt;
*'''--with-build={production,debug,default,competition}''' &lt;br /&gt;
*'''--with-antlr-dir=PATH'''&lt;br /&gt;
*'''--with-cln'''/'''--with-gmp''' selects the numbers package to use by default ([[#Optional requirements]])&lt;br /&gt;
*'''--enable-static-binary''' build a fully statically-linked binary. (This is recommended for Mac OS X users that want to be able to use gdb.)&lt;br /&gt;
*'''ANTLR=PATH''' location of the antlr3 script&lt;br /&gt;
*'''--with-boost=DIR''' installation location of the boost libraries (most users will not need this)&lt;br /&gt;
&lt;br /&gt;
See '''./configure --help''' for more.&lt;br /&gt;
&lt;br /&gt;
===Build dependencies===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are required to run CVC4. Versions&lt;br /&gt;
given are minimum versions; more recent versions should be compatible.&lt;br /&gt;
&lt;br /&gt;
*'''GNU C and C++''' (gcc and g++), reasonably recent versions&lt;br /&gt;
*'''GNU Make'''&lt;br /&gt;
*'''GNU Bash'''&lt;br /&gt;
*'''GMP v4.2''' (GNU Multi-Precision arithmetic library)&lt;br /&gt;
*'''libantlr3c v3.2 or v3.4''' (ANTLR parser generator C support library)&lt;br /&gt;
*'''The Boost C++ base libraries'''&lt;br /&gt;
*'''MacPorts'''   [highly recommended if on a Mac; see [[#MacPorts]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hardest to obtain and install is the libantlr3c requirement, and&lt;br /&gt;
is explained [[#Installing libantlr3c: ANTLR parser generator C support library|next]].&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;make&amp;quot; is non-GNU on your system, make sure to invoke &amp;quot;gmake&amp;quot; (or&lt;br /&gt;
whatever GNU Make is installed as).  If your usual shell is not Bash,&lt;br /&gt;
the configure script should auto-correct this.  If it does not, you'll&lt;br /&gt;
see strange shell syntax errors, and you may need to explicitly set&lt;br /&gt;
SHELL or CONFIG_SHELL to the location of bash on your system.&lt;br /&gt;
&lt;br /&gt;
====Installing libantlr3c: ANTLR parser generator C support library====&lt;br /&gt;
&lt;br /&gt;
For libantlr3c, you can use the convenience script in&lt;br /&gt;
''contrib/get-antlr-3.4'' in the source distribution---this will download, patch, compile and install&lt;br /&gt;
libantlr3c into your cvc4 directory as ''cvc4/antlr-3.4/''.&lt;br /&gt;
  cd contrib&lt;br /&gt;
  ./get-antlr-3.4&lt;br /&gt;
&lt;br /&gt;
CVC4 must be configured with the antlr library installation directory, '''--with-antlr-dir''', and an antlr executable script file, '''ANTLR'''.  If libantlr3c was installed via get-antlr-3.4, the following configure line should suffice for CVC44&lt;br /&gt;
  ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
&lt;br /&gt;
For 64 bit machines, libantlr3c needs to be configured with 64 bit explicitly&lt;br /&gt;
  ./configure --enable-64bit ...&lt;br /&gt;
The get-antlr-3.4 script makes a guess at whether the machine is 64 bit and adds the appropriate flag.&lt;br /&gt;
To force the script to compile 32 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86&amp;quot; ./get-antlr3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr3.4&lt;br /&gt;
&lt;br /&gt;
For a longer discussion, instructions for manual installation, and more in depth troubleshooting, see [[Developer's Guide#ANTLR3]].&lt;br /&gt;
&lt;br /&gt;
====MacPorts====&lt;br /&gt;
&lt;br /&gt;
On a Mac, it is '''highly''' recommended that you use MacPorts (see&lt;br /&gt;
http://www.macports.org/).  Doing so is easy.  Then, simply run the&lt;br /&gt;
script ''contrib/mac-build'', which installs a few ports from the MacPorts&lt;br /&gt;
repository, then compiles and installs antlr3c using the ''get-antlr-3.4''&lt;br /&gt;
script.  The mac-build script should set you up&lt;br /&gt;
with all requirements, and will tell you how to configure CVC4 when it&lt;br /&gt;
completes successfully.&lt;br /&gt;
&lt;br /&gt;
====Installing the Boost C++ base libraries====&lt;br /&gt;
&lt;br /&gt;
A Boost package is available on most Linux distributions; check yours&lt;br /&gt;
for a package named something like libboost-dev or boost-devel.  There&lt;br /&gt;
are a number of additional Boost packages in some distributions, but&lt;br /&gt;
this &amp;quot;basic&amp;quot; one should be sufficient for building CVC4.&lt;br /&gt;
&lt;br /&gt;
Should you want to install Boost manually, or to learn more about the&lt;br /&gt;
Boost project, please visit http://www.boost.org/.&lt;br /&gt;
&lt;br /&gt;
===Optional requirements===&lt;br /&gt;
&lt;br /&gt;
None of these is required, but can improve CVC4 as described below:&lt;br /&gt;
&lt;br /&gt;
*'''Optional: SWIG 2.0.x''' (Simplified Wrapper and Interface Generator)&lt;br /&gt;
*'''Optional: CLN v1.3 or newer''' (Class Library for Numbers)&lt;br /&gt;
*'''Optional: CUDD v2.4.2 or newer''' (Colorado University Decision Diagram package)&lt;br /&gt;
*'''Optional: GNU Readline library''' (for an improved interactive experience)&lt;br /&gt;
*'''Optional: The Boost C++ threading library''' (libboost_thread)&lt;br /&gt;
*'''Optional: CxxTest unit testing framework'''&lt;br /&gt;
&lt;br /&gt;
SWIG is necessary to build the Java API (and of course a JDK is&lt;br /&gt;
necessary, too).  SWIG 1.x won't work; you'll need 2.0, and the more&lt;br /&gt;
recent the better.  On Mac, we've seen SWIG segfault when generating&lt;br /&gt;
CVC4 language bindings; version 2.0.8 or higher is recommended to&lt;br /&gt;
avoid this.  See [[#Language_bindings|Language bindings]] below for build instructions.&lt;br /&gt;
&lt;br /&gt;
CLN is an alternative multiprecision arithmetic package that can offer&lt;br /&gt;
better performance and memory footprint than GMP.  CLN is covered by&lt;br /&gt;
the GNU General Public License, version 3; so if you choose to use&lt;br /&gt;
CVC4 with CLN support, you are licensing CVC4 under that same license.&lt;br /&gt;
(Usually CVC4's license is more permissive than GPL is; see the file&lt;br /&gt;
COPYING in the CVC4 source distribution for details.)  Please visit&lt;br /&gt;
http://www.ginac.de/CLN/ for more details about CLN.&lt;br /&gt;
&lt;br /&gt;
CUDD is a decision diagram package that changes the behavior of the&lt;br /&gt;
CVC4 arithmetic solver in some cases; it may or may not improve the&lt;br /&gt;
arithmetic solver's performance.  See [[#Building_with_CUDD_(optional)|below]] for instructions on&lt;br /&gt;
obtaining and building CUDD.&lt;br /&gt;
&lt;br /&gt;
The GNU Readline library is optionally used to provide command&lt;br /&gt;
editing, tab completion, and history functionality at the CVC prompt&lt;br /&gt;
(when running in interactive mode).  Check your distribution for a&lt;br /&gt;
package named &amp;quot;libreadline-dev&amp;quot; or &amp;quot;readline-devel&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
The Boost C++ threading library (often packaged independently of the&lt;br /&gt;
Boost base library) is needed to run CVC4 in &amp;quot;portfolio&amp;quot;&lt;br /&gt;
(multithreaded) mode.  Check your distribution for a package named&lt;br /&gt;
&amp;quot;libboost-thread-dev&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
CxxTest is necessary to run CVC4's unit tests (included with the&lt;br /&gt;
distribution).  Running these is not really required for users of&lt;br /&gt;
CVC4; &amp;quot;make check&amp;quot; will skip unit tests if CxxTest isn't available,&lt;br /&gt;
and go on to run the extensive system- and regression-tests in the&lt;br /&gt;
source tree.  However, if you're interested, you can download CxxTest&lt;br /&gt;
at http://cxxtest.com/ .&lt;br /&gt;
&lt;br /&gt;
====Building with CUDD (optional)====&lt;br /&gt;
&lt;br /&gt;
CUDD, if desired, must be installed delicately.  The CVC4 configure&lt;br /&gt;
script attempts to auto-detect the locations and names of CUDD headers&lt;br /&gt;
and libraries the way that the Fedora RPMs install them, the way that&lt;br /&gt;
our NYU-provided Debian packages install them, and the way they exist&lt;br /&gt;
when you download and build the CUDD sources directly.  If you install&lt;br /&gt;
from Fedora RPMs or our Debian packages, the process should be&lt;br /&gt;
completely automatic, since the libraries and headers are installed in&lt;br /&gt;
a standard location.  If you download the sources yourself, you need&lt;br /&gt;
to build them in a special way.  Fortunately, the&lt;br /&gt;
&amp;quot;contrib/build-cudd-2.4.2-with-libtool.sh&amp;quot; script in the CVC4 source&lt;br /&gt;
tree does exactly what you need: it patches the CUDD makefiles to use&lt;br /&gt;
libtool, builds the libtool libraries, then reverses the patch to&lt;br /&gt;
leave the makefiles as they were.  Once you run this script on an&lt;br /&gt;
unpacked CUDD 2.4.2 source distribution, then CVC4's configure script&lt;br /&gt;
should pick up the libraries if you provide&lt;br /&gt;
--with-cudd-dir=/PATH/TO/CUDD/SOURCES.&lt;br /&gt;
&lt;br /&gt;
If you want to force linking to CUDD, provide --with-cudd to the&lt;br /&gt;
configure script; this makes it a hard requirement rather than an&lt;br /&gt;
optional add-on.&lt;br /&gt;
&lt;br /&gt;
The NYU-provided Debian packaging of CUDD 2.4.2 and CUDD 2.5.0 are&lt;br /&gt;
here (along with the CVC4 Debian packages):&lt;br /&gt;
&lt;br /&gt;
  deb http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
&lt;br /&gt;
On Debian (and Debian-derived distributions like Ubuntu), you only&lt;br /&gt;
need to drop that one line in your /etc/apt/sources.list file, then install with your favorite package manager.&lt;br /&gt;
&lt;br /&gt;
The Debian source package &amp;quot;cudd&amp;quot;, available from the same repository,&lt;br /&gt;
includes a diff of all changes made to cudd makefiles.&lt;br /&gt;
&lt;br /&gt;
===Language bindings===&lt;br /&gt;
&lt;br /&gt;
There are several options available for using CVC4 from the API.&lt;br /&gt;
&lt;br /&gt;
First, CVC4 offers a complete and flexible API for manipulating&lt;br /&gt;
expressions, maintaining a stack of assertions, and checking&lt;br /&gt;
satisfiability, and related things.  The C++ libraries (libcvc4.so and&lt;br /&gt;
libcvc4parser.so) and required headers are installed normally via a&lt;br /&gt;
&amp;quot;make install&amp;quot;.  This API is also available from Java (via CVC4.jar&lt;br /&gt;
and libcvc4jni.so) by configuring with --enable-language-bindings=java.&lt;br /&gt;
You'll also need SWIG 2.0 installed (and you might need to help&lt;br /&gt;
configure find it if you installed it in a nonstandard place with&lt;br /&gt;
--with-swig-dir=/path/to/swig/installation).  You may also need to&lt;br /&gt;
give the configure script the path to your Java headers (in&lt;br /&gt;
particular, jni.h).  You might do so with (for example):&lt;br /&gt;
&lt;br /&gt;
  ./configure --enable-language-bindings=java \&lt;br /&gt;
      JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-openjdk-amd64/include&lt;br /&gt;
&lt;br /&gt;
There is also a &amp;quot;C++ compatibility API&amp;quot; (''#include &amp;lt;cvc4/cvc3_compat.h&amp;gt;''&lt;br /&gt;
and link against libcvc4compat.so) that attempts to maintain&lt;br /&gt;
source-level backwards-compatibility with the CVC3 C++ API.  The&lt;br /&gt;
compatibility library is built by default, and&lt;br /&gt;
''--enable-language-bindings=java'' enables the Java compatibility library&lt;br /&gt;
(CVC4compat.jar and libcvc4compatjni.so).&lt;br /&gt;
''--enable-language-bindings=c'' enables the C compatibility library&lt;br /&gt;
(''#include &amp;lt;cvc4/bindings/compat/c/c_interface.h&amp;gt;'' and link against&lt;br /&gt;
libcvc4bindings_c_compat.so), and if you want both C and Java&lt;br /&gt;
bindings, use ''--enable-language-bindings=c,java''.  These compatibility&lt;br /&gt;
language bindings do NOT require SWIG.&lt;br /&gt;
&lt;br /&gt;
The ''examples/'' directory in the source distribution includes some basic examples (the &amp;quot;simple vc&amp;quot;&lt;br /&gt;
and &amp;quot;simple vc compat&amp;quot; family of examples) of all these interfaces.&lt;br /&gt;
&lt;br /&gt;
In principle, since we use SWIG to generate the native Java API, we&lt;br /&gt;
could support other languages as well.  However, using CVC4 from other&lt;br /&gt;
languages is not supported, nor expected to work, at this time.  If&lt;br /&gt;
you're interested in helping to develop, maintain, and test a language&lt;br /&gt;
binding, please contact us via the users' mailing list at&lt;br /&gt;
cvc-users@cs.nyu.edu.&lt;br /&gt;
&lt;br /&gt;
===Building CVC4 from a repository checkout===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are additionally required to build&lt;br /&gt;
CVC4 from from a repository checkout rather than from a prepared&lt;br /&gt;
source tarball.&lt;br /&gt;
&lt;br /&gt;
*'''Automake v1.11'''&lt;br /&gt;
*'''Autoconf v2.61'''&lt;br /&gt;
*'''Libtool v2.2'''&lt;br /&gt;
*'''ANTLR3 v3.2 or v3.4'''&lt;br /&gt;
*'''Java Development Kit''' ([http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 required for ANTLR3])&lt;br /&gt;
&lt;br /&gt;
First, use &amp;quot;''./autogen.sh''&amp;quot; to create the configure script.  Then&lt;br /&gt;
proceed as normal for any distribution tarball.  The parsers are&lt;br /&gt;
pre-generated for the tarballs, but don't exist in the repository; hence the extra ANTLR3 and JDK requirements to&lt;br /&gt;
generate the source code for the parsers, when building from the&lt;br /&gt;
repository.&lt;br /&gt;
&lt;br /&gt;
===Examples and tutorials are not built or installed===&lt;br /&gt;
&lt;br /&gt;
Examples are not built by &amp;quot;''make''&amp;quot; or &amp;quot;''make install''&amp;quot;.  See&lt;br /&gt;
''examples/README'' in the source distribution for information on what to find in the ''examples/''&lt;br /&gt;
directory, as well as information about building and installing them.&lt;br /&gt;
&lt;br /&gt;
===Appendix: Build architecture===&lt;br /&gt;
&lt;br /&gt;
The build system is generated by automake, libtool, and autoconf.  It&lt;br /&gt;
is somewhat nonstandard, though, which (for one thing) requires that&lt;br /&gt;
GNU Make be used.  If you ./configure in the top-level source&lt;br /&gt;
directory, the objects will actually all appear in&lt;br /&gt;
builds/${arch}/${build_id}.  This is to allow multiple, separate&lt;br /&gt;
builds in the same place (e.g., an assertions-enabled debugging build&lt;br /&gt;
alongside a production build), without changing directories at the&lt;br /&gt;
shell.  The &amp;quot;current&amp;quot; build is maintained, and you can still use&lt;br /&gt;
(e.g.) &amp;quot;make -C src/main&amp;quot; to rebuild objects in just one subdirectory.&lt;br /&gt;
&lt;br /&gt;
You can also create your own build directory inside or outside of the&lt;br /&gt;
source tree and configure from there.  All objects will then be built&lt;br /&gt;
in that directory, and you'll ultimately find the &amp;quot;cvc4&amp;quot; binary in&lt;br /&gt;
src/main/, and the libraries under src/ and src/parser/.&lt;br /&gt;
&lt;br /&gt;
=Using the CVC4 binary=&lt;br /&gt;
&lt;br /&gt;
The CVC4 driver binary (&amp;quot;cvc4&amp;quot;), once installed, can be executed directly to enter into interactive mode:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then enter commands into CVC4 interactively:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;incremental&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;produce-models&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; TRANSFORM 25*25;&lt;br /&gt;
 625&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example shows two useful options, ''incremental'' and ''produce-models.''&lt;br /&gt;
&lt;br /&gt;
* The ''incremental'' option allows you to issue multiple QUERY (or CHECKSAT) commands, and allows the use of the PUSH and POP commands.  Without this option, CVC4 optimizes itself for a single QUERY or CHECKSAT command (though you may issue any number of ASSERT commands).  The ''incremental'' option may also be given by passing the ''-i'' command line option to CVC4.&lt;br /&gt;
* The ''produce-models'' option allows you to query the model (here, with the COUNTERMODEL command) after an &amp;quot;invalid&amp;quot; QUERY (or &amp;quot;satisfiable&amp;quot; CHECK-SAT).  Without it, CVC4 doesn't do the bookkeeping necessary to support model generation.  The ''produce-models'' option may also be given by passing the ''-m'' command line option to CVC4.&lt;br /&gt;
&lt;br /&gt;
So, if you invoke CVC4 with ''-im'', you don't need to pass those options at all:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -im&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, CVC4 operates in [[#CVC4's native input language|CVC-language mode]].  If you enter something that looks like SMT-LIB, it will suggest that you use the &amp;quot;''--lang smt''&amp;quot; command-line option for SMT-LIB mode:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (declare-fun x () Int)&lt;br /&gt;
 Parse Error: &amp;lt;shell&amp;gt;:1.7: In CVC4 presentation language mode, but SMT-LIB format detected.  Use --lang smt for SMT-LIB support.&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verbosity==&lt;br /&gt;
&lt;br /&gt;
CVC4 has various levels of verbosity.  By default, CVC4 is pretty quiet, only reporting serious warnings and notices.  If you're curious about what it's doing, you can pass CVC4 the ''-v'' option:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -v file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
For even more verbosity, you can pass CVC4 an ''additional'' ''-v'':&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -vv file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
 expanding definitions...&lt;br /&gt;
 constraining subtypes...&lt;br /&gt;
 applying substitutions...&lt;br /&gt;
 simplifying assertions...&lt;br /&gt;
 doing static learning...&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
Internally, verbosity is just an integer value.  It starts at 0, and with every ''-v'' on the command line it is incremented; with every ''-q'', decremented.  It can also be set directly.  From CVC language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;verbosity&amp;quot; 2;&lt;br /&gt;
&lt;br /&gt;
Or from SMT-LIB language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (set-option :verbosity 2)&lt;br /&gt;
&lt;br /&gt;
==Getting statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with the ''--statistics'' command line option.&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 --statistics foo.smt2&lt;br /&gt;
 sat&lt;br /&gt;
 sat::decisions, 0&lt;br /&gt;
 sat::propagations, 3&lt;br /&gt;
 sat::starts, 1&lt;br /&gt;
 theory::uf::TheoryUF::functionTermsCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::mergesCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::termsCount, 6&lt;br /&gt;
 theory&amp;lt;THEORY_UF&amp;gt;::propagations, 1 &lt;br /&gt;
 driver::filename, foo.smt2&lt;br /&gt;
 driver::sat/unsat, sat&lt;br /&gt;
 driver::totalTime, 0.02015373&lt;br /&gt;
 ''[many others]''&lt;br /&gt;
&lt;br /&gt;
Many statistics name-value pairs follow, one comma-separated pair per line.&lt;br /&gt;
&lt;br /&gt;
==Exit status==&lt;br /&gt;
&lt;br /&gt;
The exit status of CVC4 depends on the ''last'' QUERY or CHECK-SAT.  If you wish to call CVC4 from a program (e.g., a shell script) and care only about the satisfiability or validity of a single formula, you can pass the ''-q'' option (as described [[#Verbosity|above, under verbosity]]) and check the exit code.  With ''-q'', CVC4 should not produce any output unless it encounters a fatal error.&lt;br /&gt;
&lt;br /&gt;
QUERY asks a validity question, and CHECK-SAT a satisfiability question, and these are dual problems; hence the terminology is different, but really &amp;quot;sat&amp;quot; and &amp;quot;invalid&amp;quot; are the same internally, as are &amp;quot;unsat&amp;quot; and &amp;quot;valid&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Solver's last result&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Exit code&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''sat''' or '''invalid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unsat''' or '''valid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unknown'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;could be for any reason: time limit exceeded, no memory, incompleteness..&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;''no result''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no query or check-sat command issued&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;parse errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0 (in interactive mode)&amp;lt;br/&amp;gt;1 (otherwise)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;other errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1 (usually)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, and others, can produce different exit codes.  In interactive mode, parse errors are ignored and the next line read; so in interactive mode, you may see an exit code of 0 even in the presence of such an error.&lt;br /&gt;
&lt;br /&gt;
In SMT-LIB mode, an SMT-LIB command script that sets its status via &amp;quot;set-info :status&amp;quot; also affects the exit code.  So, for instance, the following SMT-LIB script returns an exit code of 10 even though it contains no &amp;quot;check-sat&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 (set-logic QF_UF)&lt;br /&gt;
 (set-info :status sat)&lt;br /&gt;
 (exit)&lt;br /&gt;
&lt;br /&gt;
Without the &amp;quot;set-info,&amp;quot; it would have returned an exit code of 0.&lt;br /&gt;
&lt;br /&gt;
=CVC4's native input language=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}\ [X_1, \ldots, X_p] \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt; are type variables,&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by some of the variables &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, and so a term such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format: &lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 is cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=CVC4's support for the SMT-LIB language=&lt;br /&gt;
&lt;br /&gt;
==SMT-LIB compliance==&lt;br /&gt;
&lt;br /&gt;
Every effort has been made to make CVC4 compliant with the SMT-LIB 2.0&lt;br /&gt;
standard (http://smtlib.org/).  However, when parsing SMT-LIB input,&lt;br /&gt;
certain default settings don't match what is stated in the official&lt;br /&gt;
standard.  To make CVC4 adhere more strictly to the standard, use the&lt;br /&gt;
&amp;quot;--smtlib&amp;quot; command-line option.  Even with this setting, CVC4 is&lt;br /&gt;
somewhat lenient; some non-conforming input may still be parsed and&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
==Using CVC4 from Java==&lt;br /&gt;
==The compatibility interface==&lt;br /&gt;
&lt;br /&gt;
=Upgrading from CVC3 to CVC4=&lt;br /&gt;
&lt;br /&gt;
==Features not supported by CVC4 (yet)==&lt;br /&gt;
&lt;br /&gt;
===Type Correctness Conditions (TCCs)===&lt;br /&gt;
&lt;br /&gt;
Type Correctness Conditions (TCCs), and the checking of such, are not&lt;br /&gt;
supported by CVC4 1.0.  Thus, a function defined only on integers can be&lt;br /&gt;
applied to REAL (as INT is a subtype of REAL), and CVC4 will not complain,&lt;br /&gt;
but may produce strange results.  For example:&lt;br /&gt;
&lt;br /&gt;
  f : INT -&amp;gt; INT;&lt;br /&gt;
  ASSERT f(1/3) = 0;&lt;br /&gt;
  ASSERT f(2/3) = 1;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  COUNTEREXAMPLE;&lt;br /&gt;
  % f : (INT) -&amp;gt; INT = LAMBDA(x1:INT) : 0;&lt;br /&gt;
&lt;br /&gt;
CVC3 can be used to produce TCCs for this input (with the +dump-tcc option).&lt;br /&gt;
The TCC can be checked by CVC3 or another solver.  (CVC3 can also check&lt;br /&gt;
TCCs while solving with +tcc.)&lt;br /&gt;
&lt;br /&gt;
==If you were using the text interfaces of CVC3==&lt;br /&gt;
&lt;br /&gt;
The native language of all solvers in the CVC family, referred to as the&lt;br /&gt;
&amp;quot;presentation language,&amp;quot; has undergone some revisions for CVC4.  The&lt;br /&gt;
most notable is that CVC4 does _not_ add counterexample assertions to&lt;br /&gt;
the current assertion set after a SAT/INVALID result.  For example:&lt;br /&gt;
&lt;br /&gt;
  x, y : INT;&lt;br /&gt;
  ASSERT x = 1 OR x = 2;&lt;br /&gt;
  ASSERT y = 1 OR y = 2;&lt;br /&gt;
  ASSERT x /= y;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  QUERY x = 1;&lt;br /&gt;
  % invalid&lt;br /&gt;
  QUERY x = 2;&lt;br /&gt;
  % invalid&lt;br /&gt;
&lt;br /&gt;
Here, CVC4 responds &amp;quot;invalid&amp;quot; to the second and third queries, because&lt;br /&gt;
each has a counterexample (x=2 is a counterexample to the first, and&lt;br /&gt;
x=1 is a counterexample to the second).  However, CVC3 will respond&lt;br /&gt;
with &amp;quot;valid&amp;quot; to one of these two, as the first query (the CHECKSAT)&lt;br /&gt;
had the side-effect of locking CVC3 into one of the two cases; the&lt;br /&gt;
later queries are effectively querying the counterexample that was&lt;br /&gt;
found by the first.  CVC4 removes this side-effect of the CHECKSAT and&lt;br /&gt;
QUERY commands.&lt;br /&gt;
&lt;br /&gt;
CVC4 supports rational literals (of type REAL) in decimal; CVC3 did not&lt;br /&gt;
support decimals.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not have support for the IS_INTEGER predicate.&lt;br /&gt;
&lt;br /&gt;
==If you were using the library (&amp;quot;in-memory&amp;quot;) interface of CVC3==&lt;br /&gt;
===If you were using CVC3 from C===&lt;br /&gt;
===If you were using CVC3 from Java===&lt;br /&gt;
&lt;br /&gt;
=Useful command-line options=&lt;br /&gt;
&lt;br /&gt;
==Statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with&lt;br /&gt;
the --statistics command line option.&lt;br /&gt;
&lt;br /&gt;
==Time and resource limits==&lt;br /&gt;
&lt;br /&gt;
CVC4 can be made to self-timeout after a given number of milliseconds.&lt;br /&gt;
Use the --tlimit command line option to limit the entire run of&lt;br /&gt;
CVC4, or use --tlimit-per to limit each individual query separately.&lt;br /&gt;
Preprocessing time is not counted by the time limit, so for some large&lt;br /&gt;
inputs which require aggressive preprocessing, you may notice that&lt;br /&gt;
--tlimit does not work very well.  If you suspect this might be the&lt;br /&gt;
case, you can use &amp;quot;-vv&amp;quot; (double verbosity) to see what CVC4 is doing.&lt;br /&gt;
&lt;br /&gt;
Time-limited runs are not deterministic; two consecutive runs with the&lt;br /&gt;
same time limit might produce different results (i.e., one may time out&lt;br /&gt;
and responds with &amp;quot;unknown&amp;quot;, while the other completes and provides an&lt;br /&gt;
answer).  To ensure that results are reproducible, use --rlimit or&lt;br /&gt;
--rlimit-per.  These options take a &amp;quot;resource count&amp;quot; (presently, based on&lt;br /&gt;
the number of SAT conflicts) that limits the search time.  A word of&lt;br /&gt;
caution, though: there is no guarantee that runs of different versions of&lt;br /&gt;
CVC4 or of different builds of CVC4 (e.g., two CVC4 binaries with different&lt;br /&gt;
features enabled, or for different architectures) will interpret the resource&lt;br /&gt;
count in the same manner.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not presently have a way to limit its memory use; you may opt&lt;br /&gt;
to run it from a shell after using &amp;quot;ulimit&amp;quot; to limit the size of the&lt;br /&gt;
heap.&lt;br /&gt;
&lt;br /&gt;
=Dumping API calls or preprocessed output=&lt;br /&gt;
&lt;br /&gt;
=Changing the output language=&lt;br /&gt;
&lt;br /&gt;
=Proof support=&lt;br /&gt;
&lt;br /&gt;
CVC4 1.0 has limited support for proofs, and they are disabled by default.&lt;br /&gt;
(Run the configure script with --enable-proof to enable proofs).  Proofs&lt;br /&gt;
are exported in LFSC format and are limited to the propositional backbone&lt;br /&gt;
of the discovered proof (theory lemmas are stated without proof in this&lt;br /&gt;
release).&lt;br /&gt;
&lt;br /&gt;
=Portfolio solving=&lt;br /&gt;
&lt;br /&gt;
If enabled at configure-time (./configure --with-portfolio), a second&lt;br /&gt;
CVC4 binary will be produced (&amp;quot;pcvc4&amp;quot;).  This binary has support for&lt;br /&gt;
running multiple instances of CVC4 in different threads.  Use --threads=N&lt;br /&gt;
to specify the number of threads, and use --thread0=&amp;quot;options for thread 0&amp;quot;&lt;br /&gt;
--thread1=&amp;quot;options for thread 1&amp;quot;, etc., to specify a configuration for the&lt;br /&gt;
threads.  Lemmas are *not* shared between the threads by default; to adjust&lt;br /&gt;
this, use the --filter-lemma-length=N option to share lemmas of N literals&lt;br /&gt;
(or smaller).  (Some lemmas are ineligible for sharing because they include&lt;br /&gt;
literals that are &amp;quot;local&amp;quot; to one thread.)&lt;br /&gt;
&lt;br /&gt;
Currently, the portfolio **does not work** with quantifiers or with&lt;br /&gt;
the theory of inductive datatypes.  These limitations will be addressed&lt;br /&gt;
in a future release.&lt;br /&gt;
&lt;br /&gt;
=Emacs support=&lt;br /&gt;
&lt;br /&gt;
For a suggestion of editing CVC4 source code with emacs, see the file&lt;br /&gt;
contrib/editing-with-emacs.  For a CVC language mode (the native input&lt;br /&gt;
language for CVC4), see contrib/cvc-mode.el.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3913</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3913"/>
				<updated>2012-11-26T04:29:50Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Arithmetic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This manual includes lots of information about how to use CVC4.&lt;br /&gt;
&lt;br /&gt;
It is a work in-progress.&lt;br /&gt;
&lt;br /&gt;
= What is CVC4? =&lt;br /&gt;
&lt;br /&gt;
CVC4 is the last of a long line of SMT solvers that started with SVC and includes CVC, CVC-Lite and CVC3.&lt;br /&gt;
Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories. &lt;br /&gt;
The current built-in theories are the theories of:&lt;br /&gt;
&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols,&lt;br /&gt;
* real and integer linear arithmetic (with some support for non-linear arithmetic),&lt;br /&gt;
* bit vectors,&lt;br /&gt;
* arrays,&lt;br /&gt;
* tuples,&lt;br /&gt;
* records,&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 checks whether a given formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is valid in the built-in theories under a given set &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; of assumptions, a ''context''. &lt;br /&gt;
More precisely, it checks whether&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma\models_T \phi&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
that is, whether &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a logical consequence in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; of the set of formulas &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the union of CVC4's built-in theories.&lt;br /&gt;
&lt;br /&gt;
Roughly speaking, when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a universal formula and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is a set of existential formulas (i.e., when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; contain at most universal, respectively existential, quantifiers), CVC4 is a decision procedure: &lt;br /&gt;
it is guaranteed (modulo bugs and memory limits) to return a correct &amp;quot;valid&amp;quot; or &amp;quot;invalid&amp;quot; answer eventually. &lt;br /&gt;
In all other cases, CVC4 is deductively sound but incomplete: &lt;br /&gt;
it will never say that an invalid formula is valid,&lt;br /&gt;
but it may either never return or give up and return &amp;quot;unknown&amp;quot; for some formulas.&lt;br /&gt;
&lt;br /&gt;
Currently, when CVC4 returns &amp;quot;valid&amp;quot; for a query formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; under a context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;&lt;br /&gt;
it provides no evidence to back its claim.&lt;br /&gt;
Future versions will also return a ''proof certificate'', &lt;br /&gt;
a formal proof that &amp;lt;math&amp;gt;\Gamma'\models_T \phi&amp;lt;/math&amp;gt; for some subset &amp;lt;math&amp;gt;\Gamma'&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When CVC4 returns &amp;quot;invalid&amp;quot; it can return &lt;br /&gt;
both a ''counter-example'' to &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;'s validity under the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and a ''counter-model''. &lt;br /&gt;
Both a counter-example and a counter-model are a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of additional formulas consistent with &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but entailing the negation of &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
Formally:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \not\models_T \mathit{false}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \models_T \lnot \phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference is that a counter-model is given as a set of equations providing a concrete assignment of values for the free symbols in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; &lt;br /&gt;
(see the section on [[#CVC4's native input language|CVC4's native input language]] for more details).&lt;br /&gt;
&lt;br /&gt;
=Obtaining and compiling CVC4=&lt;br /&gt;
&lt;br /&gt;
CVC4 is distributed in the following ways:&lt;br /&gt;
* [[#Obtaining_binary_packages|Binary packages]]&lt;br /&gt;
* [[#Obtaining_source_packages|Source packages]]&lt;br /&gt;
* [[#Source_repository|Source repository checkout]]&lt;br /&gt;
&lt;br /&gt;
==Obtaining binary packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/ Binary packages are available] for CVC4.&lt;br /&gt;
Nightly builds:&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/debian/unstable Debian] packages&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
&lt;br /&gt;
==Obtaining source packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/src/ Sources are available] from the same site as the binaries.&lt;br /&gt;
&lt;br /&gt;
==Source repository==&lt;br /&gt;
The [http://cvc4.cs.nyu.edu/builds/src/ CVC4 source repository] is currently hosted by [http://cims.nyu.edu/ CIMS] and requires a CIMS account. Please contact a member of the development team for access. Please see the additional instructions for [[#Building_CVC4 from_a_repository_checkout]] here.&lt;br /&gt;
&lt;br /&gt;
==Building from source==&lt;br /&gt;
&lt;br /&gt;
===Quick-start instructions===&lt;br /&gt;
To compile from a source package:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
    cd contrib&lt;br /&gt;
    ./get-antlr-3.4&lt;br /&gt;
    cd ..&lt;br /&gt;
    ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
    make&lt;br /&gt;
    make check   [recommended]&lt;br /&gt;
    make install [optional]&lt;br /&gt;
&lt;br /&gt;
(To build from a repository checkout, see [[#Building_CVC4_from_a_repository_checkout|below]].)&lt;br /&gt;
&lt;br /&gt;
===Common make Options===&lt;br /&gt;
* &amp;quot;''make install''&amp;quot; will install into the &amp;quot;--prefix&amp;quot; option you gave to&lt;br /&gt;
the configure script (''/usr/local'' by default).&lt;br /&gt;
    ./configure --prefix=~/install_targets/cvc4 ...&lt;br /&gt;
    make install&lt;br /&gt;
* '''You should run &amp;quot;''make check''&amp;quot;''' before installation to ensure that CVC4 has been&lt;br /&gt;
built correctly.  In particular, GCC version 4.5.1 seems to have a&lt;br /&gt;
bug in the optimizer that results in incorrect behavior (and wrong&lt;br /&gt;
results) in many builds.  This is a known problem for Minisat, and&lt;br /&gt;
since Minisat is at the core of CVC4, a problem for CVC4.  &amp;quot;''make check''&amp;quot;&lt;br /&gt;
easily detects this problem (by showing a number of FAILed test cases).&lt;br /&gt;
It is ok if the unit tests aren't run as part of &amp;quot;''make check''&amp;quot;, but all&lt;br /&gt;
system tests and regression tests should pass without incident.&lt;br /&gt;
* To build API documentation, use &amp;quot;''make doc''&amp;quot;.  Documentation is produced&lt;br /&gt;
under ''builds/doc/'' but is not installed by &amp;quot;''make install''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Examples and tutorials are not installed with &amp;quot;''make install''.&amp;quot;  See [[#Examples_and_tutorials_are_not_built_or_installed|below]].&lt;br /&gt;
&lt;br /&gt;
For more information about the build system itself (probably not&lt;br /&gt;
necessary for casual users), see the [[#Appendix:_Build_architecture|Appendix]] at the bottom of this&lt;br /&gt;
file.&lt;br /&gt;
&lt;br /&gt;
===Common configure Options===&lt;br /&gt;
*'''--prefix=PREFIX''' install architecture-independent files in PREFIX (by default /usr/local)&lt;br /&gt;
*'''--with-build={production,debug,default,competition}''' &lt;br /&gt;
*'''--with-antlr-dir=PATH'''&lt;br /&gt;
*'''--with-cln'''/'''--with-gmp''' selects the numbers package to use by default ([[#Optional requirements]])&lt;br /&gt;
*'''--enable-static-binary''' build a fully statically-linked binary. (This is recommended for Mac OS X users that want to be able to use gdb.)&lt;br /&gt;
*'''ANTLR=PATH''' location of the antlr3 script&lt;br /&gt;
*'''--with-boost=DIR''' installation location of the boost libraries (most users will not need this)&lt;br /&gt;
&lt;br /&gt;
See '''./configure --help''' for more.&lt;br /&gt;
&lt;br /&gt;
===Build dependencies===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are required to run CVC4. Versions&lt;br /&gt;
given are minimum versions; more recent versions should be compatible.&lt;br /&gt;
&lt;br /&gt;
*'''GNU C and C++''' (gcc and g++), reasonably recent versions&lt;br /&gt;
*'''GNU Make'''&lt;br /&gt;
*'''GNU Bash'''&lt;br /&gt;
*'''GMP v4.2''' (GNU Multi-Precision arithmetic library)&lt;br /&gt;
*'''libantlr3c v3.2 or v3.4''' (ANTLR parser generator C support library)&lt;br /&gt;
*'''The Boost C++ base libraries'''&lt;br /&gt;
*'''MacPorts'''   [highly recommended if on a Mac; see [[#MacPorts]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hardest to obtain and install is the libantlr3c requirement, and&lt;br /&gt;
is explained [[#Installing libantlr3c: ANTLR parser generator C support library|next]].&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;make&amp;quot; is non-GNU on your system, make sure to invoke &amp;quot;gmake&amp;quot; (or&lt;br /&gt;
whatever GNU Make is installed as).  If your usual shell is not Bash,&lt;br /&gt;
the configure script should auto-correct this.  If it does not, you'll&lt;br /&gt;
see strange shell syntax errors, and you may need to explicitly set&lt;br /&gt;
SHELL or CONFIG_SHELL to the location of bash on your system.&lt;br /&gt;
&lt;br /&gt;
====Installing libantlr3c: ANTLR parser generator C support library====&lt;br /&gt;
&lt;br /&gt;
For libantlr3c, you can use the convenience script in&lt;br /&gt;
''contrib/get-antlr-3.4'' in the source distribution---this will download, patch, compile and install&lt;br /&gt;
libantlr3c into your cvc4 directory as ''cvc4/antlr-3.4/''.&lt;br /&gt;
  cd contrib&lt;br /&gt;
  ./get-antlr-3.4&lt;br /&gt;
&lt;br /&gt;
CVC4 must be configured with the antlr library installation directory, '''--with-antlr-dir''', and an antlr executable script file, '''ANTLR'''.  If libantlr3c was installed via get-antlr-3.4, the following configure line should suffice for CVC44&lt;br /&gt;
  ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
&lt;br /&gt;
For 64 bit machines, libantlr3c needs to be configured with 64 bit explicitly&lt;br /&gt;
  ./configure --enable-64bit ...&lt;br /&gt;
The get-antlr-3.4 script makes a guess at whether the machine is 64 bit and adds the appropriate flag.&lt;br /&gt;
To force the script to compile 32 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86&amp;quot; ./get-antlr3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr3.4&lt;br /&gt;
&lt;br /&gt;
For a longer discussion, instructions for manual installation, and more in depth troubleshooting, see [[Developer's Guide#ANTLR3]].&lt;br /&gt;
&lt;br /&gt;
====MacPorts====&lt;br /&gt;
&lt;br /&gt;
On a Mac, it is '''highly''' recommended that you use MacPorts (see&lt;br /&gt;
http://www.macports.org/).  Doing so is easy.  Then, simply run the&lt;br /&gt;
script ''contrib/mac-build'', which installs a few ports from the MacPorts&lt;br /&gt;
repository, then compiles and installs antlr3c using the ''get-antlr-3.4''&lt;br /&gt;
script.  The mac-build script should set you up&lt;br /&gt;
with all requirements, and will tell you how to configure CVC4 when it&lt;br /&gt;
completes successfully.&lt;br /&gt;
&lt;br /&gt;
====Installing the Boost C++ base libraries====&lt;br /&gt;
&lt;br /&gt;
A Boost package is available on most Linux distributions; check yours&lt;br /&gt;
for a package named something like libboost-dev or boost-devel.  There&lt;br /&gt;
are a number of additional Boost packages in some distributions, but&lt;br /&gt;
this &amp;quot;basic&amp;quot; one should be sufficient for building CVC4.&lt;br /&gt;
&lt;br /&gt;
Should you want to install Boost manually, or to learn more about the&lt;br /&gt;
Boost project, please visit http://www.boost.org/.&lt;br /&gt;
&lt;br /&gt;
===Optional requirements===&lt;br /&gt;
&lt;br /&gt;
None of these is required, but can improve CVC4 as described below:&lt;br /&gt;
&lt;br /&gt;
*'''Optional: SWIG 2.0.x''' (Simplified Wrapper and Interface Generator)&lt;br /&gt;
*'''Optional: CLN v1.3 or newer''' (Class Library for Numbers)&lt;br /&gt;
*'''Optional: CUDD v2.4.2 or newer''' (Colorado University Decision Diagram package)&lt;br /&gt;
*'''Optional: GNU Readline library''' (for an improved interactive experience)&lt;br /&gt;
*'''Optional: The Boost C++ threading library''' (libboost_thread)&lt;br /&gt;
*'''Optional: CxxTest unit testing framework'''&lt;br /&gt;
&lt;br /&gt;
SWIG is necessary to build the Java API (and of course a JDK is&lt;br /&gt;
necessary, too).  SWIG 1.x won't work; you'll need 2.0, and the more&lt;br /&gt;
recent the better.  On Mac, we've seen SWIG segfault when generating&lt;br /&gt;
CVC4 language bindings; version 2.0.8 or higher is recommended to&lt;br /&gt;
avoid this.  See [[#Language_bindings|Language bindings]] below for build instructions.&lt;br /&gt;
&lt;br /&gt;
CLN is an alternative multiprecision arithmetic package that can offer&lt;br /&gt;
better performance and memory footprint than GMP.  CLN is covered by&lt;br /&gt;
the GNU General Public License, version 3; so if you choose to use&lt;br /&gt;
CVC4 with CLN support, you are licensing CVC4 under that same license.&lt;br /&gt;
(Usually CVC4's license is more permissive than GPL is; see the file&lt;br /&gt;
COPYING in the CVC4 source distribution for details.)  Please visit&lt;br /&gt;
http://www.ginac.de/CLN/ for more details about CLN.&lt;br /&gt;
&lt;br /&gt;
CUDD is a decision diagram package that changes the behavior of the&lt;br /&gt;
CVC4 arithmetic solver in some cases; it may or may not improve the&lt;br /&gt;
arithmetic solver's performance.  See [[#Building_with_CUDD_(optional)|below]] for instructions on&lt;br /&gt;
obtaining and building CUDD.&lt;br /&gt;
&lt;br /&gt;
The GNU Readline library is optionally used to provide command&lt;br /&gt;
editing, tab completion, and history functionality at the CVC prompt&lt;br /&gt;
(when running in interactive mode).  Check your distribution for a&lt;br /&gt;
package named &amp;quot;libreadline-dev&amp;quot; or &amp;quot;readline-devel&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
The Boost C++ threading library (often packaged independently of the&lt;br /&gt;
Boost base library) is needed to run CVC4 in &amp;quot;portfolio&amp;quot;&lt;br /&gt;
(multithreaded) mode.  Check your distribution for a package named&lt;br /&gt;
&amp;quot;libboost-thread-dev&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
CxxTest is necessary to run CVC4's unit tests (included with the&lt;br /&gt;
distribution).  Running these is not really required for users of&lt;br /&gt;
CVC4; &amp;quot;make check&amp;quot; will skip unit tests if CxxTest isn't available,&lt;br /&gt;
and go on to run the extensive system- and regression-tests in the&lt;br /&gt;
source tree.  However, if you're interested, you can download CxxTest&lt;br /&gt;
at http://cxxtest.com/ .&lt;br /&gt;
&lt;br /&gt;
====Building with CUDD (optional)====&lt;br /&gt;
&lt;br /&gt;
CUDD, if desired, must be installed delicately.  The CVC4 configure&lt;br /&gt;
script attempts to auto-detect the locations and names of CUDD headers&lt;br /&gt;
and libraries the way that the Fedora RPMs install them, the way that&lt;br /&gt;
our NYU-provided Debian packages install them, and the way they exist&lt;br /&gt;
when you download and build the CUDD sources directly.  If you install&lt;br /&gt;
from Fedora RPMs or our Debian packages, the process should be&lt;br /&gt;
completely automatic, since the libraries and headers are installed in&lt;br /&gt;
a standard location.  If you download the sources yourself, you need&lt;br /&gt;
to build them in a special way.  Fortunately, the&lt;br /&gt;
&amp;quot;contrib/build-cudd-2.4.2-with-libtool.sh&amp;quot; script in the CVC4 source&lt;br /&gt;
tree does exactly what you need: it patches the CUDD makefiles to use&lt;br /&gt;
libtool, builds the libtool libraries, then reverses the patch to&lt;br /&gt;
leave the makefiles as they were.  Once you run this script on an&lt;br /&gt;
unpacked CUDD 2.4.2 source distribution, then CVC4's configure script&lt;br /&gt;
should pick up the libraries if you provide&lt;br /&gt;
--with-cudd-dir=/PATH/TO/CUDD/SOURCES.&lt;br /&gt;
&lt;br /&gt;
If you want to force linking to CUDD, provide --with-cudd to the&lt;br /&gt;
configure script; this makes it a hard requirement rather than an&lt;br /&gt;
optional add-on.&lt;br /&gt;
&lt;br /&gt;
The NYU-provided Debian packaging of CUDD 2.4.2 and CUDD 2.5.0 are&lt;br /&gt;
here (along with the CVC4 Debian packages):&lt;br /&gt;
&lt;br /&gt;
  deb http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
&lt;br /&gt;
On Debian (and Debian-derived distributions like Ubuntu), you only&lt;br /&gt;
need to drop that one line in your /etc/apt/sources.list file, then install with your favorite package manager.&lt;br /&gt;
&lt;br /&gt;
The Debian source package &amp;quot;cudd&amp;quot;, available from the same repository,&lt;br /&gt;
includes a diff of all changes made to cudd makefiles.&lt;br /&gt;
&lt;br /&gt;
===Language bindings===&lt;br /&gt;
&lt;br /&gt;
There are several options available for using CVC4 from the API.&lt;br /&gt;
&lt;br /&gt;
First, CVC4 offers a complete and flexible API for manipulating&lt;br /&gt;
expressions, maintaining a stack of assertions, and checking&lt;br /&gt;
satisfiability, and related things.  The C++ libraries (libcvc4.so and&lt;br /&gt;
libcvc4parser.so) and required headers are installed normally via a&lt;br /&gt;
&amp;quot;make install&amp;quot;.  This API is also available from Java (via CVC4.jar&lt;br /&gt;
and libcvc4jni.so) by configuring with --enable-language-bindings=java.&lt;br /&gt;
You'll also need SWIG 2.0 installed (and you might need to help&lt;br /&gt;
configure find it if you installed it in a nonstandard place with&lt;br /&gt;
--with-swig-dir=/path/to/swig/installation).  You may also need to&lt;br /&gt;
give the configure script the path to your Java headers (in&lt;br /&gt;
particular, jni.h).  You might do so with (for example):&lt;br /&gt;
&lt;br /&gt;
  ./configure --enable-language-bindings=java \&lt;br /&gt;
      JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-openjdk-amd64/include&lt;br /&gt;
&lt;br /&gt;
There is also a &amp;quot;C++ compatibility API&amp;quot; (''#include &amp;lt;cvc4/cvc3_compat.h&amp;gt;''&lt;br /&gt;
and link against libcvc4compat.so) that attempts to maintain&lt;br /&gt;
source-level backwards-compatibility with the CVC3 C++ API.  The&lt;br /&gt;
compatibility library is built by default, and&lt;br /&gt;
''--enable-language-bindings=java'' enables the Java compatibility library&lt;br /&gt;
(CVC4compat.jar and libcvc4compatjni.so).&lt;br /&gt;
''--enable-language-bindings=c'' enables the C compatibility library&lt;br /&gt;
(''#include &amp;lt;cvc4/bindings/compat/c/c_interface.h&amp;gt;'' and link against&lt;br /&gt;
libcvc4bindings_c_compat.so), and if you want both C and Java&lt;br /&gt;
bindings, use ''--enable-language-bindings=c,java''.  These compatibility&lt;br /&gt;
language bindings do NOT require SWIG.&lt;br /&gt;
&lt;br /&gt;
The ''examples/'' directory in the source distribution includes some basic examples (the &amp;quot;simple vc&amp;quot;&lt;br /&gt;
and &amp;quot;simple vc compat&amp;quot; family of examples) of all these interfaces.&lt;br /&gt;
&lt;br /&gt;
In principle, since we use SWIG to generate the native Java API, we&lt;br /&gt;
could support other languages as well.  However, using CVC4 from other&lt;br /&gt;
languages is not supported, nor expected to work, at this time.  If&lt;br /&gt;
you're interested in helping to develop, maintain, and test a language&lt;br /&gt;
binding, please contact us via the users' mailing list at&lt;br /&gt;
cvc-users@cs.nyu.edu.&lt;br /&gt;
&lt;br /&gt;
===Building CVC4 from a repository checkout===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are additionally required to build&lt;br /&gt;
CVC4 from from a repository checkout rather than from a prepared&lt;br /&gt;
source tarball.&lt;br /&gt;
&lt;br /&gt;
*'''Automake v1.11'''&lt;br /&gt;
*'''Autoconf v2.61'''&lt;br /&gt;
*'''Libtool v2.2'''&lt;br /&gt;
*'''ANTLR3 v3.2 or v3.4'''&lt;br /&gt;
*'''Java Development Kit''' ([http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 required for ANTLR3])&lt;br /&gt;
&lt;br /&gt;
First, use &amp;quot;''./autogen.sh''&amp;quot; to create the configure script.  Then&lt;br /&gt;
proceed as normal for any distribution tarball.  The parsers are&lt;br /&gt;
pre-generated for the tarballs, but don't exist in the repository; hence the extra ANTLR3 and JDK requirements to&lt;br /&gt;
generate the source code for the parsers, when building from the&lt;br /&gt;
repository.&lt;br /&gt;
&lt;br /&gt;
===Examples and tutorials are not built or installed===&lt;br /&gt;
&lt;br /&gt;
Examples are not built by &amp;quot;''make''&amp;quot; or &amp;quot;''make install''&amp;quot;.  See&lt;br /&gt;
''examples/README'' in the source distribution for information on what to find in the ''examples/''&lt;br /&gt;
directory, as well as information about building and installing them.&lt;br /&gt;
&lt;br /&gt;
===Appendix: Build architecture===&lt;br /&gt;
&lt;br /&gt;
The build system is generated by automake, libtool, and autoconf.  It&lt;br /&gt;
is somewhat nonstandard, though, which (for one thing) requires that&lt;br /&gt;
GNU Make be used.  If you ./configure in the top-level source&lt;br /&gt;
directory, the objects will actually all appear in&lt;br /&gt;
builds/${arch}/${build_id}.  This is to allow multiple, separate&lt;br /&gt;
builds in the same place (e.g., an assertions-enabled debugging build&lt;br /&gt;
alongside a production build), without changing directories at the&lt;br /&gt;
shell.  The &amp;quot;current&amp;quot; build is maintained, and you can still use&lt;br /&gt;
(e.g.) &amp;quot;make -C src/main&amp;quot; to rebuild objects in just one subdirectory.&lt;br /&gt;
&lt;br /&gt;
You can also create your own build directory inside or outside of the&lt;br /&gt;
source tree and configure from there.  All objects will then be built&lt;br /&gt;
in that directory, and you'll ultimately find the &amp;quot;cvc4&amp;quot; binary in&lt;br /&gt;
src/main/, and the libraries under src/ and src/parser/.&lt;br /&gt;
&lt;br /&gt;
=Using the CVC4 binary=&lt;br /&gt;
&lt;br /&gt;
The CVC4 driver binary (&amp;quot;cvc4&amp;quot;), once installed, can be executed directly to enter into interactive mode:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then enter commands into CVC4 interactively:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;incremental&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;produce-models&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; TRANSFORM 25*25;&lt;br /&gt;
 625&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example shows two useful options, ''incremental'' and ''produce-models.''&lt;br /&gt;
&lt;br /&gt;
* The ''incremental'' option allows you to issue multiple QUERY (or CHECKSAT) commands, and allows the use of the PUSH and POP commands.  Without this option, CVC4 optimizes itself for a single QUERY or CHECKSAT command (though you may issue any number of ASSERT commands).  The ''incremental'' option may also be given by passing the ''-i'' command line option to CVC4.&lt;br /&gt;
* The ''produce-models'' option allows you to query the model (here, with the COUNTERMODEL command) after an &amp;quot;invalid&amp;quot; QUERY (or &amp;quot;satisfiable&amp;quot; CHECK-SAT).  Without it, CVC4 doesn't do the bookkeeping necessary to support model generation.  The ''produce-models'' option may also be given by passing the ''-m'' command line option to CVC4.&lt;br /&gt;
&lt;br /&gt;
So, if you invoke CVC4 with ''-im'', you don't need to pass those options at all:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -im&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, CVC4 operates in [[#CVC4's native input language|CVC-language mode]].  If you enter something that looks like SMT-LIB, it will suggest that you use the &amp;quot;''--lang smt''&amp;quot; command-line option for SMT-LIB mode:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (declare-fun x () Int)&lt;br /&gt;
 Parse Error: &amp;lt;shell&amp;gt;:1.7: In CVC4 presentation language mode, but SMT-LIB format detected.  Use --lang smt for SMT-LIB support.&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verbosity==&lt;br /&gt;
&lt;br /&gt;
CVC4 has various levels of verbosity.  By default, CVC4 is pretty quiet, only reporting serious warnings and notices.  If you're curious about what it's doing, you can pass CVC4 the ''-v'' option:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -v file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
For even more verbosity, you can pass CVC4 an ''additional'' ''-v'':&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -vv file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
 expanding definitions...&lt;br /&gt;
 constraining subtypes...&lt;br /&gt;
 applying substitutions...&lt;br /&gt;
 simplifying assertions...&lt;br /&gt;
 doing static learning...&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
Internally, verbosity is just an integer value.  It starts at 0, and with every ''-v'' on the command line it is incremented; with every ''-q'', decremented.  It can also be set directly.  From CVC language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;verbosity&amp;quot; 2;&lt;br /&gt;
&lt;br /&gt;
Or from SMT-LIB language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (set-option :verbosity 2)&lt;br /&gt;
&lt;br /&gt;
==Getting statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with the ''--statistics'' command line option.&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 --statistics foo.smt2&lt;br /&gt;
 sat&lt;br /&gt;
 sat::decisions, 0&lt;br /&gt;
 sat::propagations, 3&lt;br /&gt;
 sat::starts, 1&lt;br /&gt;
 theory::uf::TheoryUF::functionTermsCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::mergesCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::termsCount, 6&lt;br /&gt;
 theory&amp;lt;THEORY_UF&amp;gt;::propagations, 1 &lt;br /&gt;
 driver::filename, foo.smt2&lt;br /&gt;
 driver::sat/unsat, sat&lt;br /&gt;
 driver::totalTime, 0.02015373&lt;br /&gt;
 ''[many others]''&lt;br /&gt;
&lt;br /&gt;
Many statistics name-value pairs follow, one comma-separated pair per line.&lt;br /&gt;
&lt;br /&gt;
==Exit status==&lt;br /&gt;
&lt;br /&gt;
The exit status of CVC4 depends on the ''last'' QUERY or CHECK-SAT.  If you wish to call CVC4 from a program (e.g., a shell script) and care only about the satisfiability or validity of a single formula, you can pass the ''-q'' option (as described [[#Verbosity|above, under verbosity]]) and check the exit code.  With ''-q'', CVC4 should not produce any output unless it encounters a fatal error.&lt;br /&gt;
&lt;br /&gt;
QUERY asks a validity question, and CHECK-SAT a satisfiability question, and these are dual problems; hence the terminology is different, but really &amp;quot;sat&amp;quot; and &amp;quot;invalid&amp;quot; are the same internally, as are &amp;quot;unsat&amp;quot; and &amp;quot;valid&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Solver's last result&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Exit code&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''sat''' or '''invalid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unsat''' or '''valid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unknown'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;could be for any reason: time limit exceeded, no memory, incompleteness..&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;''no result''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no query or check-sat command issued&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;parse errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0 (in interactive mode)&amp;lt;br/&amp;gt;1 (otherwise)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;other errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1 (usually)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, and others, can produce different exit codes.  In interactive mode, parse errors are ignored and the next line read; so in interactive mode, you may see an exit code of 0 even in the presence of such an error.&lt;br /&gt;
&lt;br /&gt;
In SMT-LIB mode, an SMT-LIB command script that sets its status via &amp;quot;set-info :status&amp;quot; also affects the exit code.  So, for instance, the following SMT-LIB script returns an exit code of 10 even though it contains no &amp;quot;check-sat&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 (set-logic QF_UF)&lt;br /&gt;
 (set-info :status sat)&lt;br /&gt;
 (exit)&lt;br /&gt;
&lt;br /&gt;
Without the &amp;quot;set-info,&amp;quot; it would have returned an exit code of 0.&lt;br /&gt;
&lt;br /&gt;
=CVC4's native input language=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}\ [X_1, \ldots, X_p] \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt; are type variables,&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by some of the variables &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, so a terms such as +4 is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format: &lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 is cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=CVC4's support for the SMT-LIB language=&lt;br /&gt;
&lt;br /&gt;
==SMT-LIB compliance==&lt;br /&gt;
&lt;br /&gt;
Every effort has been made to make CVC4 compliant with the SMT-LIB 2.0&lt;br /&gt;
standard (http://smtlib.org/).  However, when parsing SMT-LIB input,&lt;br /&gt;
certain default settings don't match what is stated in the official&lt;br /&gt;
standard.  To make CVC4 adhere more strictly to the standard, use the&lt;br /&gt;
&amp;quot;--smtlib&amp;quot; command-line option.  Even with this setting, CVC4 is&lt;br /&gt;
somewhat lenient; some non-conforming input may still be parsed and&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
==Using CVC4 from Java==&lt;br /&gt;
==The compatibility interface==&lt;br /&gt;
&lt;br /&gt;
=Upgrading from CVC3 to CVC4=&lt;br /&gt;
&lt;br /&gt;
==Features not supported by CVC4 (yet)==&lt;br /&gt;
&lt;br /&gt;
===Type Correctness Conditions (TCCs)===&lt;br /&gt;
&lt;br /&gt;
Type Correctness Conditions (TCCs), and the checking of such, are not&lt;br /&gt;
supported by CVC4 1.0.  Thus, a function defined only on integers can be&lt;br /&gt;
applied to REAL (as INT is a subtype of REAL), and CVC4 will not complain,&lt;br /&gt;
but may produce strange results.  For example:&lt;br /&gt;
&lt;br /&gt;
  f : INT -&amp;gt; INT;&lt;br /&gt;
  ASSERT f(1/3) = 0;&lt;br /&gt;
  ASSERT f(2/3) = 1;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  COUNTEREXAMPLE;&lt;br /&gt;
  % f : (INT) -&amp;gt; INT = LAMBDA(x1:INT) : 0;&lt;br /&gt;
&lt;br /&gt;
CVC3 can be used to produce TCCs for this input (with the +dump-tcc option).&lt;br /&gt;
The TCC can be checked by CVC3 or another solver.  (CVC3 can also check&lt;br /&gt;
TCCs while solving with +tcc.)&lt;br /&gt;
&lt;br /&gt;
==If you were using the text interfaces of CVC3==&lt;br /&gt;
&lt;br /&gt;
The native language of all solvers in the CVC family, referred to as the&lt;br /&gt;
&amp;quot;presentation language,&amp;quot; has undergone some revisions for CVC4.  The&lt;br /&gt;
most notable is that CVC4 does _not_ add counterexample assertions to&lt;br /&gt;
the current assertion set after a SAT/INVALID result.  For example:&lt;br /&gt;
&lt;br /&gt;
  x, y : INT;&lt;br /&gt;
  ASSERT x = 1 OR x = 2;&lt;br /&gt;
  ASSERT y = 1 OR y = 2;&lt;br /&gt;
  ASSERT x /= y;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  QUERY x = 1;&lt;br /&gt;
  % invalid&lt;br /&gt;
  QUERY x = 2;&lt;br /&gt;
  % invalid&lt;br /&gt;
&lt;br /&gt;
Here, CVC4 responds &amp;quot;invalid&amp;quot; to the second and third queries, because&lt;br /&gt;
each has a counterexample (x=2 is a counterexample to the first, and&lt;br /&gt;
x=1 is a counterexample to the second).  However, CVC3 will respond&lt;br /&gt;
with &amp;quot;valid&amp;quot; to one of these two, as the first query (the CHECKSAT)&lt;br /&gt;
had the side-effect of locking CVC3 into one of the two cases; the&lt;br /&gt;
later queries are effectively querying the counterexample that was&lt;br /&gt;
found by the first.  CVC4 removes this side-effect of the CHECKSAT and&lt;br /&gt;
QUERY commands.&lt;br /&gt;
&lt;br /&gt;
CVC4 supports rational literals (of type REAL) in decimal; CVC3 did not&lt;br /&gt;
support decimals.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not have support for the IS_INTEGER predicate.&lt;br /&gt;
&lt;br /&gt;
==If you were using the library (&amp;quot;in-memory&amp;quot;) interface of CVC3==&lt;br /&gt;
===If you were using CVC3 from C===&lt;br /&gt;
===If you were using CVC3 from Java===&lt;br /&gt;
&lt;br /&gt;
=Useful command-line options=&lt;br /&gt;
&lt;br /&gt;
==Statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with&lt;br /&gt;
the --statistics command line option.&lt;br /&gt;
&lt;br /&gt;
==Time and resource limits==&lt;br /&gt;
&lt;br /&gt;
CVC4 can be made to self-timeout after a given number of milliseconds.&lt;br /&gt;
Use the --tlimit command line option to limit the entire run of&lt;br /&gt;
CVC4, or use --tlimit-per to limit each individual query separately.&lt;br /&gt;
Preprocessing time is not counted by the time limit, so for some large&lt;br /&gt;
inputs which require aggressive preprocessing, you may notice that&lt;br /&gt;
--tlimit does not work very well.  If you suspect this might be the&lt;br /&gt;
case, you can use &amp;quot;-vv&amp;quot; (double verbosity) to see what CVC4 is doing.&lt;br /&gt;
&lt;br /&gt;
Time-limited runs are not deterministic; two consecutive runs with the&lt;br /&gt;
same time limit might produce different results (i.e., one may time out&lt;br /&gt;
and responds with &amp;quot;unknown&amp;quot;, while the other completes and provides an&lt;br /&gt;
answer).  To ensure that results are reproducible, use --rlimit or&lt;br /&gt;
--rlimit-per.  These options take a &amp;quot;resource count&amp;quot; (presently, based on&lt;br /&gt;
the number of SAT conflicts) that limits the search time.  A word of&lt;br /&gt;
caution, though: there is no guarantee that runs of different versions of&lt;br /&gt;
CVC4 or of different builds of CVC4 (e.g., two CVC4 binaries with different&lt;br /&gt;
features enabled, or for different architectures) will interpret the resource&lt;br /&gt;
count in the same manner.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not presently have a way to limit its memory use; you may opt&lt;br /&gt;
to run it from a shell after using &amp;quot;ulimit&amp;quot; to limit the size of the&lt;br /&gt;
heap.&lt;br /&gt;
&lt;br /&gt;
=Dumping API calls or preprocessed output=&lt;br /&gt;
&lt;br /&gt;
=Changing the output language=&lt;br /&gt;
&lt;br /&gt;
=Proof support=&lt;br /&gt;
&lt;br /&gt;
CVC4 1.0 has limited support for proofs, and they are disabled by default.&lt;br /&gt;
(Run the configure script with --enable-proof to enable proofs).  Proofs&lt;br /&gt;
are exported in LFSC format and are limited to the propositional backbone&lt;br /&gt;
of the discovered proof (theory lemmas are stated without proof in this&lt;br /&gt;
release).&lt;br /&gt;
&lt;br /&gt;
=Portfolio solving=&lt;br /&gt;
&lt;br /&gt;
If enabled at configure-time (./configure --with-portfolio), a second&lt;br /&gt;
CVC4 binary will be produced (&amp;quot;pcvc4&amp;quot;).  This binary has support for&lt;br /&gt;
running multiple instances of CVC4 in different threads.  Use --threads=N&lt;br /&gt;
to specify the number of threads, and use --thread0=&amp;quot;options for thread 0&amp;quot;&lt;br /&gt;
--thread1=&amp;quot;options for thread 1&amp;quot;, etc., to specify a configuration for the&lt;br /&gt;
threads.  Lemmas are *not* shared between the threads by default; to adjust&lt;br /&gt;
this, use the --filter-lemma-length=N option to share lemmas of N literals&lt;br /&gt;
(or smaller).  (Some lemmas are ineligible for sharing because they include&lt;br /&gt;
literals that are &amp;quot;local&amp;quot; to one thread.)&lt;br /&gt;
&lt;br /&gt;
Currently, the portfolio **does not work** with quantifiers or with&lt;br /&gt;
the theory of inductive datatypes.  These limitations will be addressed&lt;br /&gt;
in a future release.&lt;br /&gt;
&lt;br /&gt;
=Emacs support=&lt;br /&gt;
&lt;br /&gt;
For a suggestion of editing CVC4 source code with emacs, see the file&lt;br /&gt;
contrib/editing-with-emacs.  For a CVC language mode (the native input&lt;br /&gt;
language for CVC4), see contrib/cvc-mode.el.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3912</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=3912"/>
				<updated>2012-11-26T04:29:23Z</updated>
		
		<summary type="html">&lt;p&gt;Tinelli: /* Arithmetic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This manual includes lots of information about how to use CVC4.&lt;br /&gt;
&lt;br /&gt;
It is a work in-progress.&lt;br /&gt;
&lt;br /&gt;
= What is CVC4? =&lt;br /&gt;
&lt;br /&gt;
CVC4 is the last of a long line of SMT solvers that started with SVC and includes CVC, CVC-Lite and CVC3.&lt;br /&gt;
Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories. &lt;br /&gt;
The current built-in theories are the theories of:&lt;br /&gt;
&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols,&lt;br /&gt;
* real and integer linear arithmetic (with some support for non-linear arithmetic),&lt;br /&gt;
* bit vectors,&lt;br /&gt;
* arrays,&lt;br /&gt;
* tuples,&lt;br /&gt;
* records,&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 checks whether a given formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is valid in the built-in theories under a given set &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; of assumptions, a ''context''. &lt;br /&gt;
More precisely, it checks whether&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma\models_T \phi&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
that is, whether &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a logical consequence in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; of the set of formulas &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the union of CVC4's built-in theories.&lt;br /&gt;
&lt;br /&gt;
Roughly speaking, when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; is a universal formula and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is a set of existential formulas (i.e., when &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; contain at most universal, respectively existential, quantifiers), CVC4 is a decision procedure: &lt;br /&gt;
it is guaranteed (modulo bugs and memory limits) to return a correct &amp;quot;valid&amp;quot; or &amp;quot;invalid&amp;quot; answer eventually. &lt;br /&gt;
In all other cases, CVC4 is deductively sound but incomplete: &lt;br /&gt;
it will never say that an invalid formula is valid,&lt;br /&gt;
but it may either never return or give up and return &amp;quot;unknown&amp;quot; for some formulas.&lt;br /&gt;
&lt;br /&gt;
Currently, when CVC4 returns &amp;quot;valid&amp;quot; for a query formula &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; under a context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;&lt;br /&gt;
it provides no evidence to back its claim.&lt;br /&gt;
Future versions will also return a ''proof certificate'', &lt;br /&gt;
a formal proof that &amp;lt;math&amp;gt;\Gamma'\models_T \phi&amp;lt;/math&amp;gt; for some subset &amp;lt;math&amp;gt;\Gamma'&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When CVC4 returns &amp;quot;invalid&amp;quot; it can return &lt;br /&gt;
both a ''counter-example'' to &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;'s validity under the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and a ''counter-model''. &lt;br /&gt;
Both a counter-example and a counter-model are a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of additional formulas consistent with &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but entailing the negation of &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
Formally:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \not\models_T \mathit{false}&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma \cup \Delta \models_T \lnot \phi&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference is that a counter-model is given as a set of equations providing a concrete assignment of values for the free symbols in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\phi&amp;lt;/math&amp;gt; &lt;br /&gt;
(see the section on [[#CVC4's native input language|CVC4's native input language]] for more details).&lt;br /&gt;
&lt;br /&gt;
=Obtaining and compiling CVC4=&lt;br /&gt;
&lt;br /&gt;
CVC4 is distributed in the following ways:&lt;br /&gt;
* [[#Obtaining_binary_packages|Binary packages]]&lt;br /&gt;
* [[#Obtaining_source_packages|Source packages]]&lt;br /&gt;
* [[#Source_repository|Source repository checkout]]&lt;br /&gt;
&lt;br /&gt;
==Obtaining binary packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/ Binary packages are available] for CVC4.&lt;br /&gt;
Nightly builds:&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/debian/unstable Debian] packages&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.nyu.edu/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
&lt;br /&gt;
==Obtaining source packages==&lt;br /&gt;
&lt;br /&gt;
[http://cvc4.cs.nyu.edu/builds/src/ Sources are available] from the same site as the binaries.&lt;br /&gt;
&lt;br /&gt;
==Source repository==&lt;br /&gt;
The [http://cvc4.cs.nyu.edu/builds/src/ CVC4 source repository] is currently hosted by [http://cims.nyu.edu/ CIMS] and requires a CIMS account. Please contact a member of the development team for access. Please see the additional instructions for [[#Building_CVC4 from_a_repository_checkout]] here.&lt;br /&gt;
&lt;br /&gt;
==Building from source==&lt;br /&gt;
&lt;br /&gt;
===Quick-start instructions===&lt;br /&gt;
To compile from a source package:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
    cd contrib&lt;br /&gt;
    ./get-antlr-3.4&lt;br /&gt;
    cd ..&lt;br /&gt;
    ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
    make&lt;br /&gt;
    make check   [recommended]&lt;br /&gt;
    make install [optional]&lt;br /&gt;
&lt;br /&gt;
(To build from a repository checkout, see [[#Building_CVC4_from_a_repository_checkout|below]].)&lt;br /&gt;
&lt;br /&gt;
===Common make Options===&lt;br /&gt;
* &amp;quot;''make install''&amp;quot; will install into the &amp;quot;--prefix&amp;quot; option you gave to&lt;br /&gt;
the configure script (''/usr/local'' by default).&lt;br /&gt;
    ./configure --prefix=~/install_targets/cvc4 ...&lt;br /&gt;
    make install&lt;br /&gt;
* '''You should run &amp;quot;''make check''&amp;quot;''' before installation to ensure that CVC4 has been&lt;br /&gt;
built correctly.  In particular, GCC version 4.5.1 seems to have a&lt;br /&gt;
bug in the optimizer that results in incorrect behavior (and wrong&lt;br /&gt;
results) in many builds.  This is a known problem for Minisat, and&lt;br /&gt;
since Minisat is at the core of CVC4, a problem for CVC4.  &amp;quot;''make check''&amp;quot;&lt;br /&gt;
easily detects this problem (by showing a number of FAILed test cases).&lt;br /&gt;
It is ok if the unit tests aren't run as part of &amp;quot;''make check''&amp;quot;, but all&lt;br /&gt;
system tests and regression tests should pass without incident.&lt;br /&gt;
* To build API documentation, use &amp;quot;''make doc''&amp;quot;.  Documentation is produced&lt;br /&gt;
under ''builds/doc/'' but is not installed by &amp;quot;''make install''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Examples and tutorials are not installed with &amp;quot;''make install''.&amp;quot;  See [[#Examples_and_tutorials_are_not_built_or_installed|below]].&lt;br /&gt;
&lt;br /&gt;
For more information about the build system itself (probably not&lt;br /&gt;
necessary for casual users), see the [[#Appendix:_Build_architecture|Appendix]] at the bottom of this&lt;br /&gt;
file.&lt;br /&gt;
&lt;br /&gt;
===Common configure Options===&lt;br /&gt;
*'''--prefix=PREFIX''' install architecture-independent files in PREFIX (by default /usr/local)&lt;br /&gt;
*'''--with-build={production,debug,default,competition}''' &lt;br /&gt;
*'''--with-antlr-dir=PATH'''&lt;br /&gt;
*'''--with-cln'''/'''--with-gmp''' selects the numbers package to use by default ([[#Optional requirements]])&lt;br /&gt;
*'''--enable-static-binary''' build a fully statically-linked binary. (This is recommended for Mac OS X users that want to be able to use gdb.)&lt;br /&gt;
*'''ANTLR=PATH''' location of the antlr3 script&lt;br /&gt;
*'''--with-boost=DIR''' installation location of the boost libraries (most users will not need this)&lt;br /&gt;
&lt;br /&gt;
See '''./configure --help''' for more.&lt;br /&gt;
&lt;br /&gt;
===Build dependencies===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are required to run CVC4. Versions&lt;br /&gt;
given are minimum versions; more recent versions should be compatible.&lt;br /&gt;
&lt;br /&gt;
*'''GNU C and C++''' (gcc and g++), reasonably recent versions&lt;br /&gt;
*'''GNU Make'''&lt;br /&gt;
*'''GNU Bash'''&lt;br /&gt;
*'''GMP v4.2''' (GNU Multi-Precision arithmetic library)&lt;br /&gt;
*'''libantlr3c v3.2 or v3.4''' (ANTLR parser generator C support library)&lt;br /&gt;
*'''The Boost C++ base libraries'''&lt;br /&gt;
*'''MacPorts'''   [highly recommended if on a Mac; see [[#MacPorts]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hardest to obtain and install is the libantlr3c requirement, and&lt;br /&gt;
is explained [[#Installing libantlr3c: ANTLR parser generator C support library|next]].&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;make&amp;quot; is non-GNU on your system, make sure to invoke &amp;quot;gmake&amp;quot; (or&lt;br /&gt;
whatever GNU Make is installed as).  If your usual shell is not Bash,&lt;br /&gt;
the configure script should auto-correct this.  If it does not, you'll&lt;br /&gt;
see strange shell syntax errors, and you may need to explicitly set&lt;br /&gt;
SHELL or CONFIG_SHELL to the location of bash on your system.&lt;br /&gt;
&lt;br /&gt;
====Installing libantlr3c: ANTLR parser generator C support library====&lt;br /&gt;
&lt;br /&gt;
For libantlr3c, you can use the convenience script in&lt;br /&gt;
''contrib/get-antlr-3.4'' in the source distribution---this will download, patch, compile and install&lt;br /&gt;
libantlr3c into your cvc4 directory as ''cvc4/antlr-3.4/''.&lt;br /&gt;
  cd contrib&lt;br /&gt;
  ./get-antlr-3.4&lt;br /&gt;
&lt;br /&gt;
CVC4 must be configured with the antlr library installation directory, '''--with-antlr-dir''', and an antlr executable script file, '''ANTLR'''.  If libantlr3c was installed via get-antlr-3.4, the following configure line should suffice for CVC44&lt;br /&gt;
  ./configure --with-antlr-dir=`pwd`/antlr-3.4 ANTLR=`pwd`/antlr-3.4/bin/antlr3&lt;br /&gt;
&lt;br /&gt;
For 64 bit machines, libantlr3c needs to be configured with 64 bit explicitly&lt;br /&gt;
  ./configure --enable-64bit ...&lt;br /&gt;
The get-antlr-3.4 script makes a guess at whether the machine is 64 bit and adds the appropriate flag.&lt;br /&gt;
To force the script to compile 32 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86&amp;quot; ./get-antlr3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr3.4&lt;br /&gt;
&lt;br /&gt;
For a longer discussion, instructions for manual installation, and more in depth troubleshooting, see [[Developer's Guide#ANTLR3]].&lt;br /&gt;
&lt;br /&gt;
====MacPorts====&lt;br /&gt;
&lt;br /&gt;
On a Mac, it is '''highly''' recommended that you use MacPorts (see&lt;br /&gt;
http://www.macports.org/).  Doing so is easy.  Then, simply run the&lt;br /&gt;
script ''contrib/mac-build'', which installs a few ports from the MacPorts&lt;br /&gt;
repository, then compiles and installs antlr3c using the ''get-antlr-3.4''&lt;br /&gt;
script.  The mac-build script should set you up&lt;br /&gt;
with all requirements, and will tell you how to configure CVC4 when it&lt;br /&gt;
completes successfully.&lt;br /&gt;
&lt;br /&gt;
====Installing the Boost C++ base libraries====&lt;br /&gt;
&lt;br /&gt;
A Boost package is available on most Linux distributions; check yours&lt;br /&gt;
for a package named something like libboost-dev or boost-devel.  There&lt;br /&gt;
are a number of additional Boost packages in some distributions, but&lt;br /&gt;
this &amp;quot;basic&amp;quot; one should be sufficient for building CVC4.&lt;br /&gt;
&lt;br /&gt;
Should you want to install Boost manually, or to learn more about the&lt;br /&gt;
Boost project, please visit http://www.boost.org/.&lt;br /&gt;
&lt;br /&gt;
===Optional requirements===&lt;br /&gt;
&lt;br /&gt;
None of these is required, but can improve CVC4 as described below:&lt;br /&gt;
&lt;br /&gt;
*'''Optional: SWIG 2.0.x''' (Simplified Wrapper and Interface Generator)&lt;br /&gt;
*'''Optional: CLN v1.3 or newer''' (Class Library for Numbers)&lt;br /&gt;
*'''Optional: CUDD v2.4.2 or newer''' (Colorado University Decision Diagram package)&lt;br /&gt;
*'''Optional: GNU Readline library''' (for an improved interactive experience)&lt;br /&gt;
*'''Optional: The Boost C++ threading library''' (libboost_thread)&lt;br /&gt;
*'''Optional: CxxTest unit testing framework'''&lt;br /&gt;
&lt;br /&gt;
SWIG is necessary to build the Java API (and of course a JDK is&lt;br /&gt;
necessary, too).  SWIG 1.x won't work; you'll need 2.0, and the more&lt;br /&gt;
recent the better.  On Mac, we've seen SWIG segfault when generating&lt;br /&gt;
CVC4 language bindings; version 2.0.8 or higher is recommended to&lt;br /&gt;
avoid this.  See [[#Language_bindings|Language bindings]] below for build instructions.&lt;br /&gt;
&lt;br /&gt;
CLN is an alternative multiprecision arithmetic package that can offer&lt;br /&gt;
better performance and memory footprint than GMP.  CLN is covered by&lt;br /&gt;
the GNU General Public License, version 3; so if you choose to use&lt;br /&gt;
CVC4 with CLN support, you are licensing CVC4 under that same license.&lt;br /&gt;
(Usually CVC4's license is more permissive than GPL is; see the file&lt;br /&gt;
COPYING in the CVC4 source distribution for details.)  Please visit&lt;br /&gt;
http://www.ginac.de/CLN/ for more details about CLN.&lt;br /&gt;
&lt;br /&gt;
CUDD is a decision diagram package that changes the behavior of the&lt;br /&gt;
CVC4 arithmetic solver in some cases; it may or may not improve the&lt;br /&gt;
arithmetic solver's performance.  See [[#Building_with_CUDD_(optional)|below]] for instructions on&lt;br /&gt;
obtaining and building CUDD.&lt;br /&gt;
&lt;br /&gt;
The GNU Readline library is optionally used to provide command&lt;br /&gt;
editing, tab completion, and history functionality at the CVC prompt&lt;br /&gt;
(when running in interactive mode).  Check your distribution for a&lt;br /&gt;
package named &amp;quot;libreadline-dev&amp;quot; or &amp;quot;readline-devel&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
The Boost C++ threading library (often packaged independently of the&lt;br /&gt;
Boost base library) is needed to run CVC4 in &amp;quot;portfolio&amp;quot;&lt;br /&gt;
(multithreaded) mode.  Check your distribution for a package named&lt;br /&gt;
&amp;quot;libboost-thread-dev&amp;quot; or similar.&lt;br /&gt;
&lt;br /&gt;
CxxTest is necessary to run CVC4's unit tests (included with the&lt;br /&gt;
distribution).  Running these is not really required for users of&lt;br /&gt;
CVC4; &amp;quot;make check&amp;quot; will skip unit tests if CxxTest isn't available,&lt;br /&gt;
and go on to run the extensive system- and regression-tests in the&lt;br /&gt;
source tree.  However, if you're interested, you can download CxxTest&lt;br /&gt;
at http://cxxtest.com/ .&lt;br /&gt;
&lt;br /&gt;
====Building with CUDD (optional)====&lt;br /&gt;
&lt;br /&gt;
CUDD, if desired, must be installed delicately.  The CVC4 configure&lt;br /&gt;
script attempts to auto-detect the locations and names of CUDD headers&lt;br /&gt;
and libraries the way that the Fedora RPMs install them, the way that&lt;br /&gt;
our NYU-provided Debian packages install them, and the way they exist&lt;br /&gt;
when you download and build the CUDD sources directly.  If you install&lt;br /&gt;
from Fedora RPMs or our Debian packages, the process should be&lt;br /&gt;
completely automatic, since the libraries and headers are installed in&lt;br /&gt;
a standard location.  If you download the sources yourself, you need&lt;br /&gt;
to build them in a special way.  Fortunately, the&lt;br /&gt;
&amp;quot;contrib/build-cudd-2.4.2-with-libtool.sh&amp;quot; script in the CVC4 source&lt;br /&gt;
tree does exactly what you need: it patches the CUDD makefiles to use&lt;br /&gt;
libtool, builds the libtool libraries, then reverses the patch to&lt;br /&gt;
leave the makefiles as they were.  Once you run this script on an&lt;br /&gt;
unpacked CUDD 2.4.2 source distribution, then CVC4's configure script&lt;br /&gt;
should pick up the libraries if you provide&lt;br /&gt;
--with-cudd-dir=/PATH/TO/CUDD/SOURCES.&lt;br /&gt;
&lt;br /&gt;
If you want to force linking to CUDD, provide --with-cudd to the&lt;br /&gt;
configure script; this makes it a hard requirement rather than an&lt;br /&gt;
optional add-on.&lt;br /&gt;
&lt;br /&gt;
The NYU-provided Debian packaging of CUDD 2.4.2 and CUDD 2.5.0 are&lt;br /&gt;
here (along with the CVC4 Debian packages):&lt;br /&gt;
&lt;br /&gt;
  deb http://cvc4.cs.nyu.edu/debian/ unstable/&lt;br /&gt;
&lt;br /&gt;
On Debian (and Debian-derived distributions like Ubuntu), you only&lt;br /&gt;
need to drop that one line in your /etc/apt/sources.list file, then install with your favorite package manager.&lt;br /&gt;
&lt;br /&gt;
The Debian source package &amp;quot;cudd&amp;quot;, available from the same repository,&lt;br /&gt;
includes a diff of all changes made to cudd makefiles.&lt;br /&gt;
&lt;br /&gt;
===Language bindings===&lt;br /&gt;
&lt;br /&gt;
There are several options available for using CVC4 from the API.&lt;br /&gt;
&lt;br /&gt;
First, CVC4 offers a complete and flexible API for manipulating&lt;br /&gt;
expressions, maintaining a stack of assertions, and checking&lt;br /&gt;
satisfiability, and related things.  The C++ libraries (libcvc4.so and&lt;br /&gt;
libcvc4parser.so) and required headers are installed normally via a&lt;br /&gt;
&amp;quot;make install&amp;quot;.  This API is also available from Java (via CVC4.jar&lt;br /&gt;
and libcvc4jni.so) by configuring with --enable-language-bindings=java.&lt;br /&gt;
You'll also need SWIG 2.0 installed (and you might need to help&lt;br /&gt;
configure find it if you installed it in a nonstandard place with&lt;br /&gt;
--with-swig-dir=/path/to/swig/installation).  You may also need to&lt;br /&gt;
give the configure script the path to your Java headers (in&lt;br /&gt;
particular, jni.h).  You might do so with (for example):&lt;br /&gt;
&lt;br /&gt;
  ./configure --enable-language-bindings=java \&lt;br /&gt;
      JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-openjdk-amd64/include&lt;br /&gt;
&lt;br /&gt;
There is also a &amp;quot;C++ compatibility API&amp;quot; (''#include &amp;lt;cvc4/cvc3_compat.h&amp;gt;''&lt;br /&gt;
and link against libcvc4compat.so) that attempts to maintain&lt;br /&gt;
source-level backwards-compatibility with the CVC3 C++ API.  The&lt;br /&gt;
compatibility library is built by default, and&lt;br /&gt;
''--enable-language-bindings=java'' enables the Java compatibility library&lt;br /&gt;
(CVC4compat.jar and libcvc4compatjni.so).&lt;br /&gt;
''--enable-language-bindings=c'' enables the C compatibility library&lt;br /&gt;
(''#include &amp;lt;cvc4/bindings/compat/c/c_interface.h&amp;gt;'' and link against&lt;br /&gt;
libcvc4bindings_c_compat.so), and if you want both C and Java&lt;br /&gt;
bindings, use ''--enable-language-bindings=c,java''.  These compatibility&lt;br /&gt;
language bindings do NOT require SWIG.&lt;br /&gt;
&lt;br /&gt;
The ''examples/'' directory in the source distribution includes some basic examples (the &amp;quot;simple vc&amp;quot;&lt;br /&gt;
and &amp;quot;simple vc compat&amp;quot; family of examples) of all these interfaces.&lt;br /&gt;
&lt;br /&gt;
In principle, since we use SWIG to generate the native Java API, we&lt;br /&gt;
could support other languages as well.  However, using CVC4 from other&lt;br /&gt;
languages is not supported, nor expected to work, at this time.  If&lt;br /&gt;
you're interested in helping to develop, maintain, and test a language&lt;br /&gt;
binding, please contact us via the users' mailing list at&lt;br /&gt;
cvc-users@cs.nyu.edu.&lt;br /&gt;
&lt;br /&gt;
===Building CVC4 from a repository checkout===&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are additionally required to build&lt;br /&gt;
CVC4 from from a repository checkout rather than from a prepared&lt;br /&gt;
source tarball.&lt;br /&gt;
&lt;br /&gt;
*'''Automake v1.11'''&lt;br /&gt;
*'''Autoconf v2.61'''&lt;br /&gt;
*'''Libtool v2.2'''&lt;br /&gt;
*'''ANTLR3 v3.2 or v3.4'''&lt;br /&gt;
*'''Java Development Kit''' ([http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 required for ANTLR3])&lt;br /&gt;
&lt;br /&gt;
First, use &amp;quot;''./autogen.sh''&amp;quot; to create the configure script.  Then&lt;br /&gt;
proceed as normal for any distribution tarball.  The parsers are&lt;br /&gt;
pre-generated for the tarballs, but don't exist in the repository; hence the extra ANTLR3 and JDK requirements to&lt;br /&gt;
generate the source code for the parsers, when building from the&lt;br /&gt;
repository.&lt;br /&gt;
&lt;br /&gt;
===Examples and tutorials are not built or installed===&lt;br /&gt;
&lt;br /&gt;
Examples are not built by &amp;quot;''make''&amp;quot; or &amp;quot;''make install''&amp;quot;.  See&lt;br /&gt;
''examples/README'' in the source distribution for information on what to find in the ''examples/''&lt;br /&gt;
directory, as well as information about building and installing them.&lt;br /&gt;
&lt;br /&gt;
===Appendix: Build architecture===&lt;br /&gt;
&lt;br /&gt;
The build system is generated by automake, libtool, and autoconf.  It&lt;br /&gt;
is somewhat nonstandard, though, which (for one thing) requires that&lt;br /&gt;
GNU Make be used.  If you ./configure in the top-level source&lt;br /&gt;
directory, the objects will actually all appear in&lt;br /&gt;
builds/${arch}/${build_id}.  This is to allow multiple, separate&lt;br /&gt;
builds in the same place (e.g., an assertions-enabled debugging build&lt;br /&gt;
alongside a production build), without changing directories at the&lt;br /&gt;
shell.  The &amp;quot;current&amp;quot; build is maintained, and you can still use&lt;br /&gt;
(e.g.) &amp;quot;make -C src/main&amp;quot; to rebuild objects in just one subdirectory.&lt;br /&gt;
&lt;br /&gt;
You can also create your own build directory inside or outside of the&lt;br /&gt;
source tree and configure from there.  All objects will then be built&lt;br /&gt;
in that directory, and you'll ultimately find the &amp;quot;cvc4&amp;quot; binary in&lt;br /&gt;
src/main/, and the libraries under src/ and src/parser/.&lt;br /&gt;
&lt;br /&gt;
=Using the CVC4 binary=&lt;br /&gt;
&lt;br /&gt;
The CVC4 driver binary (&amp;quot;cvc4&amp;quot;), once installed, can be executed directly to enter into interactive mode:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then enter commands into CVC4 interactively:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;incremental&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;produce-models&amp;quot;;&lt;br /&gt;
 CVC4&amp;gt; TRANSFORM 25*25;&lt;br /&gt;
 625&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example shows two useful options, ''incremental'' and ''produce-models.''&lt;br /&gt;
&lt;br /&gt;
* The ''incremental'' option allows you to issue multiple QUERY (or CHECKSAT) commands, and allows the use of the PUSH and POP commands.  Without this option, CVC4 optimizes itself for a single QUERY or CHECKSAT command (though you may issue any number of ASSERT commands).  The ''incremental'' option may also be given by passing the ''-i'' command line option to CVC4.&lt;br /&gt;
* The ''produce-models'' option allows you to query the model (here, with the COUNTERMODEL command) after an &amp;quot;invalid&amp;quot; QUERY (or &amp;quot;satisfiable&amp;quot; CHECK-SAT).  Without it, CVC4 doesn't do the bookkeeping necessary to support model generation.  The ''produce-models'' option may also be given by passing the ''-m'' command line option to CVC4.&lt;br /&gt;
&lt;br /&gt;
So, if you invoke CVC4 with ''-im'', you don't need to pass those options at all:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -im&lt;br /&gt;
 cvc4 1.0 assertions:off&lt;br /&gt;
 CVC4&amp;gt; x, y : INT;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = -1;&lt;br /&gt;
 y : INT = 0;&lt;br /&gt;
 CVC4&amp;gt; ASSERT x &amp;gt;= 0;&lt;br /&gt;
 CVC4&amp;gt; QUERY x = y;&lt;br /&gt;
 invalid&lt;br /&gt;
 CVC4&amp;gt; COUNTERMODEL;&lt;br /&gt;
 x : INT = 0;&lt;br /&gt;
 y : INT = 1;&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, CVC4 operates in [[#CVC4's native input language|CVC-language mode]].  If you enter something that looks like SMT-LIB, it will suggest that you use the &amp;quot;''--lang smt''&amp;quot; command-line option for SMT-LIB mode:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (declare-fun x () Int)&lt;br /&gt;
 Parse Error: &amp;lt;shell&amp;gt;:1.7: In CVC4 presentation language mode, but SMT-LIB format detected.  Use --lang smt for SMT-LIB support.&lt;br /&gt;
 CVC4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Verbosity==&lt;br /&gt;
&lt;br /&gt;
CVC4 has various levels of verbosity.  By default, CVC4 is pretty quiet, only reporting serious warnings and notices.  If you're curious about what it's doing, you can pass CVC4 the ''-v'' option:&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -v file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
For even more verbosity, you can pass CVC4 an ''additional'' ''-v'':&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 -vv file.smt2&lt;br /&gt;
 Invoking: (set-logic AUFLIRA)&lt;br /&gt;
 Invoking: (set-info :smt-lib-version 2.000000)&lt;br /&gt;
 Invoking: (set-info :category &amp;quot;crafted&amp;quot;)&lt;br /&gt;
 Invoking: (set-info :status unsat)&lt;br /&gt;
 Invoking: (declare-fun x () Real)&lt;br /&gt;
 ''etc...''&lt;br /&gt;
 expanding definitions...&lt;br /&gt;
 constraining subtypes...&lt;br /&gt;
 applying substitutions...&lt;br /&gt;
 simplifying assertions...&lt;br /&gt;
 doing static learning...&lt;br /&gt;
 ''etc...''&lt;br /&gt;
&lt;br /&gt;
Internally, verbosity is just an integer value.  It starts at 0, and with every ''-v'' on the command line it is incremented; with every ''-q'', decremented.  It can also be set directly.  From CVC language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; OPTION &amp;quot;verbosity&amp;quot; 2;&lt;br /&gt;
&lt;br /&gt;
Or from SMT-LIB language:&lt;br /&gt;
&lt;br /&gt;
 CVC4&amp;gt; (set-option :verbosity 2)&lt;br /&gt;
&lt;br /&gt;
==Getting statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with the ''--statistics'' command line option.&lt;br /&gt;
&lt;br /&gt;
 $ cvc4 --statistics foo.smt2&lt;br /&gt;
 sat&lt;br /&gt;
 sat::decisions, 0&lt;br /&gt;
 sat::propagations, 3&lt;br /&gt;
 sat::starts, 1&lt;br /&gt;
 theory::uf::TheoryUF::functionTermsCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::mergesCount, 2&lt;br /&gt;
 theory::uf::TheoryUF::termsCount, 6&lt;br /&gt;
 theory&amp;lt;THEORY_UF&amp;gt;::propagations, 1 &lt;br /&gt;
 driver::filename, foo.smt2&lt;br /&gt;
 driver::sat/unsat, sat&lt;br /&gt;
 driver::totalTime, 0.02015373&lt;br /&gt;
 ''[many others]''&lt;br /&gt;
&lt;br /&gt;
Many statistics name-value pairs follow, one comma-separated pair per line.&lt;br /&gt;
&lt;br /&gt;
==Exit status==&lt;br /&gt;
&lt;br /&gt;
The exit status of CVC4 depends on the ''last'' QUERY or CHECK-SAT.  If you wish to call CVC4 from a program (e.g., a shell script) and care only about the satisfiability or validity of a single formula, you can pass the ''-q'' option (as described [[#Verbosity|above, under verbosity]]) and check the exit code.  With ''-q'', CVC4 should not produce any output unless it encounters a fatal error.&lt;br /&gt;
&lt;br /&gt;
QUERY asks a validity question, and CHECK-SAT a satisfiability question, and these are dual problems; hence the terminology is different, but really &amp;quot;sat&amp;quot; and &amp;quot;invalid&amp;quot; are the same internally, as are &amp;quot;unsat&amp;quot; and &amp;quot;valid&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Solver's last result&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Exit code&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Notes&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''sat''' or '''invalid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unsat''' or '''valid'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'''unknown'''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;could be for any reason: time limit exceeded, no memory, incompleteness..&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;''no result''&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;no query or check-sat command issued&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;parse errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;0 (in interactive mode)&amp;lt;br/&amp;gt;1 (otherwise)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;other errors&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1 (usually)&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;see below&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, and others, can produce different exit codes.  In interactive mode, parse errors are ignored and the next line read; so in interactive mode, you may see an exit code of 0 even in the presence of such an error.&lt;br /&gt;
&lt;br /&gt;
In SMT-LIB mode, an SMT-LIB command script that sets its status via &amp;quot;set-info :status&amp;quot; also affects the exit code.  So, for instance, the following SMT-LIB script returns an exit code of 10 even though it contains no &amp;quot;check-sat&amp;quot; command:&lt;br /&gt;
&lt;br /&gt;
 (set-logic QF_UF)&lt;br /&gt;
 (set-info :status sat)&lt;br /&gt;
 (exit)&lt;br /&gt;
&lt;br /&gt;
Without the &amp;quot;set-info,&amp;quot; it would have returned an exit code of 0.&lt;br /&gt;
&lt;br /&gt;
=CVC4's native input language=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The native input language consists of a sequence of symbol declarations and commands, each followed by a semicolon (&amp;lt;code&amp;gt;;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Any text after the first occurrence of a percent character and to the end of the current line is a comment:&lt;br /&gt;
&lt;br /&gt;
 %%% This is a native language comment&lt;br /&gt;
&lt;br /&gt;
== Type System ==&lt;br /&gt;
&lt;br /&gt;
CVC4's type system includes a set of built-in types which can be expanded with additional user-defined types.&lt;br /&gt;
&lt;br /&gt;
The type system consists of ''first-order'' types, ''subtypes'' of first-order types, and ''higher-order'' types,  all of which are interpreted as sets. &lt;br /&gt;
For convenience, we will sometimes identify below the interpretation of a type with the type itself.&lt;br /&gt;
&lt;br /&gt;
First-order types consist of basic types and structured types. The basic types are &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, as well as user-defined basic types (also called uninterpreted types). &lt;br /&gt;
The structured types are array, tuple, record types, and ML-style user-defined (inductive) datatypes.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Currently, subtypes consist only of the built-in subtype &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;!-- and are covered in the [[#Subtypes|Subtypes]] section. --&amp;gt;&lt;br /&gt;
Support for CVC3-style user-defined subtypes will be added in a later release.&lt;br /&gt;
&lt;br /&gt;
Function types are the only higher-order types.&lt;br /&gt;
More precisely, they are just second-order types &lt;br /&gt;
since function symbols in CVC4, both built-in and user-defined, can take as argument or return only values of &lt;br /&gt;
a first-order type.&lt;br /&gt;
&lt;br /&gt;
=== Basic Types ===&lt;br /&gt;
&lt;br /&gt;
==== The BOOLEAN Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; type is interpreted as the two-element set of Boolean values&lt;br /&gt;
&amp;lt;math&amp;gt;\{\mathrm{TRUE},\; \mathrm{FALSE}\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' CVC4's treatment of this type differs from CVC3's where &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; is used only as the type of formulas, but not as value type. CVC3 follows the two-tiered structure of classical first-order logic &lt;br /&gt;
which distinguishes between formulas and terms, and allows terms to occur in formulas but not vice versa (with the exception of the IF-THEN-ELSE construct).&lt;br /&gt;
CVC4 drops the distinction between terms and formulas and defines the latter just as terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. As such, formulas can occur as subterms of possibly non-Boolean terms.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 [To do]&lt;br /&gt;
&lt;br /&gt;
==== The REAL Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; type is interpreted as the set of real numbers.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical reals,&lt;br /&gt;
not the floating point numbers.&lt;br /&gt;
Support for floating point types is planned for future versions.&lt;br /&gt;
&lt;br /&gt;
 x, y : REAL;&lt;br /&gt;
 QUERY (( x &amp;lt;= y ) AND ( y &amp;lt;= x )) =&amp;gt; ( x = y );&lt;br /&gt;
&lt;br /&gt;
==== The INT Type ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;math&amp;gt;\mathrm{INT}&amp;lt;/math&amp;gt; type is interpreted as the set of integer numbers&lt;br /&gt;
and is considered as a subtype of &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;.&lt;br /&gt;
The latter means in particular that it is possible to mix integer and real terms &lt;br /&gt;
in expressions without the need of an explicit ''upcasting'' operator.&lt;br /&gt;
&lt;br /&gt;
Note that these are the (infinite precision) mathematical integers,&lt;br /&gt;
not the finite precision machine integers used in most programming languages. &lt;br /&gt;
The latter are models by [[ #Bitvectors | bit vector ]] types.&lt;br /&gt;
&lt;br /&gt;
 x, y : INT;&lt;br /&gt;
 QUERY ((2 * x + 4 * y &amp;lt;= 1) AND ( y &amp;gt;= x)) =&amp;gt; (x &amp;lt;= 0);&lt;br /&gt;
 z : REAL;&lt;br /&gt;
 QUERY (2 * x + z &amp;lt;= 3.5) AND (z &amp;gt;= 1);&lt;br /&gt;
&lt;br /&gt;
==== Bit Vector Types ====&lt;br /&gt;
&lt;br /&gt;
For every positive integer &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, the type &amp;lt;math&amp;gt;\mathrm{BITVECTOR}(n)&amp;lt;/math&amp;gt; is interpreted as the set of all bit vectors of size &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
A rich set of bit vector operators is supported.&lt;br /&gt;
&lt;br /&gt;
==== User-defined Basic Types ====&lt;br /&gt;
&lt;br /&gt;
Users can define new basic types &lt;br /&gt;
(often referred to as ''uninterpreted'' types in the SMT literature).&lt;br /&gt;
Each such type is interpreted as a set of unspecified cardinality &lt;br /&gt;
but disjoint from any other type. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 Can we specify cardinalities? &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
User-defined basic types are created by declarations like the following:&lt;br /&gt;
&lt;br /&gt;
 % User declarations of basic types:&lt;br /&gt;
 &lt;br /&gt;
 MyBrandNewType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 Apples, Oranges: TYPE;&lt;br /&gt;
&lt;br /&gt;
=== Structured Types ===&lt;br /&gt;
&lt;br /&gt;
CVC4's structured types are divided in the following families. &lt;br /&gt;
&lt;br /&gt;
==== Array Types ====&lt;br /&gt;
&lt;br /&gt;
Array types are created by the mixfix type constructors &amp;lt;math&amp;gt;\mathrm{ARRAY}\ \_\ \mathrm{OF}\ \_&amp;lt;/math&amp;gt; &lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 I : TYPE;&lt;br /&gt;
 &lt;br /&gt;
 %% Array types:&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with indices from I and values from REAL&lt;br /&gt;
 Array1: TYPE = ARRAY I OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer indices and array values &lt;br /&gt;
 Array2: TYPE = ARRAY INT OF (ARRAY INT OF REAL);&lt;br /&gt;
 &lt;br /&gt;
 % Arrays with integer pair indices and integer values&lt;br /&gt;
 IntMatrix: TYPE = ARRAY [INT, INT] OF INT;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
An array type of the form &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1\ \mathrm{OF}\ T_2&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the set of all total maps from &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;. &lt;br /&gt;
The main difference with the function type &amp;lt;math&amp;gt;T_1 \to T_2&amp;lt;/math&amp;gt; is that arrays, &lt;br /&gt;
contrary to functions, are first-class objects of the language, that is, values of an array&lt;br /&gt;
type can be arguments or results of functions. &lt;br /&gt;
Furthermore, array types come equipped with an update operation.&lt;br /&gt;
&lt;br /&gt;
==== Tuple Types ====&lt;br /&gt;
&lt;br /&gt;
Tuple types are created by the mixfix type constructors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l} [\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ ] \\[1ex] [\ \_\ ,\ \_\ \ ,\ \_\ ] \\[1ex] \ldots \end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
whose arguments can be instantiated by any value type.&lt;br /&gt;
&lt;br /&gt;
 IntArray: TYPE = ARRAY INT OF INT;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple type declarations&lt;br /&gt;
 &lt;br /&gt;
 RealPair: TYPE = [REAL, REAL]&lt;br /&gt;
 &lt;br /&gt;
 MyTuple: TYPE = [ REAL, IntArray, [INT, INT] ];&lt;br /&gt;
&lt;br /&gt;
A tuple type of the form &amp;lt;math&amp;gt;[T_1, \ldots, T_n]&amp;lt;/math&amp;gt; is interpreted &lt;br /&gt;
as the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Note that while the types &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and &lt;br /&gt;
&amp;lt;math&amp;gt;[T_1 \times \cdots \times T_n] \to T&amp;lt;/math&amp;gt; are semantically equivalent, &lt;br /&gt;
they are operationally different in CVC4. &lt;br /&gt;
The first is the type of functions that take &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; arguments &lt;br /&gt;
of respective type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\ldots&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T_n&amp;lt;/math&amp;gt;, &lt;br /&gt;
while the second is the type of functions that take one argument of an &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;-tuple type.&lt;br /&gt;
&lt;br /&gt;
==== Record Types ====&lt;br /&gt;
&lt;br /&gt;
Similar to, but more general than tuple types, record types are created by type constructors of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
[\#\ l_1: \_\ ,\ \ldots\ ,\ l_n: \_\ \#]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;l_1,\ldots, l_n&amp;lt;/math&amp;gt; are field labels, &lt;br /&gt;
and the arguments can be instantiated with any first-order types.&lt;br /&gt;
&lt;br /&gt;
 MyType: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 % Record declaration&lt;br /&gt;
 &lt;br /&gt;
 RecordType: TYPE = [# id: REAL, age: INT, info: MyType #];&lt;br /&gt;
&lt;br /&gt;
The order of the fields in a record type is meaningful: &lt;br /&gt;
permuting the field names gives a different type. &lt;br /&gt;
&lt;br /&gt;
Note that record types are non-recursive. &lt;br /&gt;
For instance, it is not possible to declare a record type called &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt; containing &lt;br /&gt;
a field of type &amp;lt;code&amp;gt;Person&amp;lt;/code&amp;gt;. &lt;br /&gt;
Recursive types are provided in CVC4 by the more general inductive data types.&lt;br /&gt;
(As a matter of fact, both record and tuple types are implemented internally as inductive data types.)&lt;br /&gt;
&lt;br /&gt;
==== Inductive Data Types ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inductive data types in CVC4 are similar to inductive data types of functional languages.&lt;br /&gt;
They can be parametric or not.&lt;br /&gt;
&lt;br /&gt;
===== Non-Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Non-parametric data types are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE} \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
Such declarations define the data types &amp;lt;math&amp;gt;A_1, \ldots, A_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
For each data type &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; they introduce:&lt;br /&gt;
&lt;br /&gt;
* constructor symbols &amp;lt;math&amp;gt;cons&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;(T_1, \ldots, T_k) \to \mathit{type\_name}_i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* selector symbols &amp;lt;math&amp;gt;\mathit{sel}_j&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to T_j&amp;lt;/math&amp;gt;, and&lt;br /&gt;
* tester symbols &amp;lt;math&amp;gt;\mathit{is\_cons}&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathit{type\_name}_i \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that permitting more than one data type to be defined in the same declarations allows &lt;br /&gt;
the definition of mutually recursive types.&lt;br /&gt;
&lt;br /&gt;
 % simple enumeration type&lt;br /&gt;
 &lt;br /&gt;
 % implicitly defined are the testers: is_red, is_yellow and is_blue&lt;br /&gt;
 % (similarly for the other data types)&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   PrimaryColor = red | yellow | blue&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % infinite set of pairwise distinct values ..., v(-1), v(0), v(1), ...&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Id = v (id: INT)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % ML-style integer lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   IntList = nil | ins (head: INT, tail: IntList)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % AST for lamba calculus&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Term = var (index: INT)&lt;br /&gt;
        | apply (arg_1: Term, arg_2: Term)&lt;br /&gt;
        | lambda (arg: INT, body: Term)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Trees&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   Tree = tree (value: REAL, children: TreeList),&lt;br /&gt;
   TreeList = nil_tl&lt;br /&gt;
            | ins_tl (first_t1: Tree, rest_t1: TreeList)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
Constructor, selector and tester symbols defined for a data type have global scope. &lt;br /&gt;
So, for example, it is not possible for two different data types to use &lt;br /&gt;
the same name for a constructor.&lt;br /&gt;
&lt;br /&gt;
An inductive data type is interpreted as a term algebra constructed by the constructor symbols &lt;br /&gt;
over some sets of generators. &lt;br /&gt;
For example, the type &amp;lt;code&amp;gt;IntList&amp;lt;/code&amp;gt; defined above is interpreted as the set &lt;br /&gt;
of all terms constructed with &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ins&amp;lt;/code&amp;gt; over the integers.&lt;br /&gt;
&lt;br /&gt;
===== Parametric Data Types =====&lt;br /&gt;
&lt;br /&gt;
Parametric data types are infinite families of (non-parametric) data types &lt;br /&gt;
with each family parametrized by one or more type variables.&lt;br /&gt;
They are created by declarations of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\mathrm{DATATYPE}\ [X_1, \ldots, X_p] \\&lt;br /&gt;
\begin{array}{ccc} &lt;br /&gt;
 \ \ A_1 &amp;amp; = &amp;amp; C_{1,1} \mid C_{1,2} \mid \cdots \mid C_{1,m_1}, \\&lt;br /&gt;
 \ \ A_2 &amp;amp; = &amp;amp; C_{2,1} \mid C_{2,2} \mid \cdots \mid C_{2,m_2}, \\&lt;br /&gt;
 \ \ \vdots &amp;amp; = &amp;amp; \vdots \\&lt;br /&gt;
 \ \ A_n &amp;amp; = &amp;amp; C_{n,1} \mid C_{n,2} \mid \cdots \mid C_{n,m_n} \\&lt;br /&gt;
\end{array}&lt;br /&gt;
\\&lt;br /&gt;
\mathrm{END}; &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt; are type variables,&lt;br /&gt;
each &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt; is a type name parametrized by some of the variables &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
each &amp;lt;math&amp;gt;C_{ij}&amp;lt;/math&amp;gt; is either a constant symbol or an expression of the form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathit{cons}(\ \mathit{sel}_1: T_1,\ \ldots,\ \mathit{sel}_k: T_k\ )&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;T_1, \ldots, T_k&amp;lt;/math&amp;gt; are any first-order types, &lt;br /&gt;
possibly parametrized by &amp;lt;math&amp;gt;X_1, \ldots, X_p&amp;lt;/math&amp;gt;, including any &amp;lt;math&amp;gt;A_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 % Parametric pairs&lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Pair[X, Y] = pair (first: X, second: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 % Parametric lists&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 % Parametric trees using the list type above&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   Tree[X] = node (value: X, children: List[Tree[X]]),&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
The declarations above define infinitely many types of the form &lt;br /&gt;
Pair[S,T], List[T] and Tree[T] where S and T are first-order types.&lt;br /&gt;
Note that the identifier &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; above, for example, by itself does not denote a type.&lt;br /&gt;
In contrast, the terms &amp;lt;code&amp;gt;List[Real]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[List[Real]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;List[Tree[INT]]&amp;lt;/code&amp;gt;,&lt;br /&gt;
and so on do.&lt;br /&gt;
&lt;br /&gt;
===== Restriction to Inductive Types =====&lt;br /&gt;
&lt;br /&gt;
By adopting a term algebra semantics, CVC4 allows only ''inductive'' data types, &lt;br /&gt;
that is, data types whose values are essentially (labeled, ordered) finite trees. &lt;br /&gt;
Infinite structures such as streams or even finite but cyclic ones &lt;br /&gt;
such as circular lists are then excluded. &lt;br /&gt;
For instance, none of the following declarations define inductive data types, &lt;br /&gt;
and are rejected by CVC4:&lt;br /&gt;
&lt;br /&gt;
 DATATYPE&lt;br /&gt;
  IntStream = s (first:INT, rest: IntStream)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
  RationalTree = node1 (child: RationalTree)&lt;br /&gt;
               | node2 (left_child: RationalTree, right_child:RationalTree)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE&lt;br /&gt;
   T1 =  c1 (s1: T2),&lt;br /&gt;
   T2 =  c2 (s2: T1)&lt;br /&gt;
 END;&lt;br /&gt;
&lt;br /&gt;
In concrete, a declaration of &amp;lt;math&amp;gt;n \geq 1&amp;lt;/math&amp;gt; datatypes &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; will be rejected if for any one of the types &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;, it is impossible to build a finite term of that type using only the constructors of &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; and free constants of type other than &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Inductive data types are the only types where the user also chooses names for the built-in operations to:&lt;br /&gt;
&lt;br /&gt;
* construct a value of the type (with the constructors),&lt;br /&gt;
* extract components from a value (with the selectors), or&lt;br /&gt;
* check if a value was constructed with a certain constructor or not (with the testers).&lt;br /&gt;
&lt;br /&gt;
For all the other types, CVC4 provides predefined names for the built-in operations on the type.&lt;br /&gt;
&lt;br /&gt;
=== Function Types ===&lt;br /&gt;
&lt;br /&gt;
Function (&amp;lt;math&amp;gt;\to&amp;lt;/math&amp;gt;) types are created by the mixfix type constructors&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
\_ \to \_ \\[1ex] (\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] (\ \_\ ,\ \_\ ,\ \_\ ) \to \_ &lt;br /&gt;
\\[1ex] \ldots &lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
whose arguments can be instantiated by any first-order type.&lt;br /&gt;
&lt;br /&gt;
 % Function type declarations&lt;br /&gt;
 &lt;br /&gt;
 UnaryFunType: TYPE = INT -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 BinaryFunType: TYPE = (REAL, REAL) -&amp;gt; ARRAY REAL OF REAL;&lt;br /&gt;
 &lt;br /&gt;
 TernaryFunType: TYPE = (REAL, BITVECTOR(4), INT) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
A function type of the form &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; is interpreted as the set of all ''total'' functions from the Cartesian product &amp;lt;math&amp;gt;T_1 \times \cdots \times T_n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example above also shows how to introduce type names. &lt;br /&gt;
A name like &amp;lt;code&amp;gt;UnaryFunType&amp;lt;/code&amp;gt; above is just an abbreviation for the type &amp;lt;math&amp;gt;\mathrm{INT} \to \mathrm{REAL}&amp;lt;/math&amp;gt; and can be used interchangeably with it.&lt;br /&gt;
&lt;br /&gt;
In general, any type defined by a type expression &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; can be given a name with the declaration:&lt;br /&gt;
&lt;br /&gt;
 name : TYPE = E;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Type Checking ===&lt;br /&gt;
&lt;br /&gt;
In CVC4, formulas and terms are statically typed at the level of types &lt;br /&gt;
(as opposed to subtypes) according to the usual rules of first-order many-sorted logic,&lt;br /&gt;
with the main difference that formulas are just terms of type &amp;lt;math&amp;gt;BOOLEAN&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* each variable has one associated first-order type,&lt;br /&gt;
* each constant symbol has one or more associated first-order types,&lt;br /&gt;
* each function symbol has one or more associated function types,&lt;br /&gt;
* the type of a term consisting just of a variable is the type associated to that variable,&lt;br /&gt;
* the type of a term consisting just of a constant symbol is the type associated to that constant symbol,&lt;br /&gt;
* the term obtained by applying a function symbol &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; to the terms &amp;lt;math&amp;gt;t_1, \ldots, t_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;(T_1, \ldots, T_n) \to T&amp;lt;/math&amp;gt; and each &amp;lt;math&amp;gt;t_i&amp;lt;/math&amp;gt; has type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Attempting to enter an ill-typed term will result in an error.&lt;br /&gt;
&lt;br /&gt;
Another significant difference with standard many-sorted logic is that &lt;br /&gt;
some built-in symbols are parametrically polymorphic. &lt;br /&gt;
For instance, the function symbol for extracting the element of any array has &lt;br /&gt;
type &amp;lt;math&amp;gt;(\mathit{ARRAY}\ T_1\ \mathit{OF}\ T_2,\; T_1) \to T_2&amp;lt;/math&amp;gt; &lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1, T_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Type Ascription ====&lt;br /&gt;
&lt;br /&gt;
By the type inference rules above some terms might have more than one type.&lt;br /&gt;
This can happen with terms built with polymorphic data type constructors&lt;br /&gt;
that have more than one return type for the same input type.&lt;br /&gt;
In that case, a type ascription operator (&amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt;) must be applied &lt;br /&gt;
to the constructor to specify the intended return type.&lt;br /&gt;
&lt;br /&gt;
 DATATYPE [X]&lt;br /&gt;
   List[X] = nil | cons (head: X, tail: List[X])&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = cons(1, nil::List[REAL]);&lt;br /&gt;
 &lt;br /&gt;
 DATATYPE [X, Y]&lt;br /&gt;
   Union[X, Y] = left(val_l: X) | right(val_r: Y)&lt;br /&gt;
 END;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT y = left::Union[BOOLEAN, REAL](TRUE);&lt;br /&gt;
&lt;br /&gt;
The constant symbol &amp;lt;math&amp;gt;\mathrm{nil}&amp;lt;/math&amp;gt; declared above has infinitely many types &lt;br /&gt;
(&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{REAL}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{List}[\mathrm{BOOLEAN}]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[[\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{List}[\mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;, ...)&lt;br /&gt;
CVC4's type checker requires the user to indicate explicitly the type &lt;br /&gt;
of each occurrence of &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; in a term. &lt;br /&gt;
Similarly, &lt;br /&gt;
the injection operator &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; has infinitely many return types &lt;br /&gt;
for the same input type, for instance:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{REAL}]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, [\mathrm{REAL}, \mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{BOOLEAN} \to \mathrm{Union}[\mathrm{BOOLEAN}, \mathrm{List}[\mathrm{REAL}]]&amp;lt;/math&amp;gt;,&lt;br /&gt;
and so on.&lt;br /&gt;
Applications of &amp;lt;code&amp;gt;left&amp;lt;/code&amp;gt; need to specify the intended returned typed, as shown above.&lt;br /&gt;
&lt;br /&gt;
== Terms and Formulas ==&lt;br /&gt;
&lt;br /&gt;
In addition to type expressions, CVC4 has expressions for terms and for formulas &lt;br /&gt;
(i.e., terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;). &lt;br /&gt;
By and large, these are standard first-order terms built out of typed variables, &lt;br /&gt;
predefined theory-specific operators, free (i.e., user-defined) function symbols, &lt;br /&gt;
and quantifiers. &lt;br /&gt;
Extensions include an if-then-else operator, lambda abstractions, and local symbol &lt;br /&gt;
declarations, as illustrated below. &lt;br /&gt;
Note that these extensions still keep CVC4's language first-order. &lt;br /&gt;
In particular, lambda abstractions are restricted to take and return only terms of &lt;br /&gt;
a first-order type. &lt;br /&gt;
Similarly, variables can only be of a first-order type.&lt;br /&gt;
&lt;br /&gt;
A number of built-in function symbols (for instance, the arithmetic ones) are used &lt;br /&gt;
as infix operators. All user-defined symbols are used as prefix ones.&lt;br /&gt;
&lt;br /&gt;
User-defined, i.e., free, function symbols include ''constant symbols'' and &lt;br /&gt;
''predicate symbols'', respectively  nullary function symbols and function symbols &lt;br /&gt;
with a &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; return type. &lt;br /&gt;
These symbols are introduced with global declarations of the form &lt;br /&gt;
&amp;lt;math&amp;gt; f_1, \ldots, f_m: T;&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;f_i&amp;lt;/math&amp;gt; are the names of the symbols and &lt;br /&gt;
&amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is their type:&lt;br /&gt;
&lt;br /&gt;
 % integer constants&lt;br /&gt;
 &lt;br /&gt;
 a, b, c: INT;&lt;br /&gt;
 &lt;br /&gt;
 % real constants&lt;br /&gt;
 &lt;br /&gt;
 x, y, z: REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function&lt;br /&gt;
 &lt;br /&gt;
 f1: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % binary function&lt;br /&gt;
 &lt;br /&gt;
 f2: (REAL, INT) -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % unary function with a tuple argument&lt;br /&gt;
 &lt;br /&gt;
 f3: [INT, REAL] -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % binary predicate&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, REAL) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 % Propositional &amp;quot;variables&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 P, Q; BOOLEAN;&lt;br /&gt;
&lt;br /&gt;
Like type declarations, function symbol declarations like the above have global scope &lt;br /&gt;
and must be unique. &lt;br /&gt;
In other words, it is not possible to declare a function symbol globally more than once&lt;br /&gt;
in the same lexical scope. &lt;br /&gt;
This entails among other things that globally-defined free symbols cannot be overloaded &lt;br /&gt;
with different types and that theory symbols cannot be redeclared globally as free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Global symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
As with types, a function symbol can be defined as the name of another term &lt;br /&gt;
of the corresponding type. &lt;br /&gt;
With constant symbols, this is done with a declaration of the form &amp;lt;math&amp;gt;f:T = t;&amp;lt;/math&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
 c: INT;&lt;br /&gt;
 &lt;br /&gt;
 i: INT = 5 + 3*c;  % i is effectively a shorthand for 5 + 3*c&lt;br /&gt;
 &lt;br /&gt;
 j: REAL = 3/4;&lt;br /&gt;
 &lt;br /&gt;
 t: [REAL, INT] = (2/3, -4);&lt;br /&gt;
 &lt;br /&gt;
 r: [# key: INT, value: REAL #] = (# key := 4, value := (c + 1)/2 #);&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN = FORALL (x:INT): x &amp;lt;= 0 OR x &amp;gt; c ;&lt;br /&gt;
&lt;br /&gt;
A restriction on constants of type &amp;lt;math&amp;gt;\mathit{BOOLEAN}&amp;lt;/math&amp;gt; is that their value &lt;br /&gt;
can only be a closed formula, that is, a formula with no free variables.&lt;br /&gt;
&lt;br /&gt;
A term and its name can be used interchangeably in later expressions. &lt;br /&gt;
Named terms are often useful for shared subterms (terms used several times in different places) &lt;br /&gt;
since their use can make the input exponentially more concise. &lt;br /&gt;
Named terms are processed very efficiently by CVC4. &lt;br /&gt;
It is much more efficient to associate a complex term with a name directly rather than &lt;br /&gt;
to declare a constant and later assert that it is equal to the same term. &lt;br /&gt;
This point is explained in more detail later in section [[Commands | Commands]].&lt;br /&gt;
&lt;br /&gt;
More generally, in CVC4 one can associate a term to function symbols of any arity. &lt;br /&gt;
For non-constant function symbols this is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;f:(T_1, \ldots, T_n) \to T = \mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t\;;&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is any term of type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; with free variables &lt;br /&gt;
in &amp;lt;math&amp;gt;\{x_1, \ldots, x_n\}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The lambda binder has the usual semantics and conforms to the usual lexical scoping rules: &lt;br /&gt;
within the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; the declaration of the symbols &amp;lt;math&amp;gt;x_1, \ldots, x_n&amp;lt;/math&amp;gt; &lt;br /&gt;
as local variables of respective type &amp;lt;math&amp;gt;T_1, \ldots, T_n&amp;lt;/math&amp;gt; hides any previous&lt;br /&gt;
declarations of those symbols that are in scope.&lt;br /&gt;
&lt;br /&gt;
As a general shorthand, when &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; consecutive types &lt;br /&gt;
&amp;lt;math&amp;gt;T_i, \ldots, T_{i+k-1}&amp;lt;/math&amp;gt;  in the lambda expression &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x:T_n): t&amp;lt;/math&amp;gt; are identical, the syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{LAMBDA}(x_1:T_1, \ldots, x_i,\ldots, x_{i+k-1}:T_i,\ldots, x:T_n): t&amp;lt;/math&amp;gt;&lt;br /&gt;
can also be used.&lt;br /&gt;
&lt;br /&gt;
 % Global declaration of x as a unary function symbol&lt;br /&gt;
 &lt;br /&gt;
 x: REAL -&amp;gt; REAL;&lt;br /&gt;
 &lt;br /&gt;
 % Local declarations of x as variable (hiding the global one)&lt;br /&gt;
 &lt;br /&gt;
 f: REAL -&amp;gt; REAL = LAMBDA (x: REAL): 2*x + 3;&lt;br /&gt;
 &lt;br /&gt;
 p: (INT, INT) -&amp;gt; BOOLEAN = LAMBDA (x,i: INT): i*x - 1 &amp;gt; 0;&lt;br /&gt;
 &lt;br /&gt;
 g: (REAL, INT) -&amp;gt; [REAL, INT] = LAMBDA (x: REAL, i:INT): (x + 1, i - 3);&lt;br /&gt;
&lt;br /&gt;
Note that lambda definitions are not recursive: &lt;br /&gt;
the symbol being defined cannot occur in the body of the lambda term.&lt;br /&gt;
They should be understood as macros.&lt;br /&gt;
For instance, any occurrence of the term &amp;lt;math&amp;gt;f(t)&amp;lt;/math&amp;gt; &lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is as defined above will be treated &lt;br /&gt;
as if it was the term &amp;lt;math&amp;gt;(2*t + 3)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local symbol definitions ===&lt;br /&gt;
&lt;br /&gt;
Constant and function symbols can also be declared locally anywhere within a term &lt;br /&gt;
by means of a let binder. &lt;br /&gt;
This is done with a declaration of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f = t \ \mathrm{IN}\ t' ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is a term with no free variables, possibly a lambda term.&lt;br /&gt;
Let binders can be nested arbitrarily and follow the usual lexical scoping rules.&lt;br /&gt;
The following general form&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1, f_2 = t_2, \ldots, f_n = t_m \ \mathrm{IN}\ t ; &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
can be use above can used as a shorthand for&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \mathrm{LET}\ f_1 = t_1\ \mathrm{IN}\ &lt;br /&gt;
 \mathrm{LET}\ f_2 = t_2\ \mathrm{IN}\ &lt;br /&gt;
 \ldots \ &lt;br /&gt;
 \mathrm{LET}\ f_n = t_m \ \mathrm{IN}\ t ;&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL =&lt;br /&gt;
   LET x1 = 42,&lt;br /&gt;
       g = LAMBDA(x:INT): x + 1,&lt;br /&gt;
       x2 = 2*x1 + 7/2&lt;br /&gt;
   IN&lt;br /&gt;
      (LET x3 = g(x1) IN x3 + x2) / x1;&lt;br /&gt;
&lt;br /&gt;
Note that the same symbol = is used, unambiguously, in the syntax of global declarations, &lt;br /&gt;
let declarations, and as a predicate symbol.&lt;br /&gt;
&lt;br /&gt;
'''Note:'''&lt;br /&gt;
A &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; term with a multiple symbols defines them sequentially.&lt;br /&gt;
A parallel version of the &amp;lt;math&amp;gt;\mathrm{LET}&amp;lt;/math&amp;gt; construct will be introduced in a later version.&lt;br /&gt;
&lt;br /&gt;
== Built-in theories and their symbols ==&lt;br /&gt;
&lt;br /&gt;
In addition to user-defined symbols, CVC4 terms can use a number of predefined symbols: &lt;br /&gt;
the logical symbols, such as &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, etc., &lt;br /&gt;
as well as theory symbols, function symbols belonging to one of the built-in theories. &lt;br /&gt;
They are described next, with the theory symbols grouped by theory.&lt;br /&gt;
&lt;br /&gt;
=== Logical Symbols ===&lt;br /&gt;
&lt;br /&gt;
The logical symbols in CVC4's language include &lt;br /&gt;
the equality and disequality predicate symbols, respectively written as = and /=, &lt;br /&gt;
the multiarity disequality symbol &amp;lt;math&amp;gt;\mathrm{DISTINCT}&amp;lt;/math&amp;gt;, &lt;br /&gt;
together with the logical constants &amp;lt;math&amp;gt;\mathrm{TRUE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{FALSE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
the connectives &amp;lt;math&amp;gt;\mathrm{NOT}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{AND}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{OR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{XOR}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Rightarrow&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\Leftrightarrow&amp;lt;/math&amp;gt;, and &lt;br /&gt;
the first-order quantifiers &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt;, &lt;br /&gt;
all with the standard many-sorted logic semantics.&lt;br /&gt;
&lt;br /&gt;
The binary connectives have infix syntax and type &lt;br /&gt;
&amp;lt;math&amp;gt;(\mathrm{BOOLEAN},\mathrm{BOOLEAN}) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt;. &lt;br /&gt;
The symbols = and /=, which are also infix, are instead parametrically polymorphic, &lt;br /&gt;
having type &amp;lt;math&amp;gt;(T,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
They are interpreted respectively as the identity relation and its complement.&lt;br /&gt;
&lt;br /&gt;
The DISTINCT symbol is both overloaded and polymorphic. &lt;br /&gt;
It has type &amp;lt;math&amp;gt;(T,...,T) \to \mathrm{BOOLEAN}&amp;lt;/math&amp;gt; &lt;br /&gt;
for every sequence &amp;lt;math&amp;gt;(T,...,T)&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt; &lt;br /&gt;
and first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
For each &amp;lt;math&amp;gt;n &amp;gt; 0&amp;lt;/math&amp;gt;, it is interpreted as the relation &lt;br /&gt;
that holds exactly for tuples of pairwise distinct elements.&lt;br /&gt;
&lt;br /&gt;
The syntax for quantifiers is similar to that of the lambda binder.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a formula built just of these logical symbols and variables:&lt;br /&gt;
&lt;br /&gt;
 A, B: TYPE;&lt;br /&gt;
 &lt;br /&gt;
 q: BOOLEAN = FORALL (x,y: A, i,j,k: B): &lt;br /&gt;
                i = j AND i /= k =&amp;gt; EXISTS (z: A): x /= z OR z /= y;&lt;br /&gt;
&lt;br /&gt;
Binding and scoping of quantified variables follows the same rules as &lt;br /&gt;
in let expressions. &lt;br /&gt;
In particular, a quantifier will shadow in its scope any constant and function symbols&lt;br /&gt;
with the same name as one of the variables it quantifies:&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 i, j: INT;&lt;br /&gt;
 &lt;br /&gt;
 % The first occurrence of i and of j in f are constant symbols,&lt;br /&gt;
 % the others are variables.&lt;br /&gt;
 &lt;br /&gt;
 f: BOOLEAN =  i = j AND FORALL (i,j: A): i = j OR i /= j;&lt;br /&gt;
&lt;br /&gt;
Optionally, it is also possible to specify instantiation patterns &lt;br /&gt;
for quantified variables. &lt;br /&gt;
The general syntax for a quantified formula &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; with patterns is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
Q\;(x_1:T_1, \ldots, x_k:T_k):\; p_1: \ldots\; p_n:\; \varphi&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is &lt;br /&gt;
either &amp;lt;math&amp;gt;\mathrm{FORALL}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\mathrm{EXISTS}&amp;lt;/math&amp;gt;, &lt;br /&gt;
&amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;, &lt;br /&gt;
and each of the &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;'s, &lt;br /&gt;
a pattern for the quantifier &amp;lt;math&amp;gt;Q\;(x_1:T_1, \ldots, x_k:T_k)&amp;lt;/math&amp;gt;, has the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{PATTERN}\; (t_1, \ldots, t_m)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;m &amp;gt; 0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t_1, \ldots, t_m&amp;lt;/math&amp;gt; are &lt;br /&gt;
arbitrary binder-free terms (no lets, no quantifiers). &lt;br /&gt;
Those terms can contain (free) variables, typically, but not exclusively, &lt;br /&gt;
drawn from &amp;lt;math&amp;gt;x_1, \ldots, x_k&amp;lt;/math&amp;gt;. &lt;br /&gt;
(Additional variables can occur if &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; occurs in a bigger formula &lt;br /&gt;
binding those variables.)&lt;br /&gt;
&lt;br /&gt;
 A: TYPE;&lt;br /&gt;
 b, c: A;&lt;br /&gt;
 p, q: A -&amp;gt; BOOLEAN;&lt;br /&gt;
 r: (A, A) -&amp;gt; BOOLEAN;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x0, x1, x2: A):&lt;br /&gt;
          PATTERN (r(x0, x1), r(x1, x2)): &lt;br /&gt;
          (r(x0, x1) AND r(x1, x2)) =&amp;gt; r(x0, x2) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT FORALL (x: A):&lt;br /&gt;
          PATTERN (r(x, b)): &lt;br /&gt;
          PATTERN (r(x, c)): &lt;br /&gt;
          p(x) =&amp;gt; q(x) ;&lt;br /&gt;
 &lt;br /&gt;
 ASSERT EXISTS (y: A):&lt;br /&gt;
          FORALL (x: A):&lt;br /&gt;
            PATTERN (r(x, y), p(y)): &lt;br /&gt;
            r(x, y) =&amp;gt; q(x) ;&lt;br /&gt;
&lt;br /&gt;
Patterns have no logical meaning: &lt;br /&gt;
adding them to a formula does not change its semantics. &lt;br /&gt;
Their purpose is purely operational, as explained in &lt;br /&gt;
the [[#Instantiation Patterns | Instantiation Patterns]] section.&lt;br /&gt;
&lt;br /&gt;
In addition to these constructs, CVC4 also has a general mixfix conditional operator &lt;br /&gt;
of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathrm{IF}\ b\ \mathrm{THEN}\ t\ \mathrm{ELSIF}\ b_1\ \mathrm{THEN}\ t_1\ \ldots\ \mathrm{ELSIF}\ b_n\ \mathrm{THEN}\ t_n\ \mathrm{ELSE}\ t_{n+1}\ \mathrm{ENDIF}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &amp;lt;math&amp;gt;n \geq 0&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;math&amp;gt;b, b_1, \ldots, b_n&amp;lt;/math&amp;gt; are terms of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt; and&lt;br /&gt;
&amp;lt;math&amp;gt;t, t_1, \ldots, t_n, t_{n+1}&amp;lt;/math&amp;gt; are terms of the same first-order type &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 % Conditional term&lt;br /&gt;
 x, y, z, w: REAL;&lt;br /&gt;
 &lt;br /&gt;
 t: REAL = &lt;br /&gt;
   IF x &amp;gt; 0 THEN y&lt;br /&gt;
   ELSIF x &amp;gt;= 1 THEN z&lt;br /&gt;
   ELSIF x &amp;gt; 2 THEN w&lt;br /&gt;
   ELSE 2/3 ENDIF;&lt;br /&gt;
&lt;br /&gt;
=== User-defined Functions and Types ===&lt;br /&gt;
&lt;br /&gt;
The theory of user-defined functions,also know in the SMT literature as &lt;br /&gt;
the theory ''Equality over Uninterpreted Functions'', or ''EUF'', is in effect &lt;br /&gt;
a family of theories of equality parametrized by the basic types and the free symbols &lt;br /&gt;
a user can define during a run of CVC4.&lt;br /&gt;
&lt;br /&gt;
This theory has no built-in symbols (other than the logical ones).&lt;br /&gt;
Its types consist of ''all and only'' the user-defined types.&lt;br /&gt;
Its function symbols consist of ''all and only'' the user-defined free symbols.&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
The real arithmetic theory has two types:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{INTEGER}&amp;lt;/math&amp;gt;&lt;br /&gt;
with the latter a subtype of the first.&lt;br /&gt;
Its built-in symbols for the usual arithmetic constants &lt;br /&gt;
and operators over the type &amp;lt;math&amp;gt;\mathrm{REAL}&amp;lt;/math&amp;gt;, each with the expected type: &lt;br /&gt;
all numerals 0, 1, ..., as well as - (both unary and binary), +, *, /, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=. &lt;br /&gt;
Application of the binary symbols are in infix form.&lt;br /&gt;
Note that + is only binary, so a terms such as &amp;lt;math&amp;gt;{+}1&amp;lt;/math&amp;gt; is ill-formed.&lt;br /&gt;
&lt;br /&gt;
Rational values can be expressed in decimal or fractional format: &lt;br /&gt;
e.g., 0.1, 23.243241, 1/2, 3/4, and so on.&lt;br /&gt;
A leading 0 is mandatory for decimal numbers smaller than one &lt;br /&gt;
(e.g., the syntax .3 is cannot be used as a shorthand for 0.3).&lt;br /&gt;
However, a trailing 0 is ''not'' required for decimals that are whole numbers&lt;br /&gt;
(e.g., 3. is allowed as a shorthand for 3.0).&lt;br /&gt;
The size of the numerals used in the representation of natural and rational numbers &lt;br /&gt;
is unbounded; more accurately, bounded only by the amount of available memory.&lt;br /&gt;
&lt;br /&gt;
=== Bit vectors ===&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
The theory of arrays is a parametric theory of (total) unary maps. &lt;br /&gt;
It comes equipped with mixfix polymorphic selection and update operators, respectively&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\_[\_]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_&amp;lt;/math&amp;gt; .&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
The semantics of these operators is the expected one:&lt;br /&gt;
for all first-order types &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;\mathrm{ARRAY}\ T_1 \mathrm{OF}\ T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, and&lt;br /&gt;
&amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is of type &amp;lt;math&amp;gt;T_2&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a[i]&amp;lt;/math&amp;gt; denotes the value that &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; associates to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;,&lt;br /&gt;
* &amp;lt;math&amp;gt;a\ \mathrm{WITH}\ [i]\ := v&amp;lt;/math&amp;gt; denotes a map that associates &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to index &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and is otherwise identical to &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;.&lt;br /&gt;
Sequential updates can be chained with the shorthand syntax &lt;br /&gt;
&amp;lt;math&amp;gt;\_\ \mathrm{WITH}\ [\_]\ := \_, \ldots, [\_]\ := \_&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 A: TYPE = ARRAY INT OF REAL;&lt;br /&gt;
 a: A;&lt;br /&gt;
 i: INT = 4;&lt;br /&gt;
 &lt;br /&gt;
 % selection:&lt;br /&gt;
 &lt;br /&gt;
 elem: REAL = a[i];&lt;br /&gt;
 &lt;br /&gt;
 % update&lt;br /&gt;
 &lt;br /&gt;
 a1: A = a WITH [10] := 1/2;&lt;br /&gt;
 &lt;br /&gt;
 % sequential update &lt;br /&gt;
 % (syntactic sugar for (a WITH [10] := 2/3) WITH [42] := 3/2)&lt;br /&gt;
 &lt;br /&gt;
 a2: A = a WITH [10] := 2/3, [42] := 3/2;&lt;br /&gt;
&lt;br /&gt;
Since arrays are just maps, equality between them is extensional, that is, &lt;br /&gt;
for two arrays of the same type to be different they have to map at least one&lt;br /&gt;
index to differ values.&lt;br /&gt;
&lt;br /&gt;
=== Data types ===&lt;br /&gt;
&lt;br /&gt;
The theory of inductive data types is in fact a family of theories parametrized &lt;br /&gt;
by a data type declaration specifying constructors and selectors &lt;br /&gt;
for one or more user-defined data types.&lt;br /&gt;
&lt;br /&gt;
No built-in operators other than equality and disequality are provided &lt;br /&gt;
for this family in the native language. &lt;br /&gt;
Each user-provided data type declaration, however, generates constructor, selector and tester operators &lt;br /&gt;
as described in the [[#Inductive Data Types | Inductive Data Types]] section.&lt;br /&gt;
&lt;br /&gt;
=== Tuples and Records ===&lt;br /&gt;
&lt;br /&gt;
Semantically both records and tuples can be seen as special instances &lt;br /&gt;
of inductive data types.&lt;br /&gt;
CVC4 implements them internally indeed as data types.&lt;br /&gt;
In essence, a record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt;&lt;br /&gt;
is encoded as a data type of the form&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{array}{l}&lt;br /&gt;
 \mathrm{DATATYPE} \\&lt;br /&gt;
 \ \ \mathrm{Record} = \mathit{rec}(l_0:T_0, \ldots, l_n:T_n) \\&lt;br /&gt;
 \mathrm{END};&lt;br /&gt;
\end{array}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tuples of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; are in turn special cases of records whose field names are &lt;br /&gt;
the numerals from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Externally, tuples and records have their own syntax for constructor and selector operators.&lt;br /&gt;
* Records of type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; have the associated  record constructor &amp;lt;math&amp;gt;(\#\ l_0 := \_,\; \ldots,\; l_n := \_\ \#)&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
* Tuples of type &amp;lt;math&amp;gt;[\ T_0, \ldots, T_n\ ]&amp;lt;/math&amp;gt; have the associated tuple constructor &amp;lt;math&amp;gt;(\ \_,\; \ldots,\; \_\ )&amp;lt;/math&amp;gt; whose arguments must be terms of type &amp;lt;math&amp;gt;T_0, \ldots, T_n&amp;lt;/math&amp;gt;, respectively.&lt;br /&gt;
&lt;br /&gt;
The selector operators on records and tuples follows a dot notation syntax.&lt;br /&gt;
&lt;br /&gt;
 % Record construction and field selection&lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x: Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 k: INT = x.key;&lt;br /&gt;
 v: REAL = x.weight;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple construction and projection&lt;br /&gt;
 y: [REAL, INT, REAL] = ( 4/5, 9, 11/9 );&lt;br /&gt;
 first_elem: REAL = y.0;&lt;br /&gt;
 third_elem: REAL = y.2;&lt;br /&gt;
&lt;br /&gt;
Differently from data types, records and tuples are also provided with built-in update operators similar in syntax and semantics to the update operator for arrays. &lt;br /&gt;
More precisely, for each record type &amp;lt;math&amp;gt;[\#\ l_0:T_0, \ldots, l_n:T_n\ \#]&amp;lt;/math&amp;gt; and&lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\_\ \mathrm{WITH}\ .l_i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The operator maps a record &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt; of that type and a value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; &lt;br /&gt;
of type &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; to the record that stores &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in field &amp;lt;math&amp;gt;l_i&amp;lt;/math&amp;gt; &lt;br /&gt;
and is otherwise identical to &amp;lt;math&amp;gt;r&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, for each tuple type &amp;lt;math&amp;gt;[T_0, \ldots, T_n]&amp;lt;/math&amp;gt; and &lt;br /&gt;
each &amp;lt;math&amp;gt;i=0, \ldots, n&amp;lt;/math&amp;gt;, CVC4 provides the operator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
 \_\ \mathrm{WITH}\ .i\ := \_&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with similar semantics.&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = x WITH .weight := 48;&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = y WITH .1 := 3; &lt;br /&gt;
 &lt;br /&gt;
 Updates to a nested component can be combined in a single WITH operator:&lt;br /&gt;
 &lt;br /&gt;
 Cache: TYPE = ARRAY [0..100] OF [# addr: INT, data: REAL #];&lt;br /&gt;
 State: TYPE = [# pc: INT, cache: Cache #];&lt;br /&gt;
 &lt;br /&gt;
 s0: State;&lt;br /&gt;
 s1: State = s0 WITH .cache[10].data := 2/3;&lt;br /&gt;
&lt;br /&gt;
Note that, differently from updates on arrays, tuple and record updates are &lt;br /&gt;
just additional syntactic sugar. &lt;br /&gt;
For instance, the record &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; and tuple &amp;lt;code&amp;gt;y1&amp;lt;/code&amp;gt; defined above &lt;br /&gt;
could have been equivalently defined as follows:&lt;br /&gt;
&lt;br /&gt;
 % Record updates&lt;br /&gt;
 &lt;br /&gt;
 Item: TYPE = [# key: INT, weight: REAL #];&lt;br /&gt;
 &lt;br /&gt;
 x:  Item = (# key := 23, weight := 43/10 #);&lt;br /&gt;
 &lt;br /&gt;
 x1: Item = (# key := x.key,  weight := 48 #);&lt;br /&gt;
 &lt;br /&gt;
 % Tuple updates&lt;br /&gt;
 &lt;br /&gt;
 Tup: TYPE = [REAL,INT,REAL];&lt;br /&gt;
 y:  Tup = ( 4/5, 9, 11/9 );&lt;br /&gt;
 y1: Tup = ( y.0, 3, y.1 );&lt;br /&gt;
&lt;br /&gt;
== Commands ==&lt;br /&gt;
&lt;br /&gt;
In addition to declarations of types and function symbols, &lt;br /&gt;
the CVC4 native language contains the following commands:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ASSERT}\ F&amp;lt;/math&amp;gt; -- Add the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; to the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
* [[#CHECKSAT|&amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is satisfiable in the current logical context (&amp;lt;math&amp;gt;\Gamma \not\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{CONTINUE}&amp;lt;/math&amp;gt; -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, search for a counter-example different from the current one.&lt;br /&gt;
* [[#COUNTEREXAMPLE|&amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print the context that is a witness for invalidity/satisfiability.&lt;br /&gt;
* [[#COUNTERMODEL|&amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, print a model that makes the formula invalid/satisfiable. The model is provided in terms of concrete values for each free symbol.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{OPTION}\ o\ v&amp;lt;/math&amp;gt; -- Set the command-line option flag &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. The argument &amp;lt;math&amp;gt;o&amp;lt;/math&amp;gt; is provide as a string literal enclosed in double-quotes and &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as an integer value.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; -- Equivalent to &amp;lt;math&amp;gt;\mathrm{POPTO}\ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
* [[#POPTO|&amp;lt;math&amp;gt;\mathrm{POPTO}\ n&amp;lt;/math&amp;gt;]] -- Restore the system to the state it was in right before the most recent call to &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; made from stack level &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. Note that the current stack level is printed as part of the output of the &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; command.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; -- Save (checkpoint) the current state of the system.&lt;br /&gt;
* [[#QUERY|&amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt;]] -- Check if the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; is valid in the current logical context (&amp;lt;math&amp;gt;\Gamma\models_T F&amp;lt;/math&amp;gt;).&lt;br /&gt;
* [[#RESTART|&amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt;]] -- After an invalid &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; or satisfiable &amp;lt;math&amp;gt;\mathrm{CHECKSAT}&amp;lt;/math&amp;gt;, repeat the check but with the additional assumption &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; in the context.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{PRINT}\ t&amp;lt;/math&amp;gt; -- Parse and print back the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRANSFORM}\ t&amp;lt;/math&amp;gt; -- Simplify the term &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and print the result.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt; -- Print all the formulas in the current logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The remaining commands take a single argument, given as a string literal enclosed in double-quotes.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{ECHO}\ s&amp;lt;/math&amp;gt; -- Print string &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{INCLUDE}\ f&amp;lt;/math&amp;gt; -- Read commands from file &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{TRACE}\ f&amp;lt;/math&amp;gt; -- Turn on tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
* &amp;lt;math&amp;gt;\mathrm{UNTRACE}\ f&amp;lt;/math&amp;gt; -- Turn off tracing for the debug flag &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, we explain some of the above commands in more detail.&lt;br /&gt;
&lt;br /&gt;
=== QUERY ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; invokes the core functionality of CVC4 to check &lt;br /&gt;
the validity of the formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; with respect to the assertions made thus far,&lt;br /&gt;
which constitute the context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;. &lt;br /&gt;
The argument &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; must be well typed term of type &amp;lt;math&amp;gt;\mathrm{BOOLEAN}&amp;lt;/math&amp;gt;,&lt;br /&gt;
as described in [[#Terms and Formulas | Terms and Formulas]].&lt;br /&gt;
&lt;br /&gt;
The execution of this command always terminates and produces one of three possible answers: &lt;br /&gt;
&amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* A &amp;lt;code&amp;gt;valid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;. After a query returning such an answer, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is exactly as it was before the query.&lt;br /&gt;
* An &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer indicates that &amp;lt;math&amp;gt;\Gamma \not\models_T F&amp;lt;/math&amp;gt;, that is, there is a model of the background theory &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Gamma \cup \{\mathrm{NOT}\ F\}&amp;lt;/math&amp;gt;. When &amp;lt;math&amp;gt;\mathrm{QUERY}\ F&amp;lt;/math&amp;gt; returns &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt;, the logical context &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; is augmented with a set &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; of ground (i.e., variable-free) literals such that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;\Gamma\cup\Delta\models_T \mathrm{NOT}\ F&amp;lt;/math&amp;gt;. In fact, in this case &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; ''propositionally entails'' &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;, in the sense that, every truth assignment to the literals of &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; that satisfies &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt; falsifies &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;. We call the new context &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; a ''counterexample'' for &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
* An &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; answer is similar to an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; answer in that additional literals are added to the context which propositionally entail &amp;lt;math&amp;gt;\mathrm{NOT}\ F&amp;lt;/math&amp;gt;. The difference in this case is that CVC4 cannot guarantee that &amp;lt;math&amp;gt;\Gamma\cup\Delta&amp;lt;/math&amp;gt; is actually satisfiable in &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
CVC4 may report &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt; when the context or the query contains&lt;br /&gt;
non-linear arithmetic terms or quantifiers.&lt;br /&gt;
In all other cases, it is expected to be sound and complete, &lt;br /&gt;
i.e., to report &amp;lt;code&amp;gt;Valid&amp;lt;/code&amp;gt; if &amp;lt;math&amp;gt;\Gamma \models_T F&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;Invalid&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
After an &amp;lt;code&amp;gt;invalid&amp;lt;/code&amp;gt; (resp. &amp;lt;code&amp;gt;unknown&amp;lt;/code&amp;gt;) answer,&lt;br /&gt;
counterexamples (resp. possible counterexamples) can be obtained with &lt;br /&gt;
a &amp;lt;math&amp;gt;\mathrm{WHERE}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathrm{COUNTEREXAMPLE}&amp;lt;/math&amp;gt;, &lt;br /&gt;
or &amp;lt;math&amp;gt;\mathrm{COUNTERMODEL}&amp;lt;/math&amp;gt; command. &lt;br /&gt;
&amp;lt;!---&lt;br /&gt;
WHERE always prints out all of &amp;lt;math&amp;gt;\Gamma\cup C&amp;lt;/math&amp;gt;. COUNTEREXAMPLE may sometimes be more selective, printing a subset of those formulas from the context which are sufficient for a counterexample.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;math&amp;gt;\mathrm{QUERY}&amp;lt;/math&amp;gt; command may modify &lt;br /&gt;
the current context, if one needs to check several formulas in a row &lt;br /&gt;
in the same context, it is a good idea to surround every &lt;br /&gt;
query by a &amp;lt;math&amp;gt;\mathrm{PUSH}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathrm{POP}&amp;lt;/math&amp;gt; invocation&lt;br /&gt;
in order to preserve the context:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
&lt;br /&gt;
=== CHECKSAT ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{CHECKSAT}\ F&amp;lt;/math&amp;gt; behaves identically &lt;br /&gt;
to &amp;lt;math&amp;gt;\mathrm{QUERY}\ \mathrm{NOT}\ F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== RESTART ===&lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;math&amp;gt;\mathrm{RESTART}\ F&amp;lt;/math&amp;gt; can only be invoked after an invalid query. &lt;br /&gt;
For example, in an interactive setting:&lt;br /&gt;
&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 CVC4&amp;gt; invalid&lt;br /&gt;
 &lt;br /&gt;
 RESTART &amp;lt;formula2&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
Functionally, the behavior of the above command sequence is identical to the following:&lt;br /&gt;
&lt;br /&gt;
 PUSH;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
 POP;&lt;br /&gt;
 ASSERT &amp;lt;formula2&amp;gt;;&lt;br /&gt;
 QUERY &amp;lt;formula&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
The advantage of using the &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; command is that &lt;br /&gt;
the first command sequence may be executed much more efficiently that the second.&lt;br /&gt;
The reason is that with &amp;lt;math&amp;gt;\mathrm{RESTART}&amp;lt;/math&amp;gt; CVC4 will re-use&lt;br /&gt;
what it has learned while answering the previous query rather than starting &lt;br /&gt;
over from scratch.&lt;br /&gt;
&lt;br /&gt;
=== COUNTERMODEL ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== COUNTEREXAMPLE ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
=== POPTO ===&lt;br /&gt;
&lt;br /&gt;
[More]&lt;br /&gt;
&lt;br /&gt;
== Instantiation Patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVC4 processes each universally quantified formula in the current context &lt;br /&gt;
by adding instances of the formula obtained by replacing its universal variables &lt;br /&gt;
with ground terms. &lt;br /&gt;
Patterns restrict the choice of ground terms for the quantified variables, &lt;br /&gt;
with the goal of controlling the potential explosion of ground instances. &lt;br /&gt;
In essence, adding patterns to a formula is a way for the user to tell CVC4 &lt;br /&gt;
to focus only on certain instances which, in the user's opinion, will be &lt;br /&gt;
most helpful during a proof.&lt;br /&gt;
&lt;br /&gt;
In more detail, patterns have the following effect on formulas that are found &lt;br /&gt;
in the logical context or get added to it later while CVC4 is trying to prove &lt;br /&gt;
the validity of some formula &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If a formula in the current context starts with an existential quantifier, &lt;br /&gt;
CVC4 ''Skolemizes'' it, that is, replaces it in the context with the formula &lt;br /&gt;
obtained by substituting the existentially quantified variables &lt;br /&gt;
by fresh constants and dropping the quantifier. &lt;br /&gt;
Any patterns for the existential quantifier are simply ignored.&lt;br /&gt;
&lt;br /&gt;
If a formula starts with a universal quantifier &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{FORALL}\; (x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt;, &lt;br /&gt;
CVC4 adds to the context a number of instances of the formula, &lt;br /&gt;
with the goal of using them to prove the query &amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt; valid. &lt;br /&gt;
An instance is obtained by replacing each &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; with a ground term&lt;br /&gt;
of the same type occurring in one of the formulas in the context, &lt;br /&gt;
and dropping the universal quantifier. &lt;br /&gt;
If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; occurs in a pattern &lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{PATTERN}\; (t_1, \ldots, t_m)&amp;lt;/math&amp;gt; for the quantifier, &lt;br /&gt;
it will be instantiated only with terms obtained by simultaneously matching &lt;br /&gt;
all the terms in the pattern against ground terms in the current context &lt;br /&gt;
&amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Specifically, the matching process produces one or more substitutions &lt;br /&gt;
&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; for the variables in &amp;lt;math&amp;gt;(t_1, \ldots, t_m)&amp;lt;/math&amp;gt; &lt;br /&gt;
which satisfy the following invariant: &lt;br /&gt;
for each &amp;lt;math&amp;gt;i = 1, \ldots, m&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\sigma(t_i)&amp;lt;/math&amp;gt; is &lt;br /&gt;
a ground term and there is a ground term &amp;lt;math&amp;gt;s_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;\Gamma&amp;lt;/math&amp;gt; &lt;br /&gt;
such that &amp;lt;math&amp;gt;\Gamma \models_T \sigma(t_i) = s_i&amp;lt;/math&amp;gt;. &lt;br /&gt;
The variables of &amp;lt;math&amp;gt;(x_1:T_1, \ldots, x_n:T_n)&amp;lt;/math&amp;gt; that occur &lt;br /&gt;
in the pattern are instantiated only with those substitutions &lt;br /&gt;
(while any remaining variables are instantiated arbitrarily).&lt;br /&gt;
&lt;br /&gt;
The Skolemized version or the added instances of a context formula may themselves &lt;br /&gt;
start with a quantifier. &lt;br /&gt;
The same instantiation process is applied to them too, recursively.&lt;br /&gt;
&lt;br /&gt;
Note that the matching mechanism is not limited to syntactic matching &lt;br /&gt;
but is modulo the equations asserted in the context. &lt;br /&gt;
Because of decidability and/or efficiency limitations, the matching process &lt;br /&gt;
is not exhaustive. &lt;br /&gt;
CVC4 will typically miss some substitutions that satisfy the invariant above. &lt;br /&gt;
As a consequence, it might fail to prove the validity of the query formula &lt;br /&gt;
&amp;lt;math&amp;gt;F&amp;lt;/math&amp;gt;, which makes CVC4 incomplete for contexts containing &lt;br /&gt;
quantified formulas. &lt;br /&gt;
It should be noted though that exhaustive matching, which can be achieved &lt;br /&gt;
simply by not specifying any patterns, does not yield completeness anyway &lt;br /&gt;
since the instantiation of universal variables is still restricted &lt;br /&gt;
to just the ground terms in the context,&lt;br /&gt;
whereas in general additional ground terms might be needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 == Subtypes ==&lt;br /&gt;
&lt;br /&gt;
=== Subtype Checking ===&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=CVC4's support for the SMT-LIB language=&lt;br /&gt;
&lt;br /&gt;
==SMT-LIB compliance==&lt;br /&gt;
&lt;br /&gt;
Every effort has been made to make CVC4 compliant with the SMT-LIB 2.0&lt;br /&gt;
standard (http://smtlib.org/).  However, when parsing SMT-LIB input,&lt;br /&gt;
certain default settings don't match what is stated in the official&lt;br /&gt;
standard.  To make CVC4 adhere more strictly to the standard, use the&lt;br /&gt;
&amp;quot;--smtlib&amp;quot; command-line option.  Even with this setting, CVC4 is&lt;br /&gt;
somewhat lenient; some non-conforming input may still be parsed and&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
==Using CVC4 from Java==&lt;br /&gt;
==The compatibility interface==&lt;br /&gt;
&lt;br /&gt;
=Upgrading from CVC3 to CVC4=&lt;br /&gt;
&lt;br /&gt;
==Features not supported by CVC4 (yet)==&lt;br /&gt;
&lt;br /&gt;
===Type Correctness Conditions (TCCs)===&lt;br /&gt;
&lt;br /&gt;
Type Correctness Conditions (TCCs), and the checking of such, are not&lt;br /&gt;
supported by CVC4 1.0.  Thus, a function defined only on integers can be&lt;br /&gt;
applied to REAL (as INT is a subtype of REAL), and CVC4 will not complain,&lt;br /&gt;
but may produce strange results.  For example:&lt;br /&gt;
&lt;br /&gt;
  f : INT -&amp;gt; INT;&lt;br /&gt;
  ASSERT f(1/3) = 0;&lt;br /&gt;
  ASSERT f(2/3) = 1;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  COUNTEREXAMPLE;&lt;br /&gt;
  % f : (INT) -&amp;gt; INT = LAMBDA(x1:INT) : 0;&lt;br /&gt;
&lt;br /&gt;
CVC3 can be used to produce TCCs for this input (with the +dump-tcc option).&lt;br /&gt;
The TCC can be checked by CVC3 or another solver.  (CVC3 can also check&lt;br /&gt;
TCCs while solving with +tcc.)&lt;br /&gt;
&lt;br /&gt;
==If you were using the text interfaces of CVC3==&lt;br /&gt;
&lt;br /&gt;
The native language of all solvers in the CVC family, referred to as the&lt;br /&gt;
&amp;quot;presentation language,&amp;quot; has undergone some revisions for CVC4.  The&lt;br /&gt;
most notable is that CVC4 does _not_ add counterexample assertions to&lt;br /&gt;
the current assertion set after a SAT/INVALID result.  For example:&lt;br /&gt;
&lt;br /&gt;
  x, y : INT;&lt;br /&gt;
  ASSERT x = 1 OR x = 2;&lt;br /&gt;
  ASSERT y = 1 OR y = 2;&lt;br /&gt;
  ASSERT x /= y;&lt;br /&gt;
  CHECKSAT;&lt;br /&gt;
  % sat&lt;br /&gt;
  QUERY x = 1;&lt;br /&gt;
  % invalid&lt;br /&gt;
  QUERY x = 2;&lt;br /&gt;
  % invalid&lt;br /&gt;
&lt;br /&gt;
Here, CVC4 responds &amp;quot;invalid&amp;quot; to the second and third queries, because&lt;br /&gt;
each has a counterexample (x=2 is a counterexample to the first, and&lt;br /&gt;
x=1 is a counterexample to the second).  However, CVC3 will respond&lt;br /&gt;
with &amp;quot;valid&amp;quot; to one of these two, as the first query (the CHECKSAT)&lt;br /&gt;
had the side-effect of locking CVC3 into one of the two cases; the&lt;br /&gt;
later queries are effectively querying the counterexample that was&lt;br /&gt;
found by the first.  CVC4 removes this side-effect of the CHECKSAT and&lt;br /&gt;
QUERY commands.&lt;br /&gt;
&lt;br /&gt;
CVC4 supports rational literals (of type REAL) in decimal; CVC3 did not&lt;br /&gt;
support decimals.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not have support for the IS_INTEGER predicate.&lt;br /&gt;
&lt;br /&gt;
==If you were using the library (&amp;quot;in-memory&amp;quot;) interface of CVC3==&lt;br /&gt;
===If you were using CVC3 from C===&lt;br /&gt;
===If you were using CVC3 from Java===&lt;br /&gt;
&lt;br /&gt;
=Useful command-line options=&lt;br /&gt;
&lt;br /&gt;
==Statistics==&lt;br /&gt;
&lt;br /&gt;
Statistics can be dumped on exit (both normal and abnormal exits) with&lt;br /&gt;
the --statistics command line option.&lt;br /&gt;
&lt;br /&gt;
==Time and resource limits==&lt;br /&gt;
&lt;br /&gt;
CVC4 can be made to self-timeout after a given number of milliseconds.&lt;br /&gt;
Use the --tlimit command line option to limit the entire run of&lt;br /&gt;
CVC4, or use --tlimit-per to limit each individual query separately.&lt;br /&gt;
Preprocessing time is not counted by the time limit, so for some large&lt;br /&gt;
inputs which require aggressive preprocessing, you may notice that&lt;br /&gt;
--tlimit does not work very well.  If you suspect this might be the&lt;br /&gt;
case, you can use &amp;quot;-vv&amp;quot; (double verbosity) to see what CVC4 is doing.&lt;br /&gt;
&lt;br /&gt;
Time-limited runs are not deterministic; two consecutive runs with the&lt;br /&gt;
same time limit might produce different results (i.e., one may time out&lt;br /&gt;
and responds with &amp;quot;unknown&amp;quot;, while the other completes and provides an&lt;br /&gt;
answer).  To ensure that results are reproducible, use --rlimit or&lt;br /&gt;
--rlimit-per.  These options take a &amp;quot;resource count&amp;quot; (presently, based on&lt;br /&gt;
the number of SAT conflicts) that limits the search time.  A word of&lt;br /&gt;
caution, though: there is no guarantee that runs of different versions of&lt;br /&gt;
CVC4 or of different builds of CVC4 (e.g., two CVC4 binaries with different&lt;br /&gt;
features enabled, or for different architectures) will interpret the resource&lt;br /&gt;
count in the same manner.&lt;br /&gt;
&lt;br /&gt;
CVC4 does not presently have a way to limit its memory use; you may opt&lt;br /&gt;
to run it from a shell after using &amp;quot;ulimit&amp;quot; to limit the size of the&lt;br /&gt;
heap.&lt;br /&gt;
&lt;br /&gt;
=Dumping API calls or preprocessed output=&lt;br /&gt;
&lt;br /&gt;
=Changing the output language=&lt;br /&gt;
&lt;br /&gt;
=Proof support=&lt;br /&gt;
&lt;br /&gt;
CVC4 1.0 has limited support for proofs, and they are disabled by default.&lt;br /&gt;
(Run the configure script with --enable-proof to enable proofs).  Proofs&lt;br /&gt;
are exported in LFSC format and are limited to the propositional backbone&lt;br /&gt;
of the discovered proof (theory lemmas are stated without proof in this&lt;br /&gt;
release).&lt;br /&gt;
&lt;br /&gt;
=Portfolio solving=&lt;br /&gt;
&lt;br /&gt;
If enabled at configure-time (./configure --with-portfolio), a second&lt;br /&gt;
CVC4 binary will be produced (&amp;quot;pcvc4&amp;quot;).  This binary has support for&lt;br /&gt;
running multiple instances of CVC4 in different threads.  Use --threads=N&lt;br /&gt;
to specify the number of threads, and use --thread0=&amp;quot;options for thread 0&amp;quot;&lt;br /&gt;
--thread1=&amp;quot;options for thread 1&amp;quot;, etc., to specify a configuration for the&lt;br /&gt;
threads.  Lemmas are *not* shared between the threads by default; to adjust&lt;br /&gt;
this, use the --filter-lemma-length=N option to share lemmas of N literals&lt;br /&gt;
(or smaller).  (Some lemmas are ineligible for sharing because they include&lt;br /&gt;
literals that are &amp;quot;local&amp;quot; to one thread.)&lt;br /&gt;
&lt;br /&gt;
Currently, the portfolio **does not work** with quantifiers or with&lt;br /&gt;
the theory of inductive datatypes.  These limitations will be addressed&lt;br /&gt;
in a future release.&lt;br /&gt;
&lt;br /&gt;
=Emacs support=&lt;br /&gt;
&lt;br /&gt;
For a suggestion of editing CVC4 source code with emacs, see the file&lt;br /&gt;
contrib/editing-with-emacs.  For a CVC language mode (the native input&lt;br /&gt;
language for CVC4), see contrib/cvc-mode.el.&lt;/div&gt;</summary>
		<author><name>Tinelli</name></author>	</entry>

	</feed>