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

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Abdalrhman Mohamed
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
 * Utility class for Sygus Reconstruct module.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANTIFIERS__RCONS_TYPE_INFO_H
19
#define CVC5__THEORY__QUANTIFIERS__RCONS_TYPE_INFO_H
20
21
#include "theory/quantifiers/candidate_rewrite_database.h"
22
#include "theory/quantifiers/sygus/sygus_enumerator.h"
23
#include "theory/quantifiers/sygus_sampler.h"
24
25
namespace cvc5 {
26
namespace theory {
27
namespace quantifiers {
28
29
class RConsObligation;
30
class CandidateRewriteDatabase;
31
32
/**
33
 * A utility class for Sygus Reconstruct datatype types (grammar non-terminals).
34
 * This class is mainly responsible for enumerating sygus datatype type terms
35
 * and building sets of equivalent builtin terms for the rcons algorithm.
36
 */
37
106
class RConsTypeInfo
38
{
39
 public:
40
  /**
41
   * Initialize a sygus enumerator and a candidate rewrite database for this
42
   * class' sygus datatype type.
43
   *
44
   * @param env Reference to the environment
45
   * @param tds Database for sygus terms
46
   * @param s Statistics managed for the synth engine
47
   * @param stn The sygus datatype type encoding the syntax restrictions
48
   * @param builtinVars A list containing the builtin analog of sygus variable
49
   *                    list for the sygus datatype type
50
   */
51
  void initialize(Env& env,
52
                  TermDbSygus* tds,
53
                  SygusStatistics& s,
54
                  TypeNode stn,
55
                  const std::vector<Node>& builtinVars);
56
57
  /**
58
   * Returns the next enumerated term for the given sygus datatype type.
59
   *
60
   * @return The enumerated sygus term
61
   */
62
  Node nextEnum();
63
64
  /**
65
   * Add a pure term to the candidate rewrite database.
66
   *
67
   * @param n The term to add to the database
68
   * @return A previous term `eq_n` added to this class, such that `n` is
69
   * equivalent to `eq_n`. If no previous term equivalent to `n` exists then the
70
   * result is `n` itself
71
   */
72
  Node addTerm(Node n);
73
74
  /**
75
   * Set the obligation responsible for solving the given builtin term.
76
   *
77
   * @param t The builtin term
78
   * @param ob The corresponding obligation
79
   */
80
  void setBuiltinToOb(Node t, RConsObligation* ob);
81
82
  /**
83
   * Return the obligation responsible for solving the given builtin term.
84
   *
85
   * @param t The builtin term
86
   * @return The corresponding obligation
87
   */
88
  RConsObligation* builtinToOb(Node t);
89
90
 private:
91
  /** Sygus terms enumerator for this class' Sygus datatype type */
92
  std::unique_ptr<SygusEnumerator> d_enumerator;
93
  /** Candidate rewrite database for this class' sygus datatype type */
94
  std::unique_ptr<CandidateRewriteDatabase> d_crd;
95
  /** Sygus sampler needed for initializing the candidate rewrite database */
96
  SygusSampler d_sygusSampler;
97
  /** A map from a builtin term to its obligation.
98
   *
99
   * Each sygus datatype type has its own version of this map because it is
100
   * possible to have multiple obligations to reconstruct the same builtin term
101
   * from different sygus datatype types.
102
   */
103
  std::unordered_map<Node, RConsObligation*> d_ob;
104
};
105
106
}  // namespace quantifiers
107
}  // namespace theory
108
}  // namespace cvc5
109
110
#endif  // CVC5__THEORY__QUANTIFIERS__RCONS_TYPE_INFO_H