1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Aina Niemetz |
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 |
|
* Implementation of a cache of skolems for theory of sets. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/sets/skolem_cache.h" |
17 |
|
|
18 |
|
#include "expr/skolem_manager.h" |
19 |
|
#include "theory/rewriter.h" |
20 |
|
|
21 |
|
using namespace cvc5::kind; |
22 |
|
|
23 |
|
namespace cvc5 { |
24 |
|
namespace theory { |
25 |
|
namespace sets { |
26 |
|
|
27 |
9459 |
SkolemCache::SkolemCache() {} |
28 |
|
|
29 |
6006 |
Node SkolemCache::mkTypedSkolemCached( |
30 |
|
TypeNode tn, Node a, Node b, SkolemId id, const char* c) |
31 |
|
{ |
32 |
6006 |
a = a.isNull() ? a : Rewriter::rewrite(a); |
33 |
6006 |
b = b.isNull() ? b : Rewriter::rewrite(b); |
34 |
|
|
35 |
6006 |
std::map<SkolemId, Node>::iterator it = d_skolemCache[a][b].find(id); |
36 |
6006 |
if (it == d_skolemCache[a][b].end()) |
37 |
|
{ |
38 |
5126 |
SkolemManager* sm = NodeManager::currentNM()->getSkolemManager(); |
39 |
10252 |
Node sk; |
40 |
5126 |
if (id == SkolemId::SK_PURIFY) |
41 |
|
{ |
42 |
3860 |
Assert(a.getType() == tn); |
43 |
3860 |
sk = sm->mkPurifySkolem(a, c); |
44 |
|
} |
45 |
|
else |
46 |
|
{ |
47 |
1266 |
sk = sm->mkDummySkolem(c, tn, "sets skolem"); |
48 |
|
} |
49 |
5126 |
d_skolemCache[a][b][id] = sk; |
50 |
5126 |
d_allSkolems.insert(sk); |
51 |
5126 |
return sk; |
52 |
|
} |
53 |
880 |
return it->second; |
54 |
|
} |
55 |
3864 |
Node SkolemCache::mkTypedSkolemCached(TypeNode tn, |
56 |
|
Node a, |
57 |
|
SkolemId id, |
58 |
|
const char* c) |
59 |
|
{ |
60 |
3864 |
return mkTypedSkolemCached(tn, a, Node::null(), id, c); |
61 |
|
} |
62 |
|
|
63 |
|
Node SkolemCache::mkTypedSkolem(TypeNode tn, const char* c) |
64 |
|
{ |
65 |
|
SkolemManager* sm = NodeManager::currentNM()->getSkolemManager(); |
66 |
|
Node n = sm->mkDummySkolem(c, tn, "sets skolem"); |
67 |
|
d_allSkolems.insert(n); |
68 |
|
return n; |
69 |
|
} |
70 |
|
|
71 |
92972 |
bool SkolemCache::isSkolem(Node n) const |
72 |
|
{ |
73 |
92972 |
return d_allSkolems.find(n) != d_allSkolems.end(); |
74 |
|
} |
75 |
|
|
76 |
|
} // namespace sets |
77 |
|
} // namespace theory |
78 |
28191 |
} // namespace cvc5 |