1 /********************* */
2 /*! \file shared_solver.h
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 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.\endverbatim
12 ** \brief Base class for shared solver
15 #include "cvc4_private.h"
17 #ifndef CVC4__THEORY__SHARED_SOLVER__H
18 #define CVC4__THEORY__SHARED_SOLVER__H
20 #include "expr/node.h"
21 #include "expr/proof_node_manager.h"
22 #include "theory/ee_setup_info.h"
23 #include "theory/logic_info.h"
24 #include "theory/shared_terms_database.h"
25 #include "theory/term_registration_visitor.h"
26 #include "theory/valuation.h"
35 * A base class for shared solver. The shared solver is the component of theory
36 * engine that behaves like a theory solver, and whose purpose is to ensure the
37 * main theory combination method can be performed in CombinationEngine.
39 * (1) Notify the individual theories of shared terms via addSharedTerms,
40 * (2) Be the official interface for equality statuses,
41 * (3) Propagate equalities to TheoryEngine when necessary and explain them.
46 SharedSolver(TheoryEngine
& te
, ProofNodeManager
* pnm
);
47 virtual ~SharedSolver() {}
48 //------------------------------------- initialization
50 * Returns true if we need an equality engine, this has the same contract
51 * as Theory::needsEqualityEngine.
53 virtual bool needsEqualityEngine(theory::EeSetupInfo
& esi
);
55 * Set the equality engine. This should be called by equality engine manager
56 * during EqEngineManager::initializeTheories.
58 virtual void setEqualityEngine(eq::EqualityEngine
* ee
) = 0;
59 //------------------------------------- end initialization
61 * Called when the given term t is pre-registered in TheoryEngine.
63 * This adds t as an equality to propagate in the shared terms database
64 * if it is an equality, or adds its shared terms if it involves multiple
67 * @param t The term to preregister
68 * @param multipleTheories Whether multiple theories are present in t.
70 void preRegisterShared(TNode t
, bool multipleTheories
);
72 * Pre-notify assertion fact with the given atom. This is called when any
73 * fact is asserted in TheoryEngine, just before it is dispatched to the
76 * This calls Theory::notifySharedTerm for the shared terms of the atom.
78 void preNotifySharedFact(TNode atom
);
80 * Get the equality status of a and b.
82 * This method is used by theories via Valuation mostly for determining their
85 virtual EqualityStatus
getEqualityStatus(TNode a
, TNode b
);
87 * Explain literal, which returns a conjunction of literals that entail
90 virtual TrustNode
explain(TNode literal
, TheoryId id
) = 0;
92 * Assert equality to the shared terms database.
94 * This method is called by TheoryEngine when a fact has been marked to
95 * send to THEORY_BUILTIN, meaning that shared terms database should
96 * maintain this fact. This is the case when either an equality is
97 * asserted from the SAT solver or a theory propagates an equality between
100 virtual void assertSharedEquality(TNode equality
,
103 /** Is term t a shared term? */
104 virtual bool isShared(TNode t
) const;
107 * Method called by equalityEngine when a becomes (dis-)equal to b and a and b
108 * are shared with the theory. Returns false if there is a direct conflict
109 * (via rewrite for example).
111 bool propagateSharedEquality(theory::TheoryId theory
,
115 /** Send lemma to the theory engine, atomsTo is the theory to send atoms to */
116 void sendLemma(TrustNode trn
, TheoryId atomsTo
);
119 /** Solver-specific pre-register shared */
120 virtual void preRegisterSharedInternal(TNode t
) = 0;
121 /** Reference to the theory engine */
123 /** Logic info of theory engine (cached) */
124 const LogicInfo
& d_logicInfo
;
125 /** The database of shared terms.*/
126 SharedTermsDatabase d_sharedTerms
;
127 /** Visitor for collecting shared terms */
128 SharedTermsVisitor d_sharedTermsVisitor
;
131 } // namespace theory
134 #endif /* CVC4__THEORY__SHARED_SOLVER__H */