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