af425c57077f90f25548808d1cf86bdc842fe588
1 /********************* */
2 /*! \file inst_match.cpp
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Morgan Deters, Francois Bobot
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 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.\endverbatim
12 ** \brief Implementation of inst match class
15 #include "theory/quantifiers/inst_match.h"
17 #include "theory/quantifiers/instantiate.h"
18 #include "theory/quantifiers/quant_util.h"
19 #include "theory/quantifiers/term_database.h"
20 #include "theory/quantifiers_engine.h"
26 InstMatch::InstMatch(TNode q
)
28 d_vals
.resize(q
[0].getNumChildren());
29 Assert(!d_vals
.empty());
30 // resize must initialize with null nodes
31 Assert(d_vals
[0].isNull());
34 InstMatch::InstMatch( InstMatch
* m
) {
35 d_vals
.insert( d_vals
.end(), m
->d_vals
.begin(), m
->d_vals
.end() );
38 void InstMatch::add(InstMatch
& m
)
40 for (unsigned i
= 0, size
= d_vals
.size(); i
< size
; i
++)
42 if( d_vals
[i
].isNull() ){
43 d_vals
[i
] = m
.d_vals
[i
];
48 bool InstMatch::merge( EqualityQuery
* q
, InstMatch
& m
){
49 Assert(d_vals
.size() == m
.d_vals
.size());
50 for (unsigned i
= 0, size
= d_vals
.size(); i
< size
; i
++)
52 if( !m
.d_vals
[i
].isNull() ){
53 if( d_vals
[i
].isNull() ){
54 d_vals
[i
] = m
.d_vals
[i
];
56 if( !q
->areEqual( d_vals
[i
], m
.d_vals
[i
]) ){
66 void InstMatch::debugPrint( const char* c
){
67 for (unsigned i
= 0, size
= d_vals
.size(); i
< size
; i
++)
69 if( !d_vals
[i
].isNull() ){
70 Debug( c
) << " " << i
<< " -> " << d_vals
[i
] << std::endl
;
75 bool InstMatch::isComplete() {
76 for (Node
& v
: d_vals
)
86 bool InstMatch::empty() {
87 for (Node
& v
: d_vals
)
97 void InstMatch::clear() {
98 for( unsigned i
=0; i
<d_vals
.size(); i
++ ){
99 d_vals
[i
] = Node::null();
103 Node
InstMatch::get(size_t i
) const
105 Assert(i
< d_vals
.size());
109 void InstMatch::setValue(size_t i
, TNode n
)
111 Assert(i
< d_vals
.size());
114 bool InstMatch::set(EqualityQuery
* q
, size_t i
, TNode n
)
116 Assert(i
< d_vals
.size());
117 if( !d_vals
[i
].isNull() ){
118 if (q
->areEqual(d_vals
[i
], n
))
130 }/* CVC4::theory::inst namespace */
131 }/* CVC4::theory namespace */
132 }/* CVC4 namespace */