1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Gereon Kremer |
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 |
|
* Arithmetic preprocess. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/arith/arith_preprocess.h" |
17 |
|
|
18 |
|
#include "theory/arith/arith_state.h" |
19 |
|
#include "theory/arith/inference_manager.h" |
20 |
|
#include "theory/skolem_lemma.h" |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
namespace theory { |
24 |
|
namespace arith { |
25 |
|
|
26 |
9926 |
ArithPreprocess::ArithPreprocess(ArithState& state, |
27 |
|
InferenceManager& im, |
28 |
|
ProofNodeManager* pnm, |
29 |
9926 |
OperatorElim& oe) |
30 |
9926 |
: d_im(im), d_opElim(oe), d_reduced(state.getUserContext()) |
31 |
|
{ |
32 |
9926 |
} |
33 |
752218 |
TrustNode ArithPreprocess::eliminate(TNode n, |
34 |
|
std::vector<SkolemLemma>& lems, |
35 |
|
bool partialOnly) |
36 |
|
{ |
37 |
752218 |
return d_opElim.eliminate(n, lems, partialOnly); |
38 |
|
} |
39 |
|
|
40 |
|
bool ArithPreprocess::reduceAssertion(TNode atom) |
41 |
|
{ |
42 |
|
context::CDHashMap<Node, bool>::const_iterator it = d_reduced.find(atom); |
43 |
|
if (it != d_reduced.end()) |
44 |
|
{ |
45 |
|
// already computed |
46 |
|
return (*it).second; |
47 |
|
} |
48 |
|
std::vector<SkolemLemma> lems; |
49 |
|
TrustNode tn = eliminate(atom, lems); |
50 |
|
for (const SkolemLemma& lem : lems) |
51 |
|
{ |
52 |
|
d_im.trustedLemma(lem.d_lemma, InferenceId::ARITH_PP_ELIM_OPERATORS_LEMMA); |
53 |
|
} |
54 |
|
if (tn.isNull()) |
55 |
|
{ |
56 |
|
// did not reduce |
57 |
|
d_reduced[atom] = false; |
58 |
|
return false; |
59 |
|
} |
60 |
|
Assert(tn.getKind() == TrustNodeKind::REWRITE); |
61 |
|
// tn is of kind REWRITE, turn this into a LEMMA here |
62 |
|
TrustNode tlem = TrustNode::mkTrustLemma(tn.getProven(), tn.getGenerator()); |
63 |
|
// send the trusted lemma |
64 |
|
d_im.trustedLemma(tlem, InferenceId::ARITH_PP_ELIM_OPERATORS); |
65 |
|
// mark the atom as reduced |
66 |
|
d_reduced[atom] = true; |
67 |
|
return true; |
68 |
|
} |
69 |
|
|
70 |
|
bool ArithPreprocess::isReduced(TNode atom) const |
71 |
|
{ |
72 |
|
context::CDHashMap<Node, bool>::const_iterator it = d_reduced.find(atom); |
73 |
|
if (it == d_reduced.end()) |
74 |
|
{ |
75 |
|
return false; |
76 |
|
} |
77 |
|
return (*it).second; |
78 |
|
} |
79 |
|
|
80 |
|
} // namespace arith |
81 |
|
} // namespace theory |
82 |
29502 |
} // namespace cvc5 |