summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKshitij Bansal <kshitij@cs.nyu.edu>2014-06-06 19:40:18 -0400
committerKshitij Bansal <kshitij@cs.nyu.edu>2014-06-06 19:40:18 -0400
commit21965968150ec8d84b12a9555063e0a6451cb62a (patch)
tree3ea3f920dc4b77ec08087ad192b1f31419ab416e /examples
parentcf13918f84ddeb228cb3ec7349deeea25f75b88b (diff)
sets translator: fix for dags
Diffstat (limited to 'examples')
-rw-r--r--examples/sets-translate/sets_translate.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/sets-translate/sets_translate.cpp b/examples/sets-translate/sets_translate.cpp
index 6cf2b61e2..5b0a9c3d0 100644
--- a/examples/sets-translate/sets_translate.cpp
+++ b/examples/sets-translate/sets_translate.cpp
@@ -43,6 +43,7 @@ class Mapper {
hash_map< Expr, Expr, ExprHashFunction > substitutions;
ostringstream sout;
ExprManager* em;
+ int depth;
Expr add(SetType t, Expr e) {
@@ -140,7 +141,7 @@ class Mapper {
}
public:
- Mapper(ExprManager* e) : em(e) {
+ Mapper(ExprManager* e) : em(e),depth(0) {
sout << Expr::setlanguage(language::output::LANG_SMTLIB_V2);
}
@@ -153,17 +154,24 @@ public:
Expr collectSortsExpr(Expr e)
{
+ if(substitutions.find(e) != substitutions.end()) {
+ return substitutions[e];
+ }
+ ++depth;
Expr old_e = e;
for(unsigned i = 0; i < e.getNumChildren(); ++i) {
collectSortsExpr(e[i]);
}
e = e.substitute(substitutions);
+ // cout << "[debug] " << e << " " << e.getKind() << " " << theory::kindToTheoryId(e.getKind()) << endl;
if(theory::kindToTheoryId(e.getKind()) == theory::THEORY_SETS) {
SetType t = SetType(e.getType().isBoolean() ? e[1].getType() : e.getType());
substitutions[e] = add(t, e);
e = e.substitute(substitutions);
}
- // cout << old_e << " => " << e << endl;
+ substitutions[old_e] = e;
+ // cout << ";"; for(int i = 0; i < depth; ++i) cout << " "; cout << old_e << " => " << e << endl;
+ --depth;
return e;
}
@@ -187,6 +195,7 @@ int main(int argc, char* argv[])
Options options;
options.set(inputLanguage, language::input::LANG_SMTLIB_V2);
cout << Expr::setlanguage(language::output::LANG_SMTLIB_V2);
+ // cout << Expr::dag(0);
ExprManager exprManager(options);
Mapper m(&exprManager);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback