CSSE3100/7100 Reasoning About Programs - Semester One 2021- Final Exam - Q2 Loop Invariant Weakest Precondition Proof
This question has been solved
Question 2 [8 marks]
CourseNana.COM
(a) Provide a loop invariant and weakest precondition proof to show that the Dafny method,
CourseNana.COM
C, satisfies partial correctness. (7 marks)
CourseNana.COM
method C(n: int) returns (r: int)
requires n >= 2
ensures r <= n && forall j :: 2 <= j < r ==> n % j != 0
CourseNana.COM
{
var i := 2;
CourseNana.COM
while n % i != 0 {
CourseNana.COM
i := i + 1; }
CourseNana.COM
r := i; }
CourseNana.COM
(b) Provide a termination metric for the loop in method C. There is no need to prove termination. (1 mark)
CourseNana.COM
CSSE3100代写,CSSE7100代写,Reasoning About Programs代写,Weakest Precondition Proof代写,Queensland代写,CSSE3100代编,CSSE7100代编,Reasoning About Programs代编,Weakest Precondition Proof代编,Queensland代编,CSSE3100代考,CSSE7100代考,Reasoning About Programs代考,Weakest Precondition Proof代考,Queensland代考,CSSE3100help,CSSE7100help,Reasoning About Programshelp,Weakest Precondition Proofhelp,Queenslandhelp,CSSE3100作业代写,CSSE7100作业代写,Reasoning About Programs作业代写,Weakest Precondition Proof作业代写,Queensland作业代写,CSSE3100编程代写,CSSE7100编程代写,Reasoning About Programs编程代写,Weakest Precondition Proof编程代写,Queensland编程代写,CSSE3100programming help,CSSE7100programming help,Reasoning About Programsprogramming help,Weakest Precondition Proofprogramming help,Queenslandprogramming help,CSSE3100assignment help,CSSE7100assignment help,Reasoning About Programsassignment help,Weakest Precondition Proofassignment help,Queenslandassignment help,CSSE3100solution,CSSE7100solution,Reasoning About Programssolution,Weakest Precondition Proofsolution,Queenslandsolution,