1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Morgan Deters, Francois Bobot |
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 inst match class. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/quantifiers/inst_match.h" |
17 |
|
|
18 |
|
#include "theory/quantifiers/quantifiers_state.h" |
19 |
|
|
20 |
|
namespace cvc5 { |
21 |
|
namespace theory { |
22 |
|
namespace quantifiers { |
23 |
|
|
24 |
43999 |
InstMatch::InstMatch(TNode q) |
25 |
|
{ |
26 |
43999 |
d_vals.resize(q[0].getNumChildren()); |
27 |
43999 |
Assert(!d_vals.empty()); |
28 |
|
// resize must initialize with null nodes |
29 |
43999 |
Assert(d_vals[0].isNull()); |
30 |
43999 |
} |
31 |
|
|
32 |
14075 |
InstMatch::InstMatch( InstMatch* m ) { |
33 |
14075 |
d_vals.insert( d_vals.end(), m->d_vals.begin(), m->d_vals.end() ); |
34 |
14075 |
} |
35 |
|
|
36 |
|
void InstMatch::add(InstMatch& m) |
37 |
|
{ |
38 |
|
for (unsigned i = 0, size = d_vals.size(); i < size; i++) |
39 |
|
{ |
40 |
|
if( d_vals[i].isNull() ){ |
41 |
|
d_vals[i] = m.d_vals[i]; |
42 |
|
} |
43 |
|
} |
44 |
|
} |
45 |
|
|
46 |
|
void InstMatch::debugPrint( const char* c ){ |
47 |
|
for (unsigned i = 0, size = d_vals.size(); i < size; i++) |
48 |
|
{ |
49 |
|
if( !d_vals[i].isNull() ){ |
50 |
|
Debug( c ) << " " << i << " -> " << d_vals[i] << std::endl; |
51 |
|
} |
52 |
|
} |
53 |
|
} |
54 |
|
|
55 |
|
bool InstMatch::isComplete() { |
56 |
|
for (Node& v : d_vals) |
57 |
|
{ |
58 |
|
if (v.isNull()) |
59 |
|
{ |
60 |
|
return false; |
61 |
|
} |
62 |
|
} |
63 |
|
return true; |
64 |
|
} |
65 |
|
|
66 |
|
bool InstMatch::empty() { |
67 |
|
for (Node& v : d_vals) |
68 |
|
{ |
69 |
|
if (!v.isNull()) |
70 |
|
{ |
71 |
|
return false; |
72 |
|
} |
73 |
|
} |
74 |
|
return true; |
75 |
|
} |
76 |
|
|
77 |
11685 |
void InstMatch::clear() { |
78 |
51054 |
for( unsigned i=0; i<d_vals.size(); i++ ){ |
79 |
39369 |
d_vals[i] = Node::null(); |
80 |
|
} |
81 |
11685 |
} |
82 |
|
|
83 |
3451560 |
Node InstMatch::get(size_t i) const |
84 |
|
{ |
85 |
3451560 |
Assert(i < d_vals.size()); |
86 |
3451560 |
return d_vals[i]; |
87 |
|
} |
88 |
|
|
89 |
476855 |
void InstMatch::setValue(size_t i, TNode n) |
90 |
|
{ |
91 |
476855 |
Assert(i < d_vals.size()); |
92 |
476855 |
d_vals[i] = n; |
93 |
476855 |
} |
94 |
1964537 |
bool InstMatch::set(QuantifiersState& qs, size_t i, TNode n) |
95 |
|
{ |
96 |
1964537 |
Assert(i < d_vals.size()); |
97 |
1964537 |
if( !d_vals[i].isNull() ){ |
98 |
1351699 |
return qs.areEqual(d_vals[i], n); |
99 |
|
} |
100 |
612838 |
d_vals[i] = n; |
101 |
612838 |
return true; |
102 |
|
} |
103 |
|
|
104 |
|
} // namespace quantifiers |
105 |
|
} // namespace theory |
106 |
29577 |
} // namespace cvc5 |