GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/expr_miner_manager.h Lines: 1 1 100.0 %
Date: 2021-11-07 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Mathias Preiner
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
 * Expression miner manager, which manages individual expression miners.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H
19
#define CVC5__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H
20
21
#include "expr/node.h"
22
#include "smt/env_obj.h"
23
#include "theory/quantifiers/candidate_rewrite_database.h"
24
#include "theory/quantifiers/query_generator.h"
25
#include "theory/quantifiers/query_generator_unsat.h"
26
#include "theory/quantifiers/solution_filter.h"
27
#include "theory/quantifiers/sygus_sampler.h"
28
29
namespace cvc5 {
30
namespace theory {
31
namespace quantifiers {
32
33
/** ExpressionMinerManager
34
 *
35
 * This class manages a set of expression miners. It provides a common place
36
 * to register expressions so that multiple mining algorithms can be run in
37
 * coordination, possibly sharing information and utilities like a common
38
 * sampling object.
39
 */
40
class ExpressionMinerManager : protected EnvObj
41
{
42
 public:
43
  ExpressionMinerManager(Env& env);
44
28
  ~ExpressionMinerManager() {}
45
  /**  Initialize this class
46
   *
47
   * Initializes this class, informing it that the free variables of terms
48
   * added to this class via addTerm will have free variables that are a subset
49
   * of vars, and have type tn. All expression miners in this class with be
50
   * initialized with this variable list. The arguments nsamples and
51
   * unique_type_ids are used for initializing the sampler class of this manager
52
   * (see SygusSampler::initialize for details).
53
   */
54
  void initialize(const std::vector<Node>& vars,
55
                  TypeNode tn,
56
                  unsigned nsamples,
57
                  bool unique_type_ids = false);
58
  /** Initialize this class, sygus version
59
   *
60
   * Initializes this class, informing it that the terms added to this class
61
   * via calls to addTerm will be generated by the grammar of f. The method
62
   * takes a pointer to the quantifiers engine qe. If the argument useSygusType
63
   * is true, the terms added to this class are the sygus datatype terms.
64
   * If useSygusType is false, the terms are the builtin equivalent of these
65
   * terms. The argument nsamples is used to initialize the sampler.
66
   */
67
  void initializeSygus(TermDbSygus* tds,
68
                       Node f,
69
                       unsigned nsamples,
70
                       bool useSygusType);
71
  /** initialize options */
72
  void initializeMinersForOptions();
73
  /** add term
74
   *
75
   * Expression miners may print information on the output stream out, for
76
   * instance, candidate-rewrites. The method returns true if the term sol is
77
   * distinct (up to T-equivalence) with all previous terms added to this class,
78
   * which is computed based on the miners that this manager enables.
79
   */
80
  bool addTerm(Node sol, std::ostream& out);
81
  /**
82
   * Same as above, but the argument rew_print is set to true if a rewrite rule
83
   * was printed on the output stream out.
84
   */
85
  bool addTerm(Node sol, std::ostream& out, bool& rew_print);
86
87
 private:
88
  /** enable rewrite rule synthesis (--sygus-rr-synth) */
89
  void enableRewriteRuleSynth();
90
  /** enable query generation (--sygus-query-gen) */
91
  void enableQueryGeneration(unsigned deqThresh);
92
  /** filter strong solutions (--sygus-filter-sol=strong) */
93
  void enableFilterStrongSolutions();
94
  /** filter weak solutions (--sygus-filter-sol=weak) */
95
  void enableFilterWeakSolutions();
96
  /** whether we are doing rewrite synthesis */
97
  bool d_doRewSynth;
98
  /** whether we are doing query generation */
99
  bool d_doQueryGen;
100
  /** whether we are filtering solutions based on logical strength */
101
  bool d_doFilterLogicalStrength;
102
  /** the sygus function passed to initializeSygus, if any */
103
  Node d_sygus_fun;
104
  /** whether we are using sygus types */
105
  bool d_use_sygus_type;
106
  /** the sygus term database of the quantifiers engine */
107
  TermDbSygus* d_tds;
108
  /** candidate rewrite database */
109
  CandidateRewriteDatabase d_crd;
110
  /** query generator */
111
  std::unique_ptr<QueryGenerator> d_qg;
112
  /** query generator */
113
  std::unique_ptr<QueryGeneratorUnsat> d_qgu;
114
  /** solution filter based on logical strength */
115
  SolutionFilterStrength d_sols;
116
  /** sygus sampler object */
117
  SygusSampler d_sampler;
118
};
119
120
}  // namespace quantifiers
121
}  // namespace theory
122
}  // namespace cvc5
123
124
#endif /* CVC5__THEORY__QUANTIFIERS__EXPR_MINER_MANAGER_H */