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 quantifier relevance. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/quantifiers/quant_relevance.h" |
17 |
|
|
18 |
|
using namespace std; |
19 |
|
using namespace cvc5::kind; |
20 |
|
using namespace cvc5::context; |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
namespace theory { |
24 |
|
namespace quantifiers { |
25 |
|
|
26 |
4 |
QuantRelevance::QuantRelevance(Env& env) : QuantifiersUtil(env) {} |
27 |
|
|
28 |
344 |
void QuantRelevance::registerQuantifier(Node f) |
29 |
|
{ |
30 |
|
// compute symbols in f |
31 |
688 |
std::vector<Node> syms; |
32 |
344 |
computeSymbols(f[1], syms); |
33 |
344 |
d_syms[f].insert(d_syms[f].begin(), syms.begin(), syms.end()); |
34 |
344 |
} |
35 |
|
|
36 |
|
/** compute symbols */ |
37 |
49809 |
void QuantRelevance::computeSymbols(Node n, std::vector<Node>& syms) |
38 |
|
{ |
39 |
49809 |
if (n.getKind() == APPLY_UF) |
40 |
|
{ |
41 |
54554 |
Node op = n.getOperator(); |
42 |
27277 |
if (std::find(syms.begin(), syms.end(), op) == syms.end()) |
43 |
|
{ |
44 |
1581 |
syms.push_back(op); |
45 |
|
} |
46 |
|
} |
47 |
49809 |
if (n.getKind() != FORALL) |
48 |
|
{ |
49 |
99211 |
for (int i = 0; i < (int)n.getNumChildren(); i++) |
50 |
|
{ |
51 |
49465 |
computeSymbols(n[i], syms); |
52 |
|
} |
53 |
|
} |
54 |
49809 |
} |
55 |
|
|
56 |
1212 |
size_t QuantRelevance::getNumQuantifiersForSymbol(Node s) const |
57 |
|
{ |
58 |
1212 |
std::map<Node, std::vector<Node> >::const_iterator it = d_syms_quants.find(s); |
59 |
1212 |
if (it == d_syms_quants.end()) |
60 |
|
{ |
61 |
1212 |
return 0; |
62 |
|
} |
63 |
|
return it->second.size(); |
64 |
|
} |
65 |
|
|
66 |
|
} // namespace quantifiers |
67 |
|
} // namespace theory |
68 |
31137 |
} // namespace cvc5 |