From 3c796256852390f93c09975795b2575243405740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 29 Mar 2017 23:56:58 +0200 Subject: [PATCH] =?UTF-8?q?Constrained=20the=20element=E2=80=99s=20type=20?= =?UTF-8?q?in=20set=20element=20expressions=20to=20primitive=20terms.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/anthem/AST.h | 9 +++++++++ src/anthem/Simplification.cpp | 14 +++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/anthem/AST.h b/include/anthem/AST.h index 79c3505..9157fb9 100644 --- a/include/anthem/AST.h +++ b/include/anthem/AST.h @@ -14,6 +14,12 @@ namespace ast // //////////////////////////////////////////////////////////////////////////////////////////////////// +// Terms are primitive (or arguments) if they are neither operations nor intervals +inline bool isPrimitive(const ast::Term &term) +{ + return (!term.is() && !term.is()); +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // Primitives //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -112,12 +118,15 @@ struct Function //////////////////////////////////////////////////////////////////////////////////////////////////// +// TODO: refactor (limit element type to primitive terms) struct In { In(Term &&element, Term &&set) : element{std::move(element)}, set{std::move(set)} { + // While the set may be any term, the element must be primitive + assert(isPrimitive(element)); } Term element; diff --git a/src/anthem/Simplification.cpp b/src/anthem/Simplification.cpp index aa1b406..5340c2b 100644 --- a/src/anthem/Simplification.cpp +++ b/src/anthem/Simplification.cpp @@ -11,16 +11,6 @@ namespace anthem // //////////////////////////////////////////////////////////////////////////////////////////////////// -// Determins whether a term is primitive -// All terms but binary operations and intervals are primitive -// With primitive terms t, “X in t” and “X = t” are equivalent -bool isPrimitiveTerm(const ast::Term &term) -{ - return (!term.is() && !term.is()); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - // Determines whether a term is a specific variable bool matchesVariable(const ast::Term &term, const ast::Variable &variable) { @@ -189,7 +179,9 @@ struct SimplifyFormulaVisitor : public ast::RecursiveFormulaVisitor