LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory/quantifiers - expr_miner.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 35 35 100.0 %
Date: 2026-05-03 10:46:50 Functions: 5 5 100.0 %
Branches: 10 14 71.4 %

           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 expr_miner.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "theory/quantifiers/expr_miner.h"
      14                 :            : 
      15                 :            : #include <sstream>
      16                 :            : 
      17                 :            : #include "expr/skolem_manager.h"
      18                 :            : #include "options/quantifiers_options.h"
      19                 :            : #include "theory/quantifiers/term_util.h"
      20                 :            : #include "theory/rewriter.h"
      21                 :            : 
      22                 :            : using namespace std;
      23                 :            : using namespace cvc5::internal::kind;
      24                 :            : 
      25                 :            : namespace cvc5::internal {
      26                 :            : namespace theory {
      27                 :            : namespace quantifiers {
      28                 :            : 
      29                 :        619 : void ExprMiner::initialize(const std::vector<Node>& vars, SygusSampler* ss)
      30                 :            : {
      31                 :        619 :   d_sampler = ss;
      32                 :        619 :   d_vars.insert(d_vars.end(), vars.begin(), vars.end());
      33                 :        619 : }
      34                 :            : 
      35                 :       2657 : Node ExprMiner::convertToSkolem(Node n)
      36                 :            : {
      37         [ +  + ]:       2657 :   if (d_skolems.empty())
      38                 :            :   {
      39         [ +  + ]:        504 :     for (const Node& v : d_vars)
      40                 :            :     {
      41                 :        349 :       std::stringstream ss;
      42                 :        349 :       ss << "k_" << v;
      43                 :        698 :       Node sk = NodeManager::mkDummySkolem(ss.str(), v.getType());
      44                 :        349 :       d_skolems.push_back(sk);
      45                 :        349 :       d_fv_to_skolem[v] = sk;
      46                 :        349 :     }
      47                 :            :   }
      48                 :            :   return n.substitute(
      49                 :       2657 :       d_vars.begin(), d_vars.end(), d_skolems.begin(), d_skolems.end());
      50                 :            : }
      51                 :            : 
      52                 :       2191 : void ExprMiner::initializeChecker(std::unique_ptr<SolverEngine>& checker,
      53                 :            :                                   Node query,
      54                 :            :                                   const SubsolverSetupInfo& info)
      55                 :            : {
      56 [ -  + ][ -  + ]:       2191 :   Assert(!query.isNull());
                 [ -  - ]
      57                 :       2191 :   initializeSubsolver(
      58                 :            :       nodeManager(),
      59                 :            :       checker,
      60                 :            :       info,
      61                 :       2191 :       options().quantifiers.sygusExprMinerCheckTimeoutWasSetByUser,
      62                 :       2191 :       options().quantifiers.sygusExprMinerCheckTimeout);
      63                 :            :   // Convert bound variables to skolems. This ensures the satisfiability
      64                 :            :   // check is ground.
      65                 :       2191 :   Node squery = convertToSkolem(query);
      66                 :       2191 :   checker->assertFormula(squery);
      67                 :       2191 : }
      68                 :            : 
      69                 :       1482 : Result ExprMiner::doCheck(Node query, const SubsolverSetupInfo& info)
      70                 :            : {
      71                 :       1482 :   Node queryr = rewrite(query);
      72         [ +  + ]:       1482 :   if (queryr.isConst())
      73                 :            :   {
      74         [ +  + ]:          4 :     if (!queryr.getConst<bool>())
      75                 :            :     {
      76                 :          2 :       return Result(Result::UNSAT);
      77                 :            :     }
      78                 :            :     else
      79                 :            :     {
      80                 :          2 :       return Result(Result::SAT);
      81                 :            :     }
      82                 :            :   }
      83                 :       1478 :   std::unique_ptr<SolverEngine> smte;
      84                 :       1478 :   initializeChecker(smte, query, info);
      85                 :       1478 :   return smte->checkSat();
      86                 :       1482 : }
      87                 :            : 
      88                 :         52 : bool ExprMinerId::addTerm(Node n, std::vector<Node>& found)
      89                 :            : {
      90                 :         52 :   found.push_back(n);
      91                 :         52 :   return true;
      92                 :            : }
      93                 :            : 
      94                 :            : }  // namespace quantifiers
      95                 :            : }  // namespace theory
      96                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14