GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/booleans/theory_bool.cpp Lines: 29 31 93.5 %
Date: 2021-11-05 Branches: 51 98 52.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, Dejan Jovanovic
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
 * The theory of booleans.
14
 */
15
16
#include "theory/booleans/theory_bool.h"
17
18
#include <stack>
19
#include <vector>
20
21
#include "proof/proof_node_manager.h"
22
#include "smt/logic_exception.h"
23
#include "smt_util/boolean_simplification.h"
24
#include "theory/booleans/circuit_propagator.h"
25
#include "theory/booleans/theory_bool_rewriter.h"
26
#include "theory/substitutions.h"
27
#include "theory/theory.h"
28
#include "theory/trust_substitutions.h"
29
#include "theory/valuation.h"
30
#include "util/hash.h"
31
32
using namespace cvc5::kind;
33
34
namespace cvc5 {
35
namespace theory {
36
namespace booleans {
37
38
15271
TheoryBool::TheoryBool(Env& env, OutputChannel& out, Valuation valuation)
39
15271
    : Theory(THEORY_BOOL, env, out, valuation)
40
{
41
15271
}
42
43
15281
Theory::PPAssertStatus TheoryBool::ppAssert(
44
    TrustNode tin, TrustSubstitutionMap& outSubstitutions)
45
{
46
30562
  TNode in = tin.getNode();
47
15281
  if (in.getKind() == kind::CONST_BOOLEAN && !in.getConst<bool>()) {
48
    // If we get a false literal, we're in conflict
49
    return PP_ASSERT_STATUS_CONFLICT;
50
  }
51
52
  // Add the substitution from the variable to its value
53
15281
  if (in.getKind() == kind::NOT) {
54
8025
    if (in[0].isVar())
55
    {
56
23346
      outSubstitutions.addSubstitutionSolved(
57
15564
          in[0], NodeManager::currentNM()->mkConst<bool>(false), tin);
58
7782
      return PP_ASSERT_STATUS_SOLVED;
59
    }
60
  } else {
61
7256
    if (in.isVar())
62
    {
63
15702
      outSubstitutions.addSubstitutionSolved(
64
10468
          in, NodeManager::currentNM()->mkConst<bool>(true), tin);
65
5234
      return PP_ASSERT_STATUS_SOLVED;
66
    }
67
  }
68
69
2265
  return Theory::ppAssert(tin, outSubstitutions);
70
}
71
72
87286
TrustNode TheoryBool::ppRewrite(TNode n, std::vector<SkolemLemma>& lems)
73
{
74
87286
  Trace("bool-ppr") << "TheoryBool::ppRewrite " << n << std::endl;
75
87286
  if (n.getKind() == ITE)
76
  {
77
56678
    TypeNode tn = n.getType();
78
28339
    if (!tn.isFirstClass())
79
    {
80
4
      std::stringstream ss;
81
2
      ss << "ITE branches of type " << tn << " are currently not supported."
82
2
         << std::endl;
83
2
      throw LogicException(ss.str());
84
    }
85
  }
86
87284
  return TrustNode::null();
87
}
88
89
15271
TheoryRewriter* TheoryBool::getTheoryRewriter() { return &d_rewriter; }
90
91
7987
ProofRuleChecker* TheoryBool::getProofChecker() { return &d_checker; }
92
93
std::string TheoryBool::identify() const { return std::string("TheoryBool"); }
94
95
}  // namespace booleans
96
}  // namespace theory
97
31125
}  // namespace cvc5