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