Commit 50c0f880 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

Inf(i)|Inf(j) -> Inf(k) and Fin(i)&Fin(j) -> Fin(k)

Implement those rules in simplify_acceptance_here().

* NEWS: Mention the change.
* spot/twa/acc.cc,
spot/twa/acc.hh (acc_cond::acc_code::used_once_sets): New method.
* spot/twaalgos/cleanacc.cc, spot/twaalgos/cleanacc.hh:
Implement the above rule.
* tests/core/remfin.test: Adjust expected results.
* tests/python/simplacc.py: New file.
* tests/Makefile.am: Add it.
parent 5dc6da0b
......@@ -61,6 +61,13 @@ New in spot 2.8.5.dev (not yet released)
degeneralization to get rid of conjunction of Inf terms in
acceptance conditions.
- simplify_acceptance_here() and simplify_acceptance() learned to
simplify subformulas like Fin(i)&Fin(j) or Inf(i)|Inf(j), or some
more complex variants of those. If i us uniquely used in the
acceptance condition these become respectively Fin(i) or Inf(i),
and the automaton is adjusted to that i also appears where j
appeared.
New in spot 2.8.5 (2020-01-04)
Bugs fixed:
......
// -*- coding: utf-8 -*-
// Copyright (C) 2015-2019 Laboratoire de Recherche et Développement
// Copyright (C) 2015-2020 Laboratoire de Recherche et Développement
// de l'Epita.
//
// This file is part of Spot, a model checking library.
......@@ -2340,6 +2340,7 @@ namespace spot
std::swap(c, *this);
}
int acc_cond::acc_code::fin_one() const
{
if (empty() || is_f())
......@@ -2398,4 +2399,34 @@ namespace spot
while (pos >= &front());
return res;
}
acc_cond::mark_t acc_cond::acc_code::used_once_sets() const
{
mark_t seen = {};
mark_t dups = {};
if (empty())
return {};
const acc_cond::acc_word* pos = &back();
do
{
switch (pos->sub.op)
{
case acc_cond::acc_op::And:
case acc_cond::acc_op::Or:
--pos;
break;
case acc_cond::acc_op::Inf:
case acc_cond::acc_op::InfNeg:
case acc_cond::acc_op::FinNeg:
case acc_cond::acc_op::Fin:
auto m = pos[-1].mark;
pos -= 2;
dups |= m & seen;
seen |= m;
break;
}
}
while (pos >= &front());
return seen - dups;
}
}
// -*- coding: utf-8 -*-
// Copyright (C) 2014-2019 Laboratoire de Recherche et Développement
// Copyright (C) 2014-2020 Laboratoire de Recherche et Développement
// de l'Epita.
//
// This file is part of Spot, a model checking library.
......@@ -1199,7 +1199,7 @@ namespace spot
///
/// If multiple unit-Fin appear as unit-clauses, the set of
/// those will be returned. For instance applied to
/// `Fin(0)&Fin(1)&(Inf(2)|Fin(3))``, this will return `{0,1}`.
/// `Fin(0)&Fin(1)&(Inf(2)|Fin(3))`, this will return `{0,1}`.
mark_t fin_unit() const;
/// \brief Return one acceptance set i that appear as `Fin(i)`
......@@ -1286,6 +1286,14 @@ namespace spot
/// \brief Return the set of sets appearing in the condition.
acc_cond::mark_t used_sets() const;
/// \brief Return the sets that appears only once in the
/// acceptance.
///
/// For instance if the condition is
/// `Fin(0)&(Inf(1)|(Fin(1)&Inf(2)))`, this returns `{0,2}`,
/// because set `1` is used more than once.
mark_t used_once_sets() const;
/// \brief Return the sets used as Inf or Fin in the acceptance condition
std::pair<acc_cond::mark_t, acc_cond::mark_t> used_inf_fin_sets() const;
......
This diff is collapsed.
// -*- coding: utf-8 -*-
// Copyright (C) 2015, 2017-2019 Laboratoire de Recherche et
// Copyright (C) 2015, 2017-2020 Laboratoire de Recherche et
// Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
......@@ -57,6 +57,11 @@ namespace spot
/// - `Fin(i) | Inf(j) = Inf(j)`
/// - `Inf(i) | Inf(j) = t`
/// - `Fin(i) | Inf(i) = t`
/// And also merge terms like `Inf(i)|Inf(j)` or `Fin(i)&Fin(j)`
/// provided at least i or j is used uniquely in the formula.
/// (for instance if i is unique, `Inf(i)|Inf(j)` is rewritten
/// as `Inf(i)`, and `i` is added on all transitions where `j` is present
/// in the automaton.)
///
/// simplify_acceptance_here() works in place, simplify_acceptance()
/// returns a new automaton that has been simplified.
......
## -*- coding: utf-8 -*-
## Copyright (C) 2009-2019 Laboratoire de Recherche et Développement
## Copyright (C) 2009-2020 Laboratoire de Recherche et Développement
## de l'Epita (LRDE).
## Copyright (C) 2003-2006 Laboratoire d'Informatique de Paris 6
## (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
......@@ -410,6 +409,7 @@ TESTS_python = \
python/semidet.py \
python/setacc.py \
python/setxor.py \
python/simplacc.py \
python/simstate.py \
python/split.py \
python/streett_totgba.py \
......
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2018 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
# Copyright (C) 2015-2018, 2020 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
......@@ -340,7 +339,7 @@ HOA: v1
States: 4
Start: 0
AP: 2 "a" "b"
Acceptance: 5 (Inf(0)&Inf(1)&Inf(4)) | Inf(0) | (Inf(2)&Inf(3))
Acceptance: 4 (Inf(0)&Inf(1)) | Inf(0) | (Inf(2)&Inf(3))
properties: trans-labels explicit-labels trans-acc
--BODY--
State: 0
......@@ -357,7 +356,7 @@ State: 2
[!0&!1] 2 {0}
[!0&!1] 3
State: 3
[!0&!1] 3 {0 1 4}
[!0&!1] 3 {0 1}
--END--
HOA: v1
States: 1
......@@ -402,7 +401,8 @@ HOA: v1
States: 10
Start: 2
AP: 1 "p1"
Acceptance: 2 Inf(1) | Inf(0)
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0
......@@ -410,29 +410,29 @@ State: 0
[!0] 6
[0] 8
[0] 9
State: 1 {0 1}
State: 1
[t] 3
State: 2 {0 1}
State: 2
[0] 1
[!0] 5
State: 3 {0 1}
State: 3
[0] 0
[!0] 6
State: 4 {0 1}
State: 4 {0}
[0] 4
[!0] 6
State: 5 {0 1}
State: 5
[0] 3
[!0] 7
State: 6
[0] 0
[!0] 6
State: 7 {1}
State: 7
[0] 4
[!0] 6
State: 8
[0] 8
State: 9 {1}
State: 9 {0}
[0] 9
--END--
HOA: v1
......@@ -765,7 +765,7 @@ acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels state-acc
--BODY--
State: 0 {0}
State: 0
[!0&1] 5
[!0&1] 7
State: 1
......
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2020 Laboratoire de Recherche et Développement de l'Epita
# (LRDE).
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import spot
auts = list(spot.automata("""
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 2 Inf(0) | Inf(1) --BODY--
State: 0 [1] 0 [0] 1 {0} State: 1 [0] 1 [1] 0 {1} --END--
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 2 (Inf(0) | Inf(1)) &
Fin(0) --BODY-- State: 0 [1] 0 [0] 1 {0} State: 1 [0] 1 [1] 0 {1} --END--
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 3 (Inf(0) | Inf(1)) &
(Fin(0) | Inf(2)) --BODY-- State: 0 [1] 0 [0] 1 {0} State: 1 [0] 1 {2} [1] 0
{1} --END--
HOA: v1 States: 2 Start: 0 AP: 2 "a" "b" Acceptance: 4 (Inf(0) |
(Inf(1)&(Inf(3)|Fin(2)))) --BODY-- State: 0 [1] 0 {3} [0] 1 {0} State: 1 [0] 1
{2} [1] 0 {1} --END--
"""))
res = []
for a in auts:
b = spot.simplify_acceptance(a)
assert b.equivalent_to(a)
res.append(str(b.get_acceptance()))
a.set_acceptance(a.num_sets(), a.get_acceptance().complement())
b = spot.simplify_acceptance(a)
assert b.equivalent_to(a)
res.append(str(b.get_acceptance()))
assert res == ['Inf(0)',
'Fin(0)',
'Inf(1) & Fin(0)',
'Fin(1) | Inf(0)',
'Inf(1) & (Fin(0) | Inf(2))',
'Fin(1) | (Fin(2) & Inf(0))',
'(Fin(1) | Inf(2)) & Inf(0)',
'Fin(0) | (Fin(2) & Inf(1))']
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