Logic 编写Hoare三元组部分正确性的循环不变量
我不熟悉逻辑世界。我正在学习霍尔逻辑以及程序的部分和全部正确性。我试图解决下面的问题,但失败了Logic 编写Hoare三元组部分正确性的循环不变量,logic,loop-invariant,hoare-logic,Logic,Loop Invariant,Hoare Logic,我不熟悉逻辑世界。我正在学习霍尔逻辑以及程序的部分和全部正确性。我试图解决下面的问题,但失败了 Write a loop invariant P to show partial correctness for the Hoare triple {x = ¬x ∧ y = ¬y ∧ x >= 0} mult {z = ¬x * ¬y} where mult is the following program that computes the product of x and y and
Write a loop invariant P to show partial correctness for the Hoare triple
{x = ¬x ∧ y = ¬y ∧ x >= 0} mult {z = ¬x * ¬y}
where mult is the following program that computes the product of x and y and stores it in z:
mult:
z := 0;
while (y > 0) do
z := z + x;
y := y - 1;
我的一个朋友给了我下面的答案,但我不知道它是否正确
Invariant P is (¬x * ¬y = z + ¬x * y) ∧ x = ¬x. Intuitively, z holds the part of the result that is already computed, and (¬x * y) is what remains to compute.
请逐步教我如何解决这个问题 你能解释一下符号“y”是什么意思吗?我很确定三元组应该是
{x=x₀ ∧ y=y₀ ∧ x>=0}mult{z=x₀ * Y₀}你能解释一下符号“y”是什么意思吗?我很确定三元组应该是{x=x₀ ∧ y=y₀ ∧ x>=0}mult{z=x₀ * Y₀}代码>