blob: 4c72eb909593549c0d6a2e1c98d6ccc65d00d38c (
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
60
61
|
/******************************************************************************
* 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 "smt/env.h"
#include "theory/builtin/proof_checker.h"
#include "theory/rewriter.h"
namespace cvc5 {
namespace theory {
namespace arith {
PreprocessRewriteEq::PreprocessRewriteEq(Env& env)
: EnvObj(env),
d_ppPfGen(d_env.getProofNodeManager(), context(), "Arith::ppRewrite")
{
}
TrustNode PreprocessRewriteEq::ppRewriteEq(TNode atom)
{
Assert(atom.getKind() == kind::EQUAL);
if (!options().arith.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 (d_env.isTheoryProofProducing())
{
Node t = builtin::BuiltinProofRuleChecker::mkTheoryIdNode(THEORY_ARITH);
return d_ppPfGen.mkTrustedRewrite(
atom,
rewritten,
d_env.getProofNodeManager()->mkNode(
PfRule::THEORY_INFERENCE, {}, {atom.eqNode(rewritten), t}));
}
return TrustNode::mkTrustRewrite(atom, rewritten, nullptr);
}
} // namespace arith
} // namespace theory
} // namespace cvc5
|