GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/inst_match.cpp Lines: 26 46 56.5 %
Date: 2021-05-22 Branches: 24 142 16.9 %

Line Exec Source
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
43251
InstMatch::InstMatch(TNode q)
25
{
26
43251
  d_vals.resize(q[0].getNumChildren());
27
43251
  Assert(!d_vals.empty());
28
  // resize must initialize with null nodes
29
43251
  Assert(d_vals[0].isNull());
30
43251
}
31
32
1697
InstMatch::InstMatch( InstMatch* m ) {
33
1697
  d_vals.insert( d_vals.end(), m->d_vals.begin(), m->d_vals.end() );
34
1697
}
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
10294
void InstMatch::clear() {
78
41771
  for( unsigned i=0; i<d_vals.size(); i++ ){
79
31477
    d_vals[i] = Node::null();
80
  }
81
10294
}
82
83
3529841
Node InstMatch::get(size_t i) const
84
{
85
3529841
  Assert(i < d_vals.size());
86
3529841
  return d_vals[i];
87
}
88
89
431647
void InstMatch::setValue(size_t i, TNode n)
90
{
91
431647
  Assert(i < d_vals.size());
92
431647
  d_vals[i] = n;
93
431647
}
94
2042683
bool InstMatch::set(QuantifiersState& qs, size_t i, TNode n)
95
{
96
2042683
  Assert(i < d_vals.size());
97
2042683
  if( !d_vals[i].isNull() ){
98
1369459
    return qs.areEqual(d_vals[i], n);
99
  }
100
673224
  d_vals[i] = n;
101
673224
  return true;
102
}
103
104
}  // namespace quantifiers
105
}  // namespace theory
106
28194
}  // namespace cvc5