hoa: add support for controllable-AP

* doc/spot.bib (perez.19.hoa): New entry.
* spot/parseaut/public.hh: Mention it.
* spot/parseaut/parseaut.yy, spot/parseaut/scanaut.ll: Learn to parse
the controllable-AP header.
* spot/twaalgos/hoa.cc: Print it.
* tests/core/ltlsynt.test, tests/core/parseaut.test,
tests/core/readsave.test, tests/python/_synthesis.ipynb,
tests/python/except.py, tests/python/games.ipynb,
tests/python/mealy.py, tests/python/synthesis.py: Adjust or augment
test cases.
This commit is contained in:
Alexandre Duret-Lutz 2022-01-03 18:04:29 +01:00
parent 7cefe30d97
commit 8c33f959a3
14 changed files with 134 additions and 15 deletions

4
NEWS
View file

@ -18,6 +18,10 @@ New in spot 2.10.2.dev (not yet released)
- sbacc() learned to take the "original-classes" property into
account and preserve it.
- The HOA parser and printer learned to map the synthesis-outputs
property of Spot to the controllable-AP header for the Extended
HOA format used in SyntComp. https://arxiv.org/abs/1912.05793
Bugs fixed:
- On automata where the absence of color is not rejecting

View file

@ -726,6 +726,15 @@
doi = {10.1007/978-3-540-73370-6_17}
}
@Misc{ perez.19.hoa,
author = {Guillermo A. P{\'{e}}rez},
title = {The Extended {HOA} Format for Synthesis},
howpublished = {ArXiv},
month = {dec},
year = {2019},
url = {http://arxiv.org/abs/1912.05793}
}
@InProceedings{ piterman.06.vmcai,
author = {Nir Piterman and Amir Pnueli and Yaniv Sa'ar},
editor = {E. Allen Emerson and Kedar S. Namjoshi"},

View file

@ -1,5 +1,5 @@
/* -*- coding: utf-8 -*-
** Copyright (C) 2014-2021 Laboratoire de Recherche et Développement
** Copyright (C) 2014-2022 Laboratoire de Recherche et Développement
** de l'Epita (LRDE).
**
** This file is part of Spot, a model checking library.
@ -97,6 +97,10 @@ extern "C" int strverscmp(const char *s1, const char *s2);
named_tgba_t* namer = nullptr;
spot::acc_mapper_int* acc_mapper = nullptr;
std::vector<int> ap;
std::vector<int> controllable_ap;
bool has_controllable_ap = false;
std::vector<spot::location> controllable_ap_loc;
spot::location controllable_aps_loc;
std::vector<bdd> guards;
std::vector<bdd>::const_iterator cur_guard;
// If "Alias: ..." occurs before "AP: ..." in the HOA format we
@ -233,6 +237,7 @@ extern "C" int strverscmp(const char *s1, const char *s2);
%token ALIAS "Alias:"
%token ACCEPTANCE "Acceptance:"
%token ACCNAME "acc-name:"
%token CONTROLLABLE_AP "controllable-AP:"
%token TOOL "tool:"
%token NAME "name:"
%token PROPERTIES "properties:"
@ -404,6 +409,37 @@ header: format-version header-items
for (auto& p: res.alias)
p.second = bddtrue;
}
if (res.has_controllable_ap)
{
if (!res.ignore_more_ap && !res.controllable_ap.empty())
{
error(res.controllable_aps_loc,
"controllable-AP without AP declaration");
}
else
{
bdd cont = bddtrue;
unsigned n = res.controllable_ap.size();
unsigned maxap = res.ap.size();
for (unsigned i = 0; i < n; ++i)
{
unsigned c = res.controllable_ap[i];
if (c >= maxap)
{
error(res.controllable_ap_loc[i],
"controllable AP number is larger than"
" the number of APs...");
error(res.ap_loc, "... declared here.");
}
else
{
cont &= bdd_ithvar(res.ap[c]);
}
}
res.aut_or_ks->set_named_prop("synthesis-outputs",
new bdd(cont));
}
}
// Process properties.
{
auto explicit_labels = res.prop_is_true("explicit-labels");
@ -683,6 +719,13 @@ version: IDENTIFIER
format-version: "HOA:" { res.h->loc = @1; } version
controllable-aps: %empty
| controllable-aps INT
{
res.controllable_ap.push_back($2);
res.controllable_ap_loc.push_back(@2);
}
aps: "AP:" INT
{
if (res.ignore_more_ap)
@ -766,6 +809,11 @@ header-item: "States:" INT
res.start.emplace_back(@$, std::vector<unsigned>{$2});
}
| aps
| "controllable-AP:" controllable-aps
{
res.controllable_aps_loc = @1;
res.has_controllable_ap = true;
}
| "Alias:" ANAME { res.in_alias=true; } label-expr
{
res.in_alias = false;

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013, 2014, 2015, 2016, 2017 Laboratoire de Recherche et
// Copyright (C) 2013, 2014, 2015, 2016, 2017, 2022 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -117,6 +117,12 @@ namespace spot
/// tool that produce Büchi automata in the form of a neverclaim,
/// but is not understood by this parser, please report it to
/// spot@lrde.epita.fr.
///
/// The parser for HOA recognize a few extensions. It maps the
/// `controlled-AP:` header \cite perez.19.hoa to the
/// `synthesis-output` property of Spot. It also maps
/// `spot.highlight.edges:`, `spot.highlight.states:`, and
/// `spot.state-player:` to the associated automata properties.
class SPOT_API automaton_stream_parser final
{
spot::location last_loc;

View file

@ -1,5 +1,5 @@
/* -*- coding: utf-8 -*-
** Copyright (C) 2014-2018, 2020, 2021 Laboratoire de Recherche et Développement
** Copyright (C) 2014-2018, 2020, 2021, 2022 Laboratoire de Recherche et Développement
** de l'Epita (LRDE).
**
** This file is part of Spot, a model checking library.
@ -145,6 +145,7 @@ identifier [[:alpha:]_][[:alnum:]_.-]*
"Alias:" return token::ALIAS;
"Acceptance:" return token::ACCEPTANCE;
"acc-name:" return token::ACCNAME;
"controllable-AP:" return token::CONTROLLABLE_AP;
"tool:" return token::TOOL;
"name:" return token::NAME;
"properties:" return token::PROPERTIES;

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014-2021 Laboratoire de Recherche et
// Copyright (C) 2014-2022 Laboratoire de Recherche et
// Developpement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -627,6 +627,22 @@ namespace spot
}
os << nl;
}
if (auto synout = aut->get_named_prop<bdd>("synthesis-outputs"))
{
bdd vars = bdd_support(*synout);
os << "controllable-AP:";
while (vars != bddtrue)
{
int v = bdd_var(vars);
vars = bdd_high(vars);
if (auto p = md.ap.find(v); p != md.ap.end())
os << ' ' << p->second;
else
throw std::runtime_error("print_hoa(): synthesis-outputs has "
"unregistered proposition");
}
os << nl;
}
// If we want to output implicit labels, we have to
// fill a vector with all destinations in order.

View file

@ -1,6 +1,6 @@
#! /bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2017, 2019-2021 Laboratoire de Recherche et
# Copyright (C) 2017, 2019-2022 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -373,6 +373,7 @@ AP: 1 "p0"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
controllable-AP: 0
--BODY--
State: 0
[t] 1
@ -394,6 +395,7 @@ AP: 1 "p0"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
controllable-AP: 0
--BODY--
State: 0
[!0] 0
@ -529,6 +531,7 @@ AP: 3 "a" "b" "c"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
controllable-AP: 2
--BODY--
State: 0
[!0&!2 | !1&!2] 0

View file

@ -1,6 +1,6 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2018, 2020-2021 Laboratoire de Recherche et
# Copyright (C) 2014-2018, 2020-2022 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -165,6 +165,7 @@ HOA: v1
AP: 1 "a"
States: 0
AP: 2 "a" "b"
controllable-AP: 3 2
Acceptance: 0 t
--BODY--
--END--
@ -184,7 +185,11 @@ EOF
expecterr input <<EOF
input:4.1-3: ignoring this redeclaration of APs...
input:2.1-5: ... previously declared here.
input:14.15-17: unknown acceptance 'Foo', expected Fin or Inf
input:5.18: controllable AP number is larger than the number of APs...
input:2.1-5: ... declared here.
input:5.20: controllable AP number is larger than the number of APs...
input:2.1-5: ... declared here.
input:15.15-17: unknown acceptance 'Foo', expected Fin or Inf
EOF
cat >input <<EOF
@ -528,6 +533,7 @@ cat >input <<EOF
Acceptance: 2 (Inf(0) & Inf(1))
Alias: @a 0
Alias: @bc 1 & 2
controllable-AP: 2
--BODY--
State: 0
[!@a & !@bc] 0
@ -564,8 +570,9 @@ input:11.17-25: ... declaration of state-based acceptance.
input:16.12-14: unknown alias @bc
input:17.11-13: unknown alias @bc
input:26.18: atomic proposition used in Alias without AP declaration
input:40.16: AP number is larger than the number of APs...
input:41.1-3: ... declared here
input:27.3-18: controllable-AP without AP declaration
input:41.16: AP number is larger than the number of APs...
input:42.1-3: ... declared here
EOF
cat >input <<EOF

View file

@ -1,6 +1,6 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2009, 2010, 2012, 2014-2021 Laboratoire de
# Copyright (C) 2009, 2010, 2012, 2014-2022 Laboratoire de
# Recherche et Développement de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -34,6 +34,7 @@ AP: 3 "a" "b" "F\\G"
acc-name: generalized-Buchi 2
Acceptance: 2 Inf(0)&Inf(1)
properties: trans-labels explicit-labels state-acc deterministic
controllable-AP: 0 2
--BODY--
State: 0 {0 1}
[0&!1] 1
@ -66,6 +67,7 @@ AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
controllable-AP: /* empty */
--BODY--
State: 0
[0&1] 1 {0}
@ -86,6 +88,7 @@ AP: 2 "a" "b"
acc-name: Buchi
Acceptance: 1 Inf(0)
properties: trans-labels explicit-labels trans-acc
controllable-AP:
--BODY--
State: 0
[!1] 1

View file

@ -63,6 +63,7 @@
"acc-name: all\n",
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[!0&!1] 1\n",
@ -101,6 +102,7 @@
"acc-name: all\n",
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[!0&!1] 1\n",
@ -140,6 +142,7 @@
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"spot-state-player: 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[!0&!1] 7\n",
@ -206,6 +209,7 @@
"acc-name: all\n",
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[0&1&!2] 1\n",
@ -225,6 +229,7 @@
"acc-name: all\n",
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[0&1&!2] 1\n",
@ -245,6 +250,7 @@
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"spot-state-player: 0 0 1 1 1 1\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[0&1] 2\n",
@ -273,6 +279,7 @@
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"spot-state-player: 0 0 1 1 1 1\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[0] 2\n",
@ -296,6 +303,7 @@
"acc-name: all\n",
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[0&2] 0\n",
@ -312,6 +320,7 @@
"Acceptance: 0 t\n",
"properties: trans-labels explicit-labels state-acc deterministic\n",
"spot-state-player: 0 0 1 1 1 1\n",
"controllable-AP: 2\n",
"--BODY--\n",
"State: 0\n",
"[0] 2\n",

View file

@ -1,5 +1,5 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2018-2021 Laboratoire de Recherche et Développement de
# Copyright (C) 2018-2022 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -278,3 +278,14 @@ except OverflowError as e:
assert "reversed" in str(e)
else:
report_missing_exception()
a = spot.translate("a")
b = spot.translate("b")
spot.set_synthesis_outputs(a, b.ap_vars())
try:
a.to_str()
except RuntimeError as e:
se = str(e)
assert "synthesis-outputs" in se
assert "unregistered proposition" in se

View file

@ -972,6 +972,7 @@
"properties: trans-labels explicit-labels trans-acc colored complete\n",
"properties: deterministic\n",
"spot-state-player: 0 0 0 0 0 1 1 1 1 1 1 1\n",
"controllable-AP: 0\n",
"--BODY--\n",
"State: 0\n",
"[!1] 5 {1}\n",

View file

@ -1,6 +1,6 @@
#!/usr/bin/python3
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2021 Laboratoire de Recherche et Développement de
# Copyright (C) 2021, 2022 Laboratoire de Recherche et Développement de
# l'EPITA.
#
# This file is part of Spot, a model checking library.
@ -556,6 +556,7 @@ AP: 2 "a" "b"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
controllable-AP: 1
--BODY--
State: 0
[0&1] 0
@ -596,6 +597,7 @@ AP: 2 "a" "b"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
controllable-AP: 1
--BODY--
State: 0
[!0&!1] 1
@ -607,5 +609,3 @@ State: 1
res = spot.reduce_mealy(aut, True)
assert res.to_str() == exp

View file

@ -1,5 +1,5 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2021 Laboratoire de Recherche et Développement
# Copyright (C) 2021, 2022 Laboratoire de Recherche et Développement
# de l'Epita
#
# This file is part of Spot, a model checking library.
@ -38,6 +38,7 @@ Acceptance: 6 Inf(5) | (Fin(4) & (Inf(3) | (Fin(2) & (Inf(1) | Fin(0)))))
properties: trans-labels explicit-labels state-acc colored complete
properties: deterministic
spot-state-player: 0 1 1
controllable-AP:
--BODY--
State: 0 {1}
[!0] 1