summaryrefslogtreecommitdiff
path: root/src/theory/arith/pp_rewrite_eq.cpp
blob: 45f972038320dd7dc40dacfb828c5c4f2dbce5ee (plain)
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
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds
 *
 * 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.
 * ****************************************************************************
 *
 * Preprocess equality rewriter for arithmetic
 */

#include "theory/arith/pp_rewrite_eq.h"

#include "options/arith_options.h"
#include "theory/rewriter.h"

namespace cvc5 {
namespace theory {
namespace arith {

PreprocessRewriteEq::PreprocessRewriteEq(context::Context* c,
                                         ProofNodeManager* pnm)
    : d_ppPfGen(pnm, c, "Arith::ppRewrite"), d_pnm(pnm)
{
}

TrustNode PreprocessRewriteEq::ppRewriteEq(TNode atom)
{
  Assert(atom.getKind() == kind::EQUAL);
  if (!options::arithRewriteEq())
  {
    return TrustNode::null();
  }
  Assert(atom[0].getType().isReal());
  Node leq = NodeBuilder(kind::LEQ) << atom[0] << atom[1];
  Node geq = NodeBuilder(kind::GEQ) << atom[0] << atom[1];
  Node rewritten = Rewriter::rewrite(leq.andNode(geq));
  Debug("arith::preprocess")
      << "arith::preprocess() : returning " << rewritten << std::endl;
  // don't need to rewrite terms since rewritten is not a non-standard op
  if (proofsEnabled())
  {
    return d_ppPfGen.mkTrustedRewrite(
        atom,
        rewritten,
        d_pnm->mkNode(PfRule::INT_TRUST, {}, {atom.eqNode(rewritten)}));
  }
  return TrustNode::mkTrustRewrite(atom, rewritten, nullptr);
}

bool PreprocessRewriteEq::proofsEnabled() const { return d_pnm != nullptr; }

}  // namespace arith
}  // namespace theory
}  // namespace cvc5
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback