LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory - shared_solver_distributed.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 33 35 94.3 %
Date: 2026-03-11 10:41:32 Functions: 7 7 100.0 %
Branches: 12 20 60.0 %

           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                 :            :  * Shared solver in the distributed architecture.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "theory/shared_solver_distributed.h"
      14                 :            : 
      15                 :            : #include "theory/theory_engine.h"
      16                 :            : 
      17                 :            : namespace cvc5::internal {
      18                 :            : namespace theory {
      19                 :            : 
      20                 :      49981 : SharedSolverDistributed::SharedSolverDistributed(Env& env, TheoryEngine& te)
      21                 :      49981 :     : SharedSolver(env, te)
      22                 :            : {
      23                 :      49981 : }
      24                 :            : 
      25                 :      49981 : bool SharedSolverDistributed::needsEqualityEngine(theory::EeSetupInfo& esi)
      26                 :            : {
      27                 :      49981 :   return d_sharedTerms.needsEqualityEngine(esi);
      28                 :            : }
      29                 :            : 
      30                 :      49981 : void SharedSolverDistributed::setEqualityEngine(eq::EqualityEngine* ee)
      31                 :            : {
      32                 :      49981 :   d_sharedTerms.setEqualityEngine(ee);
      33                 :      49981 : }
      34                 :            : 
      35                 :    1840202 : void SharedSolverDistributed::preRegisterSharedInternal(TNode t)
      36                 :            : {
      37         [ +  + ]:    1840202 :   if (t.getKind() == Kind::EQUAL)
      38                 :            :   {
      39                 :            :     // When sharing is enabled, we propagate from the shared terms manager also
      40                 :     911335 :     d_sharedTerms.addEqualityToPropagate(t);
      41                 :            :   }
      42                 :    1840202 : }
      43                 :            : 
      44                 :    2071203 : EqualityStatus SharedSolverDistributed::getEqualityStatus(TNode a, TNode b)
      45                 :            : {
      46                 :            :   // if we're using a shared terms database, ask its status if a and b are
      47                 :            :   // shared.
      48                 :    2071203 :   if (d_sharedTerms.isShared(a) && d_sharedTerms.isShared(b))
      49                 :            :   {
      50         [ +  + ]:    2049775 :     if (d_sharedTerms.areEqual(a, b))
      51                 :            :     {
      52                 :      80115 :       return EQUALITY_TRUE_AND_PROPAGATED;
      53                 :            :     }
      54         [ +  + ]:    1969660 :     else if (d_sharedTerms.areDisequal(a, b))
      55                 :            :     {
      56                 :       5621 :       return EQUALITY_FALSE_AND_PROPAGATED;
      57                 :            :     }
      58                 :            :   }
      59                 :            :   // otherwise, ask the theory, which may depend on the uninterpreted sort owner
      60                 :            :   TheoryId tid =
      61                 :    1985467 :       Theory::theoryOf(a.getType(), d_env.getUninterpretedSortOwner());
      62                 :    1985467 :   return d_te.theoryOf(tid)->getEqualityStatus(a, b);
      63                 :            : }
      64                 :            : 
      65                 :     665371 : TrustNode SharedSolverDistributed::explain(TNode literal, TheoryId id)
      66                 :            : {
      67                 :     665371 :   TrustNode texp;
      68         [ +  + ]:     665371 :   if (id == THEORY_BUILTIN)
      69                 :            :   {
      70                 :            :     // explanation using the shared terms database
      71                 :     231968 :     texp = d_sharedTerms.explain(literal);
      72         [ +  - ]:     463936 :     Trace("shared-solver")
      73                 :          0 :         << "\tTerm was propagated by THEORY_BUILTIN. Explanation: "
      74 [ -  + ][ -  - ]:     231968 :         << texp.getNode() << std::endl;
      75                 :            :   }
      76                 :            :   else
      77                 :            :   {
      78                 :            :     // By default, we ask the individual theory for the explanation.
      79                 :            :     // It is possible that a centralized approach could preempt this.
      80                 :     433403 :     texp = d_te.theoryOf(id)->explain(literal);
      81         [ +  - ]:     866806 :     Trace("shared-solver") << "\tTerm was propagated by owner theory: " << id
      82 [ -  + ][ -  - ]:     433403 :                            << ". Explanation: " << texp.getNode() << std::endl;
      83                 :            :   }
      84                 :     665371 :   return texp;
      85                 :          0 : }
      86                 :            : 
      87                 :   12396200 : void SharedSolverDistributed::assertShared(TNode n, bool polarity, TNode reason)
      88                 :            : {
      89                 :   12396200 :   d_sharedTerms.assertShared(n, polarity, reason);
      90                 :   12396200 : }
      91                 :            : 
      92                 :            : }  // namespace theory
      93                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14