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

Line Exec Source
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
24120
  std::string identify() const override { return "SynthEngine"; }
60
  /** print solution for synthesis conjectures */
61
  void printSynthSolution(std::ostream& out);
62
  /** get synth solutions
63
   *
64
   * This function adds entries to sol_map that map functions-to-synthesize
65
   * with their solutions, for all active conjectures (currently just the one
66
   * assigned to d_conj). This should be called immediately after the solver
67
   * answers unsat for sygus input.
68
   *
69
   * For details on what is added to sol_map, see
70
   * SynthConjecture::getSynthSolutions.
71
   */
72
  bool getSynthSolutions(std::map<Node, std::map<Node, Node> >& sol_map);
73
  /** preregister assertion (before rewrite)
74
   *
75
   * The purpose of this method is to inform the solution reconstruction
76
   * techniques within the single invocation module that n is an original
77
   * assertion. This is used as a heuristic to remember terms that are likely
78
   * to help when trying to reconstruct a solution that fits a given input
79
   * syntax.
80
   */
81
  void preregisterAssertion(Node n);
82
83
 private:
84
  /** the conjecture formula(s) we are waiting to assign */
85
  std::vector<Node> d_waiting_conj;
86
  /** The synthesis conjectures that this class is managing. */
87
  std::vector<std::unique_ptr<SynthConjecture> > d_conjs;
88
  /**
89
   * The first conjecture in the above vector. We track this conjecture
90
   * so that a synthesis conjecture can be preregistered during a call to
91
   * preregisterAssertion.
92
   */
93
  SynthConjecture* d_conj;
94
  /**
95
   * The quantifier elimination preprocess module.
96
   */
97
  SygusQePreproc d_sqp;
98
  /** The statistics */
99
  SygusStatistics d_statistics;
100
  /** assign quantified formula q as a conjecture
101
   *
102
   * This method either assigns q to a synthesis conjecture object in d_conjs,
103
   * or otherwise reduces q to an equivalent form. This method does the latter
104
   * if this class determines that it would rather rewrite q to an equivalent
105
   * form r (in which case this method returns the lemma q <=> r). An example of
106
   * this is the quantifier elimination step option::sygusQePreproc().
107
   */
108
  void assignConjecture(Node q);
109
  /** check conjecture
110
   *
111
   * This method returns true if the conjecture is finished processing solutions
112
   * for this call to SynthEngine::check().
113
   */
114
  bool checkConjecture(SynthConjecture* conj);
115
}; /* class SynthEngine */
116
117
}  // namespace quantifiers
118
}  // namespace theory
119
}  // namespace cvc5
120
121
#endif