GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/term_registry.h Lines: 1 1 100.0 %
Date: 2021-09-09 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
9925
class TermRegistry
41
{
42
  using NodeSet = context::CDHashSet<Node>;
43
44
 public:
45
  TermRegistry(Env& env, QuantifiersState& qs, QuantifiersRegistry& qr);
46
  /** Finish init, which sets the inference manager on modules of this class */
47
  void finishInit(FirstOrderModel* fm, QuantifiersInferenceManager* qim);
48
  /** Presolve */
49
  void presolve();
50
51
  /**
52
   * Add term n, which notifies the term database that the ground term n
53
   * exists in the current context.
54
   *
55
   * @param n the term to add
56
   * @param withinQuant whether n occurs within a quantified formula body
57
   */
58
  void addTerm(Node n, bool withinQuant = false);
59
60
  /** get term for type
61
   *
62
   * This returns an arbitrary term for type tn.
63
   * This term is chosen heuristically to be the best
64
   * term for instantiation. Currently, this
65
   * heuristic enumerates the first term of the
66
   * type if the type is closed enumerable, otherwise
67
   * an existing ground term from the term database if
68
   * one exists, or otherwise a fresh variable.
69
   */
70
  Node getTermForType(TypeNode tn);
71
  /**
72
   * Declare pool p with initial value initValue.
73
   */
74
  void declarePool(Node p, const std::vector<Node>& initValue);
75
  /**
76
   * Process instantiation
77
   */
78
  void processInstantiation(Node q, const std::vector<Node>& terms);
79
  void processSkolemization(Node q, const std::vector<Node>& skolems);
80
81
  /** get term database */
82
  TermDb* getTermDatabase() const;
83
  /** get term database sygus */
84
  TermDbSygus* getTermDatabaseSygus() const;
85
  /** get term enumeration utility */
86
  TermEnumeration* getTermEnumeration() const;
87
  /** get the term pools utility */
88
  TermPools* getTermPools() const;
89
  /** get the model utility */
90
  FirstOrderModel* getModel() const;
91
92
 private:
93
  /** has presolve been called */
94
  context::CDO<bool> d_presolve;
95
  /** Whether we are using the fmc model */
96
  bool d_useFmcModel;
97
  /** the set of terms we have seen before presolve */
98
  NodeSet d_presolveCache;
99
  /** term enumeration utility */
100
  std::unique_ptr<TermEnumeration> d_termEnum;
101
  /** term enumeration utility */
102
  std::unique_ptr<TermPools> d_termPools;
103
  /** term database */
104
  std::unique_ptr<TermDb> d_termDb;
105
  /** sygus term database */
106
  std::unique_ptr<TermDbSygus> d_sygusTdb;
107
  /** extended model object */
108
  FirstOrderModel* d_qmodel;
109
};
110
111
}  // namespace quantifiers
112
}  // namespace theory
113
}  // namespace cvc5
114
115
#endif /* CVC5__THEORY__QUANTIFIERS__TERM_REGISTRY_H */