GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/ee_manager_central.h Lines: 1 1 100.0 %
Date: 2021-11-07 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
 * Equality engine manager for central equality engine architecture
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__EE_MANAGER_CENTRAL__H
19
#define CVC5__THEORY__EE_MANAGER_CENTRAL__H
20
21
#include <map>
22
#include <memory>
23
24
#include "theory/ee_manager.h"
25
#include "theory/quantifiers/master_eq_notify.h"
26
#include "theory/uf/equality_engine.h"
27
28
namespace cvc5 {
29
namespace theory {
30
31
/**
32
 * The (central) equality engine manager. This encapsulates an architecture
33
 * in which all applicable theories use a single central equality engine.
34
 *
35
 * This class is not responsible for actually initializing equality engines in
36
 * theories (since this class does not have access to the internals of Theory).
37
 * Instead, it is only responsible for the construction of the equality
38
 * engine objects themselves. TheoryEngine is responsible for querying this
39
 * class during finishInit() to determine the equality engines to pass to each
40
 * theories based on getEeTheoryInfo.
41
 *
42
 * It also may allocate a "master" equality engine, which is intuitively the
43
 * equality engine of the theory of quantifiers. If all theories use the
44
 * central equality engine, then the master equality engine is the same as the
45
 * central equality engine.
46
 *
47
 * The theories that use central equality engine are determined by
48
 * Theory::usesCentralEqualityEngine.
49
 *
50
 * The main idea behind this class is to use a notification class on the
51
 * central equality engine which dispatches *multiple* notifications to the
52
 * theories that use the central equality engine.
53
 */
54
class EqEngineManagerCentral : public EqEngineManager
55
{
56
 public:
57
  EqEngineManagerCentral(Env& env, TheoryEngine& te, SharedSolver& shs);
58
  ~EqEngineManagerCentral();
59
  /**
60
   * Initialize theories. This method allocates unique equality engines
61
   * per theories and connects them to a master equality engine.
62
   */
63
  void initializeTheories() override;
64
  /** Notify this class that we are building the model. */
65
  void notifyBuildingModel();
66
67
 private:
68
  /**
69
   * Notify class for central equality engine. This class dispatches
70
   * notifications from the central equality engine to the appropriate
71
   * theory(s).
72
   */
73
37
  class CentralNotifyClass : public theory::eq::EqualityEngineNotify
74
  {
75
   public:
76
    CentralNotifyClass(EqEngineManagerCentral& eemc);
77
    bool eqNotifyTriggerPredicate(TNode predicate, bool value) override;
78
    bool eqNotifyTriggerTermEquality(TheoryId tag,
79
                                     TNode t1,
80
                                     TNode t2,
81
                                     bool value) override;
82
    void eqNotifyConstantTermMerge(TNode t1, TNode t2) override;
83
    void eqNotifyNewClass(TNode t) override;
84
    void eqNotifyMerge(TNode t1, TNode t2) override;
85
    void eqNotifyDisequal(TNode t1, TNode t2, TNode reason) override;
86
    /** Parent */
87
    EqEngineManagerCentral& d_eemc;
88
    /** List of notify classes that need new class notification */
89
    std::vector<eq::EqualityEngineNotify*> d_newClassNotify;
90
    /** List of notify classes that need merge notification */
91
    std::vector<eq::EqualityEngineNotify*> d_mergeNotify;
92
    /** List of notify classes that need disequality notification */
93
    std::vector<eq::EqualityEngineNotify*> d_disequalNotify;
94
    /** The model notify class */
95
    eq::EqualityEngineNotify* d_mNotify;
96
    /** The quantifiers engine */
97
    QuantifiersEngine* d_quantEngine;
98
  };
99
  /** Notification when predicate gets value in central equality engine */
100
  bool eqNotifyTriggerPredicate(TNode predicate, bool value);
101
  bool eqNotifyTriggerTermEquality(TheoryId tag,
102
                                   TNode t1,
103
                                   TNode t2,
104
                                   bool value);
105
  /** Notification when constants are merged in central equality engine */
106
  void eqNotifyConstantTermMerge(TNode t1, TNode t2);
107
  /** The master equality engine notify class */
108
  std::unique_ptr<quantifiers::MasterNotifyClass> d_masterEENotify;
109
  /** The master equality engine. */
110
  eq::EqualityEngine* d_masterEqualityEngine;
111
  /** The master equality engine, if we allocated it */
112
  std::unique_ptr<eq::EqualityEngine> d_masterEqualityEngineAlloc;
113
  /** The central equality engine notify class */
114
  CentralNotifyClass d_centralEENotify;
115
  /** The central equality engine. */
116
  eq::EqualityEngine d_centralEqualityEngine;
117
  /** The proof equality engine for the central equality engine */
118
  std::unique_ptr<eq::ProofEqEngine> d_centralPfee;
119
  /**
120
   * A table of from theory IDs to notify classes.
121
   */
122
  eq::EqualityEngineNotify* d_theoryNotify[theory::THEORY_LAST];
123
};
124
125
}  // namespace theory
126
}  // namespace cvc5
127
128
#endif /* CVC5__THEORY__EE_MANAGER_CENTRAL__H */