GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/nl/nl_lemma_utils.cpp Lines: 21 28 75.0 %
Date: 2021-05-22 Branches: 20 48 41.7 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Gereon Kremer
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 utilities for the non-linear solver.
14
 */
15
16
#include "theory/arith/nl/nl_lemma_utils.h"
17
18
#include "theory/arith/nl/nl_model.h"
19
#include "theory/arith/nl/nonlinear_extension.h"
20
21
namespace cvc5 {
22
namespace theory {
23
namespace arith {
24
namespace nl {
25
26
TrustNode NlLemma::processLemma(LemmaProperty& p)
27
{
28
  if (d_nlext != nullptr)
29
  {
30
    d_nlext->processSideEffect(*this);
31
  }
32
  return SimpleTheoryLemma::processLemma(p);
33
}
34
35
std::ostream& operator<<(std::ostream& out, NlLemma& n)
36
{
37
  out << n.d_node;
38
  return out;
39
}
40
41
43063
bool SortNlModel::operator()(Node i, Node j)
42
{
43
43063
  int cv = d_nlm->compare(i, j, d_isConcrete, d_isAbsolute);
44
43063
  if (cv == 0)
45
  {
46
8387
    return i < j;
47
  }
48
34676
  return d_reverse_order ? cv < 0 : cv > 0;
49
}
50
51
8134
bool SortNonlinearDegree::operator()(Node i, Node j)
52
{
53
8134
  unsigned i_count = getDegree(i);
54
8134
  unsigned j_count = getDegree(j);
55
8134
  return i_count == j_count ? (i < j) : (i_count < j_count ? true : false);
56
}
57
58
16268
unsigned SortNonlinearDegree::getDegree(Node n) const
59
{
60
16268
  std::map<Node, unsigned>::const_iterator it = d_mdegree.find(n);
61
16268
  Assert(it != d_mdegree.end());
62
16268
  return it->second;
63
}
64
65
3899
Node ArgTrie::add(Node d, const std::vector<Node>& args)
66
{
67
3899
  ArgTrie* at = this;
68
7798
  for (const Node& a : args)
69
  {
70
3899
    at = &(at->d_children[a]);
71
  }
72
3899
  if (at->d_data.isNull())
73
  {
74
3547
    at->d_data = d;
75
  }
76
3899
  return at->d_data;
77
}
78
79
}  // namespace nl
80
}  // namespace arith
81
}  // namespace theory
82
28191
}  // namespace cvc5