Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * White box testing of the core rewriter. 11 : : */ 12 : : 13 : : #include "test_smt.h" 14 : : #include "util/rational.h" 15 : : 16 : : namespace cvc5::internal { 17 : : namespace test { 18 : : 19 : : using namespace theory; 20 : : 21 : : class TestTheoryWhiteRewriter : public TestSmt 22 : : { 23 : : }; 24 : : 25 : 4 : TEST_F(TestTheoryWhiteRewriter, deepFullRewrite) 26 : : { 27 : 1 : Rewriter* rr = d_slvEngine->getEnv().getRewriter(); 28 : 1 : TypeNode intType = d_nodeManager->integerType(); 29 : 1 : TypeNode setType = d_nodeManager->mkSetType(intType); 30 : 2 : Node x = d_skolemManager->mkDummySkolem("x", intType); 31 : 2 : Node tail = d_skolemManager->mkDummySkolem("tail", setType); 32 : 1 : Node set = tail; 33 : : 34 : 1 : constexpr size_t kDepth = 4000; 35 [ + + ]: 4001 : for (size_t i = 0; i < kDepth; ++i) 36 : : { 37 : 4000 : Node elem = d_nodeManager->mkConstInt(Rational(i)); 38 : 4000 : Node singleton = d_nodeManager->mkNode(Kind::SET_SINGLETON, elem); 39 : 4000 : set = d_nodeManager->mkNode(Kind::SET_UNION, singleton, set); 40 : 4000 : } 41 : : 42 : 2 : Node mem = d_nodeManager->mkNode(Kind::SET_MEMBER, x, set); 43 : 1 : Node rewritten = rr->rewrite(mem); 44 : : 45 [ - + ][ + - ]: 1 : ASSERT_EQ(rewritten.getKind(), Kind::OR); 46 [ - + ][ + - ]: 1 : ASSERT_EQ(rewritten.getNumChildren(), kDepth + 1); 47 : : 48 : 2 : Node memberTail = d_nodeManager->mkNode(Kind::SET_MEMBER, x, tail); 49 : 1 : bool foundTail = false; 50 [ + - ]: 4000 : for (const Node& c : rewritten) 51 : : { 52 [ + + ]: 4000 : if (c == memberTail) 53 : : { 54 : 1 : foundTail = true; 55 : 1 : break; 56 : : } 57 [ + + ]: 4000 : } 58 [ - + ][ + - ]: 1 : ASSERT_TRUE(foundTail); 59 [ + - ][ + - ]: 1 : } [ + - ][ + - ] [ + - ][ + - ] [ + - ] 60 : : 61 : : } // namespace test 62 : : } // namespace cvc5::internal