LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/booleans - theory_bool.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 28 34 82.4 %
Date: 2026-06-07 10:33:52 Functions: 4 5 80.0 %
Branches: 11 18 61.1 %

           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                 :            :  * The theory of booleans.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "theory/booleans/theory_bool.h"
      14                 :            : 
      15                 :            : #include <stack>
      16                 :            : #include <vector>
      17                 :            : 
      18                 :            : #include "proof/proof_node_manager.h"
      19                 :            : #include "theory/booleans/circuit_propagator.h"
      20                 :            : #include "theory/booleans/theory_bool_rewriter.h"
      21                 :            : #include "theory/substitutions.h"
      22                 :            : #include "theory/theory.h"
      23                 :            : #include "theory/trust_substitutions.h"
      24                 :            : #include "theory/valuation.h"
      25                 :            : #include "util/hash.h"
      26                 :            : 
      27                 :            : using namespace cvc5::internal::kind;
      28                 :            : 
      29                 :            : namespace cvc5::internal {
      30                 :            : namespace theory {
      31                 :            : namespace booleans {
      32                 :            : 
      33                 :      51241 : TheoryBool::TheoryBool(Env& env, OutputChannel& out, Valuation valuation)
      34                 :            :     : Theory(THEORY_BOOL, env, out, valuation),
      35                 :      51241 :       d_rewriter(nodeManager()),
      36                 :     102482 :       d_checker(nodeManager())
      37                 :            : {
      38                 :      51241 : }
      39                 :            : 
      40                 :      18885 : bool TheoryBool::ppAssert(TrustNode tin, TrustSubstitutionMap& outSubstitutions)
      41                 :            : {
      42 [ -  + ][ -  + ]:      18885 :   Assert(tin.getKind() == TrustNodeKind::LEMMA);
                 [ -  - ]
      43                 :      18885 :   TNode in = tin.getNode();
      44         [ -  + ]:      18885 :   if (in.getKind() == Kind::CONST_BOOLEAN)
      45                 :            :   {
      46         [ -  - ]:          0 :     if (in.getConst<bool>())
      47                 :            :     {
      48                 :          0 :       return true;
      49                 :            :     }
      50                 :            :     // should not be a false literal, which should be caught by preprocessing
      51                 :          0 :     Assert(in.getConst<bool>());
      52                 :            :   }
      53                 :            : 
      54                 :            :   // Add the substitution from the variable to its value
      55         [ +  + ]:      18885 :   if (in.getKind() == Kind::NOT)
      56                 :            :   {
      57         [ +  + ]:       8582 :     if (in[0].isVar())
      58                 :            :     {
      59                 :      16550 :       outSubstitutions.addSubstitutionSolved(
      60                 :      16550 :           in[0], nodeManager()->mkConst<bool>(false), tin);
      61                 :       8275 :       return true;
      62                 :            :     }
      63                 :        307 :     else if (in[0].getKind() == Kind::EQUAL && in[0][0].getType().isBoolean())
      64                 :            :     {
      65                 :        114 :       TNode eq = in[0];
      66                 :        114 :       if (eq[0].isVar() && d_valuation.isLegalElimination(eq[0], eq[1]))
      67                 :            :       {
      68                 :         69 :         outSubstitutions.addSubstitutionSolved(eq[0], eq[1].notNode(), tin);
      69                 :         69 :         return true;
      70                 :            :       }
      71                 :         45 :       else if (eq[1].isVar() && d_valuation.isLegalElimination(eq[1], eq[0]))
      72                 :            :       {
      73                 :          0 :         outSubstitutions.addSubstitutionSolved(eq[1], eq[0].notNode(), tin);
      74                 :          0 :         return true;
      75                 :            :       }
      76         [ +  + ]:        114 :     }
      77                 :            :   }
      78         [ +  + ]:      10303 :   else if (in.isVar())
      79                 :            :   {
      80                 :      13512 :     outSubstitutions.addSubstitutionSolved(
      81                 :      13512 :         in, nodeManager()->mkConst<bool>(true), tin);
      82                 :       6756 :     return true;
      83                 :            :   }
      84                 :            : 
      85                 :            :   // the positive Boolean equality case is handled in the default way
      86                 :       3785 :   return Theory::ppAssert(tin, outSubstitutions);
      87                 :      18885 : }
      88                 :            : 
      89                 :      51241 : TheoryRewriter* TheoryBool::getTheoryRewriter() { return &d_rewriter; }
      90                 :            : 
      91                 :      19955 : ProofRuleChecker* TheoryBool::getProofChecker() { return &d_checker; }
      92                 :            : 
      93                 :          0 : std::string TheoryBool::identify() const { return std::string("TheoryBool"); }
      94                 :            : 
      95                 :            : }  // namespace booleans
      96                 :            : }  // namespace theory
      97                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14