1 /********************* */
2 /*! \file theory_state.cpp
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Mathias Preiner
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 A theory state for Theory
15 #include "theory/theory_state.h"
17 #include "theory/uf/equality_engine.h"
22 TheoryState::TheoryState(context::Context
* c
,
23 context::UserContext
* u
,
33 void TheoryState::setEqualityEngine(eq::EqualityEngine
* ee
) { d_ee
= ee
; }
35 context::Context
* TheoryState::getSatContext() const { return d_context
; }
37 context::UserContext
* TheoryState::getUserContext() const { return d_ucontext
; }
39 bool TheoryState::hasTerm(TNode a
) const
41 Assert(d_ee
!= nullptr);
42 return d_ee
->hasTerm(a
);
45 TNode
TheoryState::getRepresentative(TNode t
) const
47 Assert(d_ee
!= nullptr);
50 return d_ee
->getRepresentative(t
);
55 bool TheoryState::areEqual(TNode a
, TNode b
) const
57 Assert(d_ee
!= nullptr);
62 else if (hasTerm(a
) && hasTerm(b
))
64 return d_ee
->areEqual(a
, b
);
69 bool TheoryState::areDisequal(TNode a
, TNode b
) const
71 Assert(d_ee
!= nullptr);
81 a
= d_ee
->getRepresentative(a
);
82 isConst
= a
.isConst();
84 else if (!a
.isConst())
86 // if not constant and not a term in the ee, it cannot be disequal
96 b
= d_ee
->getRepresentative(b
);
97 isConst
= isConst
&& b
.isConst();
99 else if (!b
.isConst())
101 // same as above, it cannot be disequal
111 // distinct constants are disequal
118 // otherwise there may be an explicit disequality in the equality engine
119 return d_ee
->areDisequal(a
, b
, false);
122 eq::EqualityEngine
* TheoryState::getEqualityEngine() const { return d_ee
; }
124 void TheoryState::notifyInConflict() { d_conflict
= true; }
126 bool TheoryState::isInConflict() const { return d_conflict
; }
128 bool TheoryState::isSatLiteral(TNode lit
) const
130 return d_valuation
.isSatLiteral(lit
);
133 TheoryModel
* TheoryState::getModel() { return d_valuation
.getModel(); }
135 bool TheoryState::hasSatValue(TNode n
, bool& value
) const
137 return d_valuation
.hasSatValue(n
, value
);
140 } // namespace theory