Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 3 ( 1 8 pts . ) : Loopy square root Below we give, in Dafny syntax, the square root method which should be
Problem pts: Loopy square root
Below we give, in Dafny syntax, the square root method which should be computing the square root of a number.a Test this code by creating the Main method and calling loopysqrt with arguments like etc. to convince yourself that this algorithm appears to be working correctly. In your answer, describe your tests and the corresponding output. ptsb Yet, the code given above fails to verify with Dafny. One of the reasons for this is that it is actually incorrect. More specifically, this code may produce the result which does not comply with the specification. Write a test or tests that reveals the bug. In your answer, describe your tests the corresponding outputs, and the bug that you found. Also, indicate which part of the specification is violated. ptsc Now, make this code correct by changing the precondition. In your answer, describe the change and show the output of the rerun of the same tests you ran before. ptsd Does your Dafny code verify now? Why or why not? If it doesn't verify, does it mean that your code still has bugs in it ptse If your Dafny code doesn't verify, uncomment invariant andor decreases annotations and supply the actual invariant andor decrementing function. Make sure your code now verifies. In your answer, describe how you guessed the invariant andor the decrementing function. Explain why your code was failing Dafny verification earlier but does verify now, despite the fact that you have not made any changes to your actual code annotations are not part of the code ptsf Submit your final Dafny code. pts autogradedg Use computational induction to prove by hand the total correctness of the final version of your Dafny code. pts
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started