Alex L.

asked • 06/07/22

Hoare logic rules

using repeated addition, where a and b are any two arbitrary numbers. Prove the program is correct using Hoare logic inference rules (precondition and postcondition have been given).


{b>=0}

x:= b;

z := 0;

WHILE (x!=0) {

z := z+a;

x := x-1;

}

{z=a*b}

please start by identifying the loop invariant, then apply the Hoare logic inference rules(Specify which rule you are using )

Daniel B.

tutor
I showed you a solution to a similar problem a couple days ago. Were you able to follow that? If not, then why? Could you apply analogous steps to this problem?
Report

06/07/22

Alex L.

Sorry!, this is my first question on the website
Report

06/08/22

Daniel B.

tutor
Why suddenly so much interest in this 50 year old logic? In the span of 5 days three almost identical questions have been posted. First by another Alex L., then by you, then by Mira S. Are you all taking the same class?
Report

06/08/22

Alex L.

I need it for homework, I know Mira, but I don't know about the other Alex, can you please help, because I'm struggling with it
Report

06/09/22

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.