eval_ltl_formula(false,_Index,_Path,false).
eval_ltl_formula(true,_Index,_Path,true).
eval_ltl_formula(ap(AP),Index,Path,Value) :-
access_index_in_path(Index,Path,State,_Trans),
path_ap(Path,Call),
(call(Call,AP,State) -> Value=true ; Value=false).
eval_ltl_formula(action(TP),Index,Path,Value) :-
access_index_in_path(Index,Path,State,Trans),
( Trans=none ->
(eval_ltl_is_deadlock(Index,Path) -> Value=false ; Value=unknown)
;
path_tp(Path,Call),
(call(Call,TP,State,Trans) -> Value=true ; Value=false)).
eval_ltl_formula(not(A),Index,Path,Value) :-
eval_ltl_formula(A,Index,Path,VA),
ltl_eval_not(VA,Value),!.
eval_ltl_formula(and(A,B),Index,Path,Value) :-
eval_ltl_formula(A,Index,Path,VA),
eval_ltl_formula(B,Index,Path,VB),
ltl_eval_and(VA,VB,Value),!.
eval_ltl_formula(or(A,B),Index,Path,Value) :-
eval_ltl_formula(A,Index,Path,VA),
eval_ltl_formula(B,Index,Path,VB),
ltl_eval_or(VA,VB,Value),!.
eval_ltl_formula(implies(A,B),Index,Path,Value) :-
eval_ltl_formula(A,Index,Path,VA),
eval_ltl_formula(B,Index,Path,VB),
ltl_eval_implies(VA,VB,Value),!.
eval_ltl_formula(equivalent(A,B),Index,Path,Value) :-
eval_ltl_formula(A,Index,Path,VA),
eval_ltl_formula(B,Index,Path,VB),
ltl_eval_equivalent(VA,VB,Value),!.
eval_ltl_formula(finally(A),Index,Path,Value) :-
eval_ltl_formula(until(true,A),Index,Path,Value). % TODO: Do not use normalisation
eval_ltl_formula(globally(A),Index,Path,Value) :-
eval_ltl_formula(not(finally(not(A))),Index,Path,Value). % TODO: Do not use normalisation
eval_ltl_formula(weakuntil(A,B),Index,Path,Value) :-
eval_ltl_formula(or(globally(A),until(A,B)),Index,Path,Value). % TODO: Do not use normalisation
eval_ltl_formula(release(A,B),Index,Path,Value) :-
eval_ltl_formula(not(until(not(A),not(B))),Index,Path,Value). % TODO: Do not use normalisation
eval_ltl_formula(once(A),Index,Path,Value) :-
eval_ltl_formula(since(true,A),Index,Path,Value). % TODO: Do not use normalisation
eval_ltl_formula(historically(A),Index,Path,Value) :-
eval_ltl_formula(not(once(not(A))),Index,Path,Value). % TODO: Do not use normalisation
eval_ltl_formula(trigger(A,B),Index,Path,Value) :-
eval_ltl_formula(not(since(not(A),not(B))),Index,Path,Value). % TODO: Do not use normalisation
eval_ltl_formula(next(A),Index,Path,Value) :-
last_index_in_path(Path,Last),
( Index<Last -> % we're are somewhere in the path,
Next is Index+1,eval_ltl_formula(A,Next,Path,Value) % just use the next position
; path_type(Path,loop(ReEntry)) -> % End of the path: If it's a loop,
eval_ltl_formula(A,ReEntry,Path,Value) % use the start of the lasso as next
; eval_ltl_is_deadlock(Index,Path) -> % End of the path (no loop): In a
Value=false % deadlock X(...) is always false
; % End of the path: We don't know the
Value=unknown). % next state
eval_ltl_formula(yesterday(A),Index,Path,Value) :-
( Index > 0 ->
Y is Index-1,eval_ltl_formula(A,Y,Path,Value)
; % Y(...) is always false in the
Value=false). % initial state.
eval_ltl_formula(until(Inv,Goal),Index,Path,Value) :-
future_indices(Index,Path,Indices),
eval_until(Indices,Inv,Goal,Path,Value).
eval_ltl_formula(since(Inv,Goal),Index,Path,Value) :-
eval_since(Index,Inv,Goal,Path,Value).