From: Andrew Reynolds Date: Wed, 14 Apr 2021 22:10:09 +0000 (-0500) Subject: Fix type rule for relations join image (#6349) X-Git-Tag: cvc5-1.0.0~1899 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d79f73a8dffa7f16b1763a5949bd483bec4c333;p=cvc5.git Fix type rule for relations join image (#6349) The join image type rule restricted that an argument was a constant. This is a logic restriction that should not be a part of the type checker. This is required for not throwing type checking exceptions during proof conversion to LFSC. --- diff --git a/src/theory/sets/theory_sets_private.cpp b/src/theory/sets/theory_sets_private.cpp index eea90da41..034af2848 100644 --- a/src/theory/sets/theory_sets_private.cpp +++ b/src/theory/sets/theory_sets_private.cpp @@ -16,6 +16,7 @@ #include "theory/sets/theory_sets_private.h" #include +#include #include "expr/emptyset.h" #include "expr/node_algorithm.h" @@ -1279,6 +1280,27 @@ void TheorySetsPrivate::preRegisterTerm(TNode node) d_equalityEngine->addTriggerPredicate(node); } break; + case kind::JOIN_IMAGE: + { + // these are logic exceptions, not type checking exceptions + if (node[1].getKind() != kind::CONST_RATIONAL) + { + throw LogicException( + "JoinImage cardinality constraint must be a constant"); + } + cvc5::Rational r(INT_MAX); + if (node[1].getConst() > r) + { + throw LogicException( + "JoinImage Exceeded INT_MAX in cardinality constraint"); + } + if (node[1].getConst().getNumerator().getSignedInt() < 0) + { + throw LogicException( + "JoinImage cardinality constraint must be non-negative"); + } + } + break; default: d_equalityEngine->addTerm(node); break; } } diff --git a/src/theory/sets/theory_sets_type_rules.h b/src/theory/sets/theory_sets_type_rules.h index ca89728d6..94e18dc64 100644 --- a/src/theory/sets/theory_sets_type_rules.h +++ b/src/theory/sets/theory_sets_type_rules.h @@ -385,19 +385,6 @@ struct JoinImageTypeRule { throw TypeCheckingExceptionPrivate( n, " JoinImage cardinality constraint must be integer"); } - if (n[1].getKind() != kind::CONST_RATIONAL) { - throw TypeCheckingExceptionPrivate( - n, " JoinImage cardinality constraint must be a constant"); - } - cvc5::Rational r(INT_MAX); - if (n[1].getConst() > r) { - throw TypeCheckingExceptionPrivate( - n, " JoinImage Exceeded INT_MAX in cardinality constraint"); - } - if (n[1].getConst().getNumerator().getSignedInt() < 0) { - throw TypeCheckingExceptionPrivate( - n, " JoinImage cardinality constraint must be non-negative"); - } std::vector newTupleTypes; newTupleTypes.push_back(tupleTypes[0]); return nodeManager->mkSetType(nodeManager->mkTupleType(newTupleTypes));