translate, simplify: limit containment checks of n-ary operators

Fixes #521.

* spot/tl/simplify.cc, spot/tl/simplify.hh,
spot/twaalgos/translate.cc, spot/twaalgos/translate.hh: Add an option
to limit automata-based implication checks of n-ary operators when too
many operands are used.  Defaults to 16.
* bin/spot-x.cc, NEWS, doc/tl/tl.tex: Document it.
* tests/core/bdd.test: Disable the limit for this test.
This commit is contained in:
Alexandre Duret-Lutz 2022-11-15 17:27:10 +01:00
parent f2c65ea557
commit 843c4cdb91
8 changed files with 33 additions and 11 deletions

View file

@ -2507,8 +2507,11 @@ namespace spot
unsigned mos = mo.size();
if ((opt_.synt_impl | opt_.containment_checks)
&& mo.is(op::Or, op::And))
&& mo.is(op::Or, op::And)
&& (opt_.containment_max_ops == 0
|| opt_.containment_max_ops >= mos))
{
bool is_and = mo.is(op::And);
// Do not merge these two loops, as rewritings from the
// second loop could prevent rewritings from the first one
// to trigger.
@ -2520,7 +2523,6 @@ namespace spot
// if fo => !fi, then fi & fo = false
// if !fi => fo, then fi | fo = true
// if !fo => fi, then fi | fo = true
bool is_and = mo.is(op::And);
if (c_->implication_neg(fi, fo, is_and)
|| c_->implication_neg(fo, fi, is_and))
return recurse(is_and ? formula::ff() : formula::tt());
@ -2531,8 +2533,8 @@ namespace spot
formula fo = mo.all_but(i);
// if fi => fo, then fi | fo = fo
// if fo => fi, then fi & fo = fo
if ((mo.is(op::Or) && c_->implication(fi, fo))
|| (mo.is(op::And) && c_->implication(fo, fi)))
if (((!is_and) && c_->implication(fi, fo))
|| (is_and && c_->implication(fo, fi)))
{
// We are about to pick fo, but hold on!
// Maybe we actually have fi <=> fo, in

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011-2017, 2019, 2020 Laboratoire de Recherche et Developpement
// Copyright (C) 2011-2022 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -96,6 +96,9 @@ namespace spot
// If greater than 0, bound the number of states used by automata
// in containment checks.
unsigned containment_max_states = 0;
// If greater than 0, maximal number of terms in a multop to perform
// containment checks on this multop.
unsigned containment_max_ops = 16;
};
// fwd declaration to hide technical details.

View file

@ -62,8 +62,8 @@ namespace spot
gf_guarantee_set_ = true;
}
ltl_split_ = opt->get("ltl-split", 1);
int tls_max_states = opt->get("tls-max-states", 64);
tls_max_states_ = std::max(0, tls_max_states);
tls_max_states_ = std::max(0, opt->get("tls-max-states", 64));
tls_max_ops_ = std::max(0, opt->get("tls-max-ops", 16));
exprop_ = opt->get("exprop", -1);
branchpost_ = opt->get("branch-post", -1);
}
@ -72,6 +72,7 @@ namespace spot
{
tl_simplifier_options options(false, false, false);
options.containment_max_states = tls_max_states_;
options.containment_max_ops = tls_max_ops_;
switch (level_)
{
case High:

View file

@ -155,7 +155,8 @@ namespace spot
bool gf_guarantee_set_ = false;
bool ltl_split_;
int branchpost_ = -1;
unsigned tls_max_states_ = 0;
unsigned tls_max_states_ = 64;
unsigned tls_max_ops_ = 16;
int exprop_;
const option_map* opt_;
};