GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/bv/bv_subtheory_inequality.h Lines: 6 6 100.0 %
Date: 2021-05-22 Branches: 5 10 50.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Mathias Preiner, Liana Hadarean, 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
 * Algebraic solver.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H
19
#define CVC5__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H
20
21
#include <unordered_set>
22
23
#include "context/cdhashset.h"
24
#include "expr/attribute.h"
25
#include "theory/bv/bv_inequality_graph.h"
26
#include "theory/bv/bv_subtheory.h"
27
28
namespace cvc5 {
29
namespace theory {
30
namespace bv {
31
32
/** Cache for InequalitySolver::isInequalityOnly() */
33
struct IneqOnlyAttributeId
34
{
35
};
36
typedef expr::Attribute<IneqOnlyAttributeId, bool> IneqOnlyAttribute;
37
38
/** Whether the above has been computed yet or not for an expr */
39
struct IneqOnlyComputedAttributeId
40
{
41
};
42
typedef expr::Attribute<IneqOnlyComputedAttributeId, bool>
43
    IneqOnlyComputedAttribute;
44
45
18810
class InequalitySolver : public SubtheorySolver
46
{
47
  struct Statistics
48
  {
49
    IntStat d_numCallstoCheck;
50
    TimerStat d_solveTime;
51
    Statistics();
52
  };
53
54
  context::CDHashSet<Node> d_assertionSet;
55
  InequalityGraph d_inequalityGraph;
56
  context::CDHashMap<Node, TNode> d_explanations;
57
  context::CDO<bool> d_isComplete;
58
  typedef std::unordered_set<Node> NodeSet;
59
  NodeSet d_ineqTerms;
60
  bool isInequalityOnly(TNode node);
61
  bool addInequality(TNode a, TNode b, bool strict, TNode fact);
62
  Statistics d_statistics;
63
64
 public:
65
9405
  InequalitySolver(context::Context* c, context::Context* u, BVSolverLazy* bv)
66
9405
      : SubtheorySolver(c, bv),
67
        d_assertionSet(c),
68
        d_inequalityGraph(c, u),
69
        d_explanations(c),
70
        d_isComplete(c, true),
71
        d_ineqTerms(),
72
9405
        d_statistics()
73
  {
74
9405
  }
75
76
  bool check(Theory::Effort e) override;
77
  void propagate(Theory::Effort e) override;
78
  void explain(TNode literal, std::vector<TNode>& assumptions) override;
79
434292
  bool isComplete() override { return d_isComplete; }
80
  bool collectModelValues(TheoryModel* m,
81
                          const std::set<Node>& termSet) override;
82
  Node getModelValue(TNode var) override;
83
  EqualityStatus getEqualityStatus(TNode a, TNode b) override;
84
  void assertFact(TNode fact) override;
85
  void preRegister(TNode node) override;
86
};
87
88
}  // namespace bv
89
}  // namespace theory
90
}  // namespace cvc5
91
92
#endif /* CVC5__THEORY__BV__BV_SUBTHEORY__INEQUALITY_H */