diff options
author | Morgan Deters <mdeters@gmail.com> | 2010-06-30 11:12:14 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2010-06-30 11:12:14 +0000 |
commit | 4375b60d5df794b2c6193f3892185ea181a0748d (patch) | |
tree | d346f9dc6bde42c3def6e0aac3b2711418e3d491 /src/theory/builtin/theory_builtin.cpp | |
parent | 4206a75e7a1635d04bb69084404a75670e164b62 (diff) |
* theory "tree" rewriting implemented and works
* added TheoryArith::preRewrite() to test and demonstrate
the use of pre-rewriting.
* array types and type checking now supported
* array type checking now supported
* theoryOf() dispatching properly to arrays now
* theories now required to implement a (simple) identify()
function that returns a string identifying them for
debugging/user output purposes
* added "builtin" theory to hold all built-in kinds and their
type rules and rewriting (currently only exploding distinct)
* fixed production build failure (regarding NodeSetDepth)
* removed an errant "using namespace std" in util/bitvector.h
(and made associated trivial fixes elsewhere)
* fixes to make unexpected exceptions more verbose in debug builds
* fixes to make multiple, cascading assertion fails simpler
* minor other fixes to comments etc.
Diffstat (limited to 'src/theory/builtin/theory_builtin.cpp')
-rw-r--r-- | src/theory/builtin/theory_builtin.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/theory/builtin/theory_builtin.cpp b/src/theory/builtin/theory_builtin.cpp new file mode 100644 index 000000000..1951e438c --- /dev/null +++ b/src/theory/builtin/theory_builtin.cpp @@ -0,0 +1,69 @@ +/********************* */ +/*! \file theory_builtin.cpp + ** \verbatim + ** Original author: mdeters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys) + ** Courant Institute of Mathematical Sciences + ** New York University + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Implementation of the builtin theory. + ** + ** Implementation of the builtin theory. + **/ + +#include "theory/builtin/theory_builtin.h" +#include "expr/kind.h" + +using namespace std; +using namespace CVC4; +using namespace CVC4::theory::builtin; + +namespace CVC4 { +namespace theory { +namespace builtin { + +Node blastDistinct(TNode in) { + Debug("theory-rewrite") << "blastDistinct: " << in << std::endl; + Assert(in.getKind() == kind::DISTINCT); + if(in.getNumChildren() == 2) { + // if this is the case exactly 1 != pair will be generated so the + // AND is not required + Node eq = NodeManager::currentNM()->mkNode(CVC4::kind::EQUAL, in[0], in[1]); + Node neq = NodeManager::currentNM()->mkNode(CVC4::kind::NOT, eq); + return neq; + } + // assume that in.getNumChildren() > 2 => diseqs.size() > 1 + vector<Node> diseqs; + for(TNode::iterator i = in.begin(); i != in.end(); ++i) { + TNode::iterator j = i; + while(++j != in.end()) { + Node eq = NodeManager::currentNM()->mkNode(CVC4::kind::EQUAL, *i, *j); + Node neq = NodeManager::currentNM()->mkNode(CVC4::kind::NOT, eq); + diseqs.push_back(neq); + } + } + Node out = NodeManager::currentNM()->mkNode(CVC4::kind::AND, diseqs); + return out; +} + +RewriteResponse TheoryBuiltin::postRewrite(TNode in, bool topLevel) { + if(topLevel) { + if(in.getKind() == kind::DISTINCT) { + return RewritingComplete(blastDistinct(in)); + } + } + + // EQUAL is a special case that should never end up here + Assert(in.getKind() != kind::EQUAL); + + return RewritingComplete(in); +} + +}/* CVC4::theory::builtin namespace */ +}/* CVC4::theory */ +}/* CVC4 namespace */ |