ltlsynt: detect APs with constant polarity
This implements the first point of issue #529. * spot/tl/apcollect.cc, spot/tl/apcollect.hh (collect_litterals): New function. * bin/ltlsynt.cc: Implement the --polarity option, use collect_litterals() to simplify the specification, finally patch the game, Mealy, or Aiger output. * spot/twaalgos/aiger.cc, spot/twaalgos/aiger.hh: Take a relabeling_map has argument to specify extra APs. * tests/core/ltlsynt.test, tests/core/ltlsynt2.test: Adjust test cases.
This commit is contained in:
parent
abca0f7fd9
commit
202ab92d1d
8 changed files with 378 additions and 76 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2014, 2015, 2018 Laboratoire de Recherche et
|
||||
// Copyright (C) 2012, 2014, 2015, 2018, 2023 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -63,4 +63,72 @@ namespace spot
|
|||
res &= bdd_ithvar(a->register_ap(f));
|
||||
return res;
|
||||
}
|
||||
|
||||
atomic_prop_set collect_litterals(formula f)
|
||||
{
|
||||
atomic_prop_set res;
|
||||
|
||||
// polirity: 0 = negative, 1 = positive, 2 or more = both.
|
||||
auto rec = [&res](formula f, unsigned polarity, auto self)
|
||||
{
|
||||
switch (f.kind())
|
||||
{
|
||||
case op::ff:
|
||||
case op::tt:
|
||||
case op::eword:
|
||||
return;
|
||||
case op::ap:
|
||||
if (polarity != 0)
|
||||
res.insert(f);
|
||||
if (polarity != 1)
|
||||
res.insert(formula::Not(f));
|
||||
return;
|
||||
case op::Not:
|
||||
case op::NegClosure:
|
||||
case op::NegClosureMarked:
|
||||
self(f[0], polarity ^ 1, self);
|
||||
return;
|
||||
case op::Xor:
|
||||
case op::Equiv:
|
||||
self(f[0], 2, self);
|
||||
self(f[1], 2, self);
|
||||
return;
|
||||
case op::Implies:
|
||||
case op::UConcat:
|
||||
self(f[0], polarity ^ 1, self);
|
||||
self(f[1], polarity, self);
|
||||
return;
|
||||
case op::U:
|
||||
case op::R:
|
||||
case op::W:
|
||||
case op::M:
|
||||
case op::EConcat:
|
||||
case op::EConcatMarked:
|
||||
self(f[0], polarity, self);
|
||||
self(f[1], polarity, self);
|
||||
return;
|
||||
case op::X:
|
||||
case op::F:
|
||||
case op::G:
|
||||
case op::Closure:
|
||||
case op::Or:
|
||||
case op::OrRat:
|
||||
case op::And:
|
||||
case op::AndRat:
|
||||
case op::AndNLM:
|
||||
case op::Concat:
|
||||
case op::Fusion:
|
||||
case op::Star:
|
||||
case op::FStar:
|
||||
case op::first_match:
|
||||
case op::strong_X:
|
||||
for (formula c: f)
|
||||
self(c, polarity, self);
|
||||
return;
|
||||
}
|
||||
};
|
||||
rec(f, 1, rec);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et
|
||||
// Copyright (C) 2012, 2013, 2014, 2015, 2023 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -59,5 +59,15 @@ namespace spot
|
|||
SPOT_API bdd
|
||||
atomic_prop_collect_as_bdd(formula f, const twa_ptr& a);
|
||||
|
||||
|
||||
/// \brief Collect the litterals occuring in f
|
||||
///
|
||||
/// This function records each atomic proposition occurring in f
|
||||
/// along with the polarity of its occurrence. For instance if the
|
||||
/// formula is `G(a -> b) & X(!b & c)`, then this will output `{!a,
|
||||
/// b, !b, c}`.
|
||||
SPOT_API
|
||||
atomic_prop_set collect_litterals(formula f);
|
||||
|
||||
/// @}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue