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

	<entry>
		<id>http://cvc4.cs.stanford.edu/w/index.php?title=Developer%27s_Guide&amp;diff=2796</id>
		<title>Developer's Guide</title>
		<link rel="alternate" type="text/html" href="http://cvc4.cs.stanford.edu/w/index.php?title=Developer%27s_Guide&amp;diff=2796"/>
				<updated>2012-03-01T21:39:12Z</updated>
		
		<summary type="html">&lt;p&gt;Dejan Jovanović: /* Adding benchmarks to the cluster */&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://church.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; - systemwide includes&lt;br /&gt;
* &amp;lt;code&amp;gt;src/lib&amp;lt;/code&amp;gt; - replacement functions needed on some platforms (which ones are needed is determined by configure)&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;
=Building CVC4=&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
&lt;br /&gt;
The following tools and libraries are required to build CVC4 (versions given are minimums; more recent releases are probably OK):&lt;br /&gt;
&lt;br /&gt;
* [http://www.gnu.org/software/automake Automake] v1.11&lt;br /&gt;
* [http://www.gnu.org/software/autoconf/ Autoconf] v2.61 &lt;br /&gt;
* [http://www.gnu.org/software/libtool Libtool] v2.2&lt;br /&gt;
* [http://gmplib.org/ GMP] v4.2&lt;br /&gt;
* [http://antlr.org ANTLR3] and [http://antlr.org/download/C libantlr3c] v3.2 or v3.4 ''([[#ANTLR3|See below]])''&lt;br /&gt;
* [http://www.ginac.de/CLN/ CLN] v1.3 ''(optional)''&lt;br /&gt;
&lt;br /&gt;
All of the above packages are available in recent releases of Fedora and in Debian 6.0 (squeeze). All current releases of Ubuntu have out-of-date packages for ANTLR3 and libantlr3c; this should be fixed in Ubuntu 11.04 (natty). Red Hat Enterprise Linux 5 has out-of-date autotools and ANTLR packages; the autotools packages should be fixed in RHEL 6 (don't know about ANTLR3 packages yet).&lt;br /&gt;
&lt;br /&gt;
==Building==&lt;br /&gt;
&lt;br /&gt;
If all of the dependencies are installed, you should be able to build CVC4 (from a subversion checkout) by running&lt;br /&gt;
&lt;br /&gt;
    ./autogen.sh&lt;br /&gt;
    ./configure --with-antlr-dir=$LIBANTLR3_INSTALL_DIR ANTLR=$ANTLR3_DIR/antlr3&amp;quot;&lt;br /&gt;
    make&lt;br /&gt;
, where &amp;lt;code&amp;gt;$LIBANTLR3_INSTALL_DIR&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$ANTLR3_DIR/antlr3&amp;lt;/code&amp;gt; have been explained in ''[[#ANTLR3|ANTLR3]]''.&lt;br /&gt;
The first step is not necessary if you have a distribution tarball (such as a release or a nightly build), as the configure scripts have already been generated in that case.  In the rest of this developer's guide below, it's generally assumed you're working with a Subversion checkout rather than a distributed source tarball.  Sometimes (as when updating the ''Makefile.am'' files, or adding source directories, you'll need to run &amp;quot;autoreconf&amp;quot; instead of &amp;quot;autogen.sh&amp;quot; if you're working from a source tarball.&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;
Sometimes you need to add something to &amp;lt;code&amp;gt;EXTRA_DIST&amp;lt;/code&amp;gt; rather than &amp;lt;code&amp;gt;*_SOURCES&amp;lt;/code&amp;gt; (for example, if something is conditionally built, depending on the &amp;lt;code&amp;gt;configure&amp;lt;/code&amp;gt; script, or a README or some such).&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, boost, and TLS macros for autoconf (under ''config/'')&lt;br /&gt;
* MiniSat (under ''src/prop/minisat'')&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;
==Checking that your Makefiles are correct==&lt;br /&gt;
&lt;br /&gt;
[http://www.gnu.org/software/hello/manual/automake/Checking-the-Distribution.html This part of the Automake manual] might be useful to people.  &amp;lt;code&amp;gt;make distcheck&amp;lt;/code&amp;gt; builds CVC4 and checks it (&amp;quot;make check&amp;quot;), then does a &amp;quot;make install&amp;quot; and &amp;quot;make uninstall&amp;quot; to make sure they are working, then builds a tarball (&amp;quot;make dist&amp;quot;), then builds ''that tarball'' with configure and make, runs the test suite (&amp;quot;make check&amp;quot;) on that, then does another &amp;quot;make dist&amp;quot; from the dist to make sure the distribution can itself make a distribution.  Then, it does a &amp;quot;make distclean&amp;quot; and makes sure nothing remains (distclean is supposed to clear out everything from a build, leaving you with a pristine distribution).&lt;br /&gt;
&lt;br /&gt;
=Profiling the code=&lt;br /&gt;
&lt;br /&gt;
==prof, gprof, valgrind, callgrind==&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;
==Google performance tools==&lt;br /&gt;
&lt;br /&gt;
Recently, [[User:cconway|Chris Conway]] recommended [http://goog-perftools.sourceforge.net/ Google's performance tools] for profiling, and as of revision 1454 (March 14, 2011), [[User:dejan|Dejan Jovanović]] added support for it.  Here are Dejan's revision notes:&lt;br /&gt;
&lt;br /&gt;
 adding support for google performance tools to the build sytem, it can be enabled at configure with&lt;br /&gt;
 --with-google-perftools&lt;br /&gt;
 &lt;br /&gt;
 to use it on ubuntu, you need to install packages google-perftools and libgoogle-perftools0&lt;br /&gt;
 &lt;br /&gt;
 to run the profiling of the heap, you can run it for example with&lt;br /&gt;
 &lt;br /&gt;
 HEAPPROFILE=/tmp/profile ./builds/bin/cvc4 test/regress/regress0/lemmas/clocksynchro_5clocks.main_invar.base.smt&lt;br /&gt;
 &lt;br /&gt;
 this will create some files  /tmp/profile* that you can then&lt;br /&gt;
 &lt;br /&gt;
 to get the pdf of the profile you can then run&lt;br /&gt;
 &lt;br /&gt;
 google-pprof --pdf ./builds/bin/cvc4 /tmp/profile.0001.heap &amp;gt; profile.pdf&lt;br /&gt;
 &lt;br /&gt;
 or for other options check http://goog-perftools.sourceforge.net/doc/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you are having problems with cln or gmp segfaulting, try setting LD_PRELOAD to libtcmalloc. For example:&lt;br /&gt;
  LD_PRELOAD=&amp;quot;/usr/lib/libtcmalloc.so&amp;quot; CPUPROFILE=profile ./builds/bin/cvc4 foo.smt&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/smt/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;
=Adding a new Theory=&lt;br /&gt;
&lt;br /&gt;
One of the first things that new developers need to do is ''add a new theory.''  Here's the overall procedure:&lt;br /&gt;
&lt;br /&gt;
# If your theory is likely to shake things up in other parts of CVC4 for awhile, branch the repo (see [[#Branching and merging|''Branching and merging'']]).  Make sure your working copy is up to date.&lt;br /&gt;
# Add a new directory for your theory (assuming you're implementing the Theory of Foo, you might use: ''mkdir src/theory/foo'')&lt;br /&gt;
# Use ''addsourcedir'' ([[#Adding source directories|see the Developer's Guide section on that script]]) to set up the directory (''contrib/addsourcedir src/theory/foo'').&lt;br /&gt;
# Add your directory to SUBDIRS in ''src/theory/Makefile.am''.&lt;br /&gt;
# Add a ''kinds'' file specifying kinds for your theory.  The file can be empty, to start.&lt;br /&gt;
# Add these files to the repository (''svn add src/theory/foo'')&lt;br /&gt;
# Add ''Makefile.in'' to the ''svn:ignore'' property of your directory (''svn ps svn:ignore Makefile.in src/theory/foo'')&lt;br /&gt;
# Re-run ''autogen.sh'' at the top-level.  This finds your new directory and adds it to the list of things to set up when ''configure'' runs.&lt;br /&gt;
&lt;br /&gt;
You'll now need to implement your theory!  Any source files you add will need to be listed in the appropriate ''SOURCES'' variable in your theory's ''Makefile.am''.  Any &amp;quot;extra things&amp;quot; (README files, notes, anything else that isn't really a &amp;quot;source&amp;quot; but should be included in the CVC4 tarball) should be listed in ''EXTRA_DIST''.&lt;br /&gt;
&lt;br /&gt;
There are places outside of your theory's directory you'll need to support, too.  If you want your theory to be supported by one or more input languages (instead of just through the CVC4 library API), you'll need to add support to the appropriate parser(s), under ''src/parser/LANGUAGE''.  (Right now we don't do prettyprinting, but that will eventually be in there, too.)  You'll also need to add typechecking to the ''NodeManager'' (in ''src/expr/node_manager.cpp''), and probably you'll want to add a ''type_rules'' file to your theory implementing theory-specific type rules (currently, the only modification to ''NodeManager'' is to switch on the node kind and delegate to your theory's type rules).&lt;br /&gt;
&lt;br /&gt;
For more details see [[How to write a theory in CVC4]].&lt;br /&gt;
&lt;br /&gt;
=Dealing with expressions (Nodes and TNodes)=&lt;br /&gt;
&lt;br /&gt;
There are three types in CVC4 that conceptually represent the same thing.&lt;br /&gt;
&lt;br /&gt;
# An ''Expr'' is a [[#Exporting library symbols|publicly-visible type]] that references expression data and the associated expression manager.&lt;br /&gt;
# A ''Node'' is a CVC4-internal type that references expression data but '''not''' the associated expression manager (the manager is implicitly the &amp;quot;current&amp;quot; node manager)&lt;br /&gt;
# A ''TNode'' is just like a ''Node'' except that it doesn't maintain a reference count.&lt;br /&gt;
&lt;br /&gt;
==Why this separation between Expr and Node?==&lt;br /&gt;
&lt;br /&gt;
In the library, we want to ensure that expressions are referenced correctly (that is, with deference to the appropriate expression manager).  We can police our own use of expressions, but we can't do the same for the users of the library.  Therefore we require external use of CVC4 expressions through the &amp;quot;heavier&amp;quot; ''Expr'' object to ensure correctness, but internally we want to use the lighter-weight ''Node'' objects.&lt;br /&gt;
&lt;br /&gt;
Similarly, ''ExprManager'' and ''NodeManager'' are split, but are conceptually the same.  ''NodeManager'' does all the real &amp;quot;managing&amp;quot; of expression data (and it has construction and reclamation-related duties) and ''ExprManager'' is the [[#Exporting library symbols|user-visible]]s, public interface to this manager.&lt;br /&gt;
&lt;br /&gt;
Under the hood, ''Expr'' objects are two simply two pointers: one to a ''Node'' and one to an ''ExprManager'', and all its implemented functionality simply delegates to one or the other.&lt;br /&gt;
&lt;br /&gt;
==Why this separation between Node and TNode?==&lt;br /&gt;
&lt;br /&gt;
Internally, then, a ''Node'' is just a &amp;quot;smart&amp;quot; pointer to a ''NodeValue'' structure, which contains expression kind information, the reference count, pointers to child expressions, etc.  Even internally to the CVC4 library, we don't allow general access to ''NodeValue''---we require all expression manipulation to go through ''Node'' objects.  Conceptually, ''Node'' objects are simple; they simply delegate to the underlying ''NodeValue''.  However, they have another purpose---to maintain the reference count on the ''NodeValue''.  When a ''Node'' object is created pointing to a ''NodeValue'', it increases the reference count on that ''NodeValue''.  When the ''Node'' is destructed (or points away), it decrements the reference count.&lt;br /&gt;
&lt;br /&gt;
This handling of the reference count can be expensive as ''Node'' objects are passed between functions, stored in data structures, updated on backtrack, etc.  Sometimes this is necessary for safety---that is, to maintain a correct reference count.  Other times, though, it's not necessary ([[#When to use TNodes|see below]]), and the use of ''TNode'' in preference to ''Node'' removes the reference-counting overhead.&lt;br /&gt;
&lt;br /&gt;
Under the hood, one template type (the ''NodeTemplate&amp;lt;&amp;gt;'') implements both ''Node'' and ''TNode''---''Node'' and ''TNode'' are typedefs to instantiations of the ''NodeTemplate&amp;lt;&amp;gt;'' template with (respectively) reference-counting turned on and off.&lt;br /&gt;
&lt;br /&gt;
==Why this separation between TNode and NodeValue?==&lt;br /&gt;
&lt;br /&gt;
One could ask, then, why does ''TNode'' exist if it conceptually provides the same services as the underlying ''NodeValue'' and it doesn't reference-count it?  Couldn't we just access the ''NodeValue'' directly?  There are two main reasons.  First, in assertions-enabled builds, ''TNode'' objects include extra assertions to make sure they're being used correctly---that is, that a ''TNode'' never references a ''NodeValue'' with a zero reference count, which is unsafe since that ''NodeValue'' is eligible for reclamation by the ''NodeManager''.  Second, the interface on ''NodeValue'' is somewhat lower-level than on ''Node'' and ''TNode'', and using the higher-level forms allows one to interchange ''Node'' and ''TNode'' without compiler troubles (one should only do so where [[#When to use TNodes|it's safe to do so]], of course).  Additionally, the use of ''TNode'' ensures that the expression data is not modified---conceptually, expressions are immutable, but of course at the lower layers of the expression package, they aren't technically immutable, so passing around a ''const NodeValue*'' would '''not''' be appropriate.&lt;br /&gt;
&lt;br /&gt;
==When to use TNodes==&lt;br /&gt;
&lt;br /&gt;
So when should one use ''TNode'' and when should one use ''Node'' when referring to expression data?&lt;br /&gt;
&lt;br /&gt;
This is a difficult question, but there are some general rules.&lt;br /&gt;
&lt;br /&gt;
First of all, it's always safe to use ''Node'', so if you're erring on the side of caution, use ''Node'' and not ''TNode''.&lt;br /&gt;
&lt;br /&gt;
''TNode'' is safe to use '''only''' when you know that a ''Node'' exists that refers to the same underlying expression data.  Since each ''NodeManager'' maintains the invariant that each expression is represented uniquely by one ''NodeValue'', that means that if a ''Node'' is guaranteed to refer to an expression, a ''TNode'' can be used to reference the same expression.  At such point as the ''Node'' no longer exists, it is no longer safe to use the ''TNode''.&lt;br /&gt;
&lt;br /&gt;
===Using TNode on the stack===&lt;br /&gt;
&lt;br /&gt;
In well-scoped situations like function calls, it's then ok to use a TNode:&lt;br /&gt;
&lt;br /&gt;
  void foo() {&lt;br /&gt;
    NodeManager* nm = NodeManager::currentNM();&lt;br /&gt;
    Node a = nm-&amp;gt;mkVar(&amp;quot;a&amp;quot;, nm-&amp;gt;booleanType());&lt;br /&gt;
    Node b = nm-&amp;gt;mkVar(&amp;quot;b&amp;quot;, nm-&amp;gt;booleanType());&lt;br /&gt;
    Node n = nm-&amp;gt;mkNode(kind::OR, a, b);&lt;br /&gt;
    Node not_n = negate(n);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  Node negate(TNode tnode) {&lt;br /&gt;
    Node x = tnode.notNode();&lt;br /&gt;
    return x;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Here, ''foo()'' calls function ''negate()'' to negate a ''Node''.  However, the function accepts the node parameter as a ''TNode''---this is ok, because a ''TNode'' can be constructed from a ''Node''.  At the function call, a copy of the underlying pointer to ''NodeValue'' is made, but no reference counting is done.  Note that when an expression is created (with ''tnode.notNode()''), however, the result is stored in a ''Node''.  It would '''not''' be safe to store this in a ''TNode'', since the negation of the parameter is not guaranteed to have an outstanding ''Node'' reference to it (and thus to have a nonzero reference count).&lt;br /&gt;
&lt;br /&gt;
'''The general rule is: functions should take TNode arguments but always return Node.'''  There are exceptions, but this one rule covers a lot.  A common mistake is reusing a variable of type ''TNode'' where it should be a ''Node'', for example:&lt;br /&gt;
&lt;br /&gt;
  Node preprocess(TNode input);&lt;br /&gt;
  &lt;br /&gt;
  void query(TNode input) {&lt;br /&gt;
    input = preprocess(input);// &amp;lt;--- BUG!!&lt;br /&gt;
    // perform query...&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is a serious error.  ''preprocess()'' will (it is presumed) take ''input'' and either create a new equivalent expression, returning that, or if no preprocessing is required, return the input.  But here, the ''Node'' return value of ''preprocess()'' is turned into a TNode in the caller's context, and the reference count on the expression data is decremented.  This means the result of preprocessing may be reclaimed by the system immediately on return of the ''preprocess()'' function!  The correct way to write ''query()'' is the following:&lt;br /&gt;
&lt;br /&gt;
  void query(TNode input) {&lt;br /&gt;
    Node preprocessed = preprocess(input);&lt;br /&gt;
    // now work with 'preprocessed'...&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Using TNode in (heap-allocated) data structures==&lt;br /&gt;
&lt;br /&gt;
So far, this only handles stack-based (function call) uses for ''TNode''.  ''TNode'' objects can also be kept in data structures, but that's more complicated.  I repeat again, from the above: '''At such point as the ''Node'' no longer exists, it is no longer safe to use the ''TNode'''''.  That has an important further clarification: '''even if the ''Node'' is re-established later, it's unsafe to maintain a ''TNode'' to the expression, since the underlying ''NodeValue'' may have been reclaimed by the system and re-constructed!'''  Consider this code:&lt;br /&gt;
&lt;br /&gt;
  void foo() {&lt;br /&gt;
    NodeManager* nm = NodeManager::currentNM();&lt;br /&gt;
    Node p = nm-&amp;gt;mkVar(&amp;quot;p&amp;quot;, nm-&amp;gt;booleanType());&lt;br /&gt;
    Node q = nm-&amp;gt;mkVar(&amp;quot;q&amp;quot;, nm-&amp;gt;booleanType());&lt;br /&gt;
    Node n = nm-&amp;gt;mkVar(kind::OR, p, q);&lt;br /&gt;
    &lt;br /&gt;
    TNode x = n; // safe reference to expression (p OR q)&lt;br /&gt;
    &lt;br /&gt;
    Kind k = x.getKind();// &amp;lt;-- safe: get the kind of expression (p OR q)&lt;br /&gt;
    &lt;br /&gt;
    // point away from (p OR q)&lt;br /&gt;
    n = nm-&amp;gt;mkVar(kind::AND, p, q);&lt;br /&gt;
    &lt;br /&gt;
    Kind k = x.getKind();// &amp;lt;-- UNSAFE: (p OR q) might not exist anymore!&lt;br /&gt;
    &lt;br /&gt;
    // reconstruct (p OR q)&lt;br /&gt;
    n = nm-&amp;gt;mkVar(kind::OR, p, q);&lt;br /&gt;
    &lt;br /&gt;
    k = x.getKind();// &amp;lt;-- ALSO UNSAFE, (p OR q) might be in a different place in memory&lt;br /&gt;
    x = n;&lt;br /&gt;
    k = x.getKind();// &amp;lt;-- this is safe&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
As you trace through this code, keep in mind that if the reference count for an expression drops to zero (there are no ''Node'' references to it, only ''TNode'' references), then it is immediately eligible for reclamation by the ''NodeManager''.  So, here, ''x'' is initially a safe ''TNode'' reference to ''(p OR q)''---but then ''n'' points elsewhere, and ''x'' is no longer safe to use.  You might think that, given that the ''NodeManager'' maintains unique underlying expression structures for all expressions, that after re-constructing ''(p OR q)'', you could use ''x'' again.  But this is not true---the expression data ''may'' have been destroyed in the meantime, and thus the reconstructed ''(p OR q)'' could be a different (but still unique, since the other one has disappeared) ''NodeValue''.  This makes ''x'' unsafe to use.&lt;br /&gt;
&lt;br /&gt;
That means that you '''cannot store a ''TNode'' in a data structure unless a ''Node'' to the same expression is guaranteed to exist at least as long as the ''TNode'' does!'''  Even if you can guarantee that a ''Node'' exists every time to ''use'' the ''TNode'', this isn't enough: a &amp;quot;solid&amp;quot; ''Node'' reference must exist at all times to the underlying expression.  If you cannot guarantee this, you cannot use a ''TNode'', you must use ''Node''.&lt;br /&gt;
&lt;br /&gt;
There is no &amp;quot;general rule&amp;quot; for putting ''TNode'' in heap-allocated data structures, as there is with function calls on the stack.  Sometimes you can store ''Node'' objects in one data structure, and that permits the storage of ''TNode'' objects in another; but it depends on your data.  You just have to make sure that reference count stays above zero at all times.&lt;br /&gt;
&lt;br /&gt;
By the way, in the above program, often a re-created expression ''does'' have the same underlying ''NodeValue'', since zero-reference-count expressions are not immediately reclaimed (they are in the so-called ''zombie'' state, and they are reclaimed in bulk when there are enough zombies).  But because they are immediately ''eligible'' for reclamation, you cannot rely on this.&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;
* ''Before you commit,'' your source tree should pass a &amp;quot;make check&amp;quot; in both ''debug'' and ''production'' configurations.&lt;br /&gt;
* Ideally, your code is cross-platform, and at the very least works equally well on 32- and 64-bit Intel, but this can be difficult to determine sometimes.&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 [''wishlist---not yet implemented, except for a few [http://church.cims.nyu.edu/newswire/ newswire] items''].&lt;br /&gt;
* ''After you commit,'' Clark will review the commit for content.  (This is after the fact, you don't have to get a sign-off to commit.)&lt;br /&gt;
* ''After Clark commits,'' others in the group will review his commits for content.  (Also after the fact.)&lt;br /&gt;
* ''In practice,'' everybody reviews everyone else's commits, but on their own schedule.&lt;br /&gt;
* Unit tests / system tests / regression tests should be included to test any new functionality included in your commit.&lt;br /&gt;
* Any new code should be well-covered.  Please check the [http://church.cims.nyu.edu/cvc4-builds/coverage/latest/ coverage report] the next day to make sure your code is well-covered by unit tests, system tests, and regressions.  If not, add some tests to the source tree.&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;
=Working with the cluster=&lt;br /&gt;
&lt;br /&gt;
We have a cluster of nine execution hosts at NYU, ''smt_crunch_01''...''smt_crunch_09''.  You don't interact with these nodes directly; instead, you interact with church through the web or ssh interface.&lt;br /&gt;
&lt;br /&gt;
==Submitting a job to the cluster via the web interface==&lt;br /&gt;
&lt;br /&gt;
Build a fully statically-linked binary (usually with something like ''./configure production-cln-staticbinary'') and submit it via the [http://church.cims.nyu.edu/regress-results/cvc4.php web interface].&lt;br /&gt;
&lt;br /&gt;
==Submitting a job to the cluster via the command line==&lt;br /&gt;
&lt;br /&gt;
Some of us have been passing around scripts that run various cluster jobs.  The simplest form is:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # cluster-regressions-cvc4&lt;br /&gt;
 TO_EMAIL=&amp;quot;`whoami`@cs.nyu.edu&amp;quot;&lt;br /&gt;
 CC_EMAIL=&amp;quot;&amp;quot;&lt;br /&gt;
 function RunClusterRegressions() {&lt;br /&gt;
   local job_name=&amp;quot;cvc4-$1&amp;quot;&lt;br /&gt;
   local cvc4_binary=&amp;quot;$2&amp;quot;&lt;br /&gt;
   local params=&amp;quot;--segv-nospin $3&amp;quot;&lt;br /&gt;
   local comment=&amp;quot;$4&amp;quot;&lt;br /&gt;
   local timeout=&amp;quot;$5&amp;quot;&lt;br /&gt;
   if [ -z &amp;quot;$timeout&amp;quot; ]; then&lt;br /&gt;
     timeout=300;&lt;br /&gt;
   fi&lt;br /&gt;
   mysql -u smt_cluster --password=`cat ~/.mysql_password` smt_cluster &amp;lt;&amp;lt;EOF&lt;br /&gt;
     insert into Jobs values(DEFAULT, &amp;quot;$job_name&amp;quot;, &amp;quot;custom job:$comment&amp;quot;, &amp;quot;22&amp;quot;, &amp;quot;$timeout&amp;quot;, &amp;quot;2000&amp;quot;, &amp;quot;24&amp;quot;, &amp;quot;$TO_EMAIL $CC_EMAIL&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;$cvc4_binary&amp;quot;, &amp;quot;$params&amp;quot;, &amp;quot;1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,29&amp;quot;, DEFAULT);&lt;br /&gt;
 EOF&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 if [ $# -ne 3 -a $# -ne 4 ]; then&lt;br /&gt;
   echo &amp;quot;usage: $0 cvc4-binary \&amp;quot;solver params\&amp;quot; \&amp;quot;comment\&amp;quot; [timeout]&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 JOB_TIME=`date +%s`&lt;br /&gt;
 NAME=&amp;quot;cluster-regressions-$JOB_TIME&amp;quot;&lt;br /&gt;
 RunClusterRegressions &amp;quot;$NAME&amp;quot; $1 &amp;quot;$2&amp;quot; &amp;quot;$3&amp;quot; &amp;quot;$4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
If this script is called ''cluster-regressions-cvc4'', you might run it like this:&lt;br /&gt;
&lt;br /&gt;
 ./cluster-regressions-cvc4 /full/path/to/cvc4/static/binary '--stats' 'running my crazy idea with stats enabled'&lt;br /&gt;
&lt;br /&gt;
which will run it on our standard regression suite for CVC4 with stats enabled and mail you the results.  The &amp;quot;22&amp;quot; in the SQL insert is the &amp;quot;runner&amp;quot;---this is the code for an &amp;quot;arbitrary tool with parameters&amp;quot;, which a general, catch-all case that you will generally want to use.  The &amp;quot;24&amp;quot; is the problem set ID, which is (here) our set of CVC4 regressions.  You can also choose all of QF_LRA in SMT-LIBv1 (problem set ID 27), the same in SMT-LIBv2 (ID 28), all of QF_UF in SMT-LIBv2 (ID 38), all of QF_AX in SMT-LIBv2 (ID 39), all of QF_BV in SMT-LIBv2 (ID 40), and others.&lt;br /&gt;
&lt;br /&gt;
'''Note that you must have''' ''~/.mysql_password'' installed in your home directory.  See someone to get the password if you don't know it.&lt;br /&gt;
&lt;br /&gt;
==Adding benchmarks to the cluster==&lt;br /&gt;
&lt;br /&gt;
# If the benchmarks are new copy them to the appropriate directory on church /usr/local/share/benchmarks. Make sure they are owned by acsys-user and are readable by all users. All cluster nodes remotely mount the benchmark files from church, so there is no need to manually sync them (like was previously done). Lets say that your benchmarks are in /usr/local/share/benchmarks/mybench&lt;br /&gt;
# Make a file to that contains all the benchmarks with for example 'find /usr/local/share/benchmarks/mybench -name &amp;quot;*.smt&amp;quot; &amp;gt; bench.txt'&lt;br /&gt;
# Use the /cluster/cvc4/scripts/add_benchmarks.sh script to add the benchmarks. The is interactive and will ask you about all the necessary information. If you are adding problems to an existing problem set you will be given the option to continue running some existing jobs on the newly added benchmarks.&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.  '''Make sure that the ''cxxtestgen.pl'' script has eXecute permission.'''  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 binaries can be submitted to the cluster for a full run of the regression suite [http://church.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/smt/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.4 jar from http://antlr.org/download/antlr-3.4-complete.jar.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Make a directory &amp;lt;code&amp;gt;$ANTLR3_DIR&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Save the following shell script file in the &amp;lt;code&amp;gt;$ANTLR3_DIR&amp;lt;/code&amp;gt; directory (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;Now, you are done with installing Antlr3.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Download &amp;quot;libantlr3c-3.4-beta4.tar.gz&amp;quot; from http://antlr.org/download/C and extract the archive. You now have an extracted src directory called &amp;quot;libantlr3c-3.4-beta4&amp;quot;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Make a directory &amp;lt;code&amp;gt;$LIBANTLR3C_INSTALL_DIR&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Enter the src directory.&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 is 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; If you're on Solaris, also change the Makefile to add &amp;quot;&amp;lt;code&amp;gt;-lnsl -lsocket&amp;lt;/code&amp;gt;&amp;quot; to the &amp;lt;code&amp;gt;libantlr3c_la_LDFLAGS&amp;lt;/code&amp;gt; definition.&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;
./autogen.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and&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;
, where &amp;lt;code&amp;gt;$LIBANTLR3_INSTALL_DIR&amp;lt;/code&amp;gt; is the path of the library installation directory, and &amp;lt;code&amp;gt;$ANTLR3_DIR/antlr3&amp;lt;/code&amp;gt; is the path of the shell script you made.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are still having problems trying to configure antlr3 with cvc4, take a look at&lt;br /&gt;
&amp;lt;pre&amp;gt;cvc4/builds/$ARCH/$BUILD_MODE/config.log&amp;lt;/pre&amp;gt;&lt;br /&gt;
and double check that your architecture is is 32 versus 64bit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ uname -a&lt;br /&gt;
Linux box38.cims.nyu.edu 2.6.18-164.15.1.el5 #1 SMP Mon Mar 1 10:56:08 EST 2010 x86_64 x86_64 x86_64 GNU/Linux&lt;br /&gt;
&amp;lt;/pre&amp;gt;&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;br /&gt;
&lt;br /&gt;
=Working with Contexts=&lt;br /&gt;
&lt;br /&gt;
Contexts are a particularly complicated part of the machinery of CVC4, and much of CVC4's work hinges on them.&lt;br /&gt;
&lt;br /&gt;
The class &amp;quot;Context&amp;quot; is an abstraction for a rollback-able memory.  One can create a ''Context'':&lt;br /&gt;
&lt;br /&gt;
  Context c;&lt;br /&gt;
&lt;br /&gt;
and some objects in it (use the ''CDO&amp;lt;&amp;gt;'' wrapper to make a simple, rollback-able object, using a pointer to the ''Context'' as the constructor argument):&lt;br /&gt;
&lt;br /&gt;
  CDO&amp;lt;int&amp;gt; i(&amp;amp;c);&lt;br /&gt;
  CDO&amp;lt;int&amp;gt; j(&amp;amp;c);&lt;br /&gt;
  i = 4;&lt;br /&gt;
  j = 3;&lt;br /&gt;
&lt;br /&gt;
One then &amp;quot;pushes a scope&amp;quot; on the ''Context'':&lt;br /&gt;
&lt;br /&gt;
  c.push();&lt;br /&gt;
&lt;br /&gt;
Further edits to ''i'' and ''j'' are then rolled back with ''pop()'':&lt;br /&gt;
&lt;br /&gt;
  i = 10000;&lt;br /&gt;
  j = -5;&lt;br /&gt;
  assert(i == 10000 &amp;amp;&amp;amp; j == -5); // succeeds&lt;br /&gt;
  &lt;br /&gt;
  c.pop();&lt;br /&gt;
  &lt;br /&gt;
  assert(i == 4 &amp;amp;&amp;amp; j == 3); // also succeeds&lt;br /&gt;
&lt;br /&gt;
Types wrapped by ''CDO&amp;lt;&amp;gt;'' simply employ a ''copy-on-write'' policy if the current scope is greater than that in which the object was last updated.  Rollbacks are eager (when ''pop()'' is called).  ''CDO&amp;lt;&amp;gt;'' just uses the underlying type's copy constructor.  Sometimes you want something more involved, in which case you write your own class that extends the class ''ContextObj'' and provides save and restore functionality.  Make sure to [http://church.cims.nyu.edu/cvc4-builds/documentation/latest/classCVC4_1_1context_1_1ContextObj.html#_details read the invariants in ''context.h'' carefully]!&lt;br /&gt;
&lt;br /&gt;
==Gotchas==&lt;br /&gt;
&lt;br /&gt;
Here are some important ''gotchas'' to keep in mind:&lt;br /&gt;
&lt;br /&gt;
# Your ''ContextObj'' subclass '''must''' call ''destroy()'' from its destructor.  This ensures that, if prematurely destructed (that is, before the Context goes away), your object is properly unregistered from the ''Context''.&lt;br /&gt;
# Be careful if you allocate in an alternative memory manager (see [[#Using ContextObj that aren't allocated in usual heap memory|below]]).&lt;br /&gt;
# FIXME add more gotchas&lt;br /&gt;
&lt;br /&gt;
==Using ContextObj that aren't allocated in usual heap memory==&lt;br /&gt;
&lt;br /&gt;
You need to be careful; even at a high scope level, all objects registered for backtracking with a Context are inserted at scope zero.  ''This means your program will crash if you delete the associated memory too soon.''  Now re-read that sentence.  If you create a ''CDO&amp;lt;int&amp;gt;'' (with '''new''') at scope level 10, and delete it upon backtracking to scope level 9, the ''CDO&amp;lt;int&amp;gt;'' destructor properly unregisters itself from the ''Context''.  However, if you allocate it in a memory manager (such as the ''ContextMemoryManager'') that doesn't guarantee that the destructor is called, your program will crash (perhaps much later), because the object is still registered at scope level 0 (and thus a bad pointer appears on a list).  You may prefer to create a ''CDO&amp;lt;int*&amp;gt;'' rather than a ''CDO&amp;lt;int&amp;gt;*'', which solves the issue (you can prematurely delete the ''int*'' without incident).  But that may leak memory, so there are additional constructors in ''ContextObj'' and ''CDO&amp;lt;&amp;gt;'' (those starting with a ''bool'' argument) that specifically &amp;quot;register&amp;quot; the object at the current scope level.  They aren't registered at scope level 0, so the problem doesn't occur.  However, you have to be careful.&lt;br /&gt;
&lt;br /&gt;
But why allocate ''ContextObj'' instances with the ''ContextMemoryManager'' if it's so complicated?  There's a big advantage: you don't have to track the lifetime of the ''ContextObj''.  The object simply ceases to exist when the ''Context'' is popped.  Thus you can create an object in context memory, and if you stow pointers to it only in context memory as well, all is cleaned up for you when the scope pops.  Here's a list of ''gotchas'':&lt;br /&gt;
&lt;br /&gt;
# For data structures intended solely to be allocated in context memory, privately declare (but don't define) an operator ''new(size_t)'' and destructor (as currently in the ''Link'' class, in ''src/theory/uf/tim/ecdata.h'').&lt;br /&gt;
# For data structures that may or may not be allocated in context memory, and are designed to be that way (especially if they contain ''ContextObj'' instances), they should be heavily documented---especially the destructor, since it ''may or may not be called''.&lt;br /&gt;
# There's also an issue for generic code---some class ''Foo&amp;lt;T&amp;gt;'' might be allocated in context memory, and that might normally be fine, but if ''T'' is a ''ContextObj'' this requires certain care.&lt;br /&gt;
# Note that certain care is required for ''ContextObj'' inside of data structures.  If the (enclosing) data structure can be allocated in ''ContextMemoryManager'' (&amp;quot;CMM&amp;quot;), that means the (enclosed) ''ContextObj'' can be, even if it was not designed to be allocated in that way.  In many instances, it may be required that data structures enclosing ''ContextObj'' be parameterized with a similar &amp;quot;''bool allocatedInCMM''&amp;quot; argument as the special constructor in this class (and pass it on to all ''ContextObj'' instances).&lt;/div&gt;</summary>
		<author><name>Dejan Jovanović</name></author>	</entry>

	</feed>