ltlcross, ltldo: add a --relabel option

* bin/common_trans.cc, bin/common_trans.hh: Add the --relabel option.
* bin/ltlcross.cc, bin/ltldo.cc: Implement it.
* doc/org/ltldo.org, NEWS: Document it.
* tests/core/ltl3ba.test: Test it.
This commit is contained in:
Alexandre Duret-Lutz 2017-01-13 21:19:17 +01:00
parent b0ba6190b7
commit 43520a3e87
7 changed files with 48 additions and 10 deletions

View file

@ -622,6 +622,7 @@ exec_with_timeout(const char* cmd)
enum {
OPT_LIST = 1,
OPT_RELABEL = 2,
};
static const argp_option options[] =
{
@ -632,6 +633,8 @@ static const argp_option options[] =
{ "timeout", 'T', "NUMBER", 0, "kill translators after NUMBER seconds", 0 },
{ "list-shorthands", OPT_LIST, nullptr, 0,
"list availabled shorthands to use in COMMANDFMT", 0},
{ "relabel", OPT_RELABEL, nullptr, 0,
"always relabel atomic propositions before calling any translator", 0 },
/**************************************************/
{ nullptr, 0, nullptr, 0,
"COMMANDFMT should specify input and output arguments using the "
@ -649,7 +652,8 @@ static const argp_option options[] =
"If either %l, %L, or %T are used, any input formula that does "
"not use LBT-style atomic propositions (i.e. p0, p1, ...) will be "
"relabeled automatically. Likewise if %s or %S are used with "
"atomic proposition that compatible with Spin's syntax.\n"
"atomic proposition that compatible with Spin's syntax. You can "
"force this relabeling to always occur with option --relabel.\n"
"The sequences %f,%s,%l,%w,%F,%S,%L,%W can optionally be \"infixed\""
" by a bracketed sequence of operators to unabbreviate before outputing"
" the formula. For instance %[MW]f will rewrite operators M and W"
@ -660,6 +664,8 @@ static const argp_option options[] =
{ nullptr, 0, nullptr, 0, nullptr, 0 }
};
bool opt_relabel = false;
static int parse_opt_trans(int key, char* arg, struct argp_state*)
{
switch (key)
@ -677,6 +683,9 @@ static int parse_opt_trans(int key, char* arg, struct argp_state*)
case OPT_LIST:
show_shorthands();
exit(0);
case OPT_RELABEL:
opt_relabel = true;
break;
default:
return ARGP_ERR_UNKNOWN;
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015, 2016 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// Copyright (C) 2015, 2016, 2017 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -29,6 +29,7 @@
extern const struct argp trans_argp;
extern bool opt_relabel;
struct translator_spec
{

View file

@ -992,10 +992,12 @@ namespace
{
static unsigned round = 0;
// If we need LBT atomic proposition in any of the input or
// output, relabel the formula.
if ((!f.has_lbt_atomic_props() &&
(runner.has('l') || runner.has('L') || runner.has('T')))
if (opt_relabel
// If we need LBT atomic proposition in any of the input or
// output, relabel the formula.
|| (!f.has_lbt_atomic_props() &&
(runner.has('l') || runner.has('L') || runner.has('T')))
// Likewise for Spin
|| (!f.has_spin_atomic_props() &&
(runner.has('s') || runner.has('S'))))
f = spot::relabel(f, spot::Pnn);

View file

@ -299,8 +299,9 @@ namespace
// If atomic propositions are incompatible with one of the
// output, relabel the formula.
if ((!f.has_lbt_atomic_props() &&
(runner.has('l') || runner.has('L') || runner.has('T')))
if (opt_relabel
|| (!f.has_lbt_atomic_props() &&
(runner.has('l') || runner.has('L') || runner.has('T')))
|| (!f.has_spin_atomic_props() &&
(runner.has('s') || runner.has('S'))))
{