Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Gereon Kremer, Andrew Reynolds 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2024 by the authors listed in the file AUTHORS 8 : : * in the top-level source directory and their institutional affiliations. 9 : : * All rights reserved. See the file COPYING in the top-level source 10 : : * directory for licensing information. 11 : : * **************************************************************************** 12 : : * 13 : : * Arithmetic evaluator. 14 : : */ 15 : : #include "theory/arith/arith_evaluator.h" 16 : : 17 : : #include "theory/arith/nl/poly_conversion.h" 18 : : #include "theory/rewriter.h" 19 : : #include "theory/theory.h" 20 : : #include "util/real_algebraic_number.h" 21 : : 22 : : namespace cvc5::internal { 23 : : namespace theory { 24 : : namespace arith { 25 : : 26 : 1827750 : std::optional<bool> isExpressionZero(Env& env, 27 : : Node expr, 28 : : const ArithSubs& subs, 29 : : bool traverseNlMult) 30 : : { 31 : : // Substitute constants and rewrite 32 : 1827750 : expr = env.getRewriter()->rewrite(expr); 33 [ + + ]: 1827750 : if (expr.isConst()) 34 : : { 35 : 708315 : return expr.getConst<Rational>().isZero(); 36 : : } 37 : : // we use an arithmetic substitution, which does not traverse into 38 : : // terms that do not belong to the core theory of arithmetic. 39 : 1119430 : expr = subs.applyArith(expr, traverseNlMult); 40 : 1119430 : expr = env.getRewriter()->rewrite(expr); 41 [ + + ]: 1119430 : if (expr.isConst()) 42 : : { 43 : 1115510 : return expr.getConst<Rational>().isZero(); 44 : : } 45 [ + + ]: 3922 : if (expr.getKind() == Kind::REAL_ALGEBRAIC_NUMBER) 46 : : { 47 : 4 : return expr.getOperator().getConst<RealAlgebraicNumber>().isZero(); 48 : : } 49 : 3918 : return std::nullopt; 50 : : } 51 : : 52 : : } // namespace arith 53 : : } // namespace theory 54 : : } // namespace cvc5::internal