GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/equality_solver.h Lines: 6 6 100.0 %
Date: 2021-08-17 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
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
 * Arithmetic equality solver
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__ARITH__EQUALITY_SOLVER_H
19
#define CVC5__THEORY__ARITH__EQUALITY_SOLVER_H
20
21
#include "context/cdhashset.h"
22
#include "expr/node.h"
23
#include "proof/trust_node.h"
24
#include "theory/arith/arith_state.h"
25
#include "theory/ee_setup_info.h"
26
#include "theory/uf/equality_engine.h"
27
28
namespace cvc5 {
29
namespace theory {
30
namespace arith {
31
32
class InferenceManager;
33
34
/**
35
 * The arithmetic equality solver. This class manages arithmetic equalities
36
 * in the default way via an equality engine.
37
 *
38
 * Since arithmetic has multiple ways of propagating literals, it tracks
39
 * the literals that it propagates and only explains the literals that
40
 * originated from this class.
41
 */
42
class EqualitySolver
43
{
44
  using NodeSet = context::CDHashSet<Node>;
45
46
 public:
47
  EqualitySolver(ArithState& astate, InferenceManager& aim);
48
39
  ~EqualitySolver() {}
49
  //--------------------------------- initialization
50
  /**
51
   * Returns true if we need an equality engine, see
52
   * Theory::needsEqualityEngine.
53
   */
54
  bool needsEqualityEngine(EeSetupInfo& esi);
55
  /**
56
   * Finish initialize
57
   */
58
  void finishInit();
59
  //--------------------------------- end initialization
60
  /**
61
   * Pre-notify fact, return true if we are finished processing, false if
62
   * we wish to assert the fact to the equality engine of this class.
63
   */
64
  bool preNotifyFact(
65
      TNode atom, bool pol, TNode fact, bool isPrereg, bool isInternal);
66
  /**
67
   * Return an explanation for the literal lit (which was previously propagated
68
   * by this solver).
69
   */
70
  TrustNode explain(TNode lit);
71
72
 private:
73
  /** Notification class from the equality engine */
74
39
  class EqualitySolverNotify : public eq::EqualityEngineNotify
75
  {
76
   public:
77
39
    EqualitySolverNotify(EqualitySolver& es) : d_es(es) {}
78
79
    bool eqNotifyTriggerPredicate(TNode predicate, bool value) override;
80
81
    bool eqNotifyTriggerTermEquality(TheoryId tag,
82
                                     TNode t1,
83
                                     TNode t2,
84
                                     bool value) override;
85
86
    void eqNotifyConstantTermMerge(TNode t1, TNode t2) override;
87
122
    void eqNotifyNewClass(TNode t) override {}
88
194
    void eqNotifyMerge(TNode t1, TNode t2) override {}
89
54
    void eqNotifyDisequal(TNode t1, TNode t2, TNode reason) override {}
90
91
   private:
92
    /** reference to parent */
93
    EqualitySolver& d_es;
94
  };
95
  /** Propagate literal */
96
  bool propagateLit(Node lit);
97
  /** Conflict when two constants merge */
98
  void conflictEqConstantMerge(TNode a, TNode b);
99
  /** reference to the state */
100
  ArithState& d_astate;
101
  /** reference to parent */
102
  InferenceManager& d_aim;
103
  /** Equality solver notify */
104
  EqualitySolverNotify d_notify;
105
  /** Pointer to the equality engine */
106
  eq::EqualityEngine* d_ee;
107
  /** The literals we have propagated */
108
  NodeSet d_propLits;
109
};
110
111
}  // namespace arith
112
}  // namespace theory
113
}  // namespace cvc5
114
115
#endif