diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2020-02-25 20:52:10 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 20:52:10 -0600 |
commit | 808bb1bd855799535a1b690865dc873793a37f7f (patch) | |
tree | 178d9bb00cccf12c11c6f7284dc66e0d6c8827ec /src/expr | |
parent | 9301607b58a3b74dcea73c500c6391d6a51093f8 (diff) |
Embed mkAssociative utilities within the API. (#3801)
Towards parser/API migration.
Diffstat (limited to 'src/expr')
-rw-r--r-- | src/expr/expr_manager_template.cpp | 16 | ||||
-rw-r--r-- | src/expr/expr_manager_template.h | 10 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp index 8bf8d9e54..76992e1ba 100644 --- a/src/expr/expr_manager_template.cpp +++ b/src/expr/expr_manager_template.cpp @@ -1013,6 +1013,22 @@ Expr ExprManager::mkRightAssociative(Kind kind, return n.toExpr(); } +Expr ExprManager::mkChain(Kind kind, const std::vector<Expr>& children) +{ + if (children.size() == 2) + { + // if this is the case exactly 1 pair will be generated so the + // AND is not required + return mkExpr(kind, children[0], children[1]); + } + std::vector<Expr> cchildren; + for (size_t i = 0, nargsmo = children.size() - 1; i < nargsmo; i++) + { + cchildren.push_back(mkExpr(kind, children[i], children[i + 1])); + } + return mkExpr(kind::AND, cchildren); +} + unsigned ExprManager::minArity(Kind kind) { return metakind::getLowerBoundForKind(kind); } diff --git a/src/expr/expr_manager_template.h b/src/expr/expr_manager_template.h index c61c7e012..0fd5bb4fa 100644 --- a/src/expr/expr_manager_template.h +++ b/src/expr/expr_manager_template.h @@ -306,6 +306,16 @@ private: */ Expr mkRightAssociative(Kind kind, const std::vector<Expr>& children); + /** make chain + * + * Given a kind k and arguments 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. + */ + Expr mkChain(Kind kind, const std::vector<Expr>& children); + /** * Determine whether Exprs of a particular Kind have operators. * @returns true if Exprs of Kind k have operators. |