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 "theory/builtin/proof_checker.h" |
20 |
|
#include "theory/rewriter.h" |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
namespace theory { |
24 |
|
namespace arith { |
25 |
|
|
26 |
9926 |
PreprocessRewriteEq::PreprocessRewriteEq(context::Context* c, |
27 |
9926 |
ProofNodeManager* pnm) |
28 |
9926 |
: d_ppPfGen(pnm, c, "Arith::ppRewrite"), d_pnm(pnm) |
29 |
|
{ |
30 |
9926 |
} |
31 |
|
|
32 |
28270 |
TrustNode PreprocessRewriteEq::ppRewriteEq(TNode atom) |
33 |
|
{ |
34 |
28270 |
Assert(atom.getKind() == kind::EQUAL); |
35 |
28270 |
if (!options::arithRewriteEq()) |
36 |
|
{ |
37 |
13167 |
return TrustNode::null(); |
38 |
|
} |
39 |
15103 |
Assert(atom[0].getType().isReal()); |
40 |
30206 |
Node leq = NodeBuilder(kind::LEQ) << atom[0] << atom[1]; |
41 |
30206 |
Node geq = NodeBuilder(kind::GEQ) << atom[0] << atom[1]; |
42 |
30206 |
Node rewritten = Rewriter::rewrite(leq.andNode(geq)); |
43 |
30206 |
Debug("arith::preprocess") |
44 |
15103 |
<< "arith::preprocess() : returning " << rewritten << std::endl; |
45 |
|
// don't need to rewrite terms since rewritten is not a non-standard op |
46 |
15103 |
if (proofsEnabled()) |
47 |
|
{ |
48 |
5294 |
Node t = builtin::BuiltinProofRuleChecker::mkTheoryIdNode(THEORY_ARITH); |
49 |
|
return d_ppPfGen.mkTrustedRewrite( |
50 |
|
atom, |
51 |
|
rewritten, |
52 |
10588 |
d_pnm->mkNode( |
53 |
10588 |
PfRule::THEORY_INFERENCE, {}, {atom.eqNode(rewritten), t})); |
54 |
|
} |
55 |
12456 |
return TrustNode::mkTrustRewrite(atom, rewritten, nullptr); |
56 |
|
} |
57 |
|
|
58 |
15103 |
bool PreprocessRewriteEq::proofsEnabled() const { return d_pnm != nullptr; } |
59 |
|
|
60 |
|
} // namespace arith |
61 |
|
} // namespace theory |
62 |
29502 |
} // namespace cvc5 |