(b) Given the following Dafny program, where you may assume that the contract provided is correct,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(b) Given the following Dafny program, where you may assume that the contract provided is correct, I. identify at least two errors in the code II. provide an appropriate loop invariant III. provide an appropriate loop variant method M (x: int, y: int) returns (r: int) requires y <0; ensures r == x + y; { r = 0; var n := y; { } while (n != 0) r n = r 1; = n + 2; - Explain your solution in each case. [6 marks] (b) Given the following Dafny program, where you may assume that the contract provided is correct, I. identify at least two errors in the code II. provide an appropriate loop invariant III. provide an appropriate loop variant method M (x: int, y: int) returns (r: int) requires y <0; ensures r == x + y; { r = 0; var n := y; { } while (n != 0) r n = r 1; = n + 2; - Explain your solution in each case. [6 marks]
Expert Answer:
Related Book For
Cambridge International AS And A Level Physics Coursebook
ISBN: 9781108859035
3rd Edition
Authors: David Sang, Graham Jones, Gurinder Chadha, Richard Woodside
Posted Date:
Students also viewed these databases questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
What is the output of the following? A. 1223445 B. 2445 C. 22445 D. 223445 E. 2233445 F. None of the above. public class InitOrder { } {System.out.print("1"); } static System.out.print("2"); } public...
-
For each of the following situations, select the best letter answer to reflect the effect of the numbered item on the acquirer's accounting entry at the date of combination when separate...
-
Parts III, V, and VI of this case study dealt with obtaining an understanding of internal control and assessing control risk for transactions affecting accounts payable of Pinnacle Manufacturing. In...
-
The following table summarizes visits to emergency departments at four hospitals in Arizona. People may leave without being seen by a physician, and those visits are denoted as LWBS. The remaining...
-
1. Write down demand and supply equations for wireless phones; include two exogenous variables in each equation. 2. Draw a supply-demand graph for wireless phones. 3. Use your graph to show how a...
-
What is the duration (in years) of an 8% 2yr bond, with semi-annually compounded interest and a ytm of 10%? What is the modified duration (in payment periods) of an 8% 2yr bond with semi-annual...
-
The 450-room Hotel Fernando is a four-star full-service hotel in San Petresco. It is highly regarded among both locals and tourists. Its service standards and ameni- ties complement its exquisite...
-
Two trains A and B are travelling in the same direction, with train A behind train B. Train A, 65 meters long is travelling at 240 kph. Train B, 85 meters long, is travelling at 120 kph. At when...
-
The influx of regular media not to mention the fast developing technological innovations, improved access to technology, social media and competitor information has led to a more intensified...
-
There are many laws that surround the First Amendment. What rights are guaranteed by the First Amendment?
-
Why is commercial risk so dangerous to the operations of a foreign subsidiary? How can you mitigate commercial risk when dealing with international suppliers and retailers?
-
How did Data Science and the use of Big Data play a role in shaping how journalists analyze(d) and report(ed) COVID19and how the rest of the public socially reacted to it?
-
Make announcements for employees in the company This is the case: There is "ABC Training" going on for 2 months and the company divides the training program into 2 part (new employee and refresher...
-
Gwen MacDonals works as an accountant for Sky High Condos, which is owned by Sam Huang. The business currently owns two buildings with 100 units in each. Sky High is in the process of expanding by...
-
Prove the result that the R 2 associated with a restricted least squares estimator is never larger than that associated with the unrestricted least squares estimator. Conclude that imposing...
-
a. Explain what is meant by the mass of a body and the weight of a body. b. State and explain one situation in which the weight of a body changes while its mass remains constant. c. State the...
-
Explain why the -rays produced in positronelectron annihilation must travel at 180 to each other.
-
Electrical energy is supplied by a high-voltage power line that has a total resistance of 4.0 . At the input to the line, the root-mean-square (r.m.s.) voltage has a value of 400 kV and the input...
-
Consider the following binary linear programming formulation of a capital budgeting problem. \[\begin{array}{ll}\text { Max } & 1,200 x_{1}+600 x_{2}+950 x_{3}+1,650 x_{4} \\\text { s.t. } & 15,000...
-
Consider the following binary linear programming formulation of a capital budgeting problem. \[\begin{array}{ll}\text { Max } & 1,200 x_{1}+600 x_{2}+950 x_{3}+1,650 x_{4} \\\text { s.t. } & 15,000...
-
Consider six mutually exclusive and indivisible investment alternatives under evaluation by TranSystems in their bridge and structure design group. At any time TranSystems chooses to exit the...
Study smarter with the SolutionInn App