GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/sygus/synth_engine.h Lines: 1 1 100.0 %
Date: 2021-03-22 Branches: 1 2 50.0 %

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