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