GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/pp_rewrite_eq.cpp Lines: 19 19 100.0 %
Date: 2021-11-07 Branches: 56 132 42.4 %

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
 * Preprocess equality rewriter for arithmetic
14
 */
15
16
#include "theory/arith/pp_rewrite_eq.h"
17
18
#include "options/arith_options.h"
19
#include "smt/env.h"
20
#include "theory/builtin/proof_checker.h"
21
#include "theory/rewriter.h"
22
23
namespace cvc5 {
24
namespace theory {
25
namespace arith {
26
27
15273
PreprocessRewriteEq::PreprocessRewriteEq(Env& env)
28
    : EnvObj(env),
29
15273
      d_ppPfGen(d_env.getProofNodeManager(), context(), "Arith::ppRewrite")
30
{
31
15273
}
32
33
29958
TrustNode PreprocessRewriteEq::ppRewriteEq(TNode atom)
34
{
35
29958
  Assert(atom.getKind() == kind::EQUAL);
36
29958
  if (!options().arith.arithRewriteEq)
37
  {
38
13800
    return TrustNode::null();
39
  }
40
16158
  Assert(atom[0].getType().isReal());
41
32316
  Node leq = NodeBuilder(kind::LEQ) << atom[0] << atom[1];
42
32316
  Node geq = NodeBuilder(kind::GEQ) << atom[0] << atom[1];
43
32316
  Node rewritten = rewrite(leq.andNode(geq));
44
32316
  Debug("arith::preprocess")
45
16158
      << "arith::preprocess() : returning " << rewritten << std::endl;
46
  // don't need to rewrite terms since rewritten is not a non-standard op
47
16158
  if (d_env.isTheoryProofProducing())
48
  {
49
6376
    Node t = builtin::BuiltinProofRuleChecker::mkTheoryIdNode(THEORY_ARITH);
50
    return d_ppPfGen.mkTrustedRewrite(
51
        atom,
52
        rewritten,
53
12752
        d_env.getProofNodeManager()->mkNode(
54
12752
            PfRule::THEORY_INFERENCE, {}, {atom.eqNode(rewritten), t}));
55
  }
56
12970
  return TrustNode::mkTrustRewrite(atom, rewritten, nullptr);
57
}
58
59
}  // namespace arith
60
}  // namespace theory
61
31137
}  // namespace cvc5