LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/sets - strategy.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 53 57 93.0 %
Date: 2026-09-23 09:32:23 Functions: 5 6 83.3 %
Branches: 16 24 66.7 %

           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                 :            :  * Implementation of the strategy of the theory of sets.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "theory/sets/strategy.h"
      14                 :            : 
      15                 :            : #include "theory/inference_manager_buffered.h"
      16                 :            : #include "theory/sets/theory_sets_private.h"
      17                 :            : #include "theory/theory_state.h"
      18                 :            : 
      19                 :            : namespace cvc5::internal {
      20                 :            : namespace theory {
      21                 :            : namespace sets {
      22                 :            : 
      23                 :      26967 : Strategy::Strategy(TheorySetsPrivate* parent,
      24                 :            :                    TheoryState* state,
      25                 :      26967 :                    InferenceManagerBuffered* im)
      26                 :      26967 :     : StrategyBase(TheoryId::THEORY_SETS, state, im), d_setsSolver(parent)
      27                 :            : {
      28                 :      26967 : }
      29                 :            : 
      30                 :      26954 : Strategy::~Strategy() {}
      31                 :            : 
      32                 :      26967 : void Strategy::initializeStrategy()
      33                 :            : {
      34                 :            :   // initialize the strategy if not already done so
      35         [ -  + ]:      26967 :   if (isStrategyInit())
      36                 :            :   {
      37                 :          0 :     return;
      38                 :            :   }
      39                 :            :   // the full-effort strategy
      40                 :      26967 :   markStartEffort(Theory::EFFORT_FULL);
      41                 :            :   // add the ence steps
      42                 :      26967 :   addStrategyStep(Step::SETS_CHECK_RESET);
      43                 :      26967 :   addStrategyStep(Step::SETS_CHECK_BASIC);
      44                 :      26967 :   addStrategyStep(Step::SETS_CHECK_RELATIONS);
      45                 :            :   // The transitive-closure down and up rules share the closure graph the down
      46                 :            :   // rule builds, so they run back-to-back in the same pass (no BREAK between
      47                 :            :   // them), mirroring TheorySetsRels::check() before the strategy refactor.
      48                 :      26967 :   addStrategyStep(
      49                 :            :       Step::SETS_CHECK_TRANSITIVE_CLOSURE_DOWN, Theory::EFFORT_FULL, false);
      50                 :      26967 :   addStrategyStep(Step::SETS_CHECK_TRANSITIVE_CLOSURE_UP);
      51                 :      26967 :   addStrategyStep(Step::SETS_CHECK_FILTER);
      52                 :      26967 :   addStrategyStep(Step::SETS_CHECK_MAP);
      53                 :      26967 :   addStrategyStep(Step::SETS_CHECK_GROUP);
      54                 :      26967 :   addStrategyStep(Step::SETS_CHECK_DISEQUALITY);
      55                 :      26967 :   addStrategyStep(Step::SETS_CHECK_CARDINALITY);
      56                 :      26967 :   addStrategyStep(Step::SETS_CHECK_COMPREHENSION);
      57                 :      26967 :   markEndEffort(Theory::EFFORT_FULL);
      58                 :            :   // set the beginning/ending ranges and mark the strategy as initialized
      59                 :      26967 :   finishInit();
      60                 :            : }
      61                 :            : 
      62                 :     430074 : void Strategy::runStep(Step s, Theory::Effort, Theory::Effort effort)
      63                 :            : {
      64         [ +  - ]:     860148 :   Trace("sets-process") << "Run " << s << ", effort = " << effort << "..."
      65                 :     430074 :                         << std::endl;
      66 [ -  + ][ -  + ]:     430074 :   Assert(d_setsSolver != nullptr);
                 [ -  - ]
      67 [ +  + ][ +  + ]:     430074 :   switch (s)
         [ +  + ][ +  + ]
         [ +  + ][ +  - ]
      68                 :            :   {
      69                 :      44430 :     case Step::SETS_CHECK_RESET: d_setsSolver->fullEffortReset(); break;
      70                 :      44430 :     case Step::SETS_CHECK_BASIC: d_setsSolver->checkBasic(); break;
      71                 :      36903 :     case Step::SETS_CHECK_CARDINALITY: d_setsSolver->checkCardinality(); break;
      72                 :      39643 :     case Step::SETS_CHECK_RELATIONS: d_setsSolver->checkRelations(); break;
      73                 :      38694 :     case Step::SETS_CHECK_TRANSITIVE_CLOSURE_DOWN:
      74                 :      38694 :       d_setsSolver->checkTransitiveClosureDown();
      75                 :      38694 :       break;
      76                 :      38694 :     case Step::SETS_CHECK_TRANSITIVE_CLOSURE_UP:
      77                 :      38694 :       d_setsSolver->checkTransitiveClosureUp();
      78                 :      38694 :       break;
      79                 :      38611 :     case Step::SETS_CHECK_FILTER: d_setsSolver->checkFilters(); break;
      80                 :      38357 :     case Step::SETS_CHECK_MAP: d_setsSolver->checkMaps(); break;
      81                 :      38329 :     case Step::SETS_CHECK_GROUP: d_setsSolver->checkGroups(); break;
      82                 :      37957 :     case Step::SETS_CHECK_DISEQUALITY:
      83                 :      37957 :       d_setsSolver->checkDisequalities();
      84                 :      37957 :       break;
      85                 :      34026 :     case Step::SETS_CHECK_COMPREHENSION:
      86                 :      34026 :       d_setsSolver->checkReduceComprehensions();
      87                 :      34026 :       break;
      88                 :            : 
      89                 :          0 :     default: Unreachable(); break;
      90                 :            :   }
      91                 :            :   // Sets asserts facts directly to the equality engine, so "addedFact" is
      92                 :            :   // reported via hasSentFact rather than the pending-fact queue.
      93         [ +  - ]:     860146 :   Trace("sets-process") << "Done " << s
      94                 :          0 :                         << ", addedFact = " << d_im->hasSentFact()
      95                 :          0 :                         << ", addedLemma = " << d_im->hasPendingLemma()
      96                 :     430073 :                         << ", conflict = " << d_state->isInConflict()
      97                 :     430073 :                         << std::endl;
      98                 :     430073 : }
      99                 :            : 
     100                 :     140424 : void Strategy::postCheck(Theory::Effort e)
     101                 :            : {
     102                 :            :   // Flush any facts that were buffered before this check so that the strategy
     103                 :            :   // runs on an up-to-date equality engine. Note this is currently a no-op:
     104                 :            :   // sets asserts its internal facts eagerly and never buffers pending facts.
     105                 :     140424 :   d_im->doPendingFacts();
     106                 :     140424 :   StrategyBase::postCheck(e);
     107                 :     140423 : }
     108                 :            : 
     109                 :            : }  // namespace sets
     110                 :            : }  // namespace theory
     111                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14