首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么TLC在有效状态上报告错误?

为什么TLC在有效状态上报告错误?
EN

Stack Overflow用户
提问于 2020-11-22 09:40:07
回答 1查看 47关注 0票数 0

对于队列,我有以下规范:

代码语言:javascript
复制
------------------------------- MODULE queue -------------------------------
EXTENDS Naturals

CONSTANT L (* The fixed max length of the queue *)
VARIABLE q (* Represents the queue as the number of items in it *)
----------------------------------------------------------------------------
TypeInvariant == q >= 0 /\ q <= L
----------------------------------------------------------------------------
Init == q = 0

NoOp == q' = q (* Queue unchanged *)

Enqueue == q' = q + 1 (* Element added *)

Dequeue == q' = IF q = 0 THEN q ELSE q - 1 (* Element removed *)

Next == NoOp \/ Enqueue \/ Dequeue
----------------------------------------------------------------------------
Spec == Init /\ [][Next]_q
----------------------------------------------------------------------------
THEOREM Spec => TypeInvariant
============================================================================

当我使用以下常量值运行TLC时:

代码语言:javascript
复制
L <- 3

这些违禁品:

代码语言:javascript
复制
INVARIANT
TypeInvariant

它报告了这些错误:

但是规范允许(0 .. L)中的值,那么为什么TLC报告q=1q=2q=3q=4为无效状态?

错误跟踪输出如下:

代码语言:javascript
复制
<<
[
 _TEAction |-> [
   position |-> 1,
   name |-> "Initial predicate",
   location |-> "Unknown location"
 ],
q |-> 0
],
[
 _TEAction |-> [
   position |-> 2,
   name |-> "Enqueue",
   location |-> "line 18, col 12 to line 18, col 21 of module queue"
 ],
q |-> 1
],
[
 _TEAction |-> [
   position |-> 3,
   name |-> "Enqueue",
   location |-> "line 18, col 12 to line 18, col 21 of module queue"
 ],
q |-> 2
],
[
 _TEAction |-> [
   position |-> 4,
   name |-> "Enqueue",
   location |-> "line 18, col 12 to line 18, col 21 of module queue"
 ],
q |-> 3
],
[
 _TEAction |-> [
   position |-> 5,
   name |-> "Enqueue",
   location |-> "line 18, col 12 to line 18, col 21 of module queue"
 ],
q |-> 4
]
>>

人们应该如何识别那些被认为是错误的,以及那些不是从这条线索中得到的错误?该接口在q=0上没有显示红灯。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-23 17:45:36

顺便说一句,TLA+群是一个问问题的好地方。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64952637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档