GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/bv/bv_subtheory_core.h Lines: 0 6 0.0 %
Date: 2021-08-16 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Liana Hadarean, Mathias Preiner
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
#pragma once
19
20
#include <unordered_map>
21
#include <unordered_set>
22
23
#include "context/cdhashset.h"
24
#include "theory/bv/bv_subtheory.h"
25
26
namespace cvc5 {
27
namespace theory {
28
namespace bv {
29
30
/**
31
 * Bitvector equality solver
32
 */
33
class CoreSolver : public SubtheorySolver {
34
  typedef std::unordered_map<TNode, Node> ModelValue;
35
  typedef std::unordered_map<TNode, bool> TNodeBoolMap;
36
  typedef std::unordered_set<TNode> TNodeSet;
37
38
  struct Statistics {
39
    IntStat d_numCallstoCheck;
40
    Statistics();
41
  };
42
43
  // NotifyClass: handles call-back from congruence closure module
44
  class NotifyClass : public eq::EqualityEngineNotify {
45
    CoreSolver& d_solver;
46
47
  public:
48
    NotifyClass(CoreSolver& solver): d_solver(solver) {}
49
    bool eqNotifyTriggerPredicate(TNode predicate, bool value) override;
50
    bool eqNotifyTriggerTermEquality(TheoryId tag,
51
                                     TNode t1,
52
                                     TNode t2,
53
                                     bool value) override;
54
    void eqNotifyConstantTermMerge(TNode t1, TNode t2) override;
55
    void eqNotifyNewClass(TNode t) override {}
56
    void eqNotifyMerge(TNode t1, TNode t2) override {}
57
    void eqNotifyDisequal(TNode t1, TNode t2, TNode reason) override {}
58
  };
59
60
61
  /** The notify class for d_equalityEngine */
62
  NotifyClass d_notify;
63
64
  /** Store a propagation to the bv solver */
65
  bool storePropagation(TNode literal);
66
67
  /** Store a conflict from merging two constants */
68
  void conflict(TNode a, TNode b);
69
70
  context::CDO<bool> d_isComplete;
71
  unsigned d_lemmaThreshold;
72
73
  bool d_preregisterCalled;
74
  bool d_checkCalled;
75
76
  /** Pointer to the parent theory solver that owns this */
77
  BVSolverLayered* d_bv;
78
  /** Pointer to the equality engine of the parent */
79
  eq::EqualityEngine* d_equalityEngine;
80
81
  /** To make sure we keep the explanations */
82
  context::CDHashSet<Node> d_reasons;
83
  ModelValue d_modelValues;
84
  void buildModel();
85
  bool assertFactToEqualityEngine(TNode fact, TNode reason);
86
  bool isCompleteForTerm(TNode term, TNodeBoolMap& seen);
87
  Statistics d_statistics;
88
89
 public:
90
  CoreSolver(context::Context* c, BVSolverLayered* bv);
91
  ~CoreSolver();
92
  bool needsEqualityEngine(EeSetupInfo& esi);
93
  void finishInit();
94
  bool isComplete() override { return d_isComplete; }
95
  void preRegister(TNode node) override;
96
  bool check(Theory::Effort e) override;
97
  void explain(TNode literal, std::vector<TNode>& assumptions) override;
98
  bool collectModelValues(TheoryModel* m,
99
                          const std::set<Node>& termSet) override;
100
  Node getModelValue(TNode var) override;
101
  EqualityStatus getEqualityStatus(TNode a, TNode b) override;
102
  bool hasTerm(TNode node) const;
103
  void addTermToEqualityEngine(TNode node);
104
};
105
106
}
107
}
108
}  // namespace cvc5