3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 09:34:08 +00:00

handle case where lower bound is above upper

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-09-20 09:54:18 -07:00
parent b506e45845
commit 4101652747
2 changed files with 5 additions and 4 deletions

View file

@ -1824,6 +1824,10 @@ br_status seq_rewriter::mk_re_loop(func_decl* f, unsigned num_args, expr* const*
expr* a = nullptr;
switch (num_args) {
case 1:
if (f->get_num_parameters() == 2 && f->get_parameter(0).get_int() > f->get_parameter(1).get_int()) {
result = m_util.re.mk_loop(args[0], f->get_parameter(1).get_int(), f->get_parameter(1).get_int());
return BR_REWRITE1;
}
// (loop (loop a lo hi) lo2 hi2) = (loop lo*lo2 hi*hi2)
if (m_util.re.is_loop(args[0], a, lo, hi) && f->get_num_parameters() == 2) {
result = m_util.re.mk_loop(a, f->get_parameter(0).get_int() * lo, f->get_parameter(1).get_int() * hi);
@ -1864,7 +1868,7 @@ br_status seq_rewriter::mk_re_loop(func_decl* f, unsigned num_args, expr* const*
break;
case 3:
if (m_autil.is_numeral(args[1], n1) && n1.is_unsigned() &&
m_autil.is_numeral(args[2], n2) && n2.is_unsigned() && n1 <= n2) {
m_autil.is_numeral(args[2], n2) && n2.is_unsigned()) {
result = m_util.re.mk_loop(args[0], n1.get_unsigned(), n2.get_unsigned());
return BR_REWRITE1;
}

View file

@ -747,9 +747,6 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters,
if (num_parameters == 0 || num_parameters > 2 || !parameters[0].is_int() || (num_parameters == 2 && !parameters[1].is_int())) {
m.raise_exception("Expecting two numeral parameters to function re-loop");
}
if (num_parameters == 2 && parameters[0].get_int() > parameters[1].get_int()) {
m.raise_exception("Lower bound cannot be higher than upper bound in loop specfication");
}
return m.mk_func_decl(m_sigs[k]->m_name, arity, domain, rng, func_decl_info(m_family_id, k, num_parameters, parameters));
case 2:
if (m_re != domain[0] || !arith_util(m).is_int(domain[1])) {