1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Mathias Preiner, Morgan Deters |
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 |
|
* The quantifiers module for managing all approaches to synthesis, |
14 |
|
* in particular, those described in Reynolds et al CAV 2015. |
15 |
|
*/ |
16 |
|
|
17 |
|
#include "cvc5_private.h" |
18 |
|
|
19 |
|
#ifndef CVC5__THEORY__QUANTIFIERS__SYNTH_ENGINE_H |
20 |
|
#define CVC5__THEORY__QUANTIFIERS__SYNTH_ENGINE_H |
21 |
|
|
22 |
|
#include "context/cdhashmap.h" |
23 |
|
#include "theory/quantifiers/quant_module.h" |
24 |
|
#include "theory/quantifiers/sygus/sygus_qe_preproc.h" |
25 |
|
#include "theory/quantifiers/sygus/sygus_stats.h" |
26 |
|
#include "theory/quantifiers/sygus/synth_conjecture.h" |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace theory { |
30 |
|
namespace quantifiers { |
31 |
|
|
32 |
|
class SynthEngine : public QuantifiersModule |
33 |
|
{ |
34 |
|
typedef context::CDHashMap<Node, bool> NodeBoolMap; |
35 |
|
|
36 |
|
public: |
37 |
|
SynthEngine(QuantifiersState& qs, |
38 |
|
QuantifiersInferenceManager& qim, |
39 |
|
QuantifiersRegistry& qr, |
40 |
|
TermRegistry& tr); |
41 |
|
~SynthEngine(); |
42 |
|
/** presolve |
43 |
|
* |
44 |
|
* Called at the beginning of each call to solve a synthesis problem, which |
45 |
|
* may be e.g. a check-synth or get-abduct call. |
46 |
|
*/ |
47 |
|
void presolve() override; |
48 |
|
/** needs check, return true if e is last call */ |
49 |
|
bool needsCheck(Theory::Effort e) override; |
50 |
|
/** always needs model at effort QEFFORT_MODEL */ |
51 |
|
QEffort needsModel(Theory::Effort e) override; |
52 |
|
/* Call during quantifier engine's check */ |
53 |
|
void check(Theory::Effort e, QEffort quant_e) override; |
54 |
|
/** check ownership */ |
55 |
|
void checkOwnership(Node q) override; |
56 |
|
/* Called for new quantifiers */ |
57 |
|
void registerQuantifier(Node q) override; |
58 |
|
/** Identify this module (for debugging, dynamic configuration, etc..) */ |
59 |
24015 |
std::string identify() const override { return "SynthEngine"; } |
60 |
|
/** get synth solutions |
61 |
|
* |
62 |
|
* This function adds entries to sol_map that map functions-to-synthesize |
63 |
|
* with their solutions, for all active conjectures (currently just the one |
64 |
|
* assigned to d_conj). This should be called immediately after the solver |
65 |
|
* answers unsat for sygus input. |
66 |
|
* |
67 |
|
* For details on what is added to sol_map, see |
68 |
|
* SynthConjecture::getSynthSolutions. |
69 |
|
*/ |
70 |
|
bool getSynthSolutions(std::map<Node, std::map<Node, Node> >& sol_map); |
71 |
|
/** preregister assertion (before rewrite) |
72 |
|
* |
73 |
|
* The purpose of this method is to inform the solution reconstruction |
74 |
|
* techniques within the single invocation module that n is an original |
75 |
|
* assertion. This is used as a heuristic to remember terms that are likely |
76 |
|
* to help when trying to reconstruct a solution that fits a given input |
77 |
|
* syntax. |
78 |
|
*/ |
79 |
|
void preregisterAssertion(Node n); |
80 |
|
|
81 |
|
private: |
82 |
|
/** the conjecture formula(s) we are waiting to assign */ |
83 |
|
std::vector<Node> d_waiting_conj; |
84 |
|
/** The synthesis conjectures that this class is managing. */ |
85 |
|
std::vector<std::unique_ptr<SynthConjecture> > d_conjs; |
86 |
|
/** |
87 |
|
* The first conjecture in the above vector. We track this conjecture |
88 |
|
* so that a synthesis conjecture can be preregistered during a call to |
89 |
|
* preregisterAssertion. |
90 |
|
*/ |
91 |
|
SynthConjecture* d_conj; |
92 |
|
/** |
93 |
|
* The quantifier elimination preprocess module. |
94 |
|
*/ |
95 |
|
SygusQePreproc d_sqp; |
96 |
|
/** The statistics */ |
97 |
|
SygusStatistics d_statistics; |
98 |
|
/** assign quantified formula q as a conjecture |
99 |
|
* |
100 |
|
* This method either assigns q to a synthesis conjecture object in d_conjs, |
101 |
|
* or otherwise reduces q to an equivalent form. This method does the latter |
102 |
|
* if this class determines that it would rather rewrite q to an equivalent |
103 |
|
* form r (in which case this method returns the lemma q <=> r). An example of |
104 |
|
* this is the quantifier elimination step option::sygusQePreproc(). |
105 |
|
*/ |
106 |
|
void assignConjecture(Node q); |
107 |
|
/** check conjecture |
108 |
|
* |
109 |
|
* This method returns true if the conjecture is finished processing solutions |
110 |
|
* for this call to SynthEngine::check(). |
111 |
|
*/ |
112 |
|
bool checkConjecture(SynthConjecture* conj); |
113 |
|
}; /* class SynthEngine */ |
114 |
|
|
115 |
|
} // namespace quantifiers |
116 |
|
} // namespace theory |
117 |
|
} // namespace cvc5 |
118 |
|
|
119 |
|
#endif |