LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/proof/lfsc - lfsc_util.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 33 38 86.8 %
Date: 2026-04-16 10:42:20 Functions: 6 6 100.0 %
Branches: 16 21 76.2 %

           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                 :            :  * Utilities for LFSC proofs.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "proof/lfsc/lfsc_util.h"
      14                 :            : 
      15                 :            : #include "proof/proof_checker.h"
      16                 :            : #include "util/rational.h"
      17                 :            : 
      18                 :            : using namespace cvc5::internal::kind;
      19                 :            : 
      20                 :            : namespace cvc5::internal {
      21                 :            : namespace proof {
      22                 :            : 
      23                 :    5878158 : const char* toString(LfscRule id)
      24                 :            : {
      25 [ +  + ][ +  + ]:    5878158 :   switch (id)
         [ +  + ][ +  + ]
         [ +  + ][ -  - ]
            [ +  + ][ - ]
      26                 :            :   {
      27                 :       2400 :     case LfscRule::DEFINITION: return "refl";
      28                 :     211426 :     case LfscRule::SCOPE: return "scope";
      29                 :        354 :     case LfscRule::NEG_SYMM: return "neg_symm";
      30                 :    3649328 :     case LfscRule::CONG: return "cong";
      31                 :      35336 :     case LfscRule::AND_INTRO1: return "and_intro1";
      32                 :      70684 :     case LfscRule::AND_INTRO2: return "and_intro2";
      33                 :       9236 :     case LfscRule::NOT_AND_REV: return "not_and_rev";
      34                 :      36114 :     case LfscRule::PROCESS_SCOPE: return "process_scope";
      35                 :      27933 :     case LfscRule::ARITH_SUM_UB: return "arith_sum_ub";
      36                 :       6971 :     case LfscRule::INSTANTIATE: return "instantiate";
      37                 :          0 :     case LfscRule::SKOLEMIZE: return "skolemize";
      38                 :          0 :     case LfscRule::BETA_REDUCE: return "beta_reduce";
      39                 :    1019901 :     case LfscRule::LAMBDA: return "\\";
      40                 :     808475 :     case LfscRule::PLET: return "plet";
      41                 :          0 :     default: return "?";
      42                 :            :   }
      43                 :            : }
      44                 :    5878158 : std::ostream& operator<<(std::ostream& out, LfscRule id)
      45                 :            : {
      46                 :    5878158 :   out << toString(id);
      47                 :    5878158 :   return out;
      48                 :            : }
      49                 :            : 
      50                 :   37218174 : bool getLfscRule(Node n, LfscRule& lr)
      51                 :            : {
      52                 :            :   uint32_t id;
      53         [ +  - ]:   37218174 :   if (ProofRuleChecker::getUInt32(n, id))
      54                 :            :   {
      55                 :   37218174 :     lr = static_cast<LfscRule>(id);
      56                 :   37218174 :     return true;
      57                 :            :   }
      58                 :          0 :   return false;
      59                 :            : }
      60                 :            : 
      61                 :   37218174 : LfscRule getLfscRule(Node n)
      62                 :            : {
      63                 :   37218174 :   LfscRule lr = LfscRule::UNKNOWN;
      64                 :   37218174 :   getLfscRule(n, lr);
      65                 :   37218174 :   return lr;
      66                 :            : }
      67                 :            : 
      68                 :    1520049 : Node mkLfscRuleNode(NodeManager* nm, LfscRule r)
      69                 :            : {
      70                 :    3040098 :   return nm->mkConstInt(Rational(static_cast<uint32_t>(r)));
      71                 :            : }
      72                 :            : 
      73                 :   32954953 : bool LfscProofLetifyTraverseCallback::shouldTraverse(const ProofNode* pn)
      74                 :            : {
      75         [ -  + ]:   32954953 :   if (pn->getRule() == ProofRule::SCOPE)
      76                 :            :   {
      77                 :          0 :     return false;
      78                 :            :   }
      79         [ +  + ]:   32954953 :   if (pn->getRule() != ProofRule::LFSC_RULE)
      80                 :            :   {
      81                 :   16619967 :     return true;
      82                 :            :   }
      83                 :            :   // do not traverse under LFSC (lambda) scope
      84                 :   16334986 :   LfscRule lr = getLfscRule(pn->getArguments()[0]);
      85                 :   16334986 :   return lr != LfscRule::LAMBDA;
      86                 :            : }
      87                 :            : 
      88                 :            : }  // namespace proof
      89                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14