GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/quant_relevance.cpp Lines: 20 21 95.2 %
Date: 2021-09-29 Branches: 21 34 61.8 %

Line Exec Source
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
1
QuantRelevance::QuantRelevance(Env& env) : QuantifiersUtil(env) {}
27
28
114
void QuantRelevance::registerQuantifier(Node f)
29
{
30
  // compute symbols in f
31
228
  std::vector<Node> syms;
32
114
  computeSymbols(f[1], syms);
33
114
  d_syms[f].insert(d_syms[f].begin(), syms.begin(), syms.end());
34
114
}
35
36
/** compute symbols */
37
13522
void QuantRelevance::computeSymbols(Node n, std::vector<Node>& syms)
38
{
39
13522
  if (n.getKind() == APPLY_UF)
40
  {
41
14650
    Node op = n.getOperator();
42
7325
    if (std::find(syms.begin(), syms.end(), op) == syms.end())
43
    {
44
520
      syms.push_back(op);
45
    }
46
  }
47
13522
  if (n.getKind() != FORALL)
48
  {
49
26909
    for (int i = 0; i < (int)n.getNumChildren(); i++)
50
    {
51
13408
      computeSymbols(n[i], syms);
52
    }
53
  }
54
13522
}
55
56
482
size_t QuantRelevance::getNumQuantifiersForSymbol(Node s) const
57
{
58
482
  std::map<Node, std::vector<Node> >::const_iterator it = d_syms_quants.find(s);
59
482
  if (it == d_syms_quants.end())
60
  {
61
482
    return 0;
62
  }
63
  return it->second.size();
64
}
65
66
}  // namespace quantifiers
67
}  // namespace theory
68
22746
}  // namespace cvc5