GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/sygus/synth_engine.h Lines: 1 1 100.0 %
Date: 2021-09-16 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(Env& env,
38
              QuantifiersState& qs,
39
              QuantifiersInferenceManager& qim,
40
              QuantifiersRegistry& qr,
41
              TermRegistry& tr);
42
  ~SynthEngine();
43
  /** presolve
44
   *
45
   * Called at the beginning of each call to solve a synthesis problem, which
46
   * may be e.g. a check-synth or get-abduct call.
47
   */
48
  void presolve() override;
49
  /** needs check, return true if e is last call */
50
  bool needsCheck(Theory::Effort e) override;
51
  /** always needs model at effort QEFFORT_MODEL */
52
  QEffort needsModel(Theory::Effort e) override;
53
  /* Call during quantifier engine's check */
54
  void check(Theory::Effort e, QEffort quant_e) override;
55
  /** check ownership */
56
  void checkOwnership(Node q) override;
57
  /* Called for new quantifiers */
58
  void registerQuantifier(Node q) override;
59
  /** Identify this module (for debugging, dynamic configuration, etc..) */
60
24026
  std::string identify() const override { return "SynthEngine"; }
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
  /** the conjecture formula(s) we are waiting to assign */
84
  std::vector<Node> d_waiting_conj;
85
  /** The synthesis conjectures that this class is managing. */
86
  std::vector<std::unique_ptr<SynthConjecture> > d_conjs;
87
  /**
88
   * The first conjecture in the above vector. We track this conjecture
89
   * so that a synthesis conjecture can be preregistered during a call to
90
   * preregisterAssertion.
91
   */
92
  SynthConjecture* d_conj;
93
  /**
94
   * The quantifier elimination preprocess module.
95
   */
96
  SygusQePreproc d_sqp;
97
  /** The statistics */
98
  SygusStatistics d_statistics;
99
  /** assign quantified formula q as a conjecture
100
   *
101
   * This method either assigns q to a synthesis conjecture object in d_conjs,
102
   * or otherwise reduces q to an equivalent form. This method does the latter
103
   * if this class determines that it would rather rewrite q to an equivalent
104
   * form r (in which case this method returns the lemma q <=> r). An example of
105
   * this is the quantifier elimination step option::sygusQePreproc().
106
   */
107
  void assignConjecture(Node q);
108
  /** check conjecture
109
   *
110
   * This method returns true if the conjecture is finished processing solutions
111
   * for this call to SynthEngine::check().
112
   */
113
  bool checkConjecture(SynthConjecture* conj);
114
}; /* class SynthEngine */
115
116
}  // namespace quantifiers
117
}  // namespace theory
118
}  // namespace cvc5
119
120
#endif