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

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
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
 * Term registry class.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__QUANTIFIERS__TERM_REGISTRY_H
19
#define CVC5__THEORY__QUANTIFIERS__TERM_REGISTRY_H
20
21
#include <map>
22
#include <unordered_set>
23
24
#include "context/cdhashset.h"
25
#include "theory/quantifiers/sygus/term_database_sygus.h"
26
#include "theory/quantifiers/term_database.h"
27
#include "theory/quantifiers/term_enumeration.h"
28
#include "theory/quantifiers/term_pools.h"
29
30
namespace cvc5 {
31
namespace theory {
32
namespace quantifiers {
33
34
class FirstOrderModel;
35
36
/**
37
 * Term Registry, which manages notifying modules within quantifiers about
38
 * (ground) terms that exist in the current context.
39
 */
40
9460
class TermRegistry
41
{
42
  using NodeSet = context::CDHashSet<Node>;
43
44
 public:
45
  TermRegistry(QuantifiersState& qs,
46
               QuantifiersRegistry& qr);
47
  /** Finish init, which sets the inference manager on modules of this class */
48
  void finishInit(FirstOrderModel* fm, QuantifiersInferenceManager* qim);
49
  /** Presolve */
50
  void presolve();
51
52
  /**
53
   * Add term n, which notifies the term database that the ground term n
54
   * exists in the current context.
55
   *
56
   * @param n the term to add
57
   * @param withinQuant whether n occurs within a quantified formula body
58
   */
59
  void addTerm(Node n, bool withinQuant = false);
60
61
  /** get term for type
62
   *
63
   * This returns an arbitrary term for type tn.
64
   * This term is chosen heuristically to be the best
65
   * term for instantiation. Currently, this
66
   * heuristic enumerates the first term of the
67
   * type if the type is closed enumerable, otherwise
68
   * an existing ground term from the term database if
69
   * one exists, or otherwise a fresh variable.
70
   */
71
  Node getTermForType(TypeNode tn);
72
  /**
73
   * Declare pool p with initial value initValue.
74
   */
75
  void declarePool(Node p, const std::vector<Node>& initValue);
76
  /**
77
   * Process instantiation
78
   */
79
  void processInstantiation(Node q, const std::vector<Node>& terms);
80
  void processSkolemization(Node q, const std::vector<Node>& skolems);
81
82
  /** get term database */
83
  TermDb* getTermDatabase() const;
84
  /** get term database sygus */
85
  TermDbSygus* getTermDatabaseSygus() const;
86
  /** get term enumeration utility */
87
  TermEnumeration* getTermEnumeration() const;
88
  /** get the term pools utility */
89
  TermPools* getTermPools() const;
90
  /** get the model utility */
91
  FirstOrderModel* getModel() const;
92
93
 private:
94
  /** has presolve been called */
95
  context::CDO<bool> d_presolve;
96
  /** Whether we are using the fmc model */
97
  bool d_useFmcModel;
98
  /** the set of terms we have seen before presolve */
99
  NodeSet d_presolveCache;
100
  /** term enumeration utility */
101
  std::unique_ptr<TermEnumeration> d_termEnum;
102
  /** term enumeration utility */
103
  std::unique_ptr<TermPools> d_termPools;
104
  /** term database */
105
  std::unique_ptr<TermDb> d_termDb;
106
  /** sygus term database */
107
  std::unique_ptr<TermDbSygus> d_sygusTdb;
108
  /** extended model object */
109
  FirstOrderModel* d_qmodel;
110
};
111
112
}  // namespace quantifiers
113
}  // namespace theory
114
}  // namespace cvc5
115
116
#endif /* CVC5__THEORY__QUANTIFIERS__TERM_REGISTRY_H */