JML中的'decreases'是怎么定义的?
How is 'decreases' in JML defined?
decreases
之后的语句必须在每个循环中严格变小并且始终为非零。但是它必须达到0吗?一定要小一吗?
如the JML documentation所述,decreases(你也可以写成decreasing)表示一个int或long表达式该说明符 "must be no less than 0 when the loop is executing, and must decrease by at least one (1) each time around the loop."
所以它可能达到也可能不达到 0,但不能小于 0。此外,它必须至少变小,但不一定正好是一个。请注意文档中的示例以获得更准确的解释。
decreases
之后的语句必须在每个循环中严格变小并且始终为非零。但是它必须达到0吗?一定要小一吗?
如the JML documentation所述,decreases(你也可以写成decreasing)表示一个int或long表达式该说明符 "must be no less than 0 when the loop is executing, and must decrease by at least one (1) each time around the loop."
所以它可能达到也可能不达到 0,但不能小于 0。此外,它必须至少变小,但不一定正好是一个。请注意文档中的示例以获得更准确的解释。