Hi Alexandre,
Thank you very much for the detailed response!
Python subprocess seems to work well for giving a timeout externally.
For the other issue, I modified the next tool in my toolchain to work correctly when receiving as input automata where the initial state is not numbered 0.

I'll be happy if you can give me some further advice on my use of SPOT:

My goal is to take TLSF specifications from syntcomp and check realizability using the tool Spectra. Since this tool is made for the GR(1) fragment, I attempt to translate individual LTL formulas from the TLSF spec into this fragment. In particular, for some of the formulas I use SPOT to translate them into a deterministic Buchi automata in HOA format, which is then given as input to a tool called DBW2GR1 (a part of Spectra) generating a GR(1) equivalent formula if such exists.

I use the following command (LTL_FORMULA here is already translated via syfco to the required syntax):
ltl2tgba -D -B -H -x sat-minimize -f LTL_FORMULA | autfilt --is-deterministic
My aim is to fail if the result is not deterministic, since a minimal DBA is a requirement for the correctness of DBW2GR1.
I'll be happy if you have any advice, especially on the use of sat-minimize: are there any parameters I should alter to get the best possible results from the sat solver? (I am aware that inherently some inputs will be difficult.)
Is there any quicker way to tell if a translation to DBA is possible, perhaps separately from the minimization procedure?

As a side note, I also use SPOT's ltlsynt to compare with my results. For this I use:
ltlsynt --realizability --tlsf FILE


Thank you,
Yoav

On Thu, Apr 13, 2023 at 6:47 PM Alexandre Duret-Lutz <adl@lrde.epita.fr> wrote:
Hi Yoav,

Sorry for this delayed answer.

Yoav Ben Shimon <yoavbenshimon@gmail.com> writes:
> I ran into a couple of issues when using SPOT in a project. I'll be
> glad for any assistance.
>
> 1) I am calling sat_minimize from a python script using the spot
> python library. Is there any way to set a timeout on this function
> call? Or do I have to use the CLI if I want a timeout?

I'm not aware of easy ways to deal with timeouts at the function level.
Those are usually set at the process level by using alarm() to trigger a
signal, and then usually killing the process when receiving this signal.

It seems easier to just runs this minimization as a separate process,
and use Python's subprocess module with a timeout.

> 2) I am manipulating an automaton generated from an LTL formula, and
> then printing it in HOA format. Is there a way to guarantee that the
> initial state is the state numbered 0?

You should generally not assume that the initial state is 0.

You could swap the initial state with state 0 in a rather crude way
by iterating on the edge vector and fixing all source and destinations,
but that will cause issue if some named-properties are attached to the
automaton as those could be vectors indexed by state numbers (e.g., a
vector of strings naming each state).  See the attachment for an
example that also removes all named properties as a security.


Another idea: the current version of the formater for the LBTT format
(compatible only with generalized Büchi acceptance) does relabels all
states in such a way that the initial state is 0.  So while
  ltl2tgba XXXGa
will print an HOA that does not start at state 0, using
  ltl2tgba XXXGa --lbtt | autfilt
will print an HOA that start at 0.  There is however nothing in the LBTT
format that forces us to start at 0, so this is unfortunately just
a side effect of how things are implemented.

> If not, is there any other way to control the naming of states?

You are probably talking about the numbering of states, but just for
completeness I'll add that the HOA format also allows you to name
states: those are strings attached to each state.  In python you can
do

  aut.set_state_names(["name for state 0",
                       "name for state 1", ...,
                       "name for state n-1"])

and those will be preserved in the HOA.