This was causing assertion failures when using Sets + Sygus.
Kind k = n.getKind();
bool childChanged = false;
bool isNonAdditive = TermUtil::isNonAdditive(k);
- bool isAssoc = TermUtil::isAssoc(k);
+ // We flatten associative operators below, which requires k to be n-ary.
+ bool isAssoc = TermUtil::isAssoc(k, true);
for (unsigned i = 0; i < n.getNumChildren(); i++)
{
Node nc = extendedRewrite(n[i]);
return k == NOT || k == BITVECTOR_NOT || k == BITVECTOR_NEG || k == UMINUS;
}
-bool TermUtil::isAssoc( Kind k ) {
+bool TermUtil::isAssoc(Kind k, bool reqNAry)
+{
+ if (reqNAry)
+ {
+ if (k == UNION || k == INTERSECTION)
+ {
+ return false;
+ }
+ }
return k == PLUS || k == MULT || k == NONLINEAR_MULT || k == AND || k == OR
|| k == XOR || k == BITVECTOR_PLUS || k == BITVECTOR_MULT
|| k == BITVECTOR_AND || k == BITVECTOR_OR || k == BITVECTOR_XOR
|| k == SEP_STAR;
}
-bool TermUtil::isComm( Kind k ) {
+bool TermUtil::isComm(Kind k, bool reqNAry)
+{
+ if (reqNAry)
+ {
+ if (k == UNION || k == INTERSECTION)
+ {
+ return false;
+ }
+ }
return k == EQUAL || k == PLUS || k == MULT || k == NONLINEAR_MULT || k == AND
|| k == OR || k == XOR || k == BITVECTOR_PLUS || k == BITVECTOR_MULT
|| k == BITVECTOR_AND || k == BITVECTOR_OR || k == BITVECTOR_XOR
* double negation if applicable, e.g. mkNegate( ~, ~x ) ---> x.
*/
static Node mkNegate(Kind notk, Node n);
- /** is assoc */
- static bool isAssoc( Kind k );
- /** is k commutative? */
- static bool isComm( Kind k );
+ /** is k associative?
+ *
+ * If flag reqNAry is true, then we additionally require that k is an
+ * n-ary operator.
+ */
+ static bool isAssoc(Kind k, bool reqNAry = false);
+ /** is k commutative?
+ *
+ * If flag reqNAry is true, then we additionally require that k is an
+ * n-ary operator.
+ */
+ static bool isComm(Kind k, bool reqNAry = false);
/** is k non-additive?
* Returns true if
RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
NodeManager* nm = NodeManager::currentNM();
Kind kind = node.getKind();
-
+ Trace("sets-postrewrite") << "Process: " << node << std::endl;
if(node.isConst()) {
// Dare you touch the const and mangle it to something else.
if( rew!=node ){
Trace("sets-rewrite") << "Sets::rewrite " << node << " -> " << rew << std::endl;
}
+ Trace("sets-rewrite") << "...no rewrite." << std::endl;
return RewriteResponse(REWRITE_DONE, rew);
}
break;
regress0/sets/pre-proc-univ.smt2
regress0/sets/rec_copy_loop_check_heap_access_43_4.smt2
regress0/sets/sets-equal.smt2
+ regress0/sets/sets-extr.smt2
regress0/sets/sets-inter.smt2
regress0/sets/sets-of-sets-subtypes.smt2
regress0/sets/sets-poly-int-real.smt2
--- /dev/null
+; COMMAND-LINE: --ext-rew-prep --ext-rew-prep-agg
+; EXPECT: sat
+(set-logic ALL)
+(declare-sort Atom 0)
+
+(declare-fun a () Atom)
+(declare-fun b () Atom)
+(declare-fun c () Atom)
+(declare-fun S () (Set Atom))
+
+
+(assert (= S (union (singleton a) (union (singleton c) (singleton b)))))
+
+(check-sat)
+