1 /******************************************************************************
2 * Top contributors (to current version):
5 * This file is part of the cvc5 project.
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 * ****************************************************************************
13 * Implementation of arrays proof checker.
16 #include "theory/arrays/proof_checker.h"
17 #include "expr/skolem_manager.h"
18 #include "theory/arrays/skolem_cache.h"
19 #include "theory/rewriter.h"
25 void ArraysProofRuleChecker::registerTo(ProofChecker
* pc
)
27 pc
->registerChecker(PfRule::ARRAYS_READ_OVER_WRITE
, this);
28 pc
->registerChecker(PfRule::ARRAYS_READ_OVER_WRITE_CONTRA
, this);
29 pc
->registerChecker(PfRule::ARRAYS_READ_OVER_WRITE_1
, this);
30 pc
->registerChecker(PfRule::ARRAYS_EXT
, this);
32 pc
->registerTrustedChecker(PfRule::ARRAYS_TRUST
, this, 2);
35 Node
ArraysProofRuleChecker::checkInternal(PfRule id
,
36 const std::vector
<Node
>& children
,
37 const std::vector
<Node
>& args
)
39 NodeManager
* nm
= NodeManager::currentNM();
40 if (id
== PfRule::ARRAYS_READ_OVER_WRITE
)
42 Assert(children
.size() == 1);
43 Assert(args
.size() == 1);
44 Node ideq
= children
[0];
45 if (ideq
.getKind() != kind::NOT
|| ideq
[0].getKind() != kind::EQUAL
)
50 if (lhs
.getKind() != kind::SELECT
|| lhs
[0].getKind() != kind::STORE
51 || lhs
[0][1] != ideq
[0][0])
55 Node rhs
= nm
->mkNode(kind::SELECT
, lhs
[0][0], ideq
[0][1]);
56 return lhs
.eqNode(rhs
);
58 else if (id
== PfRule::ARRAYS_READ_OVER_WRITE_CONTRA
)
60 Assert(children
.size() == 1);
62 Node adeq
= children
[0];
63 if (adeq
.getKind() != kind::NOT
|| adeq
[0].getKind() != kind::EQUAL
)
67 Node lhs
= adeq
[0][0];
68 Node rhs
= adeq
[0][1];
69 if (lhs
.getKind() != kind::SELECT
|| lhs
[0].getKind() != kind::STORE
70 || rhs
.getKind() != kind::SELECT
|| lhs
[1] != rhs
[1])
74 return lhs
[1].eqNode(lhs
[0][1]);
76 if (id
== PfRule::ARRAYS_READ_OVER_WRITE_1
)
78 Assert(children
.empty());
79 Assert(args
.size() == 1);
81 if (lhs
.getKind() != kind::SELECT
|| lhs
[0].getKind() != kind::STORE
82 || lhs
[0][1] != lhs
[1])
87 return lhs
.eqNode(rhs
);
89 if (id
== PfRule::ARRAYS_EXT
)
91 Assert(children
.size() == 1);
93 Node adeq
= children
[0];
94 if (adeq
.getKind() != kind::NOT
|| adeq
[0].getKind() != kind::EQUAL
95 || !adeq
[0][0].getType().isArray())
99 Node k
= SkolemCache::getExtIndexSkolem(adeq
);
102 Node as
= nm
->mkNode(kind::SELECT
, a
, k
);
103 Node bs
= nm
->mkNode(kind::SELECT
, b
, k
);
104 return as
.eqNode(bs
).notNode();
106 if (id
== PfRule::ARRAYS_TRUST
)
109 Assert(!args
.empty());
110 Assert(args
[0].getType().isBoolean());
117 } // namespace arrays
118 } // namespace theory