GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/expr_miner.cpp Lines: 29 33 87.9 %
Date: 2021-08-17 Branches: 36 96 37.5 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Andres Noetzli, Aina Niemetz
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 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
 * Implementation of expr_miner.
14
 */
15
16
#include "theory/quantifiers/expr_miner.h"
17
18
#include "expr/skolem_manager.h"
19
#include "options/quantifiers_options.h"
20
#include "smt/smt_engine.h"
21
#include "smt/smt_engine_scope.h"
22
#include "theory/quantifiers/term_util.h"
23
#include "theory/rewriter.h"
24
#include "theory/smt_engine_subsolver.h"
25
26
using namespace std;
27
using namespace cvc5::kind;
28
29
namespace cvc5 {
30
namespace theory {
31
namespace quantifiers {
32
33
62
void ExprMiner::initialize(const std::vector<Node>& vars, SygusSampler* ss)
34
{
35
62
  d_sampler = ss;
36
62
  d_vars.insert(d_vars.end(), vars.begin(), vars.end());
37
62
}
38
39
255
Node ExprMiner::convertToSkolem(Node n)
40
{
41
255
  if (d_skolems.empty())
42
  {
43
33
    NodeManager* nm = NodeManager::currentNM();
44
33
    SkolemManager* sm = nm->getSkolemManager();
45
107
    for (const Node& v : d_vars)
46
    {
47
148
      Node sk = sm->mkDummySkolem("rrck", v.getType());
48
74
      d_skolems.push_back(sk);
49
74
      d_fv_to_skolem[v] = sk;
50
    }
51
  }
52
  return n.substitute(
53
255
      d_vars.begin(), d_vars.end(), d_skolems.begin(), d_skolems.end());
54
}
55
56
255
void ExprMiner::initializeChecker(std::unique_ptr<SmtEngine>& checker,
57
                                  Node query)
58
{
59
255
  Assert (!query.isNull());
60
255
  if (Options::current().quantifiers.sygusExprMinerCheckTimeoutWasSetByUser)
61
  {
62
    initializeSubsolver(
63
        checker, nullptr, true, options::sygusExprMinerCheckTimeout());
64
  }
65
  else
66
  {
67
255
    initializeSubsolver(checker);
68
  }
69
  // also set the options
70
255
  checker->setOption("sygus-rr-synth-input", "false");
71
255
  checker->setOption("input-language", "smt2");
72
  // Convert bound variables to skolems. This ensures the satisfiability
73
  // check is ground.
74
510
  Node squery = convertToSkolem(query);
75
255
  checker->assertFormula(squery);
76
255
}
77
78
54
Result ExprMiner::doCheck(Node query)
79
{
80
108
  Node queryr = Rewriter::rewrite(query);
81
54
  if (queryr.isConst())
82
  {
83
    if (!queryr.getConst<bool>())
84
    {
85
      return Result(Result::UNSAT);
86
    }
87
    else
88
    {
89
      return Result(Result::SAT);
90
    }
91
  }
92
108
  std::unique_ptr<SmtEngine> smte;
93
54
  initializeChecker(smte, query);
94
54
  return smte->checkSat();
95
}
96
97
}  // namespace quantifiers
98
}  // namespace theory
99
29337
}  // namespace cvc5