Introduce new ways to split an automaton

The explicit way of splitting suffers if there are
too many input APs, two new ways of splitting
are introduced as well as a heuristic to chose
between them.

* NEWS: update
* spot/twaalgos/synthesis.cc,
spot/twaalgos/synthesis.hh: New fonctions
* bin/ltlsynt.cc: Add corresponding option
* tests/core/gamehoa.test,
tests/core/ltlsynt.test,
tests/python/_partitioned_relabel.ipynb,
tests/python/_synthesis.ipynb,
tests/python/game.py,
tests/python/split.py,
tests/python/synthesis.py: Adjusting and adding test
This commit is contained in:
Philipp Schlehuber 2024-03-03 22:15:27 +01:00
parent 2274308cad
commit 5ddac258e1
11 changed files with 1372 additions and 138 deletions

9
NEWS
View file

@ -86,6 +86,15 @@ New in spot 2.12 (2024-05-16)
Library:
- split_2step has now multiple ways to split for improved performance.
The option can be controlled via the synthesis_info::splittype
- EXPL: explicit splitting of each state as before
- SEMISYM: The outgoing transition of each state are encoded
as a bdd; Works better for larger number of input APs
- FULLYSYM: The automaton is first translated into a
fully symbolic version, then split.
- AUTO: Let the heuristic decide what to do.
- The following new trivial simplifications have been implemented for SEREs:
- f|[+] = [+] if f rejects [*0]
- f|[*] = [*] if f accepts [*0]

View file

@ -63,6 +63,7 @@ enum
OPT_PRINT_HOA,
OPT_REAL,
OPT_SIMPLIFY,
OPT_SPLITTYPE,
OPT_TLSF,
OPT_VERBOSE,
OPT_VERIFY
@ -118,6 +119,9 @@ static const argp_option options[] =
"reduction with output assignment, (sat) SAT-based minimization, "
"(bisim-sat) SAT after bisim, (bwoa-sat) SAT after bwoa. Defaults "
"to 'bwoa'.", 0 },
{ "splittype", OPT_SPLITTYPE, "expl|semisym|fullysym|auto", 0,
"Selects the algorithm to use to transform the automaton into "
"a game graph. Defaults to 'auto'.", 0},
/**************************************************/
{ nullptr, 0, nullptr, 0, "Output options:", 20 },
{ "print-pg", OPT_PRINT, nullptr, 0,
@ -295,6 +299,23 @@ static unsigned simplify_values[] =
};
ARGMATCH_VERIFY(simplify_args, simplify_values);
static const char* const splittype_args[] =
{
"expl",
"semisym",
"fullysym",
"auto",
nullptr
};
static spot::synthesis_info::splittype splittype_values[] =
{
spot::synthesis_info::splittype::EXPL,
spot::synthesis_info::splittype::SEMISYM,
spot::synthesis_info::splittype::FULLYSYM,
spot::synthesis_info::splittype::AUTO,
};
ARGMATCH_VERIFY(splittype_args, splittype_values);
namespace
{
static bool want_game()
@ -909,7 +930,7 @@ namespace
return 2;
}
if (!arena->get_named_prop<std::vector<bool>>("state-player"))
arena = spot::split_2step(arena, true);
arena = spot::split_2step(arena, gi);
else
{
// Check if the game is alternating and fix trivial cases
@ -1127,6 +1148,10 @@ parse_opt(int key, char *arg, struct argp_state *)
gi->minimize_lvl = XARGMATCH("--simplify", arg,
simplify_args, simplify_values);
break;
case OPT_SPLITTYPE:
gi->sp = XARGMATCH("--splittype", arg,
splittype_args, splittype_values);
break;
case OPT_TLSF:
jobs.emplace_back(arg, job_type::TLSF_FILENAME);
break;

File diff suppressed because it is too large Load diff

View file

@ -25,6 +25,71 @@
namespace spot
{
/// \ingroup synthesis
/// \brief Benchmarking data and options for synthesis
struct SPOT_API synthesis_info
{
enum class algo
{
DET_SPLIT=0,
SPLIT_DET,
DPA_SPLIT,
LAR,
LAR_OLD,
ACD,
};
enum class splittype
{
AUTO=0, // Uses a heuristic to choose
EXPL, // Explicit enumerations of inputs
SEMISYM, // Works on one bdd per env state
FULLYSYM // Works on a fully symbolic version of the automaton
};
struct bench_var
{
double total_time = 0.0;
double trans_time = 0.0;
double split_time = 0.0;
double paritize_time = 0.0;
double solve_time = 0.0;
double strat2aut_time = 0.0;
double simplify_strat_time = 0.0;
double aig_time = 0.0;
unsigned nb_states_arena = 0;
unsigned nb_states_arena_env = 0;
unsigned nb_strat_states = 0;
unsigned nb_strat_edges = 0;
unsigned nb_simpl_strat_states = 0;
unsigned nb_simpl_strat_edges = 0;
unsigned nb_latches = 0;
unsigned nb_gates = 0;
bool realizable = false;
};
synthesis_info()
: force_sbacc{false},
s{algo::LAR},
minimize_lvl{2},
sp{splittype::AUTO},
bv{},
verbose_stream{nullptr},
dict(make_bdd_dict())
{
}
bool force_sbacc;
algo s;
int minimize_lvl;
splittype sp;
std::optional<bench_var> bv;
std::ostream* verbose_stream;
option_map opt;
bdd_dict_ptr dict;
};
/// \addtogroup synthesis Reactive Synthesis
/// \ingroup twa_algorithms
@ -51,18 +116,33 @@ namespace spot
/// are treated as inputs
/// \param complete_env Whether the automaton should be complete for the
/// environment, i.e. the player of inputs
/// \param sp Defines which splitting algo to use
/// \note This function also computes the state players
/// \note If the automaton is to be completed, sink states will
/// be added for both env and player if necessary
SPOT_API twa_graph_ptr
split_2step(const const_twa_graph_ptr& aut,
const bdd& output_bdd, bool complete_env = true);
const bdd& output_bdd, bool complete_env = true,
synthesis_info::splittype sp
= synthesis_info::splittype::AUTO);
/// \ingroup synthesis
/// \brief Like split_2step but relying on the named property
/// 'synthesis-outputs'
SPOT_API twa_graph_ptr
split_2step(const const_twa_graph_ptr& aut, bool complete_env = true);
split_2step(const const_twa_graph_ptr& aut, bool complete_env = true,
synthesis_info::splittype sp
= synthesis_info::splittype::AUTO);
/// \ingroup synthesis
/// \brief Like split_2step but allows to fine-tune the splitting
/// via the options set in \a gi, always completes the
/// environment states and relies on the named property to
/// extract the output proposition
SPOT_API twa_graph_ptr
split_2step(const const_twa_graph_ptr& aut,
synthesis_info& gi);
/// \ingroup synthesis
/// \brief the inverse of split_2step
@ -75,60 +155,6 @@ namespace spot
SPOT_API twa_graph_ptr
unsplit_2step(const const_twa_graph_ptr& aut);
/// \ingroup synthesis
/// \brief Benchmarking data and options for synthesis
struct SPOT_API synthesis_info
{
enum class algo
{
DET_SPLIT=0,
SPLIT_DET,
DPA_SPLIT,
LAR,
LAR_OLD,
ACD,
};
struct bench_var
{
double total_time = 0.0;
double trans_time = 0.0;
double split_time = 0.0;
double paritize_time = 0.0;
double solve_time = 0.0;
double strat2aut_time = 0.0;
double simplify_strat_time = 0.0;
double aig_time = 0.0;
unsigned nb_states_arena = 0;
unsigned nb_states_arena_env = 0;
unsigned nb_strat_states = 0;
unsigned nb_strat_edges = 0;
unsigned nb_simpl_strat_states = 0;
unsigned nb_simpl_strat_edges = 0;
unsigned nb_latches = 0;
unsigned nb_gates = 0;
bool realizable = false;
};
synthesis_info()
: force_sbacc{false},
s{algo::LAR},
minimize_lvl{2},
bv{},
verbose_stream{nullptr},
dict(make_bdd_dict())
{
}
bool force_sbacc;
algo s;
int minimize_lvl;
std::optional<bench_var> bv;
std::ostream* verbose_stream;
option_map opt;
bdd_dict_ptr dict;
};
/// \ingroup synthesis
/// \brief Stream algo
SPOT_API std::ostream&

View file

@ -21,11 +21,13 @@
set -x
ltlsynt --ins=a,c --outs=b -f 'GF(a <-> XXXc) <-> GFb' --print-game-hoa >out
ltlsynt --ins=a,c --outs=b -f 'GF(a <-> XXXc) <-> GFb' --print-game-hoa \
--splittype=expl >out
grep spot-state-player: out
autfilt out >out2
diff out out2
ltlsynt --ins=a,c --outs=b -f 'GF(a <-> XXXc) <-> GFb' --print-game-hoa=l >out3
ltlsynt --ins=a,c --outs=b -f 'GF(a <-> XXXc) <-> GFb' --print-game-hoa=l \
--splittype=expl >out3
test 1 = `wc -l < out3`
cmp out out3 && exit 1
autfilt out3 >out2

View file

@ -484,10 +484,22 @@ i3 i3
o0 o0
o1 o1
EOF
ltlsynt -f "G((i0 && i1)<->X(o0)) && G((i2|i3)<->X(o1))" --outs="o0,o1"\
--aiger=isop+ud --algo=lar --decompose=no --simpl=no >out
ltlsynt -f "G((i0 && i1)<->X(o0)) && G((i2|i3)<->X(o1))" --outs="o0,o1" \
--aiger=isop+ud --algo=lar --decompose=no --simpl=no \
--splittype=expl >out
diff out exp
for splitt in expl semisym fullysym auto
do
res=$(ltlsynt -f "G((i0 && i1)<->X(o0)) && G((i2|i3)<->X(o1))" \
--outs="o0,o1" --aiger=isop+ud --algo=lar --decompose=no \
--simpl=no --splittype="$splitt" --realizability)
if [[ "$res" != "REALIZABLE" ]]; then
echo "Expected realizable"
fi
done
cat >exp <<EOF
REALIZABLE
aag 54 4 3 2 47
@ -555,7 +567,8 @@ o0 o0
o1 o1
EOF
ltlsynt -f "G((i0 && i1)<->X(o0)) && G((i2|i3)<->X(o1))" --outs="o0,o1"\
--aiger=isop --algo=lar --decompose=no --simpl=no >out
--aiger=isop --algo=lar --decompose=no --simpl=no \
--splittype=expl >out
diff out exp
@ -590,10 +603,10 @@ o0 o0
o1 o1
EOF
ltlsynt -f "G((i0 && i1)<->X(o0)) && G((i2|i3)<->X(o1))" --outs="o0,o1"\
--aiger=isop+ud --algo=lar --decompose=yes --simpl=no >out
--aiger=isop+ud --algo=lar --decompose=yes --simpl=no --splittype=expl >out
diff out exp
ltlsynt -f "G((i0 && i1)<->X(o0)) && G((i2|i3)<->X(o1))" --outs="o0,o1"\
--aiger=isop+ud --algo=lar --simpl=no >out
--aiger=isop+ud --algo=lar --simpl=no --splittype=expl >out
diff out exp
# Issue #477

View file

@ -203,7 +203,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46fc00> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd837fe10> >"
]
},
"execution_count": 2,
@ -411,7 +411,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46fc00> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd837fe10> >"
]
},
"execution_count": 3,
@ -597,7 +597,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46fc00> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd837fe10> >"
]
},
"execution_count": 4,
@ -782,7 +782,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46dfb0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd8394990> >"
]
},
"metadata": {},
@ -1052,7 +1052,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46dfb0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd8394990> >"
]
},
"execution_count": 5,
@ -1326,7 +1326,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46dfb0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd8394990> >"
]
},
"execution_count": 6,
@ -1537,7 +1537,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46e9d0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd83943c0> >"
]
},
"metadata": {},
@ -1760,7 +1760,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46e9d0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd83943c0> >"
]
},
"execution_count": 7,
@ -2023,7 +2023,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46e9d0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd83943c0> >"
]
},
"execution_count": 8,
@ -2055,7 +2055,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 14,
"id": "296a93d3",
"metadata": {},
"outputs": [
@ -2304,7 +2304,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46f4b0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd8395590> >"
]
},
"metadata": {},
@ -2718,7 +2718,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46eca0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd837fcf0> >"
]
},
"metadata": {},
@ -3312,7 +3312,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46eca0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd837fcf0> >"
]
},
"metadata": {},
@ -3346,7 +3346,7 @@
"display(aut)\n",
"\n",
"# Convert to split mealy machine\n",
"auts = spot.split_2step(aut)\n",
"auts = spot.split_2step(aut, True, spot.synthesis_info.splittype_EXPL)\n",
"print(auts.to_str(\"hoa\"))\n",
"display(auts)\n",
"\n",
@ -3951,7 +3951,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f483c46eca0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f0fd8396b20> >"
]
},
"metadata": {},
@ -4020,7 +4020,7 @@
" for relabel_player in [True, False]:\n",
" for split_env in [True, False]:\n",
" for split_player in [True, False]:\n",
" auts = spot.split_2step(aut)\n",
" auts = spot.split_2step(aut, True, spot.synthesis_info.splittype_EXPL)\n",
" rel_dicts = spot.partitioned_game_relabel_here(auts, relabel_env, relabel_player, split_env, split_player, 10000, 10000)\n",
" spot.relabel_game_here(auts, rel_dicts)\n",
" print(spot.are_equivalent(aut, spot.unsplit_2step(auts)))"
@ -4051,7 +4051,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.6"
}
},
"nbformat": 4,

View file

@ -48,6 +48,7 @@
"source": [
"si = spot.synthesis_info()\n",
"si.s = spot.synthesis_info.algo_LAR # Use LAR algorithm\n",
"si.sp = spot.synthesis_info.splittype_EXPL\n",
"game = spot.ltl_to_game(\"G((F(i0) && F(i1))->(G(i1<->(X(o0)))))\", [\"o0\"], si)\n",
"spot.solve_game(game)"
]
@ -787,7 +788,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8777750> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c292280> >"
]
},
"execution_count": 8,
@ -930,7 +931,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8777750> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c292280> >"
]
},
"execution_count": 9,
@ -1149,7 +1150,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8777660> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c290c30> >"
]
},
"execution_count": 10,
@ -1158,7 +1159,7 @@
}
],
"source": [
"a_s = spot.split_2step(a, True)\n",
"a_s = spot.split_2step(a, True, spot.synthesis_info.splittype_EXPL)\n",
"print(a.acc())\n",
"a_s"
]
@ -1322,7 +1323,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8774840> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c293a20> >"
]
},
"execution_count": 11,
@ -1618,7 +1619,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8774930> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94fe9f090> >"
]
},
"execution_count": 12,
@ -1627,7 +1628,7 @@
}
],
"source": [
"a_snc = spot.split_2step(a, False)\n",
"a_snc = spot.split_2step(a, False, spot.synthesis_info.splittype_EXPL)\n",
"print(a_snc.acc())\n",
"a_snc"
]
@ -2006,7 +2007,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8776f10> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c292880> >"
]
},
"execution_count": 13,
@ -2015,7 +2016,7 @@
}
],
"source": [
"a_s = spot.split_2step(a, True)\n",
"a_s = spot.split_2step(a, True, spot.synthesis_info.splittype_EXPL)\n",
"print(a_s.acc())\n",
"a_s"
]
@ -2289,7 +2290,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a9ff0db0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c2910b0> >"
]
},
"execution_count": 14,
@ -2531,7 +2532,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a9ff0db0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c2910b0> >"
]
},
"execution_count": 15,
@ -2803,7 +2804,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8775800> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c293720> >"
]
},
"execution_count": 16,
@ -3046,7 +3047,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8775800> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c293720> >"
]
},
"execution_count": 17,
@ -3757,7 +3758,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a876e310> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c290600> >"
]
},
"execution_count": 18,
@ -4015,7 +4016,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a876e310> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c290600> >"
]
},
"execution_count": 19,
@ -4298,7 +4299,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8776850> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c290f90> >"
]
},
"metadata": {},
@ -6066,7 +6067,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a9ff1350> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c2901b0> >"
]
},
"execution_count": 20,
@ -6101,7 +6102,7 @@
"\n",
"display(aut)\n",
"\n",
"aut = spot.split_2step(aut, x, False)\n",
"aut = spot.split_2step(aut, x, False, spot.synthesis_info.splittype_EXPL)\n",
"\n",
"display(aut.show_storage())\n",
"aut"
@ -6975,7 +6976,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a9ff1350> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c2901b0> >"
]
},
"execution_count": 21,
@ -7219,7 +7220,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8776970> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c290ea0> >"
]
},
"metadata": {},
@ -8107,7 +8108,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8775620> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c291b60> >"
]
},
"execution_count": 22,
@ -8141,7 +8142,7 @@
"\n",
"display(aut)\n",
"\n",
"aut = spot.split_2step(aut, x, False)\n",
"aut = spot.split_2step(aut, x, False, spot.synthesis_info.splittype_EXPL)\n",
"\n",
"display(aut.show_storage())\n",
"aut"
@ -8529,7 +8530,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a8775620> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c291b60> >"
]
},
"execution_count": 23,
@ -8679,7 +8680,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a876e100> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c291ad0> >"
]
},
"metadata": {},
@ -8858,7 +8859,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a876e100> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c291ad0> >"
]
},
"metadata": {},
@ -9062,7 +9063,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a876f570> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c27bde0> >"
]
},
"execution_count": 25,
@ -9072,6 +9073,7 @@
],
"source": [
"si = spot.synthesis_info()\n",
"si.sp = spot.synthesis_info.splittype_EXPL\n",
"\n",
"aut = spot.ltl_to_game(\"(a|b|c|d)->x\", [\"x\"], si)\n",
"aut"
@ -9268,7 +9270,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f08a876fae0> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x75e94c290210> >"
]
},
"execution_count": 27,
@ -9582,7 +9584,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.aig; proxy of <Swig Object of type 'std::shared_ptr< spot::aig > *' at 0x7f08a876f2a0> >"
"<spot.aig; proxy of <Swig Object of type 'std::shared_ptr< spot::aig > *' at 0x75e94c292b80> >"
]
},
"execution_count": 28,
@ -9594,14 +9596,6 @@
"aig = spot.mealy_machine_to_aig(ctrl, \"ite\")\n",
"aig"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb81b7d3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@ -9620,7 +9614,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.6"
}
},
"nbformat": 4,

View file

@ -282,8 +282,8 @@ spot.change_parity_here(gdpa, spot.parity_kind_max, spot.parity_style_odd)
gsdpa = spot.split_2step(gdpa, b, True)
spot.colorize_parity_here(gsdpa, True)
tc.assertTrue(spot.solve_parity_game(gsdpa))
tc.assertEqual(spot.highlight_strategy(gsdpa).to_str("HOA", "1.1"),
"""HOA: v1.1
gsdpa_solved_ref = spot.automaton(
"""HOA: v1.1
States: 18
Start: 0
AP: 2 "a" "b"
@ -292,7 +292,7 @@ Acceptance: 5 Fin(4) & (Inf(3) | (Fin(2) & (Inf(1) | Fin(0))))
properties: trans-labels explicit-labels trans-acc colored complete
properties: deterministic
spot.highlight.states: 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 """
+"""10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4
+"""10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4
spot.highlight.edges: 15 4 17 4 20 4 22 4 24 4 26 4 28 4 30 4 31 4 32 4 33 4
spot.state-player: 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1
controllable-AP: 1
@ -350,6 +350,23 @@ State: 17
[t] 4 {4}
--END--"""
)
tc.assertTrue(spot.solve_parity_game(gsdpa_solved_ref))
# Check for the same language
tc.assertTrue(spot.are_equivalent(gsdpa, gsdpa_solved_ref))
# Check if the winning regions are the same for env states
# Env states should by construction have the same number as before
players_new = spot.get_state_players(gsdpa)
players_ref = spot.get_state_players(gsdpa_solved_ref)
# States maybe renumbered, but remain in the same "class"
tc.assertEqual(players_new, players_ref)
# Check that env states have the same winner
winners_new = spot.get_state_winners(gsdpa)
winners_ref = spot.get_state_winners(gsdpa_solved_ref)
tc.assertTrue(all([wn == wr for (wn, wr, p) in
zip(winners_new, winners_ref, players_ref)
if not p]))
# Test the different parity conditions
gdpa = spot.tgba_determinize(spot.degeneralize_tba(g),

View file

@ -135,3 +135,169 @@ aut, s = do_split('((G (((! g_0) || (! g_1)) && ((r_0 && (X r_1)) -> (F (g_0 \
&& g_1))))) && (G (r_0 -> F g_0))) && (G (r_1 -> F g_1))',
['g_0', 'g_1'])
tc.assertTrue(equiv(aut, spot.unsplit_2step(s)))
# check equivalence of split automata
# for the different methods for certain cases
autstr = """HOA: v1
name: "r2b_ack0 | F((!b2r_req0 & Xr2b_ack0) | (b2r_req0 & XG!r2b_ack0)) \
| (!b2r_req0 & G(!r2b_ack0 | ((!b2r_req0 | !b2r_req1) & X!b2r_req0 \
& (!(s2b_req0 | s2b_req1) | XF(b2r_req0 | b2r_req1)) & (!b2r_req0 \
| X(b2r_req0 | (b2r_req1 M !b2r_req0))) & (!b2r_req0 | r2b_ack0 \
| Xb2r_req0))))"
States: 12
Start: 7
AP: 5 "r2b_ack0" "b2r_req0" "b2r_req1" "s2b_req0" "s2b_req1"
controllable-AP: 2 1
acc-name: parity max even 4
Acceptance: 4 Fin(3) & (Inf(2) | (Fin(1) & Inf(0)))
properties: trans-labels explicit-labels trans-acc colored complete
properties: deterministic
--BODY--
State: 0
[!0&!1] 0 {2}
[0] 1 {1}
[!0&1] 3 {2}
State: 1
[t] 1 {2}
State: 2
[!0&1] 2 {2}
[0&1] 2 {3}
[!0&!1] 4 {2}
[0&!1] 5 {3}
State: 3
[!0&!1] 0 {2}
[0&1&2] 2 {1}
[!0&1] 3 {2}
[0&!1&3 | 0&!1&4] 6 {2}
[0&!1&!3&!4] 7 {2}
[0&1&!2] 8 {2}
State: 4
[0] 1 {1}
[!0&1] 2 {2}
[!0&!1] 4 {2}
State: 5
[0] 1 {1}
[!0&1] 2 {1}
[!0&!1] 5 {1}
State: 6
[!0&!1&2] 0 {2}
[0] 1 {1}
[!0&1] 2 {1}
[!0&!1&!2] 9 {1}
State: 7
[!0&!1] 0 {2}
[0] 1 {1}
[!0&1] 2 {1}
State: 8
[!0&!1&2] 0 {2}
[1] 2 {1}
[0&!1&2&3 | 0&!1&2&4] 6 {2}
[0&!1&2&!3&!4] 7 {2}
[!0&!1&!2] 10 {1}
[0&!1&!2] 11 {1}
State: 9
[!0&!1&2] 0 {2}
[0] 1 {1}
[!0&1] 3 {2}
[!0&!1&!2] 9 {1}
State: 10
[!0&!1&2] 0 {2}
[0] 1 {1}
[!0&1] 2 {1}
[!0&!1&!2] 10 {2}
State: 11
[!0&!1&2] 0 {2}
[0] 1 {1}
[!0&1] 2 {1}
[!0&!1&!2] 11 {1}
--END--
HOA: v1
States: 2
Start: 0
AP: 15 "u0room29light0f1dturn2off1b" "u0room29light0f1dturn2on1b" \
"p0b0room29window29opened" "u0room29light0f1dtoggle1b" \
"p0b0room29window29closed" "p0p0all2windows2closed0room" \
"u0system29start2new2timer0f1dmin25231b" \
"u0system29start2new2timer0f1dhour241b" \
"u0room29warnlight29control0room29warnlight29control" \
"u0system29start2new2timer0system29start2new2timer" \
"u0room29warnlight29control0f1dturn2on1b" \
"u0room29warnlight29control0f1dturn2off1b" "u0room29light0room29light" \
"u0system29start2new2timer0f1dhour251b" "p0b0timeout"
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc deterministic
controllable-AP: 0 1 3 6 7 8 9 10 11 12 13
--BODY--
State: 0
[!0&!1&!3&!6&!7&!8&!9&!10&11&12&13 | !0&!1&!3&!6&!7&!8&!9&10&!11&12&13 \
| !0&!1&!3&!6&!7&!8&9&!10&11&12&!13 | !0&!1&!3&!6&!7&!8&9&10&!11&12&!13 \
| !0&!1&!3&!6&!7&8&!9&!10&!11&12&13 | !0&!1&!3&!6&!7&8&9&!10&!11&12&!13 \
| !0&!1&!3&!6&7&!8&!9&!10&11&12&!13 | !0&!1&!3&!6&7&!8&!9&10&!11&12&!13 \
| !0&!1&!3&!6&7&8&!9&!10&!11&12&!13 | !0&!1&!3&6&!7&!8&!9&!10&11&12&!13 \
| !0&!1&!3&6&!7&!8&!9&10&!11&12&!13 | !0&!1&!3&6&!7&8&!9&!10&!11&12&!13 \
| !0&!1&3&!6&!7&!8&!9&!10&11&!12&13 | !0&!1&3&!6&!7&!8&!9&10&!11&!12&13 \
| !0&!1&3&!6&!7&!8&9&!10&11&!12&!13 | !0&!1&3&!6&!7&!8&9&10&!11&!12&!13 \
| !0&!1&3&!6&!7&8&!9&!10&!11&!12&13 | !0&!1&3&!6&!7&8&9&!10&!11&!12&!13 \
| !0&!1&3&!6&7&!8&!9&!10&11&!12&!13 | !0&!1&3&!6&7&!8&!9&10&!11&!12&!13 \
| !0&!1&3&!6&7&8&!9&!10&!11&!12&!13 | !0&!1&3&6&!7&!8&!9&!10&11&!12&!13 \
| !0&!1&3&6&!7&!8&!9&10&!11&!12&!13 | !0&!1&3&6&!7&8&!9&!10&!11&!12&!13 \
| !0&1&!3&!6&!7&!8&!9&!10&11&!12&13 | !0&1&!3&!6&!7&!8&!9&10&!11&!12&13 \
| !0&1&!3&!6&!7&!8&9&!10&11&!12&!13 | !0&1&!3&!6&!7&!8&9&10&!11&!12&!13 \
| !0&1&!3&!6&!7&8&!9&!10&!11&!12&13 | !0&1&!3&!6&!7&8&9&!10&!11&!12&!13 \
| !0&1&!3&!6&7&!8&!9&!10&11&!12&!13 | !0&1&!3&!6&7&!8&!9&10&!11&!12&!13 \
| !0&1&!3&!6&7&8&!9&!10&!11&!12&!13 | !0&1&!3&6&!7&!8&!9&!10&11&!12&!13 \
| !0&1&!3&6&!7&!8&!9&10&!11&!12&!13 | !0&1&!3&6&!7&8&!9&!10&!11&!12&!13 \
| 0&!1&!3&!6&!7&!8&!9&!10&11&!12&13 | 0&!1&!3&!6&!7&!8&!9&10&!11&!12&13 \
| 0&!1&!3&!6&!7&!8&9&!10&11&!12&!13 | 0&!1&!3&!6&!7&!8&9&10&!11&!12&!13 \
| 0&!1&!3&!6&!7&8&!9&!10&!11&!12&13 | 0&!1&!3&!6&!7&8&9&!10&!11&!12&!13 \
| 0&!1&!3&!6&7&!8&!9&!10&11&!12&!13 | 0&!1&!3&!6&7&!8&!9&10&!11&!12&!13 \
| 0&!1&!3&!6&7&8&!9&!10&!11&!12&!13 | 0&!1&!3&6&!7&!8&!9&!10&11&!12&!13 \
| 0&!1&!3&6&!7&!8&!9&10&!11&!12&!13 | 0&!1&!3&6&!7&8&!9&!10&!11&!12&!13] 1
State: 1
[!0&!1&!3&!6&!7&!8&!9&!10&11&12&13 | !0&!1&!3&!6&!7&!8&!9&10&!11&12&13 \
| !0&!1&!3&!6&!7&!8&9&!10&11&12&!13 | !0&!1&!3&!6&!7&!8&9&10&!11&12&!13 \
| !0&!1&!3&!6&!7&8&!9&!10&!11&12&13 | !0&!1&!3&!6&!7&8&9&!10&!11&12&!13 \
| !0&!1&!3&!6&7&!8&!9&!10&11&12&!13 | !0&!1&!3&!6&7&!8&!9&10&!11&12&!13 \
| !0&!1&!3&!6&7&8&!9&!10&!11&12&!13 | !0&!1&!3&6&!7&!8&!9&!10&11&12&!13 \
| !0&!1&!3&6&!7&!8&!9&10&!11&12&!13 | !0&!1&!3&6&!7&8&!9&!10&!11&12&!13 \
| !0&!1&3&!6&!7&!8&!9&!10&11&!12&13 | !0&!1&3&!6&!7&!8&!9&10&!11&!12&13 \
| !0&!1&3&!6&!7&!8&9&!10&11&!12&!13 | !0&!1&3&!6&!7&!8&9&10&!11&!12&!13 \
| !0&!1&3&!6&!7&8&!9&!10&!11&!12&13 | !0&!1&3&!6&!7&8&9&!10&!11&!12&!13 \
| !0&!1&3&!6&7&!8&!9&!10&11&!12&!13 | !0&!1&3&!6&7&!8&!9&10&!11&!12&!13 \
| !0&!1&3&!6&7&8&!9&!10&!11&!12&!13 | !0&!1&3&6&!7&!8&!9&!10&11&!12&!13 \
| !0&!1&3&6&!7&!8&!9&10&!11&!12&!13 | !0&!1&3&6&!7&8&!9&!10&!11&!12&!13 \
| !0&1&!3&!6&!7&!8&!9&!10&11&!12&13 | !0&1&!3&!6&!7&!8&!9&10&!11&!12&13 \
| !0&1&!3&!6&!7&!8&9&!10&11&!12&!13 | !0&1&!3&!6&!7&!8&9&10&!11&!12&!13 \
| !0&1&!3&!6&!7&8&!9&!10&!11&!12&13 | !0&1&!3&!6&!7&8&9&!10&!11&!12&!13 \
| !0&1&!3&!6&7&!8&!9&!10&11&!12&!13 | !0&1&!3&!6&7&!8&!9&10&!11&!12&!13 \
| !0&1&!3&!6&7&8&!9&!10&!11&!12&!13 | !0&1&!3&6&!7&!8&!9&!10&11&!12&!13 \
| !0&1&!3&6&!7&!8&!9&10&!11&!12&!13 | !0&1&!3&6&!7&8&!9&!10&!11&!12&!13 \
| 0&!1&!3&!6&!7&!8&!9&!10&11&!12&13 | 0&!1&!3&!6&!7&!8&!9&10&!11&!12&13 \
| 0&!1&!3&!6&!7&!8&9&!10&11&!12&!13 | 0&!1&!3&!6&!7&!8&9&10&!11&!12&!13 \
| 0&!1&!3&!6&!7&8&!9&!10&!11&!12&13 | 0&!1&!3&!6&!7&8&9&!10&!11&!12&!13 \
| 0&!1&!3&!6&7&!8&!9&!10&11&!12&!13 | 0&!1&!3&!6&7&!8&!9&10&!11&!12&!13 \
| 0&!1&!3&!6&7&8&!9&!10&!11&!12&!13 | 0&!1&!3&6&!7&!8&!9&!10&11&!12&!13 \
| 0&!1&!3&6&!7&!8&!9&10&!11&!12&!13 | 0&!1&!3&6&!7&8&!9&!10&!11&!12&!13] 1
--END--
"""
for autus in spot.automata(autstr):
si = spot.synthesis_info()
all_split = []
for sp in [spot.synthesis_info.splittype_EXPL,
spot.synthesis_info.splittype_SEMISYM,
spot.synthesis_info.splittype_FULLYSYM,
spot.synthesis_info.splittype_AUTO
]:
all_split.append(spot.split_2step(autus, si))
for i in range(len(all_split)):
for j in range(i+1, len(all_split)):
tc.assertTrue(spot.are_equivalent(all_split[i], all_split[j]))
del autus
del si
del all_split
gcollect()

View file

@ -29,8 +29,7 @@ for i in range(0, 2):
tc.assertFalse(spot.solve_game(game))
# A game can have only inputs
game = spot.ltl_to_game("GFa", [])
tc.assertEqual(game.to_str(), """HOA: v1
game_ref = spot.automaton("""HOA: v1
States: 3
Start: 0
AP: 1 "a"
@ -49,3 +48,10 @@ State: 1
State: 2
[t] 0 {0}
--END--""")
gi = spot.synthesis_info()
gi.dict = game_ref.get_dict()
game = spot.ltl_to_game("GFa", [], gi)
tc.assertTrue(spot.are_equivalent(game, game_ref))