循环不变式和循环变体

时间:2018-10-07 10:11:21

标签: hoare-logic

就hoare逻辑而言,给定循环的循环不变性和变量应该是什么?

{真}

x := 0; 
y := 0; 
while (x < a) 
  x := x + 2; 
  y := y + 1;

{x = 2 ∗ y}

I thought of variant as (a-x)/2 and loop invariant as (x=2*y & x<=a)but is it correct?

0 个答案:

没有答案