python: better support for explicit Kripke
Part of issue #376, reported by Hashim Ali. * python/spot/impl.i: Add bindings for kripke_graph. * python/spot/__init__.py (automaton): Add a want_kripke option. * spot/kripke/kripkegraph.hh: Honnor the "state-names" property when displaying states. * spot/twaalgos/hoa.cc: Preserve names of Kripke states. * tests/python/ltsmin-dve.ipynb: Illustrate all the above. * NEWS: Mention those changes. * THANKS: Add Hashim.
This commit is contained in:
parent
a86925e20e
commit
f26dd904ff
7 changed files with 393 additions and 33 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2011-2018 Laboratoire de Recherche et Développement de
|
||||
// Copyright (C) 2011-2019 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE)
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -239,9 +239,11 @@ namespace spot
|
|||
|
||||
std::string format_state(unsigned n) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
auto named = get_named_prop<std::vector<std::string>>("state-names");
|
||||
if (named && n < named->size())
|
||||
return (*named)[n];
|
||||
|
||||
return std::to_string(n);
|
||||
}
|
||||
|
||||
virtual std::string format_state(const state* st) const override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2014-2018 Laboratoire de Recherche et
|
||||
// Copyright (C) 2014-2019 Laboratoire de Recherche et
|
||||
// Developpement de l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
|
|
@ -304,6 +304,9 @@ namespace spot
|
|||
case 'k':
|
||||
state_labels = true;
|
||||
break;
|
||||
case 'K':
|
||||
state_labels = false;
|
||||
break;
|
||||
case 'l':
|
||||
newline = false;
|
||||
break;
|
||||
|
|
@ -732,14 +735,12 @@ namespace spot
|
|||
const const_twa_ptr& aut,
|
||||
const char* opt)
|
||||
{
|
||||
|
||||
auto a = std::dynamic_pointer_cast<const twa_graph>(aut);
|
||||
if (!a)
|
||||
a = make_twa_graph(aut, twa::prop_set::all());
|
||||
|
||||
bool preserve_names = false;
|
||||
// for Kripke structures, automatically append "k" to the options.
|
||||
// (Unless "K" was given.)
|
||||
char* tmpopt = nullptr;
|
||||
if (std::dynamic_pointer_cast<const fair_kripke>(aut))
|
||||
if (std::dynamic_pointer_cast<const fair_kripke>(aut) &&
|
||||
(!opt || (strchr(opt, 'K') == nullptr)))
|
||||
{
|
||||
unsigned n = opt ? strlen(opt) : 0;
|
||||
tmpopt = new char[n + 2];
|
||||
|
|
@ -747,7 +748,13 @@ namespace spot
|
|||
strcpy(tmpopt, opt);
|
||||
tmpopt[n] = 'k';
|
||||
tmpopt[n + 1] = 0;
|
||||
preserve_names = true;
|
||||
}
|
||||
|
||||
auto a = std::dynamic_pointer_cast<const twa_graph>(aut);
|
||||
if (!a)
|
||||
a = make_twa_graph(aut, twa::prop_set::all(), preserve_names);
|
||||
|
||||
print_hoa(os, a, tmpopt ? tmpopt : opt);
|
||||
delete[] tmpopt;
|
||||
return os;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue