typecheck_tp(unparsed_trans(Op),xtl(Opname,Arity,Args),ResultFlag) :-
animation_mode(xtl), !,
( compound(Op) -> functor(Op,Opname,Arity), Op =.. [_|Args]
; split_atom(Op,['.'],[Opname|Args]) ->
length(Args,Arity)
;
add_error(ltl,'Failed to parse operation specification'),
ResultFlag = error).
typecheck_tp(unparsed_trans(Opname),csp(Channel,Arity,ResArgs),ResultFlag) :-
csp_mode,!,
( Opname = tick
-> Channel=Opname, Arity=0, ResArgs=[] % should we set Arity ??
; Opname = tau
-> Channel=Opname, Arity=0, ResArgs=[] % should we set Arity ??
; (split_atom(Opname,['.','!'],[Channel|Args]), channel(Channel,_))
->
(channel_type_list(Channel, TypeList),length(TypeList,Arity),length(Args,Arity)
-> (Arity = 0
-> ResArgs = []
; (\+memberchk('_',Args)
% we want to call the CSP-M parser only once when there is no '_' symbol in Args
-> mergeArgsToDotTuple([Channel|Args],DotTupleEvent),
parse_single_csp_expression(ltl,DotTupleEvent,ParsedEvent),
splitToSingleArgs(ParsedEvent,[Channel|ResArgs],Arity)
; l_parse_single_csp_expression_undescore(ltl,Args,ResArgs)
)
)
; add_error(ltl,'Number of arguments not correct for: ', Opname),
ResultFlag=error, ResArgs=[], Arity = 0
)
;
add_error(ltl,'Channel does not exist: ',Opname),
ResultFlag = error, ResArgs=[], Arity = 0
).
typecheck_tp(bop(oppattern(_Pos,Name,Args)),Result,ResultFlag) :- !,
( b_or_z_mode, b_get_machine_operation(Name,Results,Parameters,_) ->
Result = bop(Name,NumberArgs,NumberResults,ArgPatterns,ResPatterns),
length(Parameters,NumberArgs), length(Results,NumberResults),
% Pattern matching for results is not yet supported
ResPatterns = [],
( Args=[] ->
ArgPatterns = [],
ResPatterns = []
; length(Args,NumberArgs) ->
create_b_op_patterns(Args,Parameters,ArgPatterns,ResultFlag)
;
add_error(ltl,'Number of arguments not correct for: ', Name),ResultFlag=error)
; (csp_mode ; xtl_mode), Args=[] ->
debug_println(9,unparsed_trans(Name)),
typecheck_tp(unparsed_trans(Name),Result,ResultFlag)
;
add_error(ltl,'Could not find operation: ', Name),ResultFlag=error).
typecheck_tp(btrans(event(Name)),btrans(event(Name)),_ResultFlag) :- !.
typecheck_tp(btrans(event(Name,RawPredicate)),btrans(event(Name,TPredicate,Poststate)),ResultFlag) :- !,
( b_get_machine_operation(Name,_,_Parameters,_) ->
( bmachine:type_with_errors(RawPredicate,[prepost,operation(Name)],pred,TPredicate) ->
find_poststate_access(TPredicate,Poststate)
; ResultFlag=error)
;
add_error(ltl,'Could not find operation: ', Name),ResultFlag=error).
typecheck_tp(before_after(bpred(RawPredicate)),before_after(TPred),ResultFlag) :- !,
get_primed_machine_variables(PV),
(get_preference(symmetry_mode,off) -> Scope = [prob_ids(visible),identifier(PV),variables]
; Scope = [identifier(PV),variables]
),
% in classical B x$0 refers to the value before a substitution
( bmachine:type_with_errors(RawPredicate,Scope,pred,TPred0)
-> % see prepost becomes_such b_parse_machine_operation_pre_post_predicate
inline_prob_deferred_set_elements_into_bexpr(TPred0,TPred) % TODO: we could compute the $0 variables
; ResultFlag=error).
typecheck_tp(change_expr(Comparator,Expr),change_expr(Comparator,TypedExpr),Res) :-
!, typecheck_expr(Expr,TypedExpr,_Type,Res).
typecheck_tp(F,R,Res) :-
add_internal_error('Illegal LTL transition predicate:',typecheck_tp(F,R,Res)),fail.