diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2020-02-20 14:49:02 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 14:49:02 -0600 |
commit | 5489ef01beb91e256e343e2fd2d734b48b42ad6e (patch) | |
tree | f6a535c768ae4f3cfbbed765b0697300f4412657 /src/parser | |
parent | 32fdf625f66b8ebf260756962a53d63eec771c12 (diff) |
Remove front-end support for Chain (#3767)
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/parser.cpp | 16 | ||||
-rw-r--r-- | src/parser/parser.h | 11 | ||||
-rw-r--r-- | src/parser/smt2/smt2.cpp | 4 | ||||
-rw-r--r-- | src/parser/tptp/tptp.cpp | 4 |
4 files changed, 33 insertions, 2 deletions
diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp index 32d555718..664fa209d 100644 --- a/src/parser/parser.cpp +++ b/src/parser/parser.cpp @@ -515,6 +515,22 @@ Expr Parser::mkHoApply(Expr expr, std::vector<Expr>& args) return expr; } +api::Term Parser::mkChain(api::Kind k, const std::vector<api::Term>& args) +{ + if (args.size() == 2) + { + // if this is the case exactly 1 pair will be generated so the + // AND is not required + return d_solver->mkTerm(k, args[0], args[1]); + } + std::vector<api::Term> children; + for (size_t i = 0, nargsmo = args.size() - 1; i < nargsmo; i++) + { + children.push_back(d_solver->mkTerm(k, args[i], args[i + 1])); + } + return d_solver->mkTerm(api::AND, children); +} + bool Parser::isDeclared(const std::string& name, SymbolType type) { switch (type) { case SYM_VARIABLE: diff --git a/src/parser/parser.h b/src/parser/parser.h index ecf1e2961..cd70fde0f 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -24,6 +24,7 @@ #include <set> #include <string> +#include "api/cvc4cpp.h" #include "expr/expr.h" #include "expr/expr_stream.h" #include "expr/kind.h" @@ -677,6 +678,16 @@ public: */ Expr mkHoApply(Expr expr, std::vector<Expr>& args); + /** make chain + * + * Given a kind k and argument terms t_1, ..., t_n, this returns the + * conjunction of: + * (k t_1 t_2) .... (k t_{n-1} t_n) + * It is expected that k is a kind denoting a predicate, and args is a list + * of terms of size >= 2 such that the terms above are well-typed. + */ + api::Term mkChain(api::Kind k, const std::vector<api::Term>& args); + /** * Add an operator to the current legal set. * diff --git a/src/parser/smt2/smt2.cpp b/src/parser/smt2/smt2.cpp index f3b66643a..11dedb259 100644 --- a/src/parser/smt2/smt2.cpp +++ b/src/parser/smt2/smt2.cpp @@ -1887,7 +1887,9 @@ Expr Smt2::applyParseOp(ParseOp& p, std::vector<Expr>& args) || kind == kind::LEQ || kind == kind::GEQ) { /* "chainable", but CVC4 internally only supports 2 args */ - return em->mkExpr(em->mkConst(Chain(kind)), args); + api::Term ret = + mkChain(intToExtKind(kind), api::exprVectorToTerms(args)); + return ret.getExpr(); } } diff --git a/src/parser/tptp/tptp.cpp b/src/parser/tptp/tptp.cpp index 71a3e4bee..bf699ae3c 100644 --- a/src/parser/tptp/tptp.cpp +++ b/src/parser/tptp/tptp.cpp @@ -326,7 +326,9 @@ Expr Tptp::applyParseOp(ParseOp& p, std::vector<Expr>& args) || kind == kind::LEQ || kind == kind::GEQ) { /* "chainable", but CVC4 internally only supports 2 args */ - return em->mkExpr(em->mkConst(Chain(kind)), args); + api::Term ret = + mkChain(intToExtKind(kind), api::exprVectorToTerms(args)); + return ret.getExpr(); } } |