LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/preprocessing - preprocessing_pass_context.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 36 40 90.0 %
Date: 2025-02-20 12:45:24 Functions: 10 11 90.9 %
Branches: 6 6 100.0 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Andrew Reynolds, Aina Niemetz, Mathias Preiner
       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 preprocessing pass context for passes.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "preprocessing/preprocessing_pass_context.h"
      17                 :            : 
      18                 :            : #include "expr/node_algorithm.h"
      19                 :            : #include "options/base_options.h"
      20                 :            : #include "prop/prop_engine.h"
      21                 :            : #include "smt/env.h"
      22                 :            : #include "theory/theory_engine.h"
      23                 :            : #include "theory/theory_model.h"
      24                 :            : 
      25                 :            : namespace cvc5::internal {
      26                 :            : namespace preprocessing {
      27                 :            : 
      28                 :      51628 : PreprocessingPassContext::PreprocessingPassContext(
      29                 :            :     Env& env,
      30                 :            :     TheoryEngine* te,
      31                 :            :     prop::PropEngine* pe,
      32                 :      51628 :     theory::booleans::CircuitPropagator* circuitPropagator)
      33                 :            :     : EnvObj(env),
      34                 :            :       d_theoryEngine(te),
      35                 :            :       d_propEngine(pe),
      36                 :            :       d_circuitPropagator(circuitPropagator),
      37                 :            :       d_llm(env),
      38                 :      51628 :       d_symsInAssertions(userContext())
      39                 :            : {
      40                 :      51628 : }
      41                 :            : 
      42                 :            : theory::TrustSubstitutionMap&
      43                 :      84205 : PreprocessingPassContext::getTopLevelSubstitutions() const
      44                 :            : {
      45                 :      84205 :   return d_env.getTopLevelSubstitutions();
      46                 :            : }
      47                 :            : 
      48                 :    1326300 : TheoryEngine* PreprocessingPassContext::getTheoryEngine() const
      49                 :            : {
      50                 :    1326300 :   return d_theoryEngine;
      51                 :            : }
      52                 :      37118 : prop::PropEngine* PreprocessingPassContext::getPropEngine() const
      53                 :            : {
      54                 :      37118 :   return d_propEngine;
      55                 :            : }
      56                 :            : 
      57                 :     605843 : void PreprocessingPassContext::spendResource(Resource r)
      58                 :            : {
      59                 :     605843 :   d_env.getResourceManager()->spendResource(r);
      60                 :     605843 : }
      61                 :      19437 : void PreprocessingPassContext::recordSymbolsInAssertions(
      62                 :            :     const std::vector<Node>& assertions)
      63                 :            : {
      64                 :      38874 :   std::unordered_set<TNode> visited;
      65                 :      38874 :   std::unordered_set<Node> syms;
      66         [ +  + ]:      91596 :   for (TNode cn : assertions)
      67                 :            :   {
      68                 :      72159 :     expr::getSymbols(cn, syms, visited);
      69                 :            :   }
      70         [ +  + ]:      68934 :   for (const Node& s : syms)
      71                 :            :   {
      72                 :      49497 :     d_symsInAssertions.insert(s);
      73                 :            :   }
      74                 :      19437 : }
      75                 :            : 
      76                 :     241847 : void PreprocessingPassContext::notifyLearnedLiteral(TNode lit)
      77                 :            : {
      78                 :     241847 :   d_llm.notifyLearnedLiteral(lit);
      79                 :     241847 : }
      80                 :            : 
      81                 :         16 : std::vector<Node> PreprocessingPassContext::getLearnedLiterals() const
      82                 :            : {
      83                 :         16 :   return d_llm.getLearnedLiterals();
      84                 :            : }
      85                 :            : 
      86                 :       1326 : void PreprocessingPassContext::addSubstitution(const Node& lhs,
      87                 :            :                                                const Node& rhs,
      88                 :            :                                                ProofGenerator* pg)
      89                 :            : {
      90                 :       1326 :   d_propEngine->notifyTopLevelSubstitution(lhs, rhs);
      91                 :       1326 :   d_env.getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg);
      92                 :       1326 : }
      93                 :            : 
      94                 :          0 : void PreprocessingPassContext::addSubstitution(const Node& lhs,
      95                 :            :                                                const Node& rhs,
      96                 :            :                                                ProofRule id,
      97                 :            :                                                const std::vector<Node>& args)
      98                 :            : {
      99                 :          0 :   d_propEngine->notifyTopLevelSubstitution(lhs, rhs);
     100                 :          0 :   d_env.getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args);
     101                 :          0 : }
     102                 :            : 
     103                 :      38372 : void PreprocessingPassContext::addSubstitutions(
     104                 :            :     theory::TrustSubstitutionMap& tm)
     105                 :            : {
     106                 :      76744 :   std::unordered_map<Node, Node> subs = tm.get().getSubstitutions();
     107         [ +  + ]:      95368 :   for (const std::pair<const Node, Node>& s : subs)
     108                 :            :   {
     109                 :      56996 :     d_propEngine->notifyTopLevelSubstitution(s.first, s.second);
     110                 :            :   }
     111                 :      38372 :   d_env.getTopLevelSubstitutions().addSubstitutions(tm);
     112                 :      38372 : }
     113                 :            : 
     114                 :            : }  // namespace preprocessing
     115                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14