1 /********************* */
2 /*! \file expr_miner_manager.cpp
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 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.\endverbatim
12 ** \brief Implementation of expression miner manager.
15 #include "theory/quantifiers/expr_miner_manager.h"
16 #include "theory/quantifiers_engine.h"
18 #include "options/quantifiers_options.h"
22 namespace quantifiers
{
24 ExpressionMinerManager::ExpressionMinerManager()
25 : d_doRewSynth(false),
27 d_doFilterLogicalStrength(false),
28 d_use_sygus_type(false),
34 void ExpressionMinerManager::initialize(const std::vector
<Node
>& vars
,
41 d_doFilterLogicalStrength
= false;
42 d_sygus_fun
= Node::null();
43 d_use_sygus_type
= false;
46 // initialize the sampler
47 d_sampler
.initialize(tn
, vars
, nsamples
, unique_type_ids
);
50 void ExpressionMinerManager::initializeSygus(QuantifiersEngine
* qe
,
57 d_doFilterLogicalStrength
= false;
59 d_use_sygus_type
= useSygusType
;
61 d_tds
= qe
->getTermDatabaseSygus();
62 // initialize the sampler
63 d_sampler
.initializeSygus(d_tds
, f
, nsamples
, useSygusType
);
66 void ExpressionMinerManager::enableRewriteRuleSynth()
74 std::vector
<Node
> vars
;
75 d_sampler
.getVariables(vars
);
76 // initialize the candidate rewrite database
77 if (!d_sygus_fun
.isNull())
79 Assert(d_qe
!= nullptr);
80 d_crd
.initializeSygus(vars
, d_qe
, d_sygus_fun
, &d_sampler
);
84 d_crd
.initialize(vars
, &d_sampler
);
86 d_crd
.setExtendedRewriter(&d_ext_rew
);
87 d_crd
.setSilent(false);
90 void ExpressionMinerManager::enableQueryGeneration(unsigned deqThresh
)
98 std::vector
<Node
> vars
;
99 d_sampler
.getVariables(vars
);
100 // must also enable rewrite rule synthesis
103 // initialize the candidate rewrite database, in silent mode
104 enableRewriteRuleSynth();
105 d_crd
.setSilent(true);
107 // initialize the query generator
108 d_qg
.initialize(vars
, &d_sampler
);
109 d_qg
.setThreshold(deqThresh
);
112 void ExpressionMinerManager::enableFilterWeakSolutions()
114 d_doFilterLogicalStrength
= true;
115 std::vector
<Node
> vars
;
116 d_sampler
.getVariables(vars
);
117 d_sols
.initialize(vars
, &d_sampler
);
118 d_sols
.setLogicallyStrong(true);
121 void ExpressionMinerManager::enableFilterStrongSolutions()
123 d_doFilterLogicalStrength
= true;
124 std::vector
<Node
> vars
;
125 d_sampler
.getVariables(vars
);
126 d_sols
.initialize(vars
, &d_sampler
);
127 d_sols
.setLogicallyStrong(false);
130 bool ExpressionMinerManager::addTerm(Node sol
,
134 // set the builtin version
136 if (d_use_sygus_type
)
138 solb
= d_tds
->sygusToBuiltin(sol
);
141 // add to the candidate rewrite rule database
145 ret
= d_crd
.addTerm(sol
, options::sygusRewSynthRec(), out
, rew_print
);
148 // a unique term, let's try the query generator
149 if (ret
&& d_doQueryGen
)
151 d_qg
.addTerm(solb
, out
);
154 // filter based on logical strength
155 if (ret
&& d_doFilterLogicalStrength
)
157 ret
= d_sols
.addTerm(solb
, out
);
162 bool ExpressionMinerManager::addTerm(Node sol
, std::ostream
& out
)
164 bool rew_print
= false;
165 return addTerm(sol
, out
, rew_print
);
168 } // namespace quantifiers
169 } // namespace theory