cbc_enable_calc_aux2(OpName1,OpName2,Enable,Timeout1,Timeout2,PosGuard2,NegGuard2,FilteredNegGuard2) :-
%format('Check if ~w can be enabled after ~w ~n',[OpName2,OpName1]),
%print(' Pos Guard: '),translate:print_bexpr(PosGuard2),nl,
%((OpName1=winc,OpName2=winc) -> trace ; true),
testcase_path_timeout_catch(invariant,Timeout1,[OpName1],PosGuard2,_Csts,_Ops,_TestS,_TI,R), % advantage over version with [OpName1,OpName2] : one less state to setup and enumerate; but inner guards may not be checked
!,
printsilent(can_be_enabled_after(R)), printsilent(' : '),
% print('Neg Guard: '),translate:print_bexpr(NegGuard2),nl,
% TO DO: first check whether OpName2 can be disabled given Invariant ?
(testcase_path_timeout_catch(invariant,Timeout1,[OpName1],NegGuard2,_Csts2,_Ops2,_TestS2,_TI2,R2)
-> printsilent(can_be_disabled_after(R2)), printsilent(' : '),
% TO DO: test if NegGuard2 holds initially it is possible to execute [OpName1,OpName2]; if not: OpName1 cannot enable OpName2, only keep it -> Enable=keep_possible
% then we could check if OpName1 can disable OpName2: PosGuard2,[OpName1],NegGuard2
(OpName1\=OpName2, % otherwise OpName2 must be enabled if [OpName1] can be executed
%testcase_path_timeout_catch(pred(NegGuard2),Timeout2,[OpName1,OpName2],b(truth,pred,[]),_,_,_,_,R3)
testcase_path_timeout_catch(pred(NegGuard2),Timeout2,[OpName1],PosGuard2,_,_,_,_,R3)
-> printsilent(can_enable(R3)), printsilent(' : '),
%nl, translate:print_bexpr(PosGuard2),nl,print(OpName1),nl,translate:print_bexpr(NegGuard2),nl,
%print('FILTERED: '), translate:print_bexpr(FilteredNegGuard2),nl,
(testcase_path_timeout_catch(pred(PosGuard2),Timeout2,[OpName1],FilteredNegGuard2,_,_,_,_,R4)
-> printsilent(can_disable(R4)), printsilent(' : '),
(contains_timeout([R,R2,R3,R4]) -> Enable=timeout_possible ; Enable=possible)
; printsilent('cannot_disable : '),
(contains_timeout([R,R2,R3]) -> Enable=timeout_possible_enable ; Enable=possible_enable) /* Opname cannot disable OpName2; only enable it */
)
; /* OpName1 cannot enable OpName2; only preserve it */
printsilent('cannot_enable : '),
(testcase_path_timeout_catch(pred(PosGuard2),Timeout2,[OpName1],FilteredNegGuard2,_,_,_,_,R4)
-> printsilent(can_disable(R4)), printsilent(' : '),
(contains_timeout([R,R2,R4]) -> Enable=timeout_possible_disable; Enable=possible_disable)
; (contains_timeout([R,R2]) -> Enable=timeout_keep; Enable=keep) /* Opname cannot enable or disable */
)
)
; (is_timeout(R) -> Enable=timeout_guaranteed; Enable=guaranteed)
).
cbc_enable_calc_aux2(OpName1,_OpName2,Enable,_Timeout1,Timeout2,PosGuard2,_NegGuard2,FilteredNegGuard2) :-
% OpName2 can never be enabled after OpName1; check whether it can be enabled before
% Note: we could replace FilteredNegGuard2 by truth
testcase_path_timeout_catch(pred(PosGuard2),Timeout2,[OpName1],FilteredNegGuard2,_,_,_,_,R4),
!,
printsilent(can_disable(R4)), printsilent(' : '),
(is_timeout(R4) -> Enable=timeout_impossible; Enable=impossible).
cbc_enable_calc_aux2(_OpName1,_OpName2,Enable,_,_,_PosGuard2,_NegGuard2,_FilteredNegGuard2) :-
% OpName2 can never ben enabled after nor before
Enable=impossible_keep.