{
for (const Node& c : x)
{
- if (c.getKind() == EQUAL)
+ if (c.getKind() != EQUAL)
{
- if (Word::isEmpty(c[0]))
- {
- emptyNodes.insert(c[1]);
- }
- else if (Word::isEmpty(c[1]))
- {
- emptyNodes.insert(c[0]);
- }
+ allEmptyEqs = false;
+ continue;
+ }
+
+ if (Word::isEmpty(c[0]))
+ {
+ emptyNodes.insert(c[1]);
+ }
+ else if (Word::isEmpty(c[1]))
+ {
+ emptyNodes.insert(c[0]);
}
else
{
--- /dev/null
+(set-logic QF_SLIA)
+(declare-fun a () String)
+(assert
+ (xor
+ (= (= (str.replace "B" (str.replace (str.++ (str.replace "B" a "B") a) "B" "") "B")
+ (str.replace "B" (str.replace "B" a (str.++ a "B")) a))
+ (not
+ (= (str.replace "B" (str.replace a "B" "") "B")
+ (str.replace "B" a (str.++ a "B")))))
+ (= (str.replace "B" a "")
+ (str.replace "B" a
+ (ite (not (= (str.replace "" (str.replace a "" a) "") "")) ""
+ (str.replace "" (str.replace a "B" "") "B"))))))
+(set-info :status unsat)
+(check-sat)
cvc5_add_unit_test_white(theory_sets_type_enumerator_white theory)
cvc5_add_unit_test_white(theory_sets_type_rules_white theory)
cvc5_add_unit_test_white(theory_strings_skolem_cache_black theory)
+cvc5_add_unit_test_white(theory_strings_utils_white theory)
cvc5_add_unit_test_white(theory_strings_word_white theory)
cvc5_add_unit_test_white(theory_white theory)
cvc5_add_unit_test_white(type_enumerator_white theory)
--- /dev/null
+/******************************************************************************
+ * Top contributors (to current version):
+ * Andres Noetzli
+ *
+ * This file is part of the cvc5 project.
+ *
+ * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
+ * in the top-level source directory and their institutional affiliations.
+ * All rights reserved. See the file COPYING in the top-level source
+ * directory for licensing information.
+ * ****************************************************************************
+ *
+ * Unit tests for the string utils
+ */
+
+#include <unordered_set>
+#include <vector>
+
+#include "expr/node.h"
+#include "test_node.h"
+#include "theory/strings/theory_strings_utils.h"
+
+namespace cvc5 {
+
+using namespace kind;
+using namespace theory;
+using namespace theory::strings;
+
+namespace test {
+
+class TestTheoryWhiteStringsUtils : public TestNode
+{
+};
+
+TEST_F(TestTheoryWhiteStringsUtils, collect_empty_eqs)
+{
+ TypeNode strType = d_nodeManager->stringType();
+
+ Node empty = d_nodeManager->mkConst(String(""));
+ Node a = d_nodeManager->mkConst(::cvc5::String("A"));
+ Node x = d_nodeManager->mkVar("x", strType);
+
+ Node emptyEqX = empty.eqNode(x);
+ Node emptyEqA = a.eqNode(empty);
+ Node xEqA = x.eqNode(a);
+
+ std::vector<Node> emptyNodes;
+ bool allEmptyEqs;
+ std::unordered_set<Node> expected = {a, x};
+
+ std::tie(allEmptyEqs, emptyNodes) =
+ utils::collectEmptyEqs(d_nodeManager->mkNode(AND, emptyEqX, emptyEqA));
+ ASSERT_TRUE(allEmptyEqs);
+ ASSERT_EQ(std::unordered_set<Node>(emptyNodes.begin(), emptyNodes.end()),
+ expected);
+
+ std::tie(allEmptyEqs, emptyNodes) = utils::collectEmptyEqs(
+ d_nodeManager->mkNode(AND, emptyEqX, xEqA, emptyEqA));
+ ASSERT_FALSE(allEmptyEqs);
+ ASSERT_EQ(std::unordered_set<Node>(emptyNodes.begin(), emptyNodes.end()),
+ expected);
+}
+
+} // namespace test
+} // namespace cvc5