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-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.\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),
31 d_crd(options::sygusRewSynthCheck(), options::sygusRewSynthAccel(), false)
35 void ExpressionMinerManager::initialize(const std::vector
<Node
>& vars
,
42 d_doFilterLogicalStrength
= false;
43 d_sygus_fun
= Node::null();
44 d_use_sygus_type
= false;
47 // initialize the sampler
48 d_sampler
.initialize(tn
, vars
, nsamples
, unique_type_ids
);
51 void ExpressionMinerManager::initializeSygus(QuantifiersEngine
* qe
,
58 d_doFilterLogicalStrength
= false;
60 d_use_sygus_type
= useSygusType
;
62 d_tds
= qe
->getTermDatabaseSygus();
63 // initialize the sampler
64 d_sampler
.initializeSygus(d_tds
, f
, nsamples
, useSygusType
);
67 void ExpressionMinerManager::enableRewriteRuleSynth()
75 std::vector
<Node
> vars
;
76 d_sampler
.getVariables(vars
);
77 // initialize the candidate rewrite database
78 if (!d_sygus_fun
.isNull())
80 Assert(d_qe
!= nullptr);
81 d_crd
.initializeSygus(vars
, d_qe
, d_sygus_fun
, &d_sampler
);
85 d_crd
.initialize(vars
, &d_sampler
);
87 d_crd
.setExtendedRewriter(&d_ext_rew
);
88 d_crd
.setSilent(false);
91 void ExpressionMinerManager::enableQueryGeneration(unsigned deqThresh
)
99 std::vector
<Node
> vars
;
100 d_sampler
.getVariables(vars
);
101 // must also enable rewrite rule synthesis
104 // initialize the candidate rewrite database, in silent mode
105 enableRewriteRuleSynth();
106 d_crd
.setSilent(true);
108 // initialize the query generator
109 d_qg
.initialize(vars
, &d_sampler
);
110 d_qg
.setThreshold(deqThresh
);
113 void ExpressionMinerManager::enableFilterWeakSolutions()
115 d_doFilterLogicalStrength
= true;
116 std::vector
<Node
> vars
;
117 d_sampler
.getVariables(vars
);
118 d_sols
.initialize(vars
, &d_sampler
);
119 d_sols
.setLogicallyStrong(true);
122 void ExpressionMinerManager::enableFilterStrongSolutions()
124 d_doFilterLogicalStrength
= true;
125 std::vector
<Node
> vars
;
126 d_sampler
.getVariables(vars
);
127 d_sols
.initialize(vars
, &d_sampler
);
128 d_sols
.setLogicallyStrong(false);
131 bool ExpressionMinerManager::addTerm(Node sol
,
135 // set the builtin version
137 if (d_use_sygus_type
)
139 solb
= d_tds
->sygusToBuiltin(sol
);
142 // add to the candidate rewrite rule database
146 Node rsol
= d_crd
.addTerm(sol
, options::sygusRewSynthRec(), out
, rew_print
);
150 // a unique term, let's try the query generator
151 if (ret
&& d_doQueryGen
)
153 d_qg
.addTerm(solb
, out
);
156 // filter based on logical strength
157 if (ret
&& d_doFilterLogicalStrength
)
159 ret
= d_sols
.addTerm(solb
, out
);
164 bool ExpressionMinerManager::addTerm(Node sol
, std::ostream
& out
)
166 bool rew_print
= false;
167 return addTerm(sol
, out
, rew_print
);
170 } // namespace quantifiers
171 } // namespace theory