summaryrefslogtreecommitdiff
path: root/src/theory/quantifiers/sygus/synth_engine.h
blob: c623d9c0f1f3e2e719092e75d715f4c92d224147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds, Mathias Preiner, Morgan Deters
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * The quantifiers module for managing all approaches to synthesis,
 * in particular, those described in Reynolds et al CAV 2015.
 */

#include "cvc5_private.h"

#ifndef CVC5__THEORY__QUANTIFIERS__SYNTH_ENGINE_H
#define CVC5__THEORY__QUANTIFIERS__SYNTH_ENGINE_H

#include "context/cdhashmap.h"
#include "theory/quantifiers/quant_module.h"
#include "theory/quantifiers/sygus/sygus_qe_preproc.h"
#include "theory/quantifiers/sygus/sygus_stats.h"
#include "theory/quantifiers/sygus/synth_conjecture.h"

namespace cvc5 {
namespace theory {
namespace quantifiers {

class SynthEngine : public QuantifiersModule
{
  typedef context::CDHashMap<Node, bool> NodeBoolMap;

 public:
  SynthEngine(Env& env,
              QuantifiersState& qs,
              QuantifiersInferenceManager& qim,
              QuantifiersRegistry& qr,
              TermRegistry& tr);
  ~SynthEngine();
  /** presolve
   *
   * Called at the beginning of each call to solve a synthesis problem, which
   * may be e.g. a check-synth or get-abduct call.
   */
  void presolve() override;
  /** needs check, return true if e is last call */
  bool needsCheck(Theory::Effort e) override;
  /** always needs model at effort QEFFORT_MODEL */
  QEffort needsModel(Theory::Effort e) override;
  /* Call during quantifier engine's check */
  void check(Theory::Effort e, QEffort quant_e) override;
  /** check ownership */
  void checkOwnership(Node q) override;
  /* Called for new quantifiers */
  void registerQuantifier(Node q) override;
  /** Identify this module (for debugging, dynamic configuration, etc..) */
  std::string identify() const override { return "SynthEngine"; }
  /** get synth solutions
   *
   * This function adds entries to sol_map that map functions-to-synthesize
   * with their solutions, for all active conjectures (currently just the one
   * assigned to d_conj). This should be called immediately after the solver
   * answers unsat for sygus input.
   *
   * For details on what is added to sol_map, see
   * SynthConjecture::getSynthSolutions.
   */
  bool getSynthSolutions(std::map<Node, std::map<Node, Node> >& sol_map);
  /** preregister assertion (before rewrite)
   *
   * The purpose of this method is to inform the solution reconstruction
   * techniques within the single invocation module that n is an original
   * assertion. This is used as a heuristic to remember terms that are likely
   * to help when trying to reconstruct a solution that fits a given input
   * syntax.
   */
  void preregisterAssertion(Node n);

 private:
  /** the conjecture formula(s) we are waiting to assign */
  std::vector<Node> d_waiting_conj;
  /** The synthesis conjectures that this class is managing. */
  std::vector<std::unique_ptr<SynthConjecture> > d_conjs;
  /**
   * The first conjecture in the above vector. We track this conjecture
   * so that a synthesis conjecture can be preregistered during a call to
   * preregisterAssertion.
   */
  SynthConjecture* d_conj;
  /**
   * The quantifier elimination preprocess module.
   */
  SygusQePreproc d_sqp;
  /** The statistics */
  SygusStatistics d_statistics;
  /** assign quantified formula q as a conjecture
   *
   * This method either assigns q to a synthesis conjecture object in d_conjs,
   * or otherwise reduces q to an equivalent form. This method does the latter
   * if this class determines that it would rather rewrite q to an equivalent
   * form r (in which case this method returns the lemma q <=> r). An example of
   * this is the quantifier elimination step option::sygusQePreproc().
   */
  void assignConjecture(Node q);
  /** check conjecture
   *
   * This method returns true if the conjecture is finished processing solutions
   * for this call to SynthEngine::check().
   */
  bool checkConjecture(SynthConjecture* conj);
}; /* class SynthEngine */

}  // namespace quantifiers
}  // namespace theory
}  // namespace cvc5

#endif
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback