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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/********************* */
/*! \file arith_preprocess.cpp
** \verbatim
** Top contributors (to current version):
** Andrew Reynolds, Gereon Kremer
** This file is part of the CVC4 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.\endverbatim
**
** \brief Arithmetic preprocess
**/
#include "theory/arith/arith_preprocess.h"
#include "theory/arith/inference_manager.h"
namespace CVC4 {
namespace theory {
namespace arith {
ArithPreprocess::ArithPreprocess(ArithState& state,
InferenceManager& im,
ProofNodeManager* pnm,
const LogicInfo& info)
: d_im(im), d_opElim(pnm, info), d_reduced(state.getUserContext())
{
}
TrustNode ArithPreprocess::eliminate(TNode n,
std::vector<SkolemLemma>& lems,
bool partialOnly)
{
return d_opElim.eliminate(n, lems, partialOnly);
}
bool ArithPreprocess::reduceAssertion(TNode atom)
{
context::CDHashMap<Node, bool, NodeHashFunction>::const_iterator it =
d_reduced.find(atom);
if (it != d_reduced.end())
{
// already computed
return (*it).second;
}
std::vector<SkolemLemma> lems;
TrustNode tn = eliminate(atom, lems);
for (const SkolemLemma& lem : lems)
{
d_im.trustedLemma(lem.d_lemma, InferenceId::ARITH_PP_ELIM_OPERATORS_LEMMA);
}
if (tn.isNull())
{
// did not reduce
d_reduced[atom] = false;
return false;
}
Assert(tn.getKind() == TrustNodeKind::REWRITE);
// tn is of kind REWRITE, turn this into a LEMMA here
TrustNode tlem = TrustNode::mkTrustLemma(tn.getProven(), tn.getGenerator());
// send the trusted lemma
d_im.trustedLemma(tlem, InferenceId::ARITH_PP_ELIM_OPERATORS);
// mark the atom as reduced
d_reduced[atom] = true;
return true;
}
bool ArithPreprocess::isReduced(TNode atom) const
{
context::CDHashMap<Node, bool, NodeHashFunction>::const_iterator it =
d_reduced.find(atom);
if (it == d_reduced.end())
{
return false;
}
return (*it).second;
}
} // namespace arith
} // namespace theory
} // namespace CVC4
|