summaryrefslogtreecommitdiff
path: root/src/printer/smt2
diff options
context:
space:
mode:
authorHaniel Barbosa <hanielbbarbosa@gmail.com>2019-08-03 10:40:36 -0500
committerGitHub <noreply@github.com>2019-08-03 10:40:36 -0500
commitfbc61a7bbe75c99b29cd238f552c18542deb5c32 (patch)
tree166797b0e81f10b7c66fd04b10fc04c5f3fb8e69 /src/printer/smt2
parent5001fa069ab42134333244b3f27c852724cea3e2 (diff)
Collapse @ chains in SMT2 printer (#3140)
Diffstat (limited to 'src/printer/smt2')
-rw-r--r--src/printer/smt2/smt2_printer.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp
index 163c8acad..fd8b4ce85 100644
--- a/src/printer/smt2/smt2_printer.cpp
+++ b/src/printer/smt2/smt2_printer.cpp
@@ -24,6 +24,7 @@
#include "expr/node_manager_attributes.h"
#include "options/bv_options.h"
#include "options/language.h"
+#include "options/printer_options.h"
#include "options/smt_options.h"
#include "printer/dagification_visitor.h"
#include "smt/smt_engine.h"
@@ -509,7 +510,34 @@ void Smt2Printer::toStream(std::ostream& out,
// uf theory
case kind::APPLY_UF: typeChildren = true; break;
// higher-order
- case kind::HO_APPLY: break;
+ case kind::HO_APPLY:
+ if (!options::flattenHOChains())
+ {
+ break;
+ }
+ // collapse "@" chains, i.e.
+ //
+ // ((a b) c) --> (a b c)
+ //
+ // (((a b) ((c d) e)) f) --> (a b (c d e) f)
+ {
+ Node head = n;
+ std::vector<Node> args;
+ while (head.getKind() == kind::HO_APPLY)
+ {
+ args.insert(args.begin(), head[1]);
+ head = head[0];
+ }
+ toStream(out, head, toDepth, types, TypeNode::null());
+ for (unsigned i = 0, size = args.size(); i < size; ++i)
+ {
+ out << " ";
+ toStream(out, args[i], toDepth, types, TypeNode::null());
+ }
+ out << ")";
+ }
+ return;
+
case kind::LAMBDA:
out << smtKindString(k, d_variant) << " ";
break;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback