start_ltsmin(Backend, [NoDead, NoInv], MoreFlags,Result) :-
(NoDead = false, NoInv = false ->
add_warning(start_ltsmin,'Turning off deadlock checking for LTSmin command: ',Backend),
NoDead2 = true
; NoDead2 = NoDead),
get_path_to_fresh_ltsmin_endpoint(Endpoint),
ltsmin:ltsmin_init(Endpoint, Zocket),
get_path_to_fresh_trace_file(TraceFile),
get_ltsmin_flags(Backend, NoDead2, NoInv, MoreFlags, TraceFile, Flags),
(member(ltl_formula(Formula), MoreFlags)
-> get_path_to_ltl_file(LTLFile),
ltsmin_generate_ltlfile(Formula, LTLFile)
; true),
preferences:get_preference(path_to_ltsmin, Path),
runtime_application_path(PROBPATH),
get_tool_name(Backend, Tool),
lib_component_full_path(executable, Tool, ltsmin_extension, LTSminCmd),
catch(
process:process_create(LTSminCmd, [Endpoint, '--stats', '--when'|Flags], [process(PID)]),
% we could add stdout(pipe(STDOut)) option to process_create and try and parse output
error(existence_error(_,_),E),
(format(user_error,'process_create exception: ~w~n',[E]),
format('LTSMIN preference is set to: "~w"~n',[Path]),
format(' relative to ProB path: "~w"~n',[PROBPATH]),
format(' using tool: "~w"~n',[Tool]),
add_error_fail(ltsmin,'Path to LTSmin incorrect (LTSMIN preference) or LTSmin command not installed (copy prob2lts-sym, prob2lts-seq, ltsmin-printtrace from https://github.com/utwente-fmt/ltsmin/releases to ProB\'s lib folder), cannot execute: ',LTSminCmd))),
ltsmin_loop(Zocket),
process_wait(PID, ExitStatus),
(ExitStatus == exit(0)
-> Result = ltsmin_model_checking_ok
; ExitStatus = killed(_)
-> Result = ltsmin_model_checking_aborted
; ExitStatus == exit(1)
-> get_tool_name(printtrace, PrintTrace),
lib_component_full_path(executable, PrintTrace, ltsmin_extension, PrintTraceCmd),
get_path_to_fresh_csv_trace_file(CsvFile),
format('writing trace to ~w~n', CsvFile),
catch(
process:process_create(PrintTraceCmd, [TraceFile, CsvFile, '-s,,'], [process(PID2)]),
error(existence_error(_,_),E),
(format(user_error,'process_create exception: ~w~n',[E]),
add_error_fail(ltsmin,'Path to LTSmin incorrect or ltsmin-printtrace command not installed (copy command from https://github.com/utwente-fmt/ltsmin/releases to ProB\'s lib folder), cannot execute: ',PrintTraceCmd))),
process_wait(PID2, _ExitStatus2),
Result = ltsmin_counter_example_found(CsvFile)
; add_internal_error('Unexpected LTSmin exit status:',ExitStatus),
Result = ltsmin_model_checking_aborted
),
del_temp_file(TraceFile),
del_temp_file(Endpoint),
format('~w with ~w exited with status: ~w~n',[Tool, Flags, ExitStatus]),
ltsmin:ltsmin_teardown(Zocket, Endpoint).