Commit 066133b8 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

tl: implement relabel_apply()

* spot/tl/relabel.hh, spot/tl/relabel.cc: Here.
* NEWS: Mention it.
* tests/python/relabel.py: Use it.
parent e325289a
......@@ -59,6 +59,9 @@ New in spot 2.7.4.dev (not yet released)
{a:{[*i..j];b}}. The formula::sugar_delay() function implement
this SVA operator in terms of the existing PSL operators.
- spot::relabel_apply() make it easier to reverse the effect
of spot::relabel() or spot::relabel_bse() on formula.
New in spot 2.7.4 (2019-04-27)
Bugs fixed:
......
// -*- coding: utf-8 -*-
// Copyright (C) 2012-2016, 2018 Laboratoire de Recherche et
// Copyright (C) 2012-2016, 2018-2019 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -482,4 +482,17 @@ namespace spot
bse_relabeler rel(gen, c, m);
return rel.visit(f);
}
formula
relabel_apply(formula f, relabeling_map* m)
{
if (f.is(op::ap))
{
auto i = m->find(f);
if (i != m->end())
return i->second;
}
return f.map(relabel_apply, m);
}
}
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2015 Laboratoire de Recherche et
// Copyright (C) 2012, 2013, 2015, 2019 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -48,4 +48,13 @@ namespace spot
SPOT_API
formula relabel_bse(formula f, relabeling_style style,
relabeling_map* m = nullptr);
/// \ingroup tl_rewriting
/// \brief Replace atomic propositions of \a f by subformulas
/// specified in \a m.
///
/// Atomic proposition that do not appear in \a m are not
/// replaced.
SPOT_API
formula relabel_apply(formula f, relabeling_map* m);
}
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2015, 2017, 2018 Laboratoire de Recherche et Développement
# Copyright (C) 2015, 2017-2019 Laboratoire de Recherche et Développement
# de l'Epita
#
# This file is part of Spot, a model checking library.
......@@ -31,6 +31,8 @@ assert(res == """#define p0 a & b
#define p1 c
GFp0 -> (FGp0 & Gp1)""")
h = spot.relabel_apply(g, m)
assert h == f
autg = g.translate()
spot.relabel_here(autg, m)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment