我必须在TLC中使用TLA +检查变量值。例如
Res_Word == {“ _”,“ N”}
变量my_variable =“ Some_valueONE”
检查== my_variable \ in Res_Word
*表示检查变量是否包含set中所需的某些特定值。
答案 0 :(得分:0)
您所提供的方法有什么具体问题?这是一个PlusCal示例。
---- MODULE test ----
EXTENDS Integers, Sequences, TLC, FiniteSets
(* --algorithm test
variables res_positive_match = "N", res_negative_match = "Y";
define
Res_Word == {"_","N","M"}
NotInResWord == res_negative_match \in Res_Word
end define;
begin P:
print <<"res_positive_match:", res_positive_match \in Res_Word>>;
print <<"res_negative_match:", res_negative_match \in Res_Word, "NotInResWord:", NotInResWord>>;
print <<"sets matching:", {"N","_"} \subseteq Res_Word>>;
end algorithm; *)
\* BEGIN TRANSLATION
\* END TRANSLATION
=====
输出类似:
<<"res_positive_match:", TRUE>>
<<"res_negative_match:", FALSE, "NotInResWord:", FALSE>>
<<"sets matching:", TRUE>>