1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/******************************************************************************
* Top contributors (to current version):
* Andrew Reynolds, Morgan Deters, Dejan Jovanovic
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
* in the top-level source directory and their institutional affiliations.
* All rights reserved. See the file COPYING in the top-level source
* directory for licensing information.
* ****************************************************************************
*
* The theory of booleans.
*/
#include "theory/booleans/theory_bool.h"
#include <stack>
#include <vector>
#include "proof/proof_node_manager.h"
#include "smt/logic_exception.h"
#include "smt_util/boolean_simplification.h"
#include "theory/booleans/circuit_propagator.h"
#include "theory/booleans/theory_bool_rewriter.h"
#include "theory/substitutions.h"
#include "theory/theory.h"
#include "theory/trust_substitutions.h"
#include "theory/valuation.h"
#include "util/hash.h"
using namespace cvc5::kind;
namespace cvc5 {
namespace theory {
namespace booleans {
TheoryBool::TheoryBool(Env& env, OutputChannel& out, Valuation valuation)
: Theory(THEORY_BOOL, env, out, valuation)
{
}
Theory::PPAssertStatus TheoryBool::ppAssert(
TrustNode tin, TrustSubstitutionMap& outSubstitutions)
{
TNode in = tin.getNode();
if (in.getKind() == kind::CONST_BOOLEAN && !in.getConst<bool>()) {
// If we get a false literal, we're in conflict
return PP_ASSERT_STATUS_CONFLICT;
}
// Add the substitution from the variable to its value
if (in.getKind() == kind::NOT) {
if (in[0].isVar())
{
outSubstitutions.addSubstitutionSolved(
in[0], NodeManager::currentNM()->mkConst<bool>(false), tin);
return PP_ASSERT_STATUS_SOLVED;
}
} else {
if (in.isVar())
{
outSubstitutions.addSubstitutionSolved(
in, NodeManager::currentNM()->mkConst<bool>(true), tin);
return PP_ASSERT_STATUS_SOLVED;
}
}
return Theory::ppAssert(tin, outSubstitutions);
}
TrustNode TheoryBool::ppRewrite(TNode n, std::vector<SkolemLemma>& lems)
{
Trace("bool-ppr") << "TheoryBool::ppRewrite " << n << std::endl;
if (n.getKind() == ITE)
{
TypeNode tn = n.getType();
if (!tn.isFirstClass())
{
std::stringstream ss;
ss << "ITE branches of type " << tn << " are currently not supported."
<< std::endl;
throw LogicException(ss.str());
}
}
return TrustNode::null();
}
TheoryRewriter* TheoryBool::getTheoryRewriter() { return &d_rewriter; }
ProofRuleChecker* TheoryBool::getProofChecker() { return &d_checker; }
std::string TheoryBool::identify() const { return std::string("TheoryBool"); }
} // namespace booleans
} // namespace theory
} // namespace cvc5
|