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: 41 45 91.1 %
Date: 2026-08-24 10:37:28 Functions: 10 11 90.9 %
Branches: 6 6 100.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                 :            :  * The preprocessing pass context for passes.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "preprocessing/preprocessing_pass_context.h"
      14                 :            : 
      15                 :            : #include "expr/node_algorithm.h"
      16                 :            : #include "options/base_options.h"
      17                 :            : #include "prop/prop_engine.h"
      18                 :            : #include "smt/env.h"
      19                 :            : #include "theory/theory_engine.h"
      20                 :            : #include "theory/theory_model.h"
      21                 :            : 
      22                 :            : namespace cvc5::internal {
      23                 :            : namespace preprocessing {
      24                 :            : 
      25                 :      29012 : PreprocessingPassContext::PreprocessingPassContext(
      26                 :            :     Env& env,
      27                 :            :     TheoryEngine* te,
      28                 :            :     prop::PropEngine* pe,
      29                 :      29012 :     theory::booleans::CircuitPropagator* circuitPropagator)
      30                 :            :     : EnvObj(env),
      31                 :      29012 :       d_theoryEngine(te),
      32                 :      29012 :       d_propEngine(pe),
      33                 :      29012 :       d_circuitPropagator(circuitPropagator),
      34                 :      29012 :       d_llm(env),
      35                 :      29012 :       d_symsInAssertions(userContext())
      36                 :            : {
      37                 :      29012 : }
      38                 :            : 
      39                 :            : theory::TrustSubstitutionMap&
      40                 :      59208 : PreprocessingPassContext::getTopLevelSubstitutions() const
      41                 :            : {
      42                 :      59208 :   return d_env.getTopLevelSubstitutions();
      43                 :            : }
      44                 :            : 
      45                 :     978029 : TheoryEngine* PreprocessingPassContext::getTheoryEngine() const
      46                 :            : {
      47                 :     978029 :   return d_theoryEngine;
      48                 :            : }
      49                 :      25380 : prop::PropEngine* PreprocessingPassContext::getPropEngine() const
      50                 :            : {
      51                 :      25380 :   return d_propEngine;
      52                 :            : }
      53                 :            : 
      54                 :     503872 : void PreprocessingPassContext::spendResource(Resource r)
      55                 :            : {
      56                 :     503872 :   d_env.getResourceManager()->spendResource(r);
      57                 :     503872 : }
      58                 :       6767 : void PreprocessingPassContext::recordSymbolsInAssertions(
      59                 :            :     const std::vector<Node>& assertions)
      60                 :            : {
      61                 :       6767 :   std::unordered_set<TNode> visited;
      62                 :       6767 :   std::unordered_set<Node> syms;
      63         [ +  + ]:      39830 :   for (TNode cn : assertions)
      64                 :            :   {
      65                 :      33063 :     expr::getSymbols(cn, syms, visited);
      66                 :      33063 :   }
      67         [ +  + ]:      36993 :   for (const Node& s : syms)
      68                 :            :   {
      69                 :      30226 :     d_symsInAssertions.insert(s);
      70                 :            :   }
      71                 :       6767 : }
      72                 :            : 
      73                 :     155362 : void PreprocessingPassContext::notifyLearnedLiteral(TNode lit)
      74                 :            : {
      75                 :     155362 :   d_llm.notifyLearnedLiteral(lit);
      76                 :     155362 : }
      77                 :            : 
      78                 :         20 : std::vector<Node> PreprocessingPassContext::getLearnedLiterals() const
      79                 :            : {
      80                 :         20 :   return d_llm.getLearnedLiterals();
      81                 :            : }
      82                 :            : 
      83                 :       2298 : void PreprocessingPassContext::addSubstitution(const Node& lhs,
      84                 :            :                                                const Node& rhs,
      85                 :            :                                                ProofGenerator* pg)
      86                 :            : {
      87                 :       2298 :   d_propEngine->notifyTopLevelSubstitution(lhs, rhs);
      88                 :       2298 :   d_env.getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg);
      89                 :       2298 : }
      90                 :            : 
      91                 :          0 : void PreprocessingPassContext::addSubstitution(const Node& lhs,
      92                 :            :                                                const Node& rhs,
      93                 :            :                                                ProofRule id,
      94                 :            :                                                const std::vector<Node>& args)
      95                 :            : {
      96                 :          0 :   d_propEngine->notifyTopLevelSubstitution(lhs, rhs);
      97                 :          0 :   d_env.getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args);
      98                 :          0 : }
      99                 :            : 
     100                 :      26574 : void PreprocessingPassContext::addSubstitutions(
     101                 :            :     theory::TrustSubstitutionMap& tm)
     102                 :            : {
     103                 :      26574 :   std::unordered_map<Node, Node> subs = tm.get().getSubstitutions();
     104         [ +  + ]:      76688 :   for (const std::pair<const Node, Node>& s : subs)
     105                 :            :   {
     106                 :      50114 :     d_propEngine->notifyTopLevelSubstitution(s.first, s.second);
     107                 :            :   }
     108                 :      26574 :   d_env.getTopLevelSubstitutions().addSubstitutions(tm);
     109                 :      26574 : }
     110                 :            : 
     111                 :            : }  // namespace preprocessing
     112                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14