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