Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Morgan Deters, Aina Niemetz 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 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 : : * The theory of booleans. 14 : : */ 15 : : 16 : : #include "theory/booleans/theory_bool.h" 17 : : 18 : : #include <stack> 19 : : #include <vector> 20 : : 21 : : #include "proof/proof_node_manager.h" 22 : : #include "theory/booleans/circuit_propagator.h" 23 : : #include "theory/booleans/theory_bool_rewriter.h" 24 : : #include "theory/substitutions.h" 25 : : #include "theory/theory.h" 26 : : #include "theory/trust_substitutions.h" 27 : : #include "theory/valuation.h" 28 : : #include "util/hash.h" 29 : : 30 : : using namespace cvc5::internal::kind; 31 : : 32 : : namespace cvc5::internal { 33 : : namespace theory { 34 : : namespace booleans { 35 : : 36 : 51071 : TheoryBool::TheoryBool(Env& env, OutputChannel& out, Valuation valuation) 37 : : : Theory(THEORY_BOOL, env, out, valuation), 38 : : d_rewriter(nodeManager()), 39 : 51071 : d_checker(nodeManager()) 40 : : { 41 : 51071 : } 42 : : 43 : 20053 : bool TheoryBool::ppAssert(TrustNode tin, TrustSubstitutionMap& outSubstitutions) 44 : : { 45 [ - + ][ - + ]: 20053 : Assert(tin.getKind() == TrustNodeKind::LEMMA); [ - - ] 46 : 40106 : TNode in = tin.getNode(); 47 [ - + ]: 20053 : if (in.getKind() == Kind::CONST_BOOLEAN) 48 : : { 49 [ - - ]: 0 : if (in.getConst<bool>()) 50 : : { 51 : 0 : return true; 52 : : } 53 : : // should not be a false literal, which should be caught by preprocessing 54 : 0 : Assert(in.getConst<bool>()); 55 : : } 56 : : 57 : : // Add the substitution from the variable to its value 58 [ + + ]: 20053 : if (in.getKind() == Kind::NOT) 59 : : { 60 [ + + ]: 9089 : if (in[0].isVar()) 61 : : { 62 : 17376 : outSubstitutions.addSubstitutionSolved( 63 : 17376 : in[0], nodeManager()->mkConst<bool>(false), tin); 64 : 8688 : return true; 65 : : } 66 : 401 : else if (in[0].getKind() == Kind::EQUAL && in[0][0].getType().isBoolean()) 67 : : { 68 : 190 : TNode eq = in[0]; 69 : 190 : if (eq[0].isVar() && d_valuation.isLegalElimination(eq[0], eq[1])) 70 : : { 71 : 106 : outSubstitutions.addSubstitutionSolved(eq[0], eq[1].notNode(), tin); 72 : 106 : return true; 73 : : } 74 : 84 : else if (eq[1].isVar() && d_valuation.isLegalElimination(eq[1], eq[0])) 75 : : { 76 : 0 : outSubstitutions.addSubstitutionSolved(eq[1], eq[0].notNode(), tin); 77 : 0 : return true; 78 : : } 79 : : } 80 : : } 81 [ + + ]: 10964 : else if (in.isVar()) 82 : : { 83 : 14162 : outSubstitutions.addSubstitutionSolved( 84 : 14162 : in, nodeManager()->mkConst<bool>(true), tin); 85 : 7081 : return true; 86 : : } 87 : : 88 : : // the positive Boolean equality case is handled in the default way 89 : 4178 : return Theory::ppAssert(tin, outSubstitutions); 90 : : } 91 : : 92 : 51071 : TheoryRewriter* TheoryBool::getTheoryRewriter() { return &d_rewriter; } 93 : : 94 : 20191 : ProofRuleChecker* TheoryBool::getProofChecker() { return &d_checker; } 95 : : 96 : 0 : std::string TheoryBool::identify() const { return std::string("TheoryBool"); } 97 : : 98 : : } // namespace booleans 99 : : } // namespace theory 100 : : } // namespace cvc5::internal