1 /******************************************************************************
2 * Top contributors (to current version):
3 * Andrew Reynolds, Andres Noetzli, Aina Niemetz
5 * This file is part of the cvc5 project.
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 * ****************************************************************************
13 * Implementation of expr_miner.
16 #include "theory/quantifiers/expr_miner.h"
18 #include "expr/skolem_manager.h"
19 #include "options/quantifiers_options.h"
20 #include "theory/quantifiers/term_util.h"
21 #include "theory/rewriter.h"
24 using namespace cvc5::kind
;
28 namespace quantifiers
{
30 void ExprMiner::initialize(const std::vector
<Node
>& vars
, SygusSampler
* ss
)
33 d_vars
.insert(d_vars
.end(), vars
.begin(), vars
.end());
36 Node
ExprMiner::convertToSkolem(Node n
)
38 if (d_skolems
.empty())
40 NodeManager
* nm
= NodeManager::currentNM();
41 SkolemManager
* sm
= nm
->getSkolemManager();
42 for (const Node
& v
: d_vars
)
44 Node sk
= sm
->mkDummySkolem("rrck", v
.getType());
45 d_skolems
.push_back(sk
);
46 d_fv_to_skolem
[v
] = sk
;
50 d_vars
.begin(), d_vars
.end(), d_skolems
.begin(), d_skolems
.end());
53 void ExprMiner::initializeChecker(std::unique_ptr
<SolverEngine
>& checker
,
56 initializeChecker(checker
, query
, options(), logicInfo());
59 void ExprMiner::initializeChecker(std::unique_ptr
<SolverEngine
>& checker
,
62 const LogicInfo
& logicInfo
)
64 Assert (!query
.isNull());
65 if (Options::current().quantifiers
.sygusExprMinerCheckTimeoutWasSetByUser
)
68 checker
, opts
, logicInfo
, true, options::sygusExprMinerCheckTimeout());
72 initializeSubsolver(checker
, opts
, logicInfo
);
74 // also set the options
75 checker
->setOption("sygus-rr-synth-input", "false");
76 checker
->setOption("input-language", "smt2");
77 // Convert bound variables to skolems. This ensures the satisfiability
79 Node squery
= convertToSkolem(query
);
80 checker
->assertFormula(squery
);
83 Result
ExprMiner::doCheck(Node query
)
85 Node queryr
= Rewriter::rewrite(query
);
88 if (!queryr
.getConst
<bool>())
90 return Result(Result::UNSAT
);
94 return Result(Result::SAT
);
97 std::unique_ptr
<SolverEngine
> smte
;
98 initializeChecker(smte
, query
);
99 return smte
->checkSat();
102 } // namespace quantifiers
103 } // namespace theory