cb_set_up_path(Trace,Event,TargetPredicate,StateId,Timeout,Result) :-
% StateID is the last state of the previously found path Trace (without Event)
cb_try_state_caching, % if true: try to use model checking paths found; currently disabled
StateId \== no_state,
lookup_state(StateId,ConstantState,InState),
init_wait_flags(WF,[cb_set_up_path]),
set_up_transition(Event,Operation,ConstantState,InState,OutState,TransInfo,WF),
cb_finalize_path_with_timeout(TargetPredicate,OutState,Trace,Event,WF,LResult,Timeout,TO_Success),
( TO_Success = time_out ->
cb_write_timeout(Timeout,Trace),fail
;
cb_store_single_step_in_statespace(ConstantState,OutState,StateId,Operation,TransInfo,LastStateId,Sequence),
cb_save_new_step(Trace,Event,LResult,LastStateId,Sequence),
% if we did not find a test case, just a normal step, we need to fall back
% to constraint solving on the full path
!,
( LResult==testcase -> Result=testcase
; cb_set_up_path(Trace,Event,TargetPredicate,no_state,Timeout,testcase) -> Result=testcase
; Result = path)).
cb_set_up_path(Trace,Event,TargetPredicate,_StateId,Timeout,Result) :-
init_wait_flags(WF,[cb_set_up_path]),
% set up constants and initialisation:
testcase_initialise(ConstantsState,InitialState,Initialisation,TransInfo,WF),
combine_detail_infos(ConstantsState,InitialState,Initialisation,TransInfo,DT1,DT),
cb_set_up_events(Trace,InitialState,ConstantsState,FinalState,DT1,WF,WF2),
% either find a real testcase where TargetPredicate holds at end
% or find a path where TargetPredicate does not hold at end:
cb_finalize_path_with_timeout(TargetPredicate,FinalState,Trace,Event,WF2,Result,Timeout,TO_Success),
!,
( TO_Success = time_out ->
cb_write_timeout(Timeout,Trace),
fail
; (Result=testcase, bounded_model_checking -> format_err('Found BMC counter example (~w)~n',[Trace])
; debug_mode(on) -> format_ok('Found ~w path for ~w (~w)~n',[Result,Event,Trace])
; Result=testcase -> printsilent('!') %,print(Trace),nl
; printsilent('+')
),
cb_store_path_in_statespace(DT,LastStateId,Sequence), % only do if path required or new testcase generated
cb_save_new_step(Trace,Event,Result,LastStateId,Sequence)
).