<?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=Clark+Barrett</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=Clark+Barrett"/>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/wiki/Special:Contributions/Clark_Barrett"/>
		<updated>2026-04-06T02:38:40Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.4</generator>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=5723</id>
		<title>User Manual</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=User_Manual&amp;diff=5723"/>
				<updated>2018-07-12T18:19:48Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &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.stanford.edu/downloads/builds/ http://cvc4.cs.stanford.edu/downloads/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.stanford.edu/downloads/builds/x86_64-linux-opt/ Optimized] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.stanford.edu/downloads/builds/x86_64-linux-dbg/ Debug] binaries (statically linked)&lt;br /&gt;
* [http://cvc4.cs.stanford.edu/downloads/builds/debian/ Debian] packages&lt;br /&gt;
&lt;br /&gt;
'''[Not ported to Stanford yet]''' To install CVC4 on an Ubuntu Machine follow the instructions below. First add the CVC4 repository to /etc/apt/sources.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.stanford.edu/downloads/builds/src/ Sources are available] from the same site as the binaries. The source-code is also available in the [https://github.com/CVC4/CVC4 CVC4 source repository]. &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;
Successful exit is marked by the exit code 0.  Most &amp;quot;normal errors&amp;quot; return a 1 as the exit code, but out of memory conditions, terminating signals, and other conditions can produce different (nonzero) 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;
''Note on previous versions:'' Up to version 1.2 of CVC4, exit status depended on the result (&amp;quot;sat&amp;quot; results caused an exit code of 10, &amp;quot;unsat&amp;quot; of 20).  This behavior was deemed nonstandard and is no longer the case; successful exits are always 0 in version 1.3 and later.&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;
=Supported Theories=&lt;br /&gt;
The following theories are currently fully supported&lt;br /&gt;
* Booleans&lt;br /&gt;
* Uninterpreted functions&lt;br /&gt;
* Arrays [with extensionality]&lt;br /&gt;
* Inductive datatypes&lt;br /&gt;
* Tuples and record types&lt;br /&gt;
* Fixed width bitvectors&lt;br /&gt;
* Linear mixed real integer arithmetic&lt;br /&gt;
** Integer division and modulus by integer constants is supported by the &amp;quot;--rewrite-divk&amp;quot; flag&lt;br /&gt;
* [[sets|Finite sets]]&lt;br /&gt;
CVC4 supports first-order quantification and theory combinations of the above theories.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following theories are currently partially supported and are undergoing development:&lt;br /&gt;
* Strings&lt;br /&gt;
&lt;br /&gt;
Theories with '''highly limited''' support:&lt;br /&gt;
* CVC4's non-linear real and non-linear integer arithmetic support is currently unlikely to satisfy a user's needs.  The current support is for parsing, rewrites, and a very limited class of proofs of unsatisifiability. The class of proofs is what is provable by linear arithmetic where each monomial (e.g. &amp;quot;xxy&amp;quot;) is treated as a unique variable.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 library interface (API)=&lt;br /&gt;
&lt;br /&gt;
There are a number of examples of using CVC4 as a library distributed with the source code of the project. There are given in the &amp;quot;/examples&amp;quot; directory.&lt;br /&gt;
&lt;br /&gt;
==Using CVC4 in a C++ project==&lt;br /&gt;
&lt;br /&gt;
A basic C++ example for using cvc4 is given in the file [https://github.com/CVC4/CVC4/blob/master/examples/simple_vc_cxx.cpp /examples/simple_vc_cxx.cpp].&lt;br /&gt;
The file goes through the examples for the basic interaction with CVC4:&lt;br /&gt;
# Constructing an ExprManager em&lt;br /&gt;
# Constructing an SmtEngine w.r.t. em.&lt;br /&gt;
# Getting a copy of the Type for mathematical integers from em, em.integerType().&lt;br /&gt;
# Constructing new Expressions&lt;br /&gt;
## Integer variables x and y: Expr x = em.mkVar(&amp;quot;x&amp;quot;, integer);&lt;br /&gt;
## The rational constant 0: em.mkConst(Rational(0));&lt;br /&gt;
## Constructing new expressions existing expressions: em.mkExpr(kind::GT, x, zero);&lt;br /&gt;
# Querying the SmtEngine whether or not a formula is valid. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
More information on the interfaces for Expr, Type, ExprManager and SmtEngine can be found in their respective header files.&lt;br /&gt;
&lt;br /&gt;
To compile simple_vc_cxx.cpp, there are different build instructions for whether or not you are compiling against a version of CVC4 in a local build directory or one installed via &amp;quot;make install&amp;quot; into a directory $PREFIX.&lt;br /&gt;
&lt;br /&gt;
* Local Build Directory: If you have build cvc4 via the &amp;quot;make&amp;quot; command before, you can compile simple_vc_cxx.cpp via &amp;quot;make examples&amp;quot;. The executable will then be &amp;quot;./builds/examples/simple_vc_cxx&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
    $ make examples&lt;br /&gt;
    [...]&lt;br /&gt;
    $ ./builds/examples/simple_vc_cxx &lt;br /&gt;
    Checking validity of formula ((x &amp;gt; 0) AND (y &amp;gt; 0)) =&amp;gt; (((2 * x) + y) &amp;gt;= 3) with CVC4.&lt;br /&gt;
    CVC4 should report VALID.&lt;br /&gt;
    Result from CVC4 is: valid&lt;br /&gt;
* Installed Copy: If you have installed CVC4 via &amp;quot;make install&amp;quot; into the directory $PREFIX (which you can configure via &amp;quot;./configure --prefix=$PREFIX&amp;quot; you will need to modify lines 21-22.&lt;br /&gt;
    //#include &amp;lt;cvc4/cvc4.h&amp;gt; // use this after CVC4 is properly installed&lt;br /&gt;
    #include &amp;quot;smt/smt_engine.h&amp;quot;&lt;br /&gt;
:First, uncomment line 21 and comment out line 22. You may now &lt;br /&gt;
You can now compile and run by executing&lt;br /&gt;
    g++ -I$PREFIX/include -L$PREFIX/lib -lcvc4 examples/simple_vc_cxx.cpp -o simple_vc_cxx&lt;br /&gt;
    ./simple_vc_cxx&lt;br /&gt;
:You may need to add $PREFIX/lib is LD_LIBRARY_PATH or the equivalent.&lt;br /&gt;
&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;
'''[Builds not ported to Stanford yet]''' 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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5505</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5505"/>
				<updated>2017-01-27T17:19:47Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &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]]&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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5504</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5504"/>
				<updated>2017-01-27T00:16:56Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &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]]&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.nyu.edu/~barrett/pubs/LRT+14.pdf CAV 2014 paper: A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].&lt;br /&gt;
** 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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5503</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=5503"/>
				<updated>2017-01-27T00:14:56Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: /* Web site */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT)] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of a formula with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive [[Datatypes|datatypes]]&lt;br /&gt;
* [[Strings|strings]]&lt;br /&gt;
* [[Sets|finite sets]]&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://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest-unstable/copying.html license]).&lt;br /&gt;
&lt;br /&gt;
=Web site=&lt;br /&gt;
&lt;br /&gt;
For more information and the latest news about CVC4, visit the [http://cvc4.cs.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.nyu.edu/~barrett/pubs/LRT+14.pdf CAV 2014 paper: A DPLL(T) Theory Solver for a Theory of Strings and Regular Expressions].&lt;br /&gt;
** 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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Building_CVC4_from_source&amp;diff=5430</id>
		<title>Building CVC4 from source</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Building_CVC4_from_source&amp;diff=5430"/>
				<updated>2016-04-22T18:07:34Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To compile CVC4 from a source package you must do the following:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
&lt;br /&gt;
To do so run the following commands in the CVC4 directory:&lt;br /&gt;
&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;
Below are more details instructions about the various dependencies and options. &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-antlr-3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr-3.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;
&lt;br /&gt;
==Building on FreeBSD==&lt;br /&gt;
CVC4's build process currently makes extensive use of bash, sed, and other common *nix tools. It has recently come to our attention by Kostas Oikonomou that some of these are problematic outside of the GNU toolkit. Users of systems that do not assume GNU implementation like FreeBSD may experience issues building CVC4. Until we have a more permanent solution, here are Kostas Oikonomou's notes on how to modify CVC4's source to get it to compile on such systems:&lt;br /&gt;
&lt;br /&gt;
    0. export CONFIG_SHELL=/usr/local/bin/bash&lt;br /&gt;
       Edit 'configure' to set # !/usr/local/bin/bash&lt;br /&gt;
    &lt;br /&gt;
    1. configure --prefix=/opt/cvc4 --enable-gpl --with-readline CC=clang CXX=clang++ LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include&lt;br /&gt;
    &lt;br /&gt;
    2a. Edit src/mksubdirs, src/theory/{mkrewriter,mktheorytraits} to change&lt;br /&gt;
       !#/bin/bash to !#/usr/local/bin/bash&lt;br /&gt;
       Similarly for src/base/{mktags,mktagheaders}, src/expr/{mkexpr,mkkind,mkmetakind}.&lt;br /&gt;
    &lt;br /&gt;
    2b. src/options/mkoptions: same as above, plus all occurrences of expr -&amp;gt; gexpr.&lt;br /&gt;
   &lt;br /&gt;
    3. Edit src/main/util.cpp:&lt;br /&gt;
    &lt;br /&gt;
      stack_t ss;&lt;br /&gt;
      ss.ss_sp = (char *) malloc(SIGSTKSZ);&lt;br /&gt;
    &lt;br /&gt;
    4. make -j2&lt;br /&gt;
    &lt;br /&gt;
    5. Edit test/regress/run_regression to fix the bash business.&lt;br /&gt;
    &lt;br /&gt;
    6. make check&lt;br /&gt;
    &lt;br /&gt;
    7. sudo gmake install&lt;br /&gt;
&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 custom CLN installations (optional)==&lt;br /&gt;
&lt;br /&gt;
One option for compiling against a custom CLN installation is to provide the CLN_LIBS and CLN_CFLAGS arguments at configuration. Supposing you installed cln into CLN_DIR the following provides the necessary locations of the header and linking information.&lt;br /&gt;
    ./configure &amp;lt;other arguments&amp;gt; --with-cln CLN_LIBS=&amp;quot;-L&amp;lt;CLN_DIR&amp;gt;/lib -lcln&amp;quot; \&lt;br /&gt;
     CLN_CFLAGS=&amp;quot;-I&amp;lt;CLN_DIR&amp;gt;/include&amp;quot;&lt;br /&gt;
&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;
&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;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

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

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

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

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Building_CVC4_from_source&amp;diff=4762</id>
		<title>Building CVC4 from source</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Building_CVC4_from_source&amp;diff=4762"/>
				<updated>2013-10-09T05:35:36Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To compile CVC4 from a source package you must do the following:&lt;br /&gt;
# Install antlr&lt;br /&gt;
# Configure cvc4&lt;br /&gt;
# Compile cvc4&lt;br /&gt;
# Install cvc4 [optional]&lt;br /&gt;
&lt;br /&gt;
To do so run the following commands in the CVC4 directory:&lt;br /&gt;
&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;
Below are more details instructions about the various dependencies and options. &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-antlr-3.4&lt;br /&gt;
To force the script to compile 64 bit:&lt;br /&gt;
  MACHINE_TYPE=&amp;quot;x86_64&amp;quot; ./get-antlr-3.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;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

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

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

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

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4038</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=4038"/>
				<updated>2012-12-01T18:12:09Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: /* Structured 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 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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4037</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=4037"/>
				<updated>2012-12-01T18:11:26Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: /* The INT 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;
 [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 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 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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4%27s_native_language&amp;diff=4036</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=4036"/>
				<updated>2012-12-01T18:08:22Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: /* The INT 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;
 [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 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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4034</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4034"/>
				<updated>2012-12-01T02:09:17Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT) ] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors,&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* support for quantifiers through heuristic instantiaion;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/COPYING_source.html license]).&lt;br /&gt;
&lt;br /&gt;
=Web site=&lt;br /&gt;
&lt;br /&gt;
For more information and the latest news about CVC4, visit the [http://cvc4.cs.nyu.edu CVC4 web site].&lt;br /&gt;
&lt;br /&gt;
=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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4033</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4033"/>
				<updated>2012-12-01T02:08:40Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT) ] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors,&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* support for quantifiers through heuristic instantiaion;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/COPYING_source.html license]).&lt;br /&gt;
&lt;br /&gt;
=Web site=&lt;br /&gt;
&lt;br /&gt;
For the latest news about CVC4, visit the [http://cvc4.cs.nyu.edu CVC4 web site].&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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4031</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4031"/>
				<updated>2012-12-01T02:07:06Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT) ] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors,&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* support for quantifiers through heuristic instantiaion;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/COPYING_source.html license]).&lt;br /&gt;
&lt;br /&gt;
=Web site=&lt;br /&gt;
&lt;br /&gt;
For the latest news on CVC4, visit the [http://cvc4.cs.nyu.edu CVC4 web site].&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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4030</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4030"/>
				<updated>2012-12-01T02:06:49Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT) ] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors,&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* support for quantifiers through heuristic instantiaion;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/COPYING_source.html license]).&lt;br /&gt;
&lt;br /&gt;
=Web site=&lt;br /&gt;
&lt;br /&gt;
For the latest news on CVC4, visit the [http://cvc4.cs.nyu.edu CVC4 web page].&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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4029</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4029"/>
				<updated>2012-12-01T02:06:06Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT) ] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors,&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* support for quantifiers through heuristic instantiaion;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/COPYING_source.html license]).&lt;br /&gt;
&lt;br /&gt;
=Web site=&lt;br /&gt;
&lt;br /&gt;
For more information, visit the [http://cvc4.cs.nyu.edu CVC4 web page].&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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Publications&amp;diff=4027</id>
		<title>Publications</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Publications&amp;diff=4027"/>
				<updated>2012-12-01T02:01:22Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Papers about the tool&lt;br /&gt;
* Clark Barrett, Christopher L. Conway, Morgan Deters, Liana Hadarean, Dejan Jovanović, Tim King, Andrew Reynolds, and Cesare Tinelli.  [http://cs.nyu.edu/~barrett/pubs/BCD+11.pdf CVC4].  Lecture Notes in Computer Science, 2011, Volume 6806, Computer Aided Verification, Pages 171-177.&lt;br /&gt;
&lt;br /&gt;
Papers describing original research that was incorporated into CVC4&lt;br /&gt;
* Theory Combination&lt;br /&gt;
** Dejan Jovanović and Clark Barrett. [http://cs.nyu.edu/~barrett/pubs/JB10-SMT.pdf Sharing is Caring].  In Proceedings of the 8th International Workshop on Satisfiability Modulo Theories (SMT '10), July 2010.&lt;br /&gt;
** Dejan Jovanović and Clark Barrett. [http://cs.nyu.edu/~barrett/pubs/JB10-TR.pdf Polite Theories Revisited].  In Proceedings of the Seventeenth International Conference on Logic for Programming, Artificial Intelligence, and Reasoning (LPAR '10), volume 6397 of Lecture Notes in Computer Science, pages 402-416. Springer, October 2010. Yogyakarta, Indonesia.&lt;br /&gt;
&lt;br /&gt;
Applications of CVC4&lt;br /&gt;
* Tim King and Clark Barrett. [http://cs.nyu.edu/~barrett/pubs/KB11.pdf Exploring and Categorizing Error Spaces using BMC and SMT]. In Proceedings of the 9th International Workshop on Satisfiability Modulo Theories (SMT '11), July 2011.&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4022</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4022"/>
				<updated>2012-12-01T01:34:52Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT) ] (for a more formal introduction to SMT see the following book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
It can be used to prove the validity (or, dually, the satisfiability) of with respect to several built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors,&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
CVC4 has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* support for quantifiers through heuristic instantiaion;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/COPYING_source.html license]).&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>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4021</id>
		<title>About CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=About_CVC4&amp;diff=4021"/>
				<updated>2012-12-01T01:29:20Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is a solver for [http://en.wikipedia.org/wiki/Satisfiability_Modulo_Theories Satisifiability Modulo Theories (SMT) ] (for a more formal introduction to SMT see the following  book chapter [https://cs.nyu.edu/~barrett/pubs/BSST09.pdf Satisfiability Modulo Theories] ). Technically, it is an automated validity checker for a many-sorted (i.e., typed) first-order logic with built-in theories.&lt;br /&gt;
&lt;br /&gt;
CVC4 currently has support for the following theories:&lt;br /&gt;
* equality over free (aka uninterpreted) function and predicate symbols&lt;br /&gt;
* real and integer linear arithmetic&lt;br /&gt;
* bit-vectors,&lt;br /&gt;
* arrays&lt;br /&gt;
* tuples&lt;br /&gt;
* records&lt;br /&gt;
* user-defined inductive data types.&lt;br /&gt;
&lt;br /&gt;
It also supports the use of quantifiers through heuristic instantiation and can produce models for quantifier-free satisfiable queries.&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.  Some specific deficiencies of CVC3 are mentioned in&lt;br /&gt;
this article.&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4&amp;diff=4020</id>
		<title>CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4&amp;diff=4020"/>
				<updated>2012-12-01T01:27:39Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is an automatic theorem prover for Satisfiability Modulo Theories (SMT) problems. It can be used to prove the validity (or, dually, the satisfiability) of first-order formulas in a large number of built-in logical theories and their combination.&lt;br /&gt;
&lt;br /&gt;
CVC4 is the most recent of a series of popular SMT provers, which originated at Stanford University with the SVC system. CVC4 is a from-scratch redesign and reimplementation of earlier solvers; it is designed for flexibility as a research tool and performance as an industrial SMT solver.&lt;br /&gt;
&lt;br /&gt;
CVC4 works with a version of first-order logic and has a wide variety of features including:&lt;br /&gt;
&lt;br /&gt;
* several built-in base theories: rational and integer linear arithmetic, arrays, tuples, records, inductive data types, bit vectors, and equality over uninterpreted function symbols;&lt;br /&gt;
* support for quantifiers;&lt;br /&gt;
* an interactive text-based interface;&lt;br /&gt;
* a rich [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/ C++ API] for embedding in other systems;&lt;br /&gt;
* model generation abilities;&lt;br /&gt;
* source compatibility with much of the CVC3 API via a &amp;quot;compatibility library&amp;quot;;&lt;br /&gt;
* essentially no limit on its use for research or commercial purposes (see [http://church.cims.nyu.edu/cvc4-builds/documentation/public/latest/COPYING_source.html license]).&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Acknowledgments&amp;diff=3655</id>
		<title>Acknowledgments</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Acknowledgments&amp;diff=3655"/>
				<updated>2012-10-10T21:36:30Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is supported in part by the following organizations:&lt;br /&gt;
&lt;br /&gt;
* [http://www.wpafb.af.mil/AFRL/afosr/ The Air Force Office of Scientific Research]&lt;br /&gt;
* [http://www.intel.com/ Intel Corporation]&lt;br /&gt;
* [http://www.nsf.gov/ The National Science Foundation]&lt;br /&gt;
* [http://www.nyu.edu/ New York University]&lt;br /&gt;
* [http://www.src.org/ The Semiconductor Research Corporation] (contract 2008-TJ-1850)&lt;br /&gt;
&lt;br /&gt;
Any opinions, findings and conclusions or recommendations expressed in this site are those of the authors and do not necessarily reflect the views of the organizations listed above.&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Acknowledgments&amp;diff=3654</id>
		<title>Acknowledgments</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Acknowledgments&amp;diff=3654"/>
				<updated>2012-10-10T21:36:14Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CVC4 is supported in part by the following organizations:&lt;br /&gt;
&lt;br /&gt;
* [http://www.wpafb.af.mil/AFRL/afosr/ The Air Force Office of Scientific Research]&lt;br /&gt;
* [http://www.intel.com/ Intel Corporation]&lt;br /&gt;
* [http://www.nsf.gov/ The National Science Foundation]&lt;br /&gt;
* [http://www.nyu.edu/ New York University]&lt;br /&gt;
* [http://www.src.org/ The Semiconductor Research Corporation (contract 2008-TJ-1850)&lt;br /&gt;
&lt;br /&gt;
Any opinions, findings and conclusions or recommendations expressed in this site are those of the authors and do not necessarily reflect the views of the organizations listed above.&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Related_Links&amp;diff=3653</id>
		<title>Related Links</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Related_Links&amp;diff=3653"/>
				<updated>2012-10-10T21:32:57Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: /* Other */&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;
* 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;
* SMT Workshops: [http://www.lsi.upc.edu/~oliveras/smt07/ 2007] [http://research.microsoft.com/en-us/um/redmond/events/smt08/ 2008] [http://ie.technion.ac.il/SMT09/ 2009] [http://www.cprover.org/SMT10/ 2010] [http://uclid.eecs.berkeley.edu/smt11/ 2011] [http://smt2012.loria.fr/ 2012]&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://www.cs.uiowa.edu/~tinelli Cesare Tinelli's page at University of Iowa]&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=CVC4&amp;diff=3073</id>
		<title>CVC4</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=CVC4&amp;diff=3073"/>
				<updated>2012-05-16T17:49:02Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the CVC portal and CVC4 developers' wiki.  This service is only intended for the developers of CVC4 at [http://www.nyu.edu/ NYU] and [http://www.uiowa.edu/ UIowa].&lt;br /&gt;
&lt;br /&gt;
A valid login is required for many of these links.&lt;br /&gt;
&lt;br /&gt;
'''Relevant to CVC4 development:'''&lt;br /&gt;
* [[Developer Meeting Minutes]]&amp;lt;ul&amp;gt;{{#ifexist: Meeting Minutes - {{#timel:F j, Y}}|&amp;lt;li&amp;gt;[[Meeting Minutes - {{#timel:F j, Y}}|'''Today's meeting''' - {{#timel:D M j}}]]&amp;lt;/li&amp;gt;}}{{#if: {{mtglinks_recent}}|&amp;lt;li&amp;gt;'''Recent meetings:''' {{mtglinks_recent}}&amp;lt;/li&amp;gt;}}{{#if: {{mtglinks_upcoming}}|&amp;lt;li&amp;gt;'''Upcoming meetings:''' {{mtglinks_upcoming}}&amp;lt;/li&amp;gt;}}&amp;lt;/ul&amp;gt;&lt;br /&gt;
* [http://church.cims.nyu.edu/~mdeters/cvc4-devel.logs/ cvc4-devel IRC logs]&lt;br /&gt;
* [[CVC4 Contest|CVC4 Contest]]&lt;br /&gt;
* [[CVC4 Wishlist|CVC4 wishlist]]&lt;br /&gt;
* [[Developer's Guide]]&lt;br /&gt;
* [[User's Manual]]&lt;br /&gt;
* [[How do I... ?]]&lt;br /&gt;
* [[Library|Our library: bibliographical references of interest]]&lt;br /&gt;
* [[To Discuss|Items &amp;quot;yet to discuss&amp;quot;]]&lt;br /&gt;
* [[CVC4 Parsing]]&lt;br /&gt;
* [[How to write a theory in CVC4]]&lt;br /&gt;
&lt;br /&gt;
'''Some CVC3 resources:'''&lt;br /&gt;
* [http://www.cs.nyu.edu/acsys/bugs/ CVC3 Bugzilla]&lt;br /&gt;
* [http://www.cs.nyu.edu/acsys/cvc3/wiki CVC3 Wiki]&lt;br /&gt;
* [http://cs.nyu.edu/mailman/listinfo/cvc-devel Mailing list]&lt;br /&gt;
* [http://cs.nyu.edu/acsys/cvc3/ CVC3 public page]&lt;br /&gt;
* [[Fuzz-testing, October 2009|Results of Fuzz-testing CVC3 prior to release]]&lt;br /&gt;
&lt;br /&gt;
'''Some CVC4 resources:'''&lt;br /&gt;
* [http://church.cims.nyu.edu/bugzilla/ CVC4 Bugzilla]&lt;br /&gt;
* [http://cs.nyu.edu/mailman/listinfo/cvc4-devel Mailing list]&lt;br /&gt;
&amp;lt;!--* [[CVC3 Benchmarking|CVC3 benchmarking useful for CVC4 design]] {{NEW}}--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Relevant to this wiki:'''&lt;br /&gt;
* [[User Registration|User registration]]&lt;br /&gt;
* [[Developer Resources|Developer resources]]&lt;br /&gt;
* [[Using SSL with Church]]&lt;br /&gt;
&lt;br /&gt;
To register as a new user, or recommend someone for an account, contact [http://cs.nyu.edu/~dejan/ Dejan] or [http://cs.nyu.edu/~mdeters/ Morgan].&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	<entry>
		<id>http://cvc4.stanford.edu/w/index.php?title=Developer%27s_Guide&amp;diff=1396</id>
		<title>Developer's Guide</title>
		<link rel="alternate" type="text/html" href="http://cvc4.stanford.edu/w/index.php?title=Developer%27s_Guide&amp;diff=1396"/>
				<updated>2010-06-14T15:16:38Z</updated>
		
		<summary type="html">&lt;p&gt;Clark Barrett: /* ANTLR3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In addition to this wiki, we also have a [http://cs.nyu.edu/mailman/listinfo/cvc4-devel developer mailing list] and [http://goedel.cims.nyu.edu/bugzilla3/ Bugzilla database] for this version of CVC.  CVC3 resources have been kept separate, at this time, because of the different needs of CVC4 during active development.&lt;br /&gt;
&lt;br /&gt;
=Source tree layout=&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; - this directory holds m4 macro processor files (autoconf code) as well as bits of the autotools build system that go out as part of the distribution to ''smooth over'' platform differences.&lt;br /&gt;
* &amp;lt;code&amp;gt;contrib&amp;lt;/code&amp;gt; - this directory includes maintainer scripts and other things that aren't '''directly''' part of CVC4&lt;br /&gt;
* &amp;lt;code&amp;gt;doc&amp;lt;/code&amp;gt; - documentation&lt;br /&gt;
* &amp;lt;code&amp;gt;src/context&amp;lt;/code&amp;gt; - context manager, context-dependent object/collection sources&lt;br /&gt;
* &amp;lt;code&amp;gt;src/expr&amp;lt;/code&amp;gt; - the expression package&lt;br /&gt;
* &amp;lt;code&amp;gt;src/include&amp;lt;/code&amp;gt; - public includes (installed in /usr/local or whatever on a users' machines)&lt;br /&gt;
* &amp;lt;code&amp;gt;src/main&amp;lt;/code&amp;gt; - source for the main cvc4 binary&lt;br /&gt;
* &amp;lt;code&amp;gt;src/parser&amp;lt;/code&amp;gt; - parsers for supported CVC4 input formats&lt;br /&gt;
* &amp;lt;code&amp;gt;src/prop&amp;lt;/code&amp;gt; - propositional parts of CVC4; these include imported minisat sources and the PropEngine&lt;br /&gt;
* &amp;lt;code&amp;gt;src/smt&amp;lt;/code&amp;gt; - SmtEngine&lt;br /&gt;
* &amp;lt;code&amp;gt;src/theory&amp;lt;/code&amp;gt; - the TheoryEngine and all theory solvers&lt;br /&gt;
* &amp;lt;code&amp;gt;src/util&amp;lt;/code&amp;gt; - utility classes, debugging macros, the Exception class, etc.&lt;br /&gt;
* &amp;lt;code&amp;gt;test&amp;lt;/code&amp;gt; - CxxTest unit tests (invoked by &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=Using CVC4's Subversion source control repository=&lt;br /&gt;
&lt;br /&gt;
CVC4 keeps a source control repository using [http://subversion.tigris.org/ Subversion], allowing us to track changes, effectively branch and merge, etc.&lt;br /&gt;
&lt;br /&gt;
==Accessing CVC4's repository==&lt;br /&gt;
&lt;br /&gt;
Access to CVC4's Subversion repository is restricted; you must have an AcSys-group CIMS account, or apply to us for outside collaborator access to the repository.  Once you have access, you can:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;svn --username $USERNAME checkout https://subversive.cims.nyu.edu/cvc4/cvc4/trunk cvc4&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...where &amp;lt;code&amp;gt;$USERNAME&amp;lt;/code&amp;gt; is your CIMS username (or the username you were given as an outside collaborator).  If your username on the Windows/UNIX machine you're coming from is the same, you can leave out the &amp;lt;code&amp;gt;--username&amp;amp;nbsp;$USERNAME&amp;lt;/code&amp;gt; part.&lt;br /&gt;
&lt;br /&gt;
The above checks out &amp;lt;code&amp;gt;/cvc4/cvc4/trunk&amp;lt;/code&amp;gt; to your local directory &amp;lt;code&amp;gt;cvc4&amp;lt;/code&amp;gt;.  This second argument (your local working directory for  CVC4 development), you can of course call whatever you like.  The first is the path in the repository.  The initial &amp;lt;code&amp;gt;/cvc4&amp;lt;/code&amp;gt; is the base of our repository (other groups' repositories are hosted on the same server).  The second &amp;lt;code&amp;gt;/cvc4&amp;lt;/code&amp;gt; in the path is the ''product'' (since we might decide to keep other, CVC4-related projects in the CVC4 repository even if they aren't directly part of CVC4.  This includes things like useful benchmark suites (that aren't part of the source tree proper), benchmark-processing utilities, the nightly build system scripts, the webpage, etc.  These things may not belong directly in the source tree, but are still worth keeping in the CVC4 repository.  The third component of the path, &amp;lt;code&amp;gt;/trunk&amp;lt;/code&amp;gt;, is the ''branch'' of CVC4 you're requesting.  In Subversion terminology, ''trunk'' is the head of development: the most recent version of CVC4 that's been committed.  The ''trunk'' is where most of our CVC4 mainline development will take place, for now.  We may occasionally branch (see below) to develop and test new or experimental features, but generally these branches will be merged back into the trunk.&lt;br /&gt;
&lt;br /&gt;
Once you've checked out a working directory, some helpful commands are:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;svn&amp;amp;nbsp;update&amp;lt;/code&amp;gt; - updates your working directory to the most recent version, merging updates into your edits)&lt;br /&gt;
* &amp;lt;code&amp;gt;svn&amp;amp;nbsp;status&amp;lt;/code&amp;gt; - tells you what you've changed&lt;br /&gt;
* &amp;lt;code&amp;gt;svn&amp;amp;nbsp;diff&amp;lt;/code&amp;gt; - gives you a diff of what you've changed&lt;br /&gt;
&lt;br /&gt;
===Repository access from Eclipse===&lt;br /&gt;
&lt;br /&gt;
From [http://www.eclipse.org/ Eclipse], you can go to &amp;lt;code&amp;gt;File -&amp;gt; New -&amp;gt; Project...&amp;lt;/code&amp;gt; and then choose ''Project from SVN'' under the SVN category.  Use the repository location &amp;lt;code&amp;gt;https://subversive.cims.nyu.edu/cvc4/cvc4/trunk&amp;lt;/code&amp;gt; and click ''Finish.''  Your Eclipse CVC4 project is then associated to the repository and you can use the Subversion facilities of Eclipse to perform the operations in this section instead of the command line.&lt;br /&gt;
&lt;br /&gt;
===Browsing the repository===&lt;br /&gt;
&lt;br /&gt;
You can also browse CVC4 sources without checking them out from Subversion.  Simply point your browser to:&lt;br /&gt;
&lt;br /&gt;
  https://subversive.cims.nyu.edu/cvc4/cvc4/trunk&lt;br /&gt;
&lt;br /&gt;
Your browser may complain about the security certificate.  Use your CIMS login and password, or the outside collaborator credentials we've given you.&lt;br /&gt;
&lt;br /&gt;
==Branching and merging==&lt;br /&gt;
&lt;br /&gt;
Branches live in the repository under &amp;lt;code&amp;gt;/cvc4/cvc4/branches&amp;lt;/code&amp;gt;.  You can see a list of all branches available (that haven't been deleted) by using &amp;lt;code&amp;gt;svn&amp;amp;nbsp;ls&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;svn --username $USERNAME ls https://subversive.cims.nyu.edu/cvc4/cvc4/branches&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check out a branch, you check out the branch path instead of the trunk:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;svn --username $USERNAME checkout https://subversive.cims.nyu.edu/cvc4/cvc4/branches/experimental-quantifier-instantiation cvc4.quant&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get information about where a working directory came from, use &amp;lt;code&amp;gt;svn&amp;amp;nbsp;info&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 [mdeters@adric ~]$ cd cvc4&lt;br /&gt;
 [mdeters@adric cvc4]$ svn info&lt;br /&gt;
 Path: .&lt;br /&gt;
 URL: https://subversive.cims.nyu.edu/cvc4/cvc4/trunk&lt;br /&gt;
 Repository Root: https://subversive.cims.nyu.edu/cvc4&lt;br /&gt;
 Repository UUID: 615e1583-3794-4256-8e52-04c157d34929&lt;br /&gt;
 Revision: 59&lt;br /&gt;
 Node Kind: directory&lt;br /&gt;
 Schedule: normal&lt;br /&gt;
 Last Changed Author: barrett&lt;br /&gt;
 Last Changed Rev: 59&lt;br /&gt;
 Last Changed Date: 2009-12-15 13:20:31 -0500 (Tue, 15 Dec 2009)&lt;br /&gt;
 &lt;br /&gt;
 [mdeters@adric cvc4]$&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Creating a branch===&lt;br /&gt;
&lt;br /&gt;
To create a branch, you ''copy'' the source tree to another place:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;svn --username $USERNAME cp https://subversive.cims.nyu.edu/cvc4/cvc4/trunk https://subversive.cims.nyu.edu/cvc4/cvc4/branches/my-branch&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...though '''please use a more descriptive name for your branch than this!'''  Then proceed by checking out the branch:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;svn --username $USERNAME checkout https://subversive.cims.nyu.edu/cvc4/cvc4/branches/my-branch cvc4.mybranch&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before doing lots of development on it, please document why your branch exists in a file named &amp;lt;code&amp;gt;README.&amp;amp;lt;branchname&amp;amp;gt;&amp;lt;/code&amp;gt; in the top-level directory:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 [mdeters@adric ~]$ cd cvc4&lt;br /&gt;
 [mdeters@adric cvc4]$ vi README.my-branch&lt;br /&gt;
 [mdeters@adric cvc4]$ cat README.my-branch&lt;br /&gt;
 This branch is to test the ideas of Splitting On Demand in SMT:&lt;br /&gt;
 &lt;br /&gt;
   ftp://ftp.cs.uiowa.edu/pub/tinelli/papers/BarNOT-LPAR-06.pdf&lt;br /&gt;
 &lt;br /&gt;
 -- Morgan Deters &amp;lt;mdeters@cs.nyu.edu&amp;gt;  Tue, 15 Dec 2009 17:31:01 -0500&lt;br /&gt;
 [mdeters@adric cvc4]$ svn add README.my-branch&lt;br /&gt;
 [mdeters@adric cvc4]$ svn commit&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This makes it easy to see what each branch exists for (without even checking it out):&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;svn --username $USERNAME cat https://subversive.cims.nyu.edu/cvc4/cvc4/branches/my-branch/README.my-branch&lt;br /&gt;
 This branch is to test the ideas of Splitting On Demand in SMT:&lt;br /&gt;
 &lt;br /&gt;
   ftp://ftp.cs.uiowa.edu/pub/tinelli/papers/BarNOT-LPAR-06.pdf&lt;br /&gt;
 &lt;br /&gt;
 -- Morgan Deters &amp;lt;mdeters@cs.nyu.edu&amp;gt;  Tue, 15 Dec 2009 17:31:01 -0500&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course, the above example created a branch from the trunk.  That need not be the case; you might create a branch from another branch (simply copy that branch instead of the trunk).&lt;br /&gt;
&lt;br /&gt;
===Merging a branch back to the trunk===&lt;br /&gt;
&lt;br /&gt;
Recent versions of Subversion make merging incredibly easy, because for versions of CVC4 with a common ancestral line (which you get from branching) have ''merge metadata'' stored regarding their merges.  This makes it '''much, MUCH''' easier to merge than it used to be under CVS.  Let's say you've created a branch &amp;lt;code&amp;gt;my-branch&amp;lt;/code&amp;gt; from the CVC4 trunk, like above.  First, commit all your changes to my-branch that you want.  Then, get a clean copy of the CVC4 trunk:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 [mdeters@adric ~]$ svn co https://subversive.cims.nyu.edu/cvc4/cvc4/trunk cvc4.clean&lt;br /&gt;
 [mdeters@adric ~]$ cd cvc4.clean&lt;br /&gt;
 [mdeters@adric cvc4.clean]$ svn merge https://subversive.cims.nyu.edu/cvc4/cvc4/branches/my-branch&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's all there is to it.  Subversion will merge all of the differences between ''trunk'' and ''my-branch'' '''since the last merge''' into the working directory.  That's the key part:  '''since the last merge.'''  It keeps track of this information for you.  You can inspect the changes, do a test build, and when you're happy with the changes, commit them.&lt;br /&gt;
&lt;br /&gt;
You might occasionally merge the other way, too.  If you've been developing along a branch for a long time, you might want to get the newest bugfixes from other parts of CVC4 that have been committed to the trunk.  You can merge changes in the trunk to my-branch as well:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 [mdeters@adric ~]$ cd cvc4.my-branch&lt;br /&gt;
 [mdeters@adric cvc4.my-branch]$ svn merge https://subversive.cims.nyu.edu/cvc4/cvc4/trunk&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Naturally, if you don't want to incorporate changes into/from the trunk, but rather another version, then specify that URL instead.&lt;br /&gt;
&lt;br /&gt;
==Symbolically tagging a version==&lt;br /&gt;
&lt;br /&gt;
Symbolically tagging a branch (for example, a release version) is very similar to [[#Creating a branch|branching]], but put under &amp;lt;code&amp;gt;/tags&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;/branches&amp;lt;/code&amp;gt;.  For example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;svn --username $USERNAME cp https://subversive.cims.nyu.edu/cvc4/cvc4/trunk https://subversive.cims.nyu.edu/cvc4/cvc4/tags/cade2010&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Just as with branching, please provide a README file:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&lt;br /&gt;
  [mdeters@adric ~]$ svn --username $USERNAME checkout https://subversive.cims.nyu.edu/cvc4/cvc4/tags/cade2010 cvc4.cade2010&lt;br /&gt;
  [mdeters@adric ~]$ cd cvc4.cade2010&lt;br /&gt;
  [mdeters@adric cvc4.cade2010]$ vi README.cade2010&lt;br /&gt;
  [mdeters@adric cvc4.cade2010]$ cat README.cade2010&lt;br /&gt;
  cade2010 version of CVC4&lt;br /&gt;
  ------------------------&lt;br /&gt;
  This version generated the results published in the CADE 2010 paper.&lt;br /&gt;
  &lt;br /&gt;
  -- Morgan Deters &amp;lt;mdeters@cs.nyu.edu&amp;gt;  Tue, 15 Dec 2009 17:39:05 -0500&lt;br /&gt;
  [mdeters@adric cvc4.cade2010]$ svn add README.cade2010&lt;br /&gt;
  [mdeters@adric cvc4.cade2010]$ svn commit&lt;br /&gt;
  &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Branches versus tags==&lt;br /&gt;
&lt;br /&gt;
Use a [[#Creating a branch|''branch'']] when you plan to do major (and perhaps experimental) editing on the source tree and don't want to screw up the nightly builds, tests, or other developers with a work in progress.  Use a [[#Symbolically tagging a version|''tag'']] when no development will occur on the source tree; it's merely a &amp;quot;bookmark&amp;quot; on a historical version of CVC4 in case we need to refer to it later in the repository.&lt;br /&gt;
&lt;br /&gt;
==Working with files and directories==&lt;br /&gt;
&lt;br /&gt;
Occasionally a class name might change (and its source file will therefore need renaming), or you want to move around files and directories in other ways.  In the old days under the CVS version control system, you had to remove the files under the old name/location and add them anew under the new name/location, losing all of the history information.  Not so under Subversion.  You can &amp;lt;code&amp;gt;mv&amp;lt;/code&amp;gt; files and directories just like under UNIX:&lt;br /&gt;
&lt;br /&gt;
  svn mv foo.cpp bar.cpp&lt;br /&gt;
&lt;br /&gt;
You can &amp;lt;code&amp;gt;mkdir&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  svn mkdir newdir&lt;br /&gt;
&lt;br /&gt;
If you already have the directory (and sources in it), you can &amp;lt;code&amp;gt;svn&amp;amp;nbsp;add&amp;lt;/code&amp;gt; it:&lt;br /&gt;
&lt;br /&gt;
  svn add newdir&lt;br /&gt;
&lt;br /&gt;
The same goes with new source files:&lt;br /&gt;
&lt;br /&gt;
  svn add new_source_file.cpp&lt;br /&gt;
&lt;br /&gt;
And, also, if you want to remove a file from the repository, you can do so:&lt;br /&gt;
&lt;br /&gt;
  svn rm obsolete_test.h&lt;br /&gt;
&lt;br /&gt;
Note that these commands operate on the working directory.  This has two consequences:&lt;br /&gt;
&lt;br /&gt;
# You don't need to use &amp;lt;code&amp;gt;--username&amp;amp;nbsp;$USERNAME&amp;lt;/code&amp;gt;, because the working directory is already linked to your login credentials (it was stored in the working directory meta-information when you checked out the working copy).&lt;br /&gt;
# The changes aren't immediate.  You still need to use &amp;lt;code&amp;gt;svn&amp;amp;nbsp;commit&amp;lt;/code&amp;gt; to commit your changes (and leave a log in the commit history).&lt;br /&gt;
&lt;br /&gt;
==Reverting a file in a working directory==&lt;br /&gt;
&lt;br /&gt;
Sometimes you make a local edit to a file and decide you want to undo the edit (restoring the last version you retrieved from the repository via a ''checkout'' or ''update'').  To do that, use &amp;lt;code&amp;gt;svn&amp;amp;nbsp;revert&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  svn revert file.cpp&lt;br /&gt;
&lt;br /&gt;
==Reverting a commit==&lt;br /&gt;
&lt;br /&gt;
Sometimes you want to revert a commit previously done by you or someone else.  Perhaps a bugfix actually caused more problems than it solved, or you want to back out of a refactoring decision that turned out to be a bad idea.  Let's say that revision 120 was perfect but a bugfix committed as revision 121 broke something and you want to undo that change.  Now the repository is at revision 130.  No problem:&lt;br /&gt;
&lt;br /&gt;
 [mdeters@adric ~]$ svn co https://subversive.cims.nyu.edu/cvc4/cvc4/trunk cvc4.clean&lt;br /&gt;
 [mdeters@adric ~]$ cd cvc4.clean&lt;br /&gt;
 [mdeters@adric cvc4.clean]$ svn merge . -r 121:120&lt;br /&gt;
&lt;br /&gt;
''Merge'' here means to ''merge the differences between two revisions;'' it's similar in some respects to the notion of ''merge'' between branches, but here there is no branch.  Subversion computes a diff between revisions 121 and 120 (here, order is important---we're doing a rollback so the revision number goes down) and merges it into the working directory.  The &amp;quot;.&amp;quot; is the directory to be merged.  Perhaps revision 121 committed a lot of things, and you only want to rollback the changes made to the context manager.  No problem:&lt;br /&gt;
&lt;br /&gt;
 [mdeters@adric cvc4.clean]$ svn merge src/context -r 121:120&lt;br /&gt;
&lt;br /&gt;
==Ignoring files==&lt;br /&gt;
&lt;br /&gt;
If you're familiar with CVS, you're probably familiar with &amp;lt;code&amp;gt;.cvsignore&amp;lt;/code&amp;gt; files---these are committed to the repository but are ''special'' in that they instruct CVS to ignore certain files in the working directory (and not report them as &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; when you update).  In Subversion, an &amp;lt;code&amp;gt;svn&amp;amp;nbsp;status&amp;lt;/code&amp;gt; is similar; it will complain about files that exist but aren't in the repository.  You can tell Subversion to ignore some files if they shouldn't ever be committed to the repository by using the property system (specifically the &amp;lt;code&amp;gt;svn:ignore&amp;lt;/code&amp;gt; property on directories).  &amp;quot;&amp;lt;code&amp;gt;svn&amp;amp;nbsp;proplist&amp;lt;/code&amp;gt;&amp;quot; lists the properties on a file/directory, &amp;quot;&amp;lt;code&amp;gt;svn&amp;amp;nbsp;propget&amp;lt;/code&amp;gt;&amp;quot; and &amp;quot;&amp;lt;code&amp;gt;svn&amp;amp;nbsp;propset&amp;lt;/code&amp;gt;&amp;quot; get and set a specific property value on a file or directory, &amp;quot;&amp;lt;code&amp;gt;svn&amp;amp;nbsp;propdel&amp;lt;/code&amp;gt;&amp;quot; deletes a property, and &amp;quot;&amp;lt;code&amp;gt;svn&amp;amp;nbsp;propedit&amp;lt;/code&amp;gt;&amp;quot; edits a property (using the current &amp;lt;code&amp;gt;$EDITOR&amp;lt;/code&amp;gt; from your environment).  For example:&lt;br /&gt;
&lt;br /&gt;
 [mdeters@adric ~]$ cd cvc4&lt;br /&gt;
 [mdeters@adric cvc4]$ EDITOR=vi svn propedit svn:ignore .&lt;br /&gt;
&lt;br /&gt;
...edits the &amp;lt;code&amp;gt;svn:ignore&amp;lt;/code&amp;gt; property on the top-level cvc4 source directory with the &amp;lt;code&amp;gt;vi&amp;lt;/code&amp;gt; editor.&lt;br /&gt;
&lt;br /&gt;
Changes to properties are versioned and tracked as well; changes must be committed just like a file.&lt;br /&gt;
&lt;br /&gt;
==Marking a file as executable in Subversion==&lt;br /&gt;
&lt;br /&gt;
Another property is used for the eXecute bit.  If you want to make a file executable, you can set the ''svn:executable'' property:&lt;br /&gt;
&lt;br /&gt;
  svn propset svn:executable yes ''filename''&lt;br /&gt;
&lt;br /&gt;
==Resolving conflicts in a working directory==&lt;br /&gt;
&lt;br /&gt;
Sometimes you do an &amp;lt;code&amp;gt;svn&amp;amp;nbsp;update&amp;lt;/code&amp;gt; and the update procedure causes a ''conflict'' (because you made changes in the same place as someone else did).  In such cases, Subversion punts: it doesn't know which change should override the other, or if they need to be combined in some (non-na&amp;amp;iuml;ve) way.&lt;br /&gt;
&lt;br /&gt;
Open the file with the conflict and edit it to remove the conflicts.  If Subversion still thinks it's in conflict (it has a &amp;lt;code&amp;gt;C&amp;lt;/code&amp;gt; mark when you run &amp;lt;code&amp;gt;svn&amp;amp;nbsp;status&amp;lt;/code&amp;gt;), then you should inform it that the conflict has been resolved:&lt;br /&gt;
&lt;br /&gt;
 svn resolved conflicting_file.cpp&lt;br /&gt;
&lt;br /&gt;
==For more information==&lt;br /&gt;
&lt;br /&gt;
Refer to the [http://svnbook.red-bean.com/ Subversion book] for more information on Subversion and how to work with repositories.&lt;br /&gt;
&lt;br /&gt;
=The CVC4 build system=&lt;br /&gt;
&lt;br /&gt;
The build system behind CVC4 is pretty complex.  It attempts to:&lt;br /&gt;
&lt;br /&gt;
# be cross platform (automake, libtool, autoconf are used)&lt;br /&gt;
# support a set of standard ''build profiles'' (default, production, debug, competition) with standard settings for assertions, debugging symbols, etc.&lt;br /&gt;
# allow deviating from the standard build profile by overriding its settings&lt;br /&gt;
# keep separate object/library files and sources (doing ./configure from the source directory creates a build directory and configures it instead)&lt;br /&gt;
# support multiple builds at once in same source tree (build directory names are based on build profile, ''e.g.,'' debug or production, and architecture)&lt;br /&gt;
# support changing Makefile.am automake specifications without re-running a bootstrap script&lt;br /&gt;
# support partial tree rebuilding from the source directories (Makefile in source directory delegates to &amp;quot;current&amp;quot; build directory)&lt;br /&gt;
# support partial tree rebuilding from the build directories (recursive make)&lt;br /&gt;
&lt;br /&gt;
Due to these constraints, the build system of CVC4 resembles a recursive-make implementation using automake/autoconf/libtool, ''except'' that it's very nonstandard.&lt;br /&gt;
&lt;br /&gt;
==Build profiles==&lt;br /&gt;
&lt;br /&gt;
The build profiles supported are:&lt;br /&gt;
&lt;br /&gt;
* '''production''' - highly optimized, no assertions, no tracing&lt;br /&gt;
* '''debug''' - unoptimized, debug symbols, assertions, tracing&lt;br /&gt;
* '''default''' - moderately optimized, assertions, tracing&lt;br /&gt;
* '''competition''' - maximally optimized, no assertions, no tracing, muzzled&lt;br /&gt;
&lt;br /&gt;
The default build profile is, not surprisingly, ''default''.  That's what you'll get if you just run &amp;quot;&amp;lt;code&amp;gt;./configure&amp;lt;/code&amp;gt;&amp;quot;.  To build a ''debug'' build, use:&lt;br /&gt;
&lt;br /&gt;
  $ ./configure debug&lt;br /&gt;
&lt;br /&gt;
and then &amp;quot;&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&amp;quot; as usual.&lt;br /&gt;
&lt;br /&gt;
===Working with multiple, concurrent build profiles===&lt;br /&gt;
&lt;br /&gt;
You can configure multiple types of builds.  They are built in separate directories.  &amp;quot;&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&amp;quot; will always build the last-''configured'' one.  If you want to build another (already configured) build, you can use &amp;quot;&amp;lt;code&amp;gt;make CURRENT_BUILD=debug&amp;lt;/code&amp;gt;&amp;quot;, but this is not &amp;quot;sticky&amp;quot;---the build profile built by default remains the last-''configured'' one.  For example:&lt;br /&gt;
&lt;br /&gt;
  $ ./configure debug&lt;br /&gt;
  [a debug build is configured under builds/[ARCH]/debug/]&lt;br /&gt;
  $ make&lt;br /&gt;
  [builds the debug build, puts the binaries under builds/bin/]&lt;br /&gt;
  $ ./configure production&lt;br /&gt;
  [a production build is configured under builds/[ARCH]/production/]&lt;br /&gt;
  $ make&lt;br /&gt;
  [builds the production build, puts the binaries under builds/bin]&lt;br /&gt;
  $ make CURRENT_BUILD=[ARCH]/debug&lt;br /&gt;
  [builds the debug build, puts the binaries under builds/bin]&lt;br /&gt;
  $ make&lt;br /&gt;
  [builds the '''production build'''---it was the last-''configured'' one]&lt;br /&gt;
&lt;br /&gt;
Build profiles can be customized.  For example, to make a debug build with support for profiling but without assertions, use:&lt;br /&gt;
&lt;br /&gt;
  $ ./configure debug --enable-profiling --disable-assertions&lt;br /&gt;
&lt;br /&gt;
Note that when you override build profile options in this way, the build is considered distinct.  Here, &amp;quot;debug-with-profiling-but-without-assertions&amp;quot; is distinct from a &amp;quot;debug&amp;quot; build:&lt;br /&gt;
&lt;br /&gt;
  $ ./configure debug --enable-profiling --disable-assertions&lt;br /&gt;
  [a debug build with profiling and without assertions is configured under builds/[ARCH]/debug-profiling-noassertions/]&lt;br /&gt;
  $ make&lt;br /&gt;
  [builds the debug-noassertions-profiling build, puts the binaries under builds/bin/]&lt;br /&gt;
  $ ./configure debug&lt;br /&gt;
  [a debug build (with assertions, no profiling code) is configured under builds/[ARCH]/debug/]&lt;br /&gt;
  $ make&lt;br /&gt;
  [builds the debug build, puts the binaries under builds/bin]&lt;br /&gt;
  $ make CURRENT_BUILD=[ARCH]/debug-noassertions-profiling&lt;br /&gt;
  [builds the debug-noassertions-profiling build, puts the binaries under builds/bin]&lt;br /&gt;
&lt;br /&gt;
===Determining the type of build from a binary===&lt;br /&gt;
&lt;br /&gt;
Sometimes you're left with a ''cvc4'' binary and have no idea what produced it.  Use the &amp;quot;&amp;lt;code&amp;gt;--show-config&amp;lt;/code&amp;gt;&amp;quot; command-line option to inspect it:&lt;br /&gt;
&lt;br /&gt;
 $ builds/bin/cvc4 --show-config&lt;br /&gt;
 This is a pre-release of CVC4.&lt;br /&gt;
 Copyright (C) 2009, 2010&lt;br /&gt;
   The ACSys Group&lt;br /&gt;
   Courant Institute of Mathematical Sciences,&lt;br /&gt;
   New York University&lt;br /&gt;
   New York, NY  10012  USA&lt;br /&gt;
 &lt;br /&gt;
 version   : prerelease&lt;br /&gt;
 &lt;br /&gt;
 debug code: yes&lt;br /&gt;
 tracing   : yes&lt;br /&gt;
 muzzled   : no&lt;br /&gt;
 assertions: yes&lt;br /&gt;
 coverage  : no&lt;br /&gt;
 profiling : no&lt;br /&gt;
&lt;br /&gt;
To see if the binary is statically linked, or not, use the '''ldd''' command:&lt;br /&gt;
&lt;br /&gt;
 $ ldd builds/bin/cvc4&lt;br /&gt;
         linux-gate.so.1 =&amp;gt;  (0x006b0000)&lt;br /&gt;
         libcvc4parser.so.0 =&amp;gt; /home/mdeters/cvc4-cleancheckout/builds/usr/local/lib/libcvc4parser.so.0 (0x00e6d000)&lt;br /&gt;
         libcvc4.so.0 =&amp;gt; /home/mdeters/cvc4-cleancheckout/builds/usr/local/lib/libcvc4.so.0 (0x00a75000)&lt;br /&gt;
         libgmp.so.3 =&amp;gt; /usr/lib/libgmp.so.3 (0x00110000)&lt;br /&gt;
         libstdc++.so.6 =&amp;gt; /usr/lib/libstdc++.so.6 (0x008d8000)&lt;br /&gt;
         libm.so.6 =&amp;gt; /lib/tls/i686/cmov/libm.so.6 (0x00a11000)&lt;br /&gt;
         libgcc_s.so.1 =&amp;gt; /lib/libgcc_s.so.1 (0x00298000)&lt;br /&gt;
         libc.so.6 =&amp;gt; /lib/tls/i686/cmov/libc.so.6 (0x002b6000)&lt;br /&gt;
         /lib/ld-linux.so.2 (0x00d91000)&lt;br /&gt;
&lt;br /&gt;
This was a dynamically-linked binary, and is dynamically-linked against the cvc4 libraries.  If the cvc4 libraries are missing from the list, the binary was statically-linked against the cvc4 libraries (and dynamically-linked against the others).  If ldd's output looks like this:&lt;br /&gt;
&lt;br /&gt;
 $ ldd /bin/bash-static&lt;br /&gt;
         not a dynamic executable&lt;br /&gt;
&lt;br /&gt;
then the cvc4 binary was configured with &amp;lt;code&amp;gt;--enable-static-binary&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Adding source and header files==&lt;br /&gt;
&lt;br /&gt;
To add a ''source'' file to CVC4, all you need to do is create the file, add the content, then:&lt;br /&gt;
&lt;br /&gt;
 $ svn add source_file.cpp&lt;br /&gt;
&lt;br /&gt;
to add it to the repository, and edit the appropriate &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt; (usually in that directory, or if not then in the immediate parent directory) to list the file under &amp;lt;code&amp;gt;*_SOURCES&amp;lt;/code&amp;gt; for the correct convenience library.  When you next build the project, the &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt;'s new timestamp should trigger ''make'' to regenerate the &amp;lt;code&amp;gt;Makefile.in&amp;lt;/code&amp;gt; (in the source directory) and the Makefile (in the build directory), remake dependencies for the source, and rebuild what's necessary.&lt;br /&gt;
&lt;br /&gt;
To add a ''header'' file to CVC4, create the file, add the content, then:&lt;br /&gt;
&lt;br /&gt;
 $ svn add header_file.h&lt;br /&gt;
&lt;br /&gt;
to add it to the repository, and edit the appropriate &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt; to list the file under &amp;lt;code&amp;gt;*_SOURCES&amp;lt;/code&amp;gt; for the correct convenience library.  All the above should still apply.&lt;br /&gt;
&lt;br /&gt;
If you have problems getting the Makefile.in/Makefile/dependencies rebuilt, or get a warning from the &amp;lt;code&amp;gt;missing&amp;lt;/code&amp;gt; script, re-run &amp;lt;code&amp;gt;autogen.sh&amp;lt;/code&amp;gt; in the top-level source directory, re-run &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt;, and then proceed.&lt;br /&gt;
&lt;br /&gt;
==Adding source directories==&lt;br /&gt;
&lt;br /&gt;
If you add a source ''directory'' to CVC4 (under &amp;lt;code&amp;gt;src/&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;test/&amp;lt;/code&amp;gt;), make sure it's pristine (that is, just as you want it in the repository), and then:&lt;br /&gt;
&lt;br /&gt;
# Add it to SVN: &amp;lt;pre&amp;gt;$ svn add newdir&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Make sure that the &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt; in the parent directory lists it in &amp;lt;code&amp;gt;SUBDIRS&amp;lt;/code&amp;gt; in the correct order (''e.g.,'' if it depends on the build artifacts of another subdirectory, it should be listed after).&lt;br /&gt;
# Run &amp;lt;code&amp;gt;contrib/addsourcedir ''path''&amp;lt;/code&amp;gt; to auto-generate a basic &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt;.  You'll need to edit the &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt;, but this gives you a template to start with.  Existing files are not overwritten.  Alternatively, you can generate these two Makefiles yourself:&lt;br /&gt;
## Create &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt; in the new directory (using as a template another &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt;).&lt;br /&gt;
## Set up &amp;lt;code&amp;gt;Makefile.am&amp;lt;/code&amp;gt; to build a convenience libtool library (&amp;lt;code&amp;gt;noinst_LTLIBRARIES&amp;lt;/code&amp;gt;) with an appropriate &amp;lt;code&amp;gt;lib*_la_SOURCES&amp;lt;/code&amp;gt; listing the headers and sources in the directory.&lt;br /&gt;
## Add the new convenience library to the &amp;lt;code&amp;gt;*_LIBADD&amp;lt;/code&amp;gt; in the parent directory.&lt;br /&gt;
## Create a &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; in the new directory (using other source &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;s as a template).  &lt;br /&gt;
# Add the new &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;s to SVN.&lt;br /&gt;
# You may need to re-run &amp;lt;code&amp;gt;autogen.sh&amp;lt;/code&amp;gt; in the top-level source directory.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;'s sole purpose is to support typing &amp;quot;''make''&amp;quot; inside a source subdirectory.  It needs to set up a few variables correctly and then include &amp;lt;code&amp;gt;Makefile.subdirs&amp;lt;/code&amp;gt; from the top level.  It looks like this: (but use a template from another source directory, it might be more up-to-date than this version)&lt;br /&gt;
&lt;br /&gt;
 topdir = ../..&lt;br /&gt;
 srcdir = src/expr&lt;br /&gt;
  &lt;br /&gt;
 include $(topdir)/Makefile.subdir&lt;br /&gt;
&lt;br /&gt;
First, &amp;lt;code&amp;gt;topdir&amp;lt;/code&amp;gt; is the relative path to the root of the source tree.  &amp;lt;code&amp;gt;srcdir&amp;lt;/code&amp;gt; is the relative path ''from'' the root to this directory.  &amp;lt;code&amp;gt;builddir&amp;lt;/code&amp;gt; should have the same definition for every subdirectory; it gives the full relative path to the associated build directory.  The &amp;lt;code&amp;gt;include&amp;lt;/code&amp;gt; line gets the standard rules for running ''make'' from a source subdirectory.&lt;br /&gt;
&lt;br /&gt;
'''Note also''' that when you add a convenience library you need to add it also to the unit testing makefile in &amp;lt;code&amp;gt;test/unit/Makefile.am&amp;lt;/code&amp;gt;.  This is because the testing framework links directly against the convenience libraries to avoid the symbols that are ''hidden'' by the linker.&lt;br /&gt;
&lt;br /&gt;
==Adding copyrighted sources==&lt;br /&gt;
&lt;br /&gt;
The procedure for adding sources from other projects is a bit trickier.  CVC4 incorporates source from others in a few different places:&lt;br /&gt;
&lt;br /&gt;
* ''autogen.sh'', our auto-build-system-generation script&lt;br /&gt;
* doxygen macros for autoconf (under ''contrib/'')&lt;br /&gt;
* MiniSat (under ''src/prop/minisat'')&lt;br /&gt;
* ANTLR3 (some parts under ''src/parser'')&lt;br /&gt;
&lt;br /&gt;
Naturally, we have other ''dependencies'' too, like on ''CxxTest'' and on ''libgmp'', but for these we don't need to copy source under our tree; we are simply a client of those tools.&lt;br /&gt;
&lt;br /&gt;
Generally, the steps you should perform when you choose to copy copyrighted sources into CVC4's source tree are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
'''Does this make sense?'''  Incorporating source from others can be a headache.  We have to exclude these sources from our copyright, and include their copyright notice in ours.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
'''Identify legal implications.'''  Is the license used by this software compatible with CVC4?  Are we permitted to copy their sources?  Are we permitted to modify them in any way?  Are we permitted to re-distribute them?&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
'''Create a vendor branch in the Subversion repository.'''  Before copying into the CVC4 tree, create a vendor version of the software you're about to import:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Import a pristine version into the repository under ''&amp;lt;nowiki&amp;gt;https://subversive.cims.nyu.edu/cvc4/vendor/$PACKAGE/$VERSION_NUMBER&amp;lt;/nowiki&amp;gt;''. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Copy to &amp;quot;current&amp;quot;:&amp;lt;pre&amp;gt;svn copy https://subversive.cims.nyu.edu/cvc4/vendor/$PACKAGE/$VERSION_NUMBER https://subversive.cims.nyu.edu/cvc4/vendor/$PACKAGE/current&amp;lt;/pre&amp;gt; &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Now copy into the cvc4 source tree.  You can &amp;quot;copy&amp;quot; into your current working directory with svn checkout, for example:&amp;lt;pre&amp;gt;svn checkout https://subversive.cims.nyu.edu/cvc4/vendor/$PACKAGE/current src/util/bar&amp;lt;/pre&amp;gt; will copy your package under CVC4's src/util directory as &amp;quot;bar.&amp;quot;  '''It is important that you use svn to do this, so there's a record of the link between the vendor branch and the &amp;quot;bar&amp;quot; directory.'''&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
'''Importing another build system.'''  If you're importing sources, you have to decide how to cleanly incorporate the imported project with CVC4.  In most cases, for small imported projects, it's easiest to create a Makefile.am in their top-level that is just like our Makefile.am files, and compiles their entire project.  But you may need to rely on their ''configure''/''make'' build system if the imported project is more complex, which means that in the future we may need to create [http://www.gnu.org/software/autoconf/manual/autoconf.html#Subdirectories configurable subprojects] (though it'd be nice to avoid that, if possible).  Use your best judgment.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
'''Adding a copyright exemption.'''  You '''MUST''' edit the ''COPYING'' file at the top-level source directory for CVC4.  I am not a lawyer, however, I would say that '''this is crucial'''.  In ''COPYING'', indicate:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Where the copied sources are in the CVC4 tree. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; What its copyright and (lack of) warranty is.  Include all its legal information. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
There are a lot of examples in ''COPYING'' already of this; use them as a template.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
'''Exclude from auto-copyright.'''  If you have imported headers or source files into the CVC4 tree, '''you must edit''' the ''contrib/update-copyright.pl'' script to make sure it doesn't automatically add CVC4's copyright to the top of the file the next time it's run.  Add the full (relative) path to it under ''$excluded_paths'' (''$excluded_directories'' are names excluded at any level of the directory tree).  If you don't know Perl-compatible regular expressions, ask someone.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Coding guidelines=&lt;br /&gt;
&lt;br /&gt;
The following sections attempt to standardize C++ coding and organizational style for the CVC4 project.&lt;br /&gt;
&lt;br /&gt;
Note that many of these standards apply to unit tests under &amp;lt;code&amp;gt;test/&amp;lt;/code&amp;gt; as well, but many do not.&lt;br /&gt;
&lt;br /&gt;
The guiding philosophy in the coding guidelines for CVC4 is to make the code readable and consistent throughout without getting in the way by being overly restrictive.  Flexibility is afforded in edge cases where the developer should make his or her best effort to satisfy the guidelines, but not at the expense of making the code less readable or formatted poorly or insensibly.&lt;br /&gt;
&lt;br /&gt;
==File and directory names==&lt;br /&gt;
&lt;br /&gt;
* File names are all lowercase.  Class ''FooSolver'' has its definition in &amp;lt;code&amp;gt;foo_solver.h&amp;lt;/code&amp;gt; and its implementation in &amp;lt;code&amp;gt;foo_solver.cpp&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* File extensions &amp;lt;code&amp;gt;.cpp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.h&amp;lt;/code&amp;gt; are generally preferred, with &amp;lt;code&amp;gt;.ypp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.lpp&amp;lt;/code&amp;gt; for yacc and lex inputs---an exception is made for headers when other tools have clashing preferences for generated sources; ''e.g.'', autotools wants to output parser definitions for the presentation language as &amp;lt;code&amp;gt;pl.hpp&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Preprocessor macros==&lt;br /&gt;
&lt;br /&gt;
Preprocessor macros should be avoided when possible.&lt;br /&gt;
&lt;br /&gt;
Preprocessor macro names are &amp;lt;code&amp;gt;ALWAYS_UPPERCASE&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Binary macros ===&lt;br /&gt;
&lt;br /&gt;
A binary macro is a symbol that has two states. There are two kinds of binary macros:&lt;br /&gt;
&lt;br /&gt;
* A macro that is either &amp;quot;defined&amp;quot; or &amp;quot;undefined.&amp;quot; These macros should have names that are nouns or noun phrases. The should not be defined to have a value&amp;amp;mdash;their definition should be empty. For example:&lt;br /&gt;
  #define DEBUG&lt;br /&gt;
These macros can be tested using the &amp;lt;code&amp;gt;#ifdef&amp;lt;/code&amp;gt; directive:&lt;br /&gt;
  #ifdef DEBUG&lt;br /&gt;
  /* ... */&lt;br /&gt;
  #endif /* DEBUG */&lt;br /&gt;
&lt;br /&gt;
* A macro that has one of the values 0 or 1. These macros should have names that are verbs or verb phrases. For example:&lt;br /&gt;
  #define USE_MINISAT 1&lt;br /&gt;
These macros should be tested using &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; statements rather than preprocessor directives:&lt;br /&gt;
  if(USE_MINISAT) {&lt;br /&gt;
    /* do something with minisat */&lt;br /&gt;
  } else {&lt;br /&gt;
    /* some non-minisat default behavior */&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=== Block macros ===&lt;br /&gt;
&lt;br /&gt;
Macros that expand to multiple statements should use the &amp;lt;code&amp;gt;do { ... } while(0)&amp;lt;/code&amp;gt;. For example, a macro &amp;lt;code&amp;gt;FOO&amp;lt;/code&amp;gt; that generates the statements &amp;lt;code&amp;gt;S1; S2;&amp;lt;/code&amp;gt; should be defined using&lt;br /&gt;
    #define FOO do { S1; S2; } while(0)&lt;br /&gt;
(Note that there is ''no semicolon'' after &amp;lt;code&amp;gt;while(0)&amp;lt;/code&amp;gt;.)&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous ===&lt;br /&gt;
&lt;br /&gt;
* Since macro parameters may be expressions with side effects, they should not be used multiple times in a definition.&lt;br /&gt;
&lt;br /&gt;
* Remember these aren't hygienic macros!  You can capture names:&lt;br /&gt;
   #define ADD(c, a, b) { int x = a, y = b; c = x + y; }&lt;br /&gt;
   int main() {&lt;br /&gt;
     int x = 5;&lt;br /&gt;
     // print out the value x + x ^ 2 (should be 30)&lt;br /&gt;
     int z;&lt;br /&gt;
     ADD(z, x, x * x);&lt;br /&gt;
     printf(&amp;quot;%d\n&amp;quot;, z); // does NOT print 30  :-(&lt;br /&gt;
   }&lt;br /&gt;
The usual way to combat this problem is to prefix the names in the macro with underscores:&lt;br /&gt;
   #define ADD(c, a, b) { int __x = a, __y = b; c = x + y; }&lt;br /&gt;
Though it's best to use longer names and perhaps to mix in the name of the macro as well, to avoid any possible clash.&lt;br /&gt;
&lt;br /&gt;
* Except when you're playing clever/stupid tricks with macro expansion, you should guard against unwitting order-of-operations surprises by parenthesizing arguments when expanded in macro bodies:&lt;br /&gt;
   #define ADD(c, a, b) { int __add_x = (a), __add_y = (b); (c) = x + y; }&lt;br /&gt;
This approximates (in this case) macro-call-by-value.&lt;br /&gt;
&lt;br /&gt;
* There is an exception to the &amp;lt;code&amp;gt;ALWAYS_UPPERCASE&amp;lt;/code&amp;gt; rule for ''CVC4::Assert()'' and friends.&lt;br /&gt;
&lt;br /&gt;
==Class names==&lt;br /&gt;
&lt;br /&gt;
* Classes, and type names in general, are in CamelCase.  There are exceptions to this rule, however, where lower case names with embedded underscores are acceptable:&lt;br /&gt;
** STL type names are not CamelCase, and when implementing traits and STL-like typedefs (''iterators'' for instance), you should match the STL style as closely as possible:&lt;br /&gt;
  class Foo {&lt;br /&gt;
    class Item;&lt;br /&gt;
    typedef Item*       iterator;&lt;br /&gt;
    typedef const Item* const_iterator;&lt;br /&gt;
  };&lt;br /&gt;
** for low-level ''exception'' types (similar to STL's &amp;lt;code&amp;gt;bad_alloc&amp;lt;/code&amp;gt;).  However, for derived classes of ''CVC4::Exception'', the names should be CamelCase.&lt;br /&gt;
** Low-level unions and structs may be in a similar lower case form, ''e.g.'', &amp;lt;code&amp;gt;low_level_struct&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Note that acronyms (SMT, CVC4) inside ''type'' names should generally be lowercase after the first letter, such as in ''CVC4::SmtEngine''.  This is preferred to ''SMTEngine'' or ''SMT_Engine'', but use judgment on a case-by-case basis.&lt;br /&gt;
&lt;br /&gt;
==Namespaces==&lt;br /&gt;
&lt;br /&gt;
* Everything is in the ''CVC4'' namespace or a sub-namespace.  Generally, the sub-namespace follows the module (and thus the source directory) structure.  The name remains uncapitalized, and acronyms are all in lowercase letters (''e.g.'' ''CVC4::smt'', ''CVC4::main'', ''CVC4::parser'').  However, certain base types go in ''CVC4'' directly ''instead'' of a sub-namespace despite belonging to a module.  These are user-visible (such as ''CVC4::Exception''), core functionality classes, and utility classes from &amp;lt;code&amp;gt;src/util/&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Member names==&lt;br /&gt;
&lt;br /&gt;
* Data members are prefixed with &amp;lt;code&amp;gt;d_&amp;lt;/code&amp;gt;, and are generally in lowerCamelCase after that.  For example:&lt;br /&gt;
  class Foo {&lt;br /&gt;
    int d_thisIsAnInt;&lt;br /&gt;
  };&lt;br /&gt;
* Static members are prefixed with &amp;lt;code&amp;gt;s_&amp;lt;/code&amp;gt;:&lt;br /&gt;
  class Foo {&lt;br /&gt;
    static int s_thisIsAStaticInt;&lt;br /&gt;
  };&lt;br /&gt;
* Union elements are prefixed with &amp;lt;code&amp;gt;u_&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* There is an exception to these rules for low-level ''struct'' types that have no member functions and no destructors (and only simple, initializing constructors).  For an example see the definition of ''CVC4::Options'' in &amp;lt;code&amp;gt;src/util/options.h&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Class Organization==&lt;br /&gt;
&lt;br /&gt;
Declarations of class members should be organized as follows.&lt;br /&gt;
&lt;br /&gt;
* Members are declared in the following order:&lt;br /&gt;
:# Typedefs and friend declarations&lt;br /&gt;
:# Static members&lt;br /&gt;
:# Data members&lt;br /&gt;
:# Constructors and destructors&lt;br /&gt;
:# Methods&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;public&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;private&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;protected&amp;lt;/code&amp;gt; sections may come in any order. Alternation between sections should be minimized as much as possible.&lt;br /&gt;
&lt;br /&gt;
==Communicating with the user: the output classes==&lt;br /&gt;
&lt;br /&gt;
ALL OUTPUT through ''Debug'' and ''Trace'' and ''Notice'' and ''Warning'' functionality please!  Very easy:&lt;br /&gt;
  #include &amp;quot;util/output.h&amp;quot;&lt;br /&gt;
  CVC4::Debug(&amp;quot;arith&amp;quot;, &amp;quot;foo!&amp;quot;); // prints &amp;quot;foo!&amp;quot; if arith debugging is on&lt;br /&gt;
  CVC4::Warning(&amp;quot;Equivalence classes didn't get merged.&amp;quot;); // prints unless user gave -q or in SMT-COMP mode&lt;br /&gt;
  CVC4::Notice(&amp;quot;Hi, so you don't get bored, here are some statistics: &amp;quot; + stats); // if user gives -v&lt;br /&gt;
  CVC4::Chat(&amp;quot;I feel like doing some theory propagation.&amp;quot;);// if user gives -vv&lt;br /&gt;
  CVC4::Trace(&amp;quot;arith&amp;quot;, &amp;quot;&amp;lt;ralph&amp;gt;I'm now calling a function!&amp;lt;/ralph&amp;gt;&amp;quot;);// if user gives -vvv&lt;br /&gt;
''Chatting'' in particular should be useful for tuning/strategy things.  Parts of the code that aren't conditional on particular settings in CVC4 should avoid ''Chat'' and use ''Trace'' or ''Debug''.  Tracing is tagged with the module to which it's relevant.  The above add a &amp;lt;code&amp;gt;\n&amp;lt;/code&amp;gt; for you.  If you don't want that, you can use a &amp;lt;code&amp;gt;printf()&amp;lt;/code&amp;gt; interface:&lt;br /&gt;
  CVC4::Debug::printf(&amp;quot;arith&amp;quot;, &amp;quot;foo!&amp;quot;); // no line termination&lt;br /&gt;
or the stream interface:&lt;br /&gt;
  CVC4::Debug(&amp;quot;arith&amp;quot;) &amp;lt;&amp;lt; &amp;quot;foo!&amp;quot;; // also no line termination&lt;br /&gt;
For non-debug builds, ''CVC4::Debug'' is a no-op and everything will be inlined away.&lt;br /&gt;
&lt;br /&gt;
==Assertions==&lt;br /&gt;
&lt;br /&gt;
CVC4 Assertions:&lt;br /&gt;
  #include &amp;quot;util/assert.h&amp;quot;&lt;br /&gt;
  CVC4::Assert(condition); // asserts condition is true&lt;br /&gt;
  CVC4::Assert(condition, &amp;quot;error message on fail&amp;quot;); // asserts condition is true, custom error message&lt;br /&gt;
Note that Assert is a macro (in order to collect source line and file and expression-string information from the C preprocessor).  A ''CVC4::AssertionException'' is thrown if it fails.  When assertions are turned off, this is a no-op and everything is inlined away.&lt;br /&gt;
&lt;br /&gt;
The above assertions can be turned off (with &amp;lt;code&amp;gt;--disable-assertions&amp;lt;/code&amp;gt; at ''configure''-time).  You might want to have an assertion be checked even if assertions are off.  For example:&lt;br /&gt;
# ''Unreachable code.''  If you have a section of code that is intended to be unreachable (you have, perhaps, proved on paper that the code should never enter this state), it costs nothing to check the assertion (it's essentially an &amp;lt;code&amp;gt;assert(false)&amp;lt;/code&amp;gt;---''always'' fail).&lt;br /&gt;
# ''Highly-compromised state.'' In cases where a wrong answer is unlikely and the assertion check is cheap and infrequently-run, you may consider leaving an assertion in.  This is the case also with the above unreachable-code assertion.&lt;br /&gt;
&lt;br /&gt;
For ''unreachable code'', use the &amp;lt;code&amp;gt;Unreachable()&amp;lt;/code&amp;gt; macro.  It will throw a ''CVC4::UnreachableCodeException'' (a subclass of ''CVC4::AssertionException''):&lt;br /&gt;
  #include &amp;quot;util/assert.h&amp;quot;&lt;br /&gt;
  CVC4::Unreachable(); // flags (supposedly) unreachable code; fails even under --disable-assertions&lt;br /&gt;
  CVC4::Unreachable(&amp;quot;error message&amp;quot;); // custom error message&lt;br /&gt;
&lt;br /&gt;
Another special case is an ''unhandled case'' (for example, a ''default'' block in a switch that was designed to handle all cases).  It will throw a ''CVC4::UnhandledCaseException'' (a subclass of ''CVC4::UnreachableCodeException''):&lt;br /&gt;
  #include &amp;quot;util/assert.h&amp;quot;&lt;br /&gt;
  CVC4::Unhandled(); // flags an unhandled case; fails even under --disable-assertions&lt;br /&gt;
  CVC4::Unhandled(the_case); // same but prints out the_case that's unhandled as well (which should be whatever is in the switch)&lt;br /&gt;
  CVC4::Unhandled(&amp;quot;error message&amp;quot;); // custom error message&lt;br /&gt;
  CVC4::Unhandled(the_case, &amp;quot;error message&amp;quot;); // custom error message with the_case that is unhandled&lt;br /&gt;
&lt;br /&gt;
For a ''strong'' assertion that's checked even with &amp;lt;code&amp;gt;--disable-assertions&amp;lt;/code&amp;gt;, use an &amp;lt;code&amp;gt;AlwaysAssert()&amp;lt;/code&amp;gt;.  It throws a ''CVC4::AssertionException'' just as &amp;lt;code&amp;gt;Assert()&amp;lt;/code&amp;gt; does.&lt;br /&gt;
  #include &amp;quot;util/assert.h&amp;quot;&lt;br /&gt;
  CVC4::AlwaysAssert(condition);&lt;br /&gt;
  CVC4::AlwaysAssert(condition, &amp;quot;error message&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
==Doxygen comments==&lt;br /&gt;
&lt;br /&gt;
==Exporting library symbols==&lt;br /&gt;
&lt;br /&gt;
When built with a GNU toolchain, libcvc4 hides all symbols by default (with &amp;lt;code&amp;gt;-fvisibility-hidden&amp;lt;/code&amp;gt;).  This is a good way to ensure that the public interface is complete, that no undocumented interface is used by anyone, and it also permits more aggressive optimization of the library.  Those symbols intended to be the public interface to CVC4, however, must be ''explicitly'' exported.&lt;br /&gt;
&lt;br /&gt;
Fortunately, this isn't difficult.  To use a symbol, a user should have a header file anyway.  Only a subset of CVC4 headers are installed with &amp;lt;code&amp;gt;make install&amp;lt;/code&amp;gt;, and these all live in &amp;lt;code&amp;gt;src/include/&amp;lt;/code&amp;gt; and comprise the complete public interface.  Public symbols are marked with &amp;lt;code&amp;gt;CVC4_PUBLIC&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
  class CVC4_PUBLIC Expr {&lt;br /&gt;
    /* ... */&lt;br /&gt;
  public:&lt;br /&gt;
    Expr();&lt;br /&gt;
  };&lt;br /&gt;
&lt;br /&gt;
Note here that ''types'' and ''private members'' need not be marked &amp;lt;code&amp;gt;CVC4_EXPORT&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Now.  What do you care?  Well, if you ever forward-declare something that's public, you have to mark it PUBLIC in the forward-declaration too.  (Is this true??)&lt;br /&gt;
&lt;br /&gt;
Exception classes should all be marked CVC4_PUBLIC, because they might end up in user code (external to ''libcvc4'') and their ''type_info'' information must be available to the catch block in user code.  If you don't think your exception can (nor should by design) exit the library and end up in user code, then first double-check this, then triple-check it, then document that fact clearly at call site, the catch site (inside the library), and at the exception class definition.&lt;br /&gt;
&lt;br /&gt;
See http://gcc.gnu.org/wiki/Visibility for more information on visibility.&lt;br /&gt;
&lt;br /&gt;
==Source file layout==&lt;br /&gt;
&lt;br /&gt;
===Class header files===&lt;br /&gt;
&lt;br /&gt;
* A class named &amp;lt;code&amp;gt;AdjectiveNoun&amp;lt;/code&amp;gt; has its definition in &amp;lt;code&amp;gt;adjective_noun.h&amp;lt;/code&amp;gt;. Each header file is guarded by a preprocessor macro to prevent duplicate declarations. For example, in &amp;lt;code&amp;gt;adjective_noun.h&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
    #ifndef __CVC4__ADJECTIVE_NOUN_H&lt;br /&gt;
    #define __CVC4__ADJECTIVE_NOUN_H&lt;br /&gt;
    &lt;br /&gt;
    ... declarations go here ...&lt;br /&gt;
    &lt;br /&gt;
    #endif /* __CVC4__ADJECTIVE_NOUN_H */&lt;br /&gt;
&lt;br /&gt;
Generally all &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt;s of other headers should go inside the &amp;lt;code&amp;gt;#ifndef&amp;lt;/code&amp;gt; guard.  There is an exception though (with an &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; going above the guard) for circular dependencies and other special circumstances.  Such things should be documented in the code.  All &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt;s should generally go at the top of the file, however, for inlined and template implementations following a class definition, sometimes additional files should be included after the class definition but before these member function definitions (again, when breaking circular dependencies).&lt;br /&gt;
&lt;br /&gt;
If the class &amp;lt;code&amp;gt;AdjectiveNoun&amp;lt;/code&amp;gt; is in the &amp;lt;code&amp;gt;CVC4&amp;lt;/code&amp;gt; namespace, the macro guard is named &amp;lt;code&amp;gt;__CVC4__ADJECTIVE_NOUN_H&amp;lt;/code&amp;gt;. If it is in a sub-namespace &amp;lt;code&amp;gt;Foo&amp;lt;/code&amp;gt;, then the macro guard is &amp;lt;code&amp;gt;__CVC4__FOO__ADJECTIVE_NOUN_H&amp;lt;/code&amp;gt;. Note the ''two'' underscores for each &amp;lt;code&amp;gt;::&amp;lt;/code&amp;gt; and the two prefix underscores.  One underscore is used between words in a type or namespace name.&lt;br /&gt;
* Prefer forward-declaration of classes instead of &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt;'ing their header from another header, wherever this is possible.&lt;br /&gt;
* Public headers (in &amp;lt;code&amp;gt;src/include/&amp;lt;/code&amp;gt;), use preprocessor macro guard &amp;lt;code&amp;gt;__CVC4_&amp;lt;/code&amp;gt;''headername''&amp;lt;code&amp;gt;_H&amp;lt;/code&amp;gt;, for example, &amp;lt;code&amp;gt;__CVC4_EXPR_H&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;cvc4_expr.h&amp;lt;/code&amp;gt;.  Note here the ''one'' underscore between ''CVC4'' and the name.&lt;br /&gt;
* Other (non-class) header files should use a similar preprocessor macro guard, based on relevant module and header file name, as class header files do.  In all cases, prefix the name of the guard with &amp;lt;code&amp;gt;__CVC4_&amp;lt;/code&amp;gt; and design it to be unlikely that it will ever conflict with any other (future) CVC4 header, whether it might be for internal use only or externally provided to a library user.&lt;br /&gt;
* Everything should be in the ''CVC4'' namespace, or a sub-namespace of ''CVC4'' (based on module).&lt;br /&gt;
* '''For test classes.'''  [[#Unit testing|Unit test classes (under &amp;lt;code&amp;gt;test/unit/&amp;lt;/code&amp;gt;)]] are implemented as header files and do not need to be in a namespace, nor guarded by a preprocessor macro.  The idea is to keep them as simple and ''clean'' as possible, so the tests can be easily read.  They are special-purpose and compiled and linked individually, so they don't need these protections.&lt;br /&gt;
&lt;br /&gt;
===Class implementation files===&lt;br /&gt;
&lt;br /&gt;
* A class named ''ThisIsAClass'' should have its implementation under &amp;lt;code&amp;gt;src/&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;this_is_a_class.cpp&amp;lt;/code&amp;gt; in the relevant module directory.&lt;br /&gt;
&lt;br /&gt;
===Imported sources===&lt;br /&gt;
&lt;br /&gt;
* '''For imported sources.'''  Make sure to add an exclusion to the &amp;lt;code&amp;gt;contrib/update-copyright.pl&amp;lt;/code&amp;gt; script so that a CVC4 copyright isn't added when the script is run.&lt;br /&gt;
&lt;br /&gt;
==Source file headers==&lt;br /&gt;
&lt;br /&gt;
* A common comment blurb heads all sources in CVC4 (including lex and yacc inputs and unit tests, but excluding imported sources).&lt;br /&gt;
* A script, &amp;lt;code&amp;gt;update-copyright.pl&amp;lt;/code&amp;gt; is used to maintain/update this comment blurb.&lt;br /&gt;
&lt;br /&gt;
===update-copyright.pl===&lt;br /&gt;
&lt;br /&gt;
* You can run &amp;lt;code&amp;gt;contrib/update-copyright.pl&amp;lt;/code&amp;gt; to update ''all'' sources with a new copyright template.  (Some) efforts are made to throw away old boilerplate comment blurbs while keeping file-specific comments.&lt;br /&gt;
* '''PLEASE BE CAREFUL.'''  This updates files in place without keeping a backup.  ''The script is probably buggy.  You have been warned.''  It's best to do this on a copy of your source tree, or on a fresh repository checkout.  (The program will warn you too.)&lt;br /&gt;
* Please consult &amp;lt;code&amp;gt;svn diff&amp;lt;/code&amp;gt; before committing changes made by the script.&lt;br /&gt;
* You can run the update script on specific files/directories by providing arguments to the script.  By default it processes all sources in the &amp;lt;code&amp;gt;src/&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;test/&amp;lt;/code&amp;gt; directories.&lt;br /&gt;
&lt;br /&gt;
==Using emacs==&lt;br /&gt;
&lt;br /&gt;
* There's an emacs-lisp snippet available that you can drop in your &amp;lt;code&amp;gt;~/.emacs&amp;lt;/code&amp;gt; to conform to spacing, indentation, etc., in the CVC4 source tree.&lt;br /&gt;
* See &amp;lt;code&amp;gt;contrib/editing-with-emacs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Textual source layout==&lt;br /&gt;
&lt;br /&gt;
===Whitespace/tabs===&lt;br /&gt;
&lt;br /&gt;
* No tabs, please.&lt;br /&gt;
* No whitespace between '''if''', '''for''', '''while''', ''''catch'''', etc., and their opening parenthesis.&lt;br /&gt;
* One space between closing paren and open curly brace (except if aligning to other nearby source lines).&lt;br /&gt;
** The matching right curly brace goes on a line by itself (possibly with an end-comment tagging the construct it's part of) in the same column as the first letter of the construct keyword.  (That is, the right-brace lines up with the '''if''', '''for''', etc.)&lt;br /&gt;
* One space around binary operators to avoid crowding, ''e.g.'':&lt;br /&gt;
   x = y;&lt;br /&gt;
   z = y + 1;&lt;br /&gt;
* In complicated arithmetic expressions, even when parentheses aren't required by operator order of evaluation, sometimes parentheses and extra spacing and alignment should be used for ''visual'' clarity, or to match more closely what is being implemented, what is described in associated source code comments, or both.  For example:&lt;br /&gt;
   if( ( ( x1 + y1 ) - ( z  * 2 ) ) &amp;lt;=  4 ||&lt;br /&gt;
       ( ( x2 + y2 ) - ( zp * 2 ) ) &amp;gt;= -4 ) { ... }&lt;br /&gt;
* Occasionally to emphasize a !, so it doesn't get visually lost, it's best followed or even surrounded by space.  For example, this is bad:&lt;br /&gt;
   if(!(x + y &amp;gt; 4 &amp;amp;&amp;amp; z &amp;lt; x)) ...&lt;br /&gt;
* while this is much preferred, since it emphasizes the negation of the entire condition:&lt;br /&gt;
   if( !( x + y &amp;gt; 4 &amp;amp;&amp;amp; z &amp;lt; x ) ) { ... }&lt;br /&gt;
* (assuming that it's preferable '''not''' to rewrite this as x + y &amp;lt;= 4 for some other reason of course).&lt;br /&gt;
* Between type names and &amp;lt;code&amp;gt;*/&amp;amp;&amp;lt;/code&amp;gt; when declaring members and variables, to emphasize the ''introduced name'' is a pointer:&lt;br /&gt;
  Foo *a, *b;&lt;br /&gt;
* ''NOT'' between type names and &amp;lt;code&amp;gt;*/&amp;amp;&amp;lt;/code&amp;gt; when in an argument list or return type, to emphasize that the ''type'' is a pointer:&lt;br /&gt;
  Bar* fooToBar(Foo* f);&lt;br /&gt;
* There is an exception for array types.  Since &amp;lt;code&amp;gt;char *argv[]&amp;lt;/code&amp;gt; is actually an array of pointers, it doesn't make sense to attach &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; to the type in this case (in C/C++, the &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt; must come after the formal name and can't be attached to the type name, as it can be in Java).  In particular:&lt;br /&gt;
  int main(int argc, char *argv[]);&lt;br /&gt;
is how the signature for the ''main'' function is written.&lt;br /&gt;
* No trailing spaces please.  ''M-x delete-trailing-whitespace'' in emacs might help.&lt;br /&gt;
&lt;br /&gt;
===Increment/Decrement===&lt;br /&gt;
&lt;br /&gt;
* Preincrement/decrement preferred over postincrement/-decrement, ''e.g.'':&lt;br /&gt;
   for(int x = 0; x &amp;lt; 10; ++x) { ... }&lt;br /&gt;
&lt;br /&gt;
===Bracing===&lt;br /&gt;
&lt;br /&gt;
* Braces are not required around one-line blocks, but preferred in complicated cases, especially with if (to avoid visually-ambiguous '''else'''s).&lt;br /&gt;
** ''E.g.'' this is fine:&lt;br /&gt;
    if(extra_output)&lt;br /&gt;
      do_something();&lt;br /&gt;
** But this is debatable (preferring braces on the &amp;lt;code&amp;gt;if()&amp;lt;/code&amp;gt; but not the &amp;lt;code&amp;gt;for():&amp;lt;/code&amp;gt;&lt;br /&gt;
    if(extra_output)&lt;br /&gt;
      for(int i = 0; i &amp;lt; 10; ++i)&lt;br /&gt;
        do_something();&lt;br /&gt;
** And this is horrible:&lt;br /&gt;
    if(extra_output)&lt;br /&gt;
      do_something_simple();&lt;br /&gt;
    else&lt;br /&gt;
      while(!done)&lt;br /&gt;
        for(int i = 0; i &amp;lt; 10; ++i)&lt;br /&gt;
          if(a[i] &amp;lt; 5)&lt;br /&gt;
            a[i + 10] += a[i];&lt;br /&gt;
&lt;br /&gt;
* Generally, if the ''then'' part of an '''if''' is complicated and braced, but the ''else'' part is simple, the else need not be braced but may be.  But if the '''else''' part is complicated and braced then the '''then''' part should be (even if it's simple).&lt;br /&gt;
* If in doubt, brace.&lt;br /&gt;
* If anything is visually ambiguous, brace for clarity.&lt;br /&gt;
&lt;br /&gt;
===Indentation===&lt;br /&gt;
&lt;br /&gt;
* Indentation level is 2.&lt;br /&gt;
* No indentation under ''switch() {}'' or ''namespace {}''&lt;br /&gt;
** An exception is forward-declarations inside namespaces, where you ''do'' indent.  For instance, from &amp;lt;code&amp;gt;src/include/cvc4_expr.h&amp;lt;/code&amp;gt;:&lt;br /&gt;
   namespace CVC4 {&lt;br /&gt;
   &lt;br /&gt;
   namespace expr {&lt;br /&gt;
     class ExprValue;&lt;br /&gt;
   }/* CVC4::expr namespace */&lt;br /&gt;
   &lt;br /&gt;
   class Expr {&lt;br /&gt;
     /* ... */&lt;br /&gt;
   }/* class Expr */&lt;br /&gt;
   &lt;br /&gt;
   }/* CVC4 namespace */&lt;br /&gt;
* Goto labels, case labels, and &amp;quot;private/public/protected&amp;quot; are recessed 2.&lt;br /&gt;
* &amp;lt;code&amp;gt;template &amp;lt;class T&amp;gt;&amp;lt;/code&amp;gt; generally belongs on its own line before a function declaration or definition.  An exception is inside a class file where there's a long string of simple functions that are best not separated by vertical space.&lt;br /&gt;
* If something is templated in this way, the entire construct must be vertically separated from its surroundings with blank lines, and the &amp;lt;code&amp;gt;template &amp;lt;&amp;gt;&amp;lt;/code&amp;gt; specification is on its own line.&lt;br /&gt;
* Attempt to keep lines under 80 columns wide.  Though if this makes things excessively ugly or confusing, it's probably ok to go over 80.&lt;br /&gt;
* Indentation level is 2 for preprocessor directives as well, but the leading # is ''always'' in the first column.  For example:&lt;br /&gt;
  #if A&lt;br /&gt;
  #  if B&lt;br /&gt;
  #    warning A B case&lt;br /&gt;
  #  else /* ! B */&lt;br /&gt;
  #    warning A -B case&lt;br /&gt;
  #  endif /* B */&lt;br /&gt;
  #else /* ! B */&lt;br /&gt;
  #  if B&lt;br /&gt;
  #    warning -A B case&lt;br /&gt;
  #  else /* ! B */&lt;br /&gt;
  #    warning -A -B case&lt;br /&gt;
  #  endif /* B */&lt;br /&gt;
  #endif /* A */&lt;br /&gt;
&lt;br /&gt;
==Misc C++==&lt;br /&gt;
&lt;br /&gt;
* int foo(void) -- (void) unnecessary&lt;br /&gt;
* An array reference &amp;lt;code&amp;gt;a[i]&amp;lt;/code&amp;gt; in C++ may also be reversed as &amp;lt;code&amp;gt;i[a]&amp;lt;/code&amp;gt;, due to a symmetric definition of &amp;lt;code&amp;gt;operator[]&amp;lt;/code&amp;gt; when applied to array and integral types in C.  In CVC4, array indexing should be done in the standard way.&lt;br /&gt;
* never use &amp;quot;using&amp;quot; in header files&lt;br /&gt;
* enums require operator&amp;lt;&amp;lt;&lt;br /&gt;
&lt;br /&gt;
==Intentionally not covered==&lt;br /&gt;
&lt;br /&gt;
* 0 vs NULL&lt;br /&gt;
&lt;br /&gt;
=Use of autotools: automake, autoconf, autoheader, libtool=&lt;br /&gt;
&lt;br /&gt;
* Please don't check into the repository things generated by automake, autoconf, or autoheader, for example: &amp;lt;code&amp;gt;config.h.in&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Makefile.in&amp;lt;/code&amp;gt;s, &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt;s, &amp;lt;code&amp;gt;ylwrap&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;libtool&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;aclocal.m4&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;missing&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;config.guess&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
&lt;br /&gt;
=Commit policy=&lt;br /&gt;
&lt;br /&gt;
* Before you commit, everything should be documented and your code should conform to the coding guidelines.&lt;br /&gt;
* An automated bot will review code commits and complain loudly to you if it doesn't like your documentation or coding style.&lt;br /&gt;
* Clark will review all code commits for content.&lt;br /&gt;
* Others in the group will review Clark's commits for content.&lt;br /&gt;
* Unit tests should be included to test any new functionality included in your commit.  These tests should pass the ''gcov'' coverage assessment for CVC4.&lt;br /&gt;
&lt;br /&gt;
=Unit tests with CxxTest=&lt;br /&gt;
&lt;br /&gt;
There are two unit tests for modules:&lt;br /&gt;
* those written by the main author of the module/piece of functionality (white-box)&lt;br /&gt;
* those written by another group member to test the exported interface of the module (black-box)&lt;br /&gt;
&lt;br /&gt;
==Coverage testing with gcov==&lt;br /&gt;
&lt;br /&gt;
Every ''non-exceptional'' line of code should be tickled by a unit test. To generate code coverage information, configure CVC4 with &amp;lt;code&amp;gt;--enable-coverage&amp;lt;/code&amp;gt;, recompile the project, then run &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The code coverage information for a single file &amp;lt;code&amp;gt;SRC_PATH/foo.cpp&amp;lt;/code&amp;gt; (and its &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt;'d dependencies) can be obtained by executing:&lt;br /&gt;
    gcov -o builds/ARCH/BUILD_ID/SRC_PATH SRC_PATH/foo.cpp&lt;br /&gt;
''If you have multiple builds configured simultaneously, remember to use the correct BUILD_ID!  It will have '''coverage''' in its name, something like '''debug-coverage''' or '''production-coverage'''.''&lt;br /&gt;
This will print out the percentage coverage of each processed file and create a set of &amp;lt;code&amp;gt;.gcov&amp;lt;/code&amp;gt; files in the current directory. The &amp;lt;code&amp;gt;.gcov&amp;lt;/code&amp;gt; files reproduce the source code with execution counts. More information about &amp;lt;code&amp;gt;gcov&amp;lt;/code&amp;gt; usage is available from [http://gcc.gnu.org/onlinedocs/gcc/Gcov.html the online manual].&lt;br /&gt;
&lt;br /&gt;
You can use the [http://ltp.sourceforge.net/coverage/lcov.php &amp;lt;code&amp;gt;lcov&amp;lt;/code&amp;gt;] tool to produce a more global, browseable coverage report. (&amp;lt;code&amp;gt;lcov&amp;lt;/code&amp;gt; is installable via ''APT'' and the package includes both ''lcov'' and ''genhtml'', used below). Simply run &amp;lt;code&amp;gt;make lcov&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If that doesn't work for some reason, you can try running &amp;lt;code&amp;gt;lcov&amp;lt;/code&amp;gt; manually. After running &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt; with a coverage-enabled build, execute:&lt;br /&gt;
   mkdir -p HTML_DIR&lt;br /&gt;
   lcov --directory builds/ARCH/BUILD_ID/ --capture --output-file HTML_DIR/cvc4-gcov.info&lt;br /&gt;
   cd HTML_DIR&lt;br /&gt;
   genhtml cvc4-gcov.info&lt;br /&gt;
Open &amp;lt;code&amp;gt;HTML_DIR/index.html&amp;lt;/code&amp;gt; to start browsing.&lt;br /&gt;
&lt;br /&gt;
=Other coding guidelines (as yet uncategorized)=&lt;br /&gt;
&lt;br /&gt;
* No &amp;lt;code&amp;gt;using&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;using namespace&amp;lt;/code&amp;gt; in header files, please!&lt;br /&gt;
* All exceptions thrown by CVC4 should be types publicly derived from ''CVC4::Exception'', unless the exception is very low-level (similar to &amp;lt;code&amp;gt;std::bad_alloc&amp;lt;/code&amp;gt;) and there's a compelling reason to avoid the CVC4 infrastructure (this is true, for instance, for non-exceptional signals that are thrown internally by CVC4 and never escape the library; it's preferable to avoid memory allocation in this case).&lt;br /&gt;
* Traditionally long declaration blocks (classes, namespaces, #endifs) should have an associated comment, ''even when they are short:''&lt;br /&gt;
  namespace CVC4 {&lt;br /&gt;
  class Foo {&lt;br /&gt;
    /* pages&lt;br /&gt;
     * and&lt;br /&gt;
     * pages&lt;br /&gt;
     * go&lt;br /&gt;
     * by&lt;br /&gt;
     */&lt;br /&gt;
  };/* class Foo */&lt;br /&gt;
  }/* CVC4 namespace */&lt;br /&gt;
Others ('''if''', '''while''', '''switch''', function definitions, etc.) should be close-commented for clarity where necessary.  No space exists between the last token of the declaration or definition and the start of the close-comment.&lt;br /&gt;
&lt;br /&gt;
Always end with a comment that matches the declaration (&amp;quot;struct Foo&amp;quot;, &amp;quot;class Foo&amp;quot;, &amp;quot;enum Foo&amp;quot;), except for namespaces, where it's the &amp;quot;Foo namespace.&amp;quot;  Comment preprocessor macros similarly:&lt;br /&gt;
  #ifdef SOMETHING&lt;br /&gt;
  #  ifdef OTHERTHING&lt;br /&gt;
  #    error You can't do that.&lt;br /&gt;
  #  else /* !OTHERTHING */&lt;br /&gt;
  #    warning This is experimental code.&lt;br /&gt;
  #    define FOO(x) x&lt;br /&gt;
  #  endif /* OTHERTHING */&lt;br /&gt;
  #else /* SOMETHING */&lt;br /&gt;
  #  define FOO(x)&lt;br /&gt;
  #endif /* SOMETHING */&lt;br /&gt;
Note that the indentation level for preprocessor macros is 2, but that the leading # is always in the first column, and that the #else takes the '''negation''' of the condition as a comment (but #endif takes the non-negated one).  Here, note that the else-comment and close-comment is preceded by a single space.  In cases where these blocks are long and you want to include additional context information about what macros are true, please do:&lt;br /&gt;
  #ifdef SOMETHING&lt;br /&gt;
  /* lots of&lt;br /&gt;
   * code here&lt;br /&gt;
   */&lt;br /&gt;
  #else /* !SOMETHING */&lt;br /&gt;
  /* lots of&lt;br /&gt;
   * code here&lt;br /&gt;
   */&lt;br /&gt;
  #  ifdef OTHERTHING /* &amp;amp;&amp;amp; !SOMETHING */&lt;br /&gt;
  /* code... */&lt;br /&gt;
  #  endif&lt;br /&gt;
  #endif&lt;br /&gt;
* Code and preprocessor indentation levels need not match unless it makes sense for them to.&lt;br /&gt;
* ALWAYS COMMENT FALL-THROUGH CASES IN ''switch() {}'':&lt;br /&gt;
  switch(foo) {&lt;br /&gt;
  case THIS_ONE:&lt;br /&gt;
    printf(&amp;quot;this!\n&amp;quot;);&lt;br /&gt;
    /* fall through */&lt;br /&gt;
  case THAT_ONE:&lt;br /&gt;
    printf(&amp;quot;that!\n&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Vertical spacing==&lt;br /&gt;
&lt;br /&gt;
Vertical spacing depends on context.  Logically group statements.  Debugging bits should generally be offset from the rest of the code by blank lines.  ''switch() {}'' blocks should generally leave a space between a case label and the preceding break.&lt;br /&gt;
&lt;br /&gt;
=Code reviews=&lt;br /&gt;
&lt;br /&gt;
[[Image:Code_review_lifecycle.png|400px|thumb|The typical code review lifecycle.]]&lt;br /&gt;
&lt;br /&gt;
A code review ticket is opened in Bugzilla with importance &amp;quot;review&amp;quot;.  The scope of the review is indicated in the comments.&lt;br /&gt;
&lt;br /&gt;
If you are assigned a code review, here is a guide to the life cycle for your review ticket:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt; '''Familiarize yourself with the code in the assigned module (and possibly other, related modules).'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt; If something simple is unclear, ask the developer in person or via email. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; If something less-than-simple is unclear, please ask the developer publicly on the ticket, so the discussion is tracked and better documentation can be produced as part of the code review.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; If something less-than-simple is unclear and has larger, team-level consequences, ask the developer publicly on the developers' mailing list and/or raise it at a developers' meeting.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; '''Review the code of the assigned module.'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt; Simple code formatting, typos, etc., should be directly fixed and committed by the reviewer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Slightly larger issues (refactoring, renaming of critical variables, methods, etc.), even when it's to bring the code in line with coding guidelines, can be directly committed but should be communicated to the developer of the code and noted on the Subversion revision log and the code review bug ticket.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Larger, architectural changes to the module should be worked on WITH the developer, not solely by the code reviewer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; If, during the course of review, additional changes are indicated to modules ''other'' than the one formally under review, those should be opened as an additional review/bug ticket, or mentioned to the developer of those modules for correction.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; In general, ''please avoid having &amp;quot;discussions&amp;quot; with the developer in comments in the source code.''&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; '''Bugs, requests for documentation, etc., should be filed as ''separate'' bug tickets in bugzilla, with the module's original developer as the assignee.'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt; Simple things (questions, or requests to &amp;quot;document this please,&amp;quot; etc.) can be included as part of the review ticket.  As the reviewer, post your questions and requests, and re-assign the ticket to the developer.  When the developer answers and addresses the issue, the developer should re-assign the ticket to the reviewer.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; More complex things (separate these two modules, provide documentation of invariants to this class, re-architect this to be in line with this other thing, etc.) should be opened as tickets, one per request, separate from the review ticket.  These new tickets are assigned the developer.  The review ticket itself does not get re-assigned to the developer unless there are (simpler-to-address) questions and requests on the review ticket.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; ''' ''Black-box'' and ''Public'' tests should be written by the reviewer for the general contract of the class.'''&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; If the reviewer chooses, the reviewer may write some white-box tests also, to assert internal state of the class is what the reviewer expects.&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; '''Ensure the code in the module is ''sufficiently'' covered by tests.'''&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; For guidance on what is ''sufficient,'' please review the output of ''gcov'' and apply common sense, as informed by experience.  All methods should be called and at least partly covered.  If important methods aren't covered, certainly they should be.  It's probably okay if some branches of exceptional paths are not covered.  Some paths are difficult to cover in a black-box or regression test and may need to be triggered in a white-box test.&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; '''In the documentation at the top of all relevant file(s), mark yourself as the reviewer.'''&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;If there are other reviews listed, put yours at the end of the list (so they remain in chronological order).&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;List your name, the date, and the code review ticket number.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;For example:&lt;br /&gt;
&amp;lt;div style=&amp;quot;white-space:pre;font-size:larger;&amp;quot;&amp;gt;&lt;br /&gt;
 /*********************                                                        */&lt;br /&gt;
 /** ecdata.cpp&lt;br /&gt;
  ** Original author: taking&lt;br /&gt;
  ** Major contributors: mdeters&lt;br /&gt;
  ** Minor contributors (to current version): none&lt;br /&gt;
  ** This file is part of the CVC4 prototype.&lt;br /&gt;
  ** Copyright (c) 2009, 2010  The Analysis of Computer Systems Group (ACSys)&lt;br /&gt;
  ** Courant Institute of Mathematical Sciences&lt;br /&gt;
  ** New York University&lt;br /&gt;
  ** See the file COPYING in the top-level source directory for licensing&lt;br /&gt;
  ** information.&lt;br /&gt;
  **&lt;br /&gt;
  ** Implementation of equivalence class data for UF theory.  This is a&lt;br /&gt;
  ** context-dependent object.&lt;br /&gt;
  **&lt;br /&gt;
  ** &amp;lt;span style=&amp;quot;color:#a00;&amp;quot;&amp;gt;Reviewed by dejan, Feb 24 2010 (bug #10).&amp;lt;/span&amp;gt;&lt;br /&gt;
  ** &amp;lt;span style=&amp;quot;color:#a00;&amp;quot;&amp;gt;Reviewed by mdeters, Apr 4 2010 (bug #64).&amp;lt;/span&amp;gt;&lt;br /&gt;
  **/&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt; '''The ticket can be closed when:'''&lt;br /&gt;
&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt; tests cover the code sufficiently, '''and''' &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; the simple requests in the review ticket itself have been addressed, '''and''' &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; bugs have been opened to address more complex requests. &amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
The more complex requests need not be addressed to close the review ticket; it is enough that they have been identified and entered into Bugzilla.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Binary compatibility: what is it and why do we care?=&lt;br /&gt;
&lt;br /&gt;
*http://sources.redhat.com/autobook/autobook/autobook_91.html&lt;br /&gt;
*http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html&lt;br /&gt;
*http://ispras.linux-foundation.org/index.php/ABI_compliance_checker_Downloads&lt;br /&gt;
*http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html&lt;br /&gt;
&lt;br /&gt;
=Unit testing=&lt;br /&gt;
&lt;br /&gt;
First, get CxxTest from here:&lt;br /&gt;
&lt;br /&gt;
  http://cxxtest.tigris.org/files/documents/6421/43281/cxxtest-3.10.1.tar.gz&lt;br /&gt;
&lt;br /&gt;
Unpack it in, say, your home directory.  Then, just point CVC4's configure to it:&lt;br /&gt;
&lt;br /&gt;
  ./configure --with-cxxtest-dir=~/cxxtest&lt;br /&gt;
&lt;br /&gt;
Now, &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt; will run the CxxTest unit tests under &amp;lt;code&amp;gt;test/&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Running unit tests==&lt;br /&gt;
&lt;br /&gt;
The simplest way to run all unit tests (and regressions and system tests) is to run &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt; in the top-level source directory.  If you specifically want to run units and not other kinds of tests, &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt; in just the unit tests directory:&lt;br /&gt;
&lt;br /&gt;
 $ make -C test/unit check&lt;br /&gt;
&lt;br /&gt;
There is also experimental support for running unit tests related to a specific package.  If you specifically want to run units for the expr package, for example, &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt; ''in the source directory for expr'' (not in the test directory):&lt;br /&gt;
&lt;br /&gt;
 $ make -C src/expr check&lt;br /&gt;
&lt;br /&gt;
==Types of unit tests==&lt;br /&gt;
&lt;br /&gt;
There are three kinds of unit tests:&lt;br /&gt;
&lt;br /&gt;
* '''white tests''' test the system from a '''white-box''' point of view: they have access to the private functionality of classes (that is, usual C++ access restrictions '''do not''' apply), and they are written (typically by the author of the tested class) to test the internal functions and invariants of a class implementation.  If the implementation details of a class change, one or more tests will likely change too.&lt;br /&gt;
**By convention, white tests are named &amp;lt;code&amp;gt;*_white.h&amp;lt;/code&amp;gt;.  For example, for the '''Node''' class, which is in the '''CVC4::expr''' namespace, the test is under the &amp;lt;code&amp;gt;expr/&amp;lt;/code&amp;gt; directory in &amp;lt;code&amp;gt;node_white.h&amp;lt;/code&amp;gt;.&lt;br /&gt;
* '''black tests''' test the system from a '''black-box''' point of view: they have access only to the public functionality of classes (that is, usual C++ access restrictions '''do''' apply), and they are written (typically ''not'' by the author of the tested class) to test the external interface and invariants of a class.  If the implementation details of a class change, the tests do not change; if the external interface of a class change, the test should be updated.&lt;br /&gt;
**By convention, black tests are named &amp;lt;code&amp;gt;*_black.h&amp;lt;/code&amp;gt;.  For example, for the '''Node''' class, which is in the '''CVC4::expr''' namespace, the test is under the &amp;lt;code&amp;gt;expr/&amp;lt;/code&amp;gt; directory in &amp;lt;code&amp;gt;node_black.h&amp;lt;/code&amp;gt;.&lt;br /&gt;
**a subcategory of black tests are '''public''' tests; these test the system from a '''public''' point of view: they have access only to the public, functionality of '''libraries'''---the exported symbols of various libraries.  Usual C++ access restrictions apply, as do the usual linking procedures against the library.  Essentially, these '''public''' tests are black tests that test the public functionality of a public class.  It is useful to separate them from the black tests in order to test that the exported symbols of a library are adequate.  Public tests are named &amp;lt;code&amp;gt;*_public.h&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Adding unit tests==&lt;br /&gt;
&lt;br /&gt;
To add a new test, create a test header file under &amp;lt;code&amp;gt;test/unit&amp;lt;/code&amp;gt; (possibly in a subdirectory based on the relevant CVC4 module).  If your test is a ''white-box test'' (it calls private functionality of the tested class directly and was written knowing the implementation details), its name should include ''White'', ''e.g.,'' ''NodeWhite'', and it should be in a file like &amp;lt;code&amp;gt;test/unit/expr/node_white.h&amp;lt;/code&amp;gt;, and you should add it to &amp;lt;code&amp;gt;TESTS_WHITE&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;test/unit/Makefile.am&amp;lt;/code&amp;gt;.  If your test is a ''black-box test'' (it calls only the public functionality of the tested class and was written knowing the interface only), its name should include ''Black'', ''e.g.,'' ''NodeBlack'', and it should be in a file like &amp;lt;code&amp;gt;test/unit/expr/node_black.h&amp;lt;/code&amp;gt;, and you should add it to &amp;lt;code&amp;gt;TESTS_BLACK&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;test/unit/Makefile.am&amp;lt;/code&amp;gt;.  If your test is a ''public test'' (it calls only the public functionality of the tested class, which is exported in the public-facing interface of the library), its name should include ''Public'', ''e.g.,'' ''ExprPublic'', and it should be in a file like &amp;lt;code&amp;gt;test/unit/expr/expr_public.h&amp;lt;/code&amp;gt;, and you should add it to &amp;lt;code&amp;gt;TESTS_PUBLIC&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;test/unit/Makefile.am&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you add your test to the correct &amp;lt;code&amp;gt;TESTS_*&amp;lt;/code&amp;gt; block in &amp;lt;code&amp;gt;test/unit/Makefile.am&amp;lt;/code&amp;gt;, and you're using the GNU C++ compiler, it will be compiled and linked correctly: that is, if it's a '''white-box test,''' the compiler will ignore access restrictions; if it's a '''black-box test,''' it can still access hidden symbols; and if it's a '''public test,''' it must only access the public-facing, exported symbols of the appropriate library.&lt;br /&gt;
&lt;br /&gt;
==Test implementations==&lt;br /&gt;
&lt;br /&gt;
Your test methods are named &amp;lt;code&amp;gt;test*&amp;lt;/code&amp;gt;, ''e.g.,'' &amp;lt;code&amp;gt;testNull()&amp;lt;/code&amp;gt;.  They return &amp;lt;code&amp;gt;void&amp;lt;/code&amp;gt; and take no arguments.&lt;br /&gt;
&lt;br /&gt;
There are numerous testing assertions you can make inside your testing code.  For example:&lt;br /&gt;
&lt;br /&gt;
 TS_ASSERT( 1 + 1 &amp;gt; 1 );&lt;br /&gt;
 TS_ASSERT_EQUALS( 1 + 1, 2 );&lt;br /&gt;
&lt;br /&gt;
There's also a &amp;lt;code&amp;gt;TS_FAIL()&amp;lt;/code&amp;gt; that fails unconditionally:&lt;br /&gt;
&lt;br /&gt;
 void testSomething() {&lt;br /&gt;
   TS_FAIL( &amp;quot;I don't know how to test this!&amp;quot; );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
...and a &amp;lt;code&amp;gt;TS_WARN()&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 void testSomething() {&lt;br /&gt;
   TS_WARN( &amp;quot;TODO: This test still needs to be written!&amp;quot; );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
[http://cxxtest.sourceforge.net/guide.html The users' guide is here for your reference.]&lt;br /&gt;
&lt;br /&gt;
==Debugging unit tests==&lt;br /&gt;
&lt;br /&gt;
In order to run, CxxTest takes a header file, generates from that a new cpp file, and then then compiles the cpp file into a binary.&lt;br /&gt;
The binaries for the unit tests live in the builds directory.&lt;br /&gt;
If a unit test had the path &lt;br /&gt;
  cvc4/test/unit/foo/bar.h&lt;br /&gt;
then the binary will have the path &amp;lt;code&amp;gt;cvc4/builds/test/unit/foo/bar&amp;lt;/code&amp;gt;. (The CxxTest cpp file will have the path &amp;lt;code&amp;gt;cvc4/builds/test/unit/foo/bar.cpp&amp;lt;/code&amp;gt;.)&lt;br /&gt;
&lt;br /&gt;
If you have compiled cvc4 in debug mode, then the unit tests binaries can be run in gdb.&lt;br /&gt;
&lt;br /&gt;
Tests are executed in the order that they appear in the header file.&lt;br /&gt;
Moving a broken test to the top of the class definition (temporarily) makes it execute before the other tests. This is a useful trick for making debugging with gdb easier.&lt;br /&gt;
&lt;br /&gt;
To recompile all of the tests, you can run &amp;lt;code&amp;gt;make check&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;cvc4/&amp;lt;/code&amp;gt;.  If you just run &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; after changing the source of cvc4 or a unit test, the test will not be recompiled.&lt;br /&gt;
&lt;br /&gt;
===Compile-time errors in unit tests===&lt;br /&gt;
&lt;br /&gt;
The most common errors with unit tests are duplicating method names, improper copy-'n'-paste between tests, etc.&lt;br /&gt;
&lt;br /&gt;
If you get strange errors, make sure you called your test class something unique (''e.g.,'' &amp;quot;ExprBlack&amp;quot; for black-box tests on ''Expr'').  If you get an error that looks like this:&lt;br /&gt;
&lt;br /&gt;
 expr/expr_black.cpp:20: error: expected initializer before ‘suite_ExprBlack’                                                                                                                         &lt;br /&gt;
 expr/expr_black.cpp:23: error: ‘suite_ExprBlack’ was not declared in this scope                                                                                                                      &lt;br /&gt;
 expr/expr_black.cpp: In member function ‘virtual void TestDescription_ExprBlack_testDefaultCtor::runTest()’:                                                                                         &lt;br /&gt;
 expr/expr_black.cpp:28: error: ‘suite_ExprBlack’ was not declared in this scope                                                                                                                      &lt;br /&gt;
 expr/expr_black.cpp: In member function ‘virtual void TestDescription_ExprBlack_testCtors::runTest()’:                                                                                               &lt;br /&gt;
 expr/expr_black.cpp:34: error: ‘suite_ExprBlack’ was not declared in this scope                                                                                                                      &lt;br /&gt;
 ...etc...&lt;br /&gt;
&lt;br /&gt;
...then you're missing a closing semicolon at the end of your test class definition.  (They're easy to forget.)&lt;br /&gt;
&lt;br /&gt;
==Test rebuilding==&lt;br /&gt;
&lt;br /&gt;
{{BUG|44}} states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
As our unit-test database is growing the time to compile all the tests is&lt;br /&gt;
getting increasingly unbearable, specially as every change in the source spawns&lt;br /&gt;
recompilation of all tests. I know it might be impossible, but I would be&lt;br /&gt;
wonderful if we could get around this somehow.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, in response to {{bug|13}}, entitied ''Test not rebuilding on code&lt;br /&gt;
changes,'' the behavior was fixed precisely to force test rebuilding&lt;br /&gt;
&lt;br /&gt;
Fortunately, the answer is yes, this rebuilding can be avoided.&lt;br /&gt;
&lt;br /&gt;
But it must be stressed that before any commit, '''you should always let the&lt;br /&gt;
build tree rebuild, relink, and rerun all tests!'''&lt;br /&gt;
&lt;br /&gt;
===Partial testing===&lt;br /&gt;
&lt;br /&gt;
First, the preferred method involves ''partial rebuilding:'' you&lt;br /&gt;
can run subsets of unit tests (rebuilding only those necessary for the&lt;br /&gt;
subset).  Say you have an up-to-date build tree (including all&lt;br /&gt;
unit tests).  You make a small change to &amp;lt;code&amp;gt;src/theory/theory.h&amp;lt;/code&amp;gt; and&lt;br /&gt;
want to rerun ''just'' the theory tests.  Run ''make'' to rebuild the&lt;br /&gt;
libraries, then:&lt;br /&gt;
&lt;br /&gt;
  $ make -C src/theory check&lt;br /&gt;
&lt;br /&gt;
By the way, -C isn't anything magical, it just chdir's into &amp;lt;code&amp;gt;src/theory&amp;lt;/code&amp;gt;&lt;br /&gt;
first.  So the same results from:&lt;br /&gt;
&lt;br /&gt;
  $ (cd src/theory &amp;amp;&amp;amp; make check)&lt;br /&gt;
&lt;br /&gt;
With the current build tree (that is, March 4, 2010), this will rebuild ''only'' the &amp;lt;code&amp;gt;theory_black&amp;lt;/code&amp;gt;&lt;br /&gt;
and &amp;lt;code&amp;gt;theory_uf_white&amp;lt;/code&amp;gt; tests and then run them.  When we have more&lt;br /&gt;
theory-related unit tests, it will include those too.&lt;br /&gt;
&lt;br /&gt;
===Marking the test tree up-to-date (not preferred)===&lt;br /&gt;
&lt;br /&gt;
''If'' you are using dynamic linking (&amp;lt;code&amp;gt;--enable-shared&amp;lt;/code&amp;gt;, which is the default), and&lt;br /&gt;
you make a change to &amp;lt;code&amp;gt;libcvc4&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;libcvc4parser&amp;lt;/code&amp;gt; that shouldn't require&lt;br /&gt;
a rebuild of test binaries---a small change to a non-inlined function,&lt;br /&gt;
for example---you can use:&lt;br /&gt;
&lt;br /&gt;
  $ make&lt;br /&gt;
  [ libraries are rebuilt ]&lt;br /&gt;
  $ make -t check&lt;br /&gt;
  [the tests are marked up-to-date even though they aren't]&lt;br /&gt;
  $ make check&lt;br /&gt;
  [the tests are run]&lt;br /&gt;
&lt;br /&gt;
You cannot combine these three steps.  Providing &amp;quot;-t&amp;quot; to ''make'' won't do any rebuilding, which you need in the first and third invocations.&lt;br /&gt;
&lt;br /&gt;
If you change interface, data layout, or inline-able function&lt;br /&gt;
implementations, you'll run into problems and the tests should be&lt;br /&gt;
rebuilt, so use good judgment and '''always rebuild, relink, and rerun&lt;br /&gt;
all unit tests before a commit!'''&lt;br /&gt;
&lt;br /&gt;
Also, if you use this &amp;quot;&amp;lt;code&amp;gt;make -t check&amp;lt;/code&amp;gt;&amp;quot; method, your build tree may&lt;br /&gt;
become out-of-sync with itself.  If you see strange behavior&lt;br /&gt;
(unexpected segfaults, weird debugger behavior, etc.), rebuild and&lt;br /&gt;
relink all tests.&lt;br /&gt;
&lt;br /&gt;
=Regression testing=&lt;br /&gt;
&lt;br /&gt;
''Regression tests'' in CVC4 are tests of the CVC4 binary.&lt;br /&gt;
&lt;br /&gt;
To add a regression test, drop the file (which should have extension ''.smt'' or ''.cvc'' in &amp;lt;code&amp;gt;test/regress/regress''N''/&amp;lt;/code&amp;gt; (for ''N'' the regression level it should be in) and add it under &amp;lt;code&amp;gt;TESTS&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;test/regress/regress''N''/Makefile.am&amp;lt;/code&amp;gt;.  Then add it to subversion:&lt;br /&gt;
&lt;br /&gt;
  $ svn add test/regress/my_test.cvc&lt;br /&gt;
&lt;br /&gt;
In the case of a &amp;lt;code&amp;gt;.cvc&amp;lt;/code&amp;gt; benchmark, add one or more &amp;lt;code&amp;gt;% EXPECT: ''output''&amp;lt;/code&amp;gt; lines in the file (either at the top or scattered throughout).  This is the expected output of CVC4 (running without -q or -v or debugging or anything).  '''Any''' differences in output from the expected are flagged as test errors.  See other &amp;lt;code&amp;gt;.cvc&amp;lt;/code&amp;gt; regression tests for examples.  If there are no ''EXPECT'' lines, the ''run_regression'' script flags an error.  An ''EXIT'' line indicates the expected exit code of CVC4, but is optional; if omitted, CVC4 may have any exit status.&lt;br /&gt;
&lt;br /&gt;
In the case of an &amp;lt;code&amp;gt;.smt&amp;lt;/code&amp;gt; benchmark, make sure it has '':status sat'' or '':status unsat''.  This is used to determine if the output is correct and if CVC4 exits with the correct exit code.&lt;br /&gt;
&lt;br /&gt;
This should be all that's necessary.  Before committing to the repository, you should re-run ''autogen.sh'' in the root directory so that your commit includes the newest &amp;lt;code&amp;gt;Makefile.in&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Multi-level regression testing==&lt;br /&gt;
&lt;br /&gt;
The directories&lt;br /&gt;
* &amp;lt;code&amp;gt;test/regress/regress0&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;test/regress/regress1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;test/regress/regress2&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;test/regress/regress3&amp;lt;/code&amp;gt;&lt;br /&gt;
contain benchmarks at different regression levels.  More difficult or longer-running benchmarks are typically placed in higher regression levels.&lt;br /&gt;
&lt;br /&gt;
A simple ''make check'' at the top-level source directory (or top-level build or test source or build directories) does regression testing at level 0.  For a specific level, use ''make regressN:'' this runs all tests at levels less than or equal to ''N''.  (At the top-level, the ''regressN'' target implies the ''check'' target, so you can ''make regress3'' to run all unit tests, system tests, '''and also''' regressions at all levels.)&lt;br /&gt;
&lt;br /&gt;
To run a specific level of regressions, ''e.g.,'' regressions at level 2, without running regressions at lower levels, run a ''make check'' inside that specific directory.  For example:&lt;br /&gt;
&lt;br /&gt;
  $ make -C test/regress/regress2 check&lt;br /&gt;
&lt;br /&gt;
==Running the full regression suite on the cluster==&lt;br /&gt;
&lt;br /&gt;
Experimental CVC4 binarys can be submitted to the cluster for a full run of the regression suite [http://goedel.cims.nyu.edu/regress-results/submit_cvc4.html here]. The test daemon will send you an email with a link to the results when the jobs is finished running.&lt;br /&gt;
&lt;br /&gt;
=System testing=&lt;br /&gt;
&lt;br /&gt;
''System,'' or ''API,'' testing is a form of regression testing on CVC4 libraries rather than the driver.  Rather than .cvc and .smt instances as input, a system test is a source file that is built and linked against the cvc4 libraries and uses its API, bypassing the usual CVC4 driver.  These tests are located under &amp;lt;code&amp;gt;test/system/&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''FIXME expand this section.'''&lt;br /&gt;
&lt;br /&gt;
=Command-line options=&lt;br /&gt;
&lt;br /&gt;
To add a new command-line option to CVC4, open up &amp;lt;code&amp;gt;src/main/getopt.cpp&amp;lt;/code&amp;gt;.  Add an entry to the &amp;lt;code&amp;gt;cmdlineOptions&amp;lt;/code&amp;gt; array:&lt;br /&gt;
&lt;br /&gt;
* the first item is the ''long'' name of the command-line option.  For example, ''verbose'' for &amp;lt;code&amp;gt;--verbose&amp;lt;/code&amp;gt;.&lt;br /&gt;
* the second item is &amp;lt;code&amp;gt;required_argument&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;optional_argument&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;no_argument&amp;lt;/code&amp;gt;, depending on whether the option takes an argument, an optional argument, or does not take an argument.&lt;br /&gt;
* the third item should be NULL.&lt;br /&gt;
* the last item should be the equivalent short option (a &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt;), or a member of the &amp;lt;code&amp;gt;OptionValue&amp;lt;/code&amp;gt; enumeration if there isn't an equivalent short option.&lt;br /&gt;
&lt;br /&gt;
Next, if you don't have an equivalent short option, add the appropriate item to the &amp;lt;code&amp;gt;OptionValue&amp;lt;/code&amp;gt; enumeration.  If you '''do''' have an equivalent short option, append the short option to the string passed to &amp;lt;code&amp;gt;getopt_long()&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;parseOptions()&amp;lt;/code&amp;gt;.  Your option character should be followed by a single colon if an argument is required, or two colons if an argument is optional.&lt;br /&gt;
&lt;br /&gt;
Next, modify the ''switch()'' construct in &amp;lt;code&amp;gt;parseOptions()&amp;lt;/code&amp;gt; to handle your short option character (or the value from the &amp;lt;code&amp;gt;OptionValue&amp;lt;/code&amp;gt; enumeration).  If you need a new field in the &amp;lt;code&amp;gt;CVC4::Options&amp;lt;/code&amp;gt; structure, add it in &amp;lt;code&amp;gt;src/util/options.h&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Finally, change the usage string in &amp;lt;code&amp;gt;src/main/usage.h&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=NodeBuilders=&lt;br /&gt;
&lt;br /&gt;
'''FIXME'''.  ADD CONTENT.&lt;br /&gt;
&lt;br /&gt;
=Attributes=&lt;br /&gt;
&lt;br /&gt;
What does this mean?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/attribute.h: In member function �$-1òøvoid CVC4::expr::AttributeManager::setAttribute(const CVC4::Node&amp;amp;, const AttrKind&amp;amp;, const typename AttrKind::value_type&amp;amp;) [with AttrKind = TestFlag6]òù:&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/node_manager.h:128:   instantiated from �$-1òøvoid CVC4::NodeManager::setAttribute(const CVC4::Node&amp;amp;, const AttrKind&amp;amp;, const typename AttrKind::value_type&amp;amp;) [with AttrKind = TestFlag6]òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/node.h:291:   instantiated from �$-1òøvoid CVC4::Node::setAttribute(const AttrKind&amp;amp;, const typename AttrKind::value_type&amp;amp;) [with AttrKind = TestFlag6]òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../test/unit/expr/node_white.h:113:   instantiated from here&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/attribute.h:753: error: invalid use of undefined type �$-1òøstruct CVC4::expr::getTable&amp;lt;FooBar&amp;gt;òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/attribute.h:508: error: declaration of �$-1òøstruct CVC4::expr::getTable&amp;lt;FooBar&amp;gt;òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/attribute.h:755: error: invalid use of undefined type �$-1òøstruct CVC4::expr::getTable&amp;lt;FooBar&amp;gt;òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/attribute.h:508: error: declaration of �$-1òøstruct CVC4::expr::getTable&amp;lt;FooBar&amp;gt;òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/node_manager.h:128:   instantiated from �$-1òøvoid CVC4::NodeManager::setAttribute(const CVC4::Node&amp;amp;, const AttrKind&amp;amp;, const typename AttrKind::value_type&amp;amp;) [with AttrKind = TestFlag6]òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/node.h:291:   instantiated from �$-1òøvoid CVC4::Node::setAttribute(const AttrKind&amp;amp;, const typename AttrKind::value_type&amp;amp;) [with AttrKind = TestFlag6]òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../test/unit/expr/node_white.h:113:   instantiated from here&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/attribute.h:755: error: invalid use of undefined type �$-1òøstruct CVC4::expr::getTable&amp;lt;FooBar&amp;gt;òù&lt;br /&gt;
/home/mdeters/cvc4/builds/x86_64-unknown-linux-gnu/debug/../../../src/expr/attribute.h:508: error: declaration of �$-1òøstruct CVC4::expr::getTable&amp;lt;FooBar&amp;gt;òù&lt;br /&gt;
make[5]: *** [expr/node_white] Error 1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It means that the Attribute value-type (in this case ''FooBar''), is invalid; there's no hashtable of appropriate kind to put it in.  You probably want FooBar*.&lt;br /&gt;
&lt;br /&gt;
=ANTLR3=&lt;br /&gt;
&lt;br /&gt;
To get ANTLR3, which isn't yet distributed as a Debian/Ubuntu package:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Go to the ANTLR3 page and download Complete ANTLR 3.2 jar; all tools, runtime, etc... &amp;lt;http://antlr.org/download/antlr-3.2.jar&amp;gt; to &amp;lt;code&amp;gt;$ANTLR3_JAR&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Save the following as &amp;lt;code&amp;gt;$ANTLR3_DIR/antlr3&amp;lt;/code&amp;gt; (and make sure the file is executable), substituting the correct fully-qualified path for &amp;quot;&amp;lt;code&amp;gt;$ANTLR3_JAR&amp;lt;/code&amp;gt;&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
export CLASSPATH=/usr/share/java/stringtemplate.jar:$ANTLR3_JAR&lt;br /&gt;
exec java org.antlr.Tool &amp;quot;$@&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Download &amp;quot;libantlr3c-3.2.tar.gz&amp;quot; from http://antlr.org/download/C and extract the archive to &amp;lt;code&amp;gt;LIBANTLR3C_SRC_DIR&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter &amp;lt;code&amp;gt;$LIBANTLR3C_SRC_DIR&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If you are on a 32-bit machine, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure --prefix=$LIBANTLR3C_INSTALL_DIR&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are on a 64 bit machine, run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure --prefix=$LIBANTLR3C_INSTALL_DIR --enable-64bit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;--prefix=PREFIX&amp;lt;/code&amp;gt; specifies the library installation directory. This defaults to &amp;lt;code&amp;gt;/usr/local&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Open up the Makefile that's generated at the top-level source directory and add &amp;lt;code&amp;gt;-fexceptions&amp;lt;/code&amp;gt; to the CFLAGS setting. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Note the following installation information for &amp;lt;code&amp;gt;libantlr3c&amp;lt;/code&amp;gt; (where &amp;lt;code&amp;gt;LIBDIR&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;$LIBANTLR3C_INSTALL_DIR&amp;lt;/code&amp;gt;):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
If you ever happen to want to link against installed libraries&lt;br /&gt;
in a given directory, LIBDIR, you must either use libtool, and&lt;br /&gt;
specify the full pathname of the library, or use the `-LLIBDIR'&lt;br /&gt;
flag during linking and do at least one of the following:&lt;br /&gt;
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable&lt;br /&gt;
     during execution&lt;br /&gt;
   - add LIBDIR to the `LD_RUN_PATH' environment variable&lt;br /&gt;
     during linking&lt;br /&gt;
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag&lt;br /&gt;
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to the CVC4 source tree. &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Now run &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure --with-antlr-dir=$LIBANTLR3_INSTALL_DIR ANTLR=$ANTLR3_DIR/antlr3&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Profiling the code ==&lt;br /&gt;
&lt;br /&gt;
To profile CVC4, configure with &amp;lt;code&amp;gt;--enable-profiling&amp;lt;/code&amp;gt;. Unfortunately, GProf can't instrument system calls, so it will give misleading results for allocation-heavy programs like CVC4. Instead, you can use the Callgrind tool (a component of Valgrind):&lt;br /&gt;
 valgrind --tool=callgrind --dump-every-bb=100000000 ''&amp;lt;executable&amp;gt; &amp;lt;arguments...&amp;gt;''&lt;br /&gt;
(The &amp;lt;code&amp;gt;--dump-every-bb&amp;lt;/code&amp;gt; argument causes Callgrind to produce incremental data periodically throughout the execution. A value of 100,000,000 or higher is recommended to keep the number of data files emitted manageable.) Callgrind will create a master file &amp;lt;code&amp;gt;callgrind.out.''&amp;lt;pid&amp;gt;''&amp;lt;/code&amp;gt; and a number of incremental data files (&amp;lt;code&amp;gt;callgrind.out.''&amp;lt;pid&amp;gt;''.1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;callgrind.out.''&amp;lt;pid&amp;gt;''.2&amp;lt;/code&amp;gt;, etc). Open &amp;lt;code&amp;gt;callgrind.out.''&amp;lt;pid&amp;gt;''&amp;lt;/code&amp;gt; using the KCachegrind GUI tool to visualize the profiling information. (You can do this before the program has terminated. Pressing F5 will cause KCachegrind to load any new incremental data.)&lt;br /&gt;
&lt;br /&gt;
== Adding theory support to the parser ==&lt;br /&gt;
&lt;br /&gt;
To add support for a new theory to the SMT parser, you will need to edit &amp;lt;code&amp;gt;src/parser/smt/Smt.g&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Add any new operators to the list of operator tokens near the end of file (look for &amp;lt;code&amp;gt;AND_TOK&amp;lt;/code&amp;gt;, etc).&lt;br /&gt;
&amp;lt;li&amp;gt; Add the new operator as an alternative in the rule &amp;lt;code&amp;gt;builtinOp&amp;lt;/code&amp;gt;, mapping it to its corresponding CVC4 &amp;lt;code&amp;gt;Kind&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;li&amp;gt; Add the rules to match new constant tokens near the end of the file (look for &amp;lt;code&amp;gt;NUMERAL_TOK&amp;lt;/code&amp;gt;, etc). &lt;br /&gt;
&amp;lt;li&amp;gt;Add the new constants as alternatives in the rule &amp;lt;code&amp;gt;annotatedFormula&amp;lt;/code&amp;gt;, decoding the token text and calling &amp;lt;code&amp;gt;MK_CONST&amp;lt;/code&amp;gt; (which is just a macro that calls &amp;lt;code&amp;gt;ExprManager::mkConst&amp;lt;/code&amp;gt;). NOTE: if you have a constant token type &amp;lt;code&amp;gt;MY_CONST_TOK&amp;lt;/code&amp;gt;, you can get a &amp;lt;code&amp;gt;std::string&amp;lt;/code&amp;gt; representing the matched input using the static method &amp;lt;code&amp;gt;AntlrInput::tokenText&amp;lt;/code&amp;gt;, e.g.,    &lt;br /&gt;
&amp;lt;pre&amp;gt;  // annotatedFormula alternatives ...&lt;br /&gt;
  | MY_CONST_TOK &lt;br /&gt;
    { std::string myConstText = AntlrInput::tokenText($MY_CONST_TOK);&lt;br /&gt;
      MyConstType c = ...;&lt;br /&gt;
      expr = MK_CONST(c); }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Building a 32-bit binary on a 64-bit machine ==&lt;br /&gt;
&lt;br /&gt;
(These instructions are for Debian/Ubuntu)&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the 32-bit library dependencies installed&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install libc6-dev-i386 g++-multilib lib32gmpxx4 lib32gmp3 lib32gmp3-dev&lt;br /&gt;
&lt;br /&gt;
You will also need to build a 32-bit version of the ANTLR library. Just configure the library with &amp;lt;code&amp;gt;--disable-64bit&amp;lt;/code&amp;gt;. [I found that I had to first configure and build with &amp;lt;code&amp;gt;--enable-64bit&amp;lt;/code&amp;gt;, then reconfigure and build with &amp;lt;code&amp;gt;--disable-64bit&amp;lt;/code&amp;gt; to get it to work. -Chris]&lt;br /&gt;
&lt;br /&gt;
Configure CVC4 with &amp;lt;code&amp;gt;CFLAGS=-m32 CXXFLAGS=-m32&amp;lt;/code&amp;gt; and build as usual.&lt;/div&gt;</summary>
		<author><name>Clark Barrett</name></author>	</entry>

	</feed>