Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/cvc5/cvc5 into pfTrustId
Browse files Browse the repository at this point in the history
  • Loading branch information
ajreynol committed Dec 20, 2024
2 parents 1502035 + 96a35d7 commit 4f05d0a
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 26 deletions.
2 changes: 0 additions & 2 deletions proofs/eo/cpc/theories/BitVectors.eo
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,6 @@
(BitVec m) Int)
)

(declare-const BITVECTOR_EAGER_ATOM (-> Bool Bool))

; internal operators

(declare-const @bit
Expand Down
4 changes: 2 additions & 2 deletions proofs/eo/cpc/theories/Datatypes.eo
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
; disclaimer: This function is not in the SMT-LIB standard.
(declare-const nullable.lift (-> (! Type :var F :implicit) F ($get_type_nullable_lift F)))

; skolems
;SHARED_SELECTOR
; shared selector
(declare-const @shared_selector (-> (! Type :var D) (! Type :var T) Int D T))
33 changes: 21 additions & 12 deletions src/proof/alf/alf_node_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "expr/dtype.h"
#include "expr/dtype_cons.h"
#include "expr/sequence.h"
#include "expr/sort_to_term.h"
#include "printer/smt2/smt2_printer.h"
#include "theory/builtin/generic_op.h"
#include "theory/bv/theory_bv_utils.h"
Expand Down Expand Up @@ -552,22 +553,30 @@ Node AlfNodeConverter::getOperatorOfTerm(Node n, bool reqCast)
else if (k == Kind::APPLY_SELECTOR)
{
// maybe a shared selector
ret = maybeMkSkolemFun(op);
if (!ret.isNull())
if (op.getSkolemId() == SkolemId::SHARED_SELECTOR)
{
return ret;
}
unsigned index = DType::indexOf(op);
const DType& dt = DType::datatypeOf(op);
if (dt.isTuple())
{
indices.push_back(d_nm->mkConstInt(index));
opName << "tuple.select";
std::vector<Node> kindices = op.getSkolemIndices();
opName << "@shared_selector";
indices.push_back(
typeAsNode(kindices[0].getConst<SortToTerm>().getType()));
indices.push_back(
typeAsNode(kindices[1].getConst<SortToTerm>().getType()));
indices.push_back(kindices[2]);
}
else
{
unsigned cindex = DType::cindexOf(op);
opName << dt[cindex][index].getSelector();
unsigned index = DType::indexOf(op);
const DType& dt = DType::datatypeOf(op);
if (dt.isTuple())
{
indices.push_back(d_nm->mkConstInt(index));
opName << "tuple.select";
}
else
{
unsigned cindex = DType::cindexOf(op);
opName << dt[cindex][index].getSelector();
}
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/smt/set_defaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ bool SetDefaults::incompatibleWithProofs(Options& opts,
if (opts.smt.proofMode == options::ProofMode::FULL_STRICT)
{
// symmetry breaking does not have proof support
SET_AND_NOTIFY_VAL_SYM(uf, ufSymmetryBreaker, false, "full strict proofs");
SET_AND_NOTIFY(uf, ufSymmetryBreaker, false, "full strict proofs");
// CEGQI with deltas and infinities is not supported
SET_AND_NOTIFY(quantifiers, cegqiMidpoint, true, "full strict proofs");
SET_AND_NOTIFY(quantifiers, cegqiUseInfInt, false, "full strict proofs");
Expand Down
11 changes: 9 additions & 2 deletions src/theory/datatypes/datatypes_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ Node DatatypesRewriter::rewriteViaRule(ProofRewriteRule id, const Node& n)
Assert(tn.isDatatype());
const DType& dt = tn.getDType();
size_t i = utils::indexOf(n.getOperator());
bool sharedSel = d_opts.datatypes.dtSharedSelectors;
Node ticons = utils::getInstCons(t, dt, i, sharedSel);
// Note that we set shared selectors to false. This proof rule will
// be (unintentionally) unsuccessful when reconstructing proofs of the
// rewriter when using shared selectors.
Node ticons = utils::getInstCons(t, dt, i, false);
return t.eqNode(ticons);
}
case ProofRewriteRule::DT_COLLAPSE_SELECTOR:
Expand All @@ -90,6 +92,11 @@ Node DatatypesRewriter::rewriteViaRule(ProofRewriteRule id, const Node& n)
return Node::null();
}
Node selector = n.getOperator();
// shared selectors are not supported
if (selector.getSkolemId() == SkolemId::SHARED_SELECTOR)
{
return Node::null();
}
size_t constructorIndex = utils::indexOf(n[0].getOperator());
const DType& dt = utils::datatypeOf(selector);
const DTypeConstructor& c = dt[constructorIndex];
Expand Down
5 changes: 2 additions & 3 deletions src/theory/datatypes/proof_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ namespace cvc5::internal {
namespace theory {
namespace datatypes {

DatatypesProofRuleChecker::DatatypesProofRuleChecker(NodeManager* nm,
bool sharedSel)
: ProofRuleChecker(nm), d_sharedSel(sharedSel)
DatatypesProofRuleChecker::DatatypesProofRuleChecker(NodeManager* nm)
: ProofRuleChecker(nm)
{
}

Expand Down
4 changes: 1 addition & 3 deletions src/theory/datatypes/proof_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace datatypes {
class DatatypesProofRuleChecker : public ProofRuleChecker
{
public:
DatatypesProofRuleChecker(NodeManager* nm, bool sharedSel);
DatatypesProofRuleChecker(NodeManager* nm);

/** Register all rules owned by this rule checker into pc. */
void registerTo(ProofChecker* pc) override;
Expand All @@ -40,8 +40,6 @@ class DatatypesProofRuleChecker : public ProofRuleChecker
Node checkInternal(ProofRule id,
const std::vector<Node>& children,
const std::vector<Node>& args) override;
/** Whether we are using shared selectors */
bool d_sharedSel;
};

} // namespace datatypes
Expand Down
2 changes: 1 addition & 1 deletion src/theory/datatypes/theory_datatypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TheoryDatatypes::TheoryDatatypes(Env& env,
d_state(env, valuation),
d_im(env, *this, d_state),
d_notify(d_im, *this),
d_checker(nodeManager(), options().datatypes.dtSharedSelectors),
d_checker(nodeManager()),
d_cpacb(*this)
{
d_true = nodeManager()->mkConst(true);
Expand Down
6 changes: 6 additions & 0 deletions src/theory/quantifiers/term_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class DeqCongProofGenerator : protected EnvObj, public ProofGenerator
CDProof cdp(d_env);
if (a.getOperator() != b.getOperator())
{
// TODO: wishue #158, likely corresponds to a higher-order term
// indexing conflict.
cdp.addTrustedStep(fact, TrustId::QUANTIFIERS_PREPROCESS, {}, {});
return cdp.getProofFor(fact);
}
Expand All @@ -90,6 +92,10 @@ class DeqCongProofGenerator : protected EnvObj, public ProofGenerator
{
cdp.addStep(eq, ProofRule::REFL, {}, {a[i]});
}
else
{
Assert(std::find(assumps.begin(), assumps.end(), eq) != assumps.end());
}
}
cdp.addStep(fact[1], cr, premises, cargs);
std::shared_ptr<ProofNode> pfn = cdp.getProofFor(fact[1]);
Expand Down
3 changes: 3 additions & 0 deletions test/regress/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ set(regress_0_tests
regress0/datatypes/pair-real-bool.smt2
regress0/datatypes/par-updater-type-rule.smt2
regress0/datatypes/parametric-alt-list.cvc.smt2
regress0/datatypes/pf-v2l60078.smt2
regress0/datatypes/proj-issue172.smt2
regress0/datatypes/proj-issue474-app-cons-value.smt2
regress0/datatypes/proj-issue578-clash-pf.smt2
Expand Down Expand Up @@ -1468,6 +1469,7 @@ set(regress_0_tests
regress0/quantifiers/dd_german169_semi_eval.smt2
regress0/quantifiers/dd_spark2014-pat.smt2
regress0/quantifiers/dd_TwoSquares.z3.611901.smt2
regress0/quantifiers/dd_SA10-027-dt-ipc.smt2
regress0/quantifiers/dd.german169-ieval.smt2
regress0/quantifiers/dd.german169-lemma-inp.smt2
regress0/quantifiers/dd.ho-matching-enum.smt2
Expand Down Expand Up @@ -2890,6 +2892,7 @@ set(regress_1_tests
regress1/quantifiers/nra-interleave-inst.smt2
regress1/quantifiers/opisavailable-12.smt2
regress1/quantifiers/parametric-lists.smt2
regress1/quantifiers/pivc-deq-cong.smt2
regress1/quantifiers/pool-decidable-arrays-1.smt2
regress1/quantifiers/pool-example.smt2
regress1/quantifiers/pool-tuple.smt2
Expand Down
6 changes: 6 additions & 0 deletions test/regress/cli/regress0/datatypes/pf-v2l60078.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; EXPECT: unsat
(set-logic QF_DT)
(declare-datatypes ((n 0) (l 0) (t 0)) (((z)) ((ln) (n (r l))) ((f))))
(declare-fun x () l)
(assert (and (not (= ln (r x))) (not ((_ is n) (r x)))))
(check-sat)
1 change: 1 addition & 0 deletions test/regress/cli/regress0/proofs/t3_rw903.smt2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; EXPECT: unsat
; DISABLE-TESTER: unsat-core
; DISABLE-TESTER: lfsc
(set-logic UFNIA)
(declare-fun pow2 (Int) Int)
(declare-fun intor (Int Int Int) Int)
Expand Down
15 changes: 15 additions & 0 deletions test/regress/cli/regress0/quantifiers/dd_SA10-027-dt-ipc.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; EXPECT: unsat
; DISABLE-TESTER: cpc
; Disabled cpc due to congruence on overloaded user functions.
(set-logic ALL)
(declare-sort i 0)
(declare-sort s 0)
(declare-datatypes ((u 0)) (((us (r Bool) (e Int) (c s)))))
(declare-datatypes ((us_ 0)) (((us (c i) (e u)))))
(declare-datatypes ((_r 0)) (((s_ (_s us_)))))
(declare-fun s_ (s) _r)
(declare-fun us (_r) s)
(assert (forall ((x _r)) (= x (s_ (us x)))))
(declare-const n u)
(assert (exists ((x_ us_)) (not (=> (r n) (= (s_ x_) (s_ (c (us false 0 (us (s_ (us (c (_s (s_ (c n)))) n))))))) (forall ((o u)) (or (forall ((x us_)) (or (forall ((o u)) (or (forall ((x us_)) (or (forall ((o u)) (or (forall ((x us_)) (or (exists ((t u)) (= (r o) (= (r o) (r (e (_s (s_ (c t)))))))) (= (s_ x_) (s_ (c (us false 0 (us (s_ (us (c (_s (s_ (c o)))) (us (r (e (_s (s_ (c (us false 0 (us (s_ x_)))))))) (e (e (_s (s_ (c o))))) (us (s_ x_))))))))))))))))))))))))))
(check-sat)
10 changes: 10 additions & 0 deletions test/regress/cli/regress1/quantifiers/pivc-deq-cong.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; COMMAND-LINE: --enum-inst
; EXPECT: unsat
(set-logic ALL)
(declare-fun V () Int)
(declare-fun e () Int)
(declare-fun a2 () (Array Int Int))
(declare-fun a () (Array Int Int))
(declare-fun i () Int)
(assert (and (< i V) (<= 0 i) (forall ((? Int)) (= 1 (select a2 i))) (forall ((? Int)) (= (select a ?) (select a2 ?))) (forall ((? Int)) (forall ((? Int)) (= 1 (select a2 ?)))) (forall ((? Int)) (or (distinct e (select a ?)) (> ? (- i 1)))) (or (and (= 1 V) (exists ((? Int)) (> 1 (select a 0)))) (exists ((? Int)) (and (<= ? i) (= e (select a ?)))))))
(check-sat)

0 comments on commit 4f05d0a

Please sign in to comment.