Task 1.3 (Written, 5 points). Fill in an appropriate precondition such that the following triple is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 1.3 (Written, 5 points). Fill in an appropriate precondition such that the following triple is valid. Don't provide a trivial precondition (that is, don't make the precondition a contradiction). Updated 10/4: Added minus sign to postcondition n := -m; while n‡0 do r := r * -3; n := n - 1 od [r = 3-m ] Task 1.4 (Written, 3 points). = Write a precondition P₁ such that the triple = [P₁] x sqrt(x)/y [T] is valid. Don't make your precondition trivial (a contradiction). Explain by unfolding the definition of the triple as we saw in the class. Task 1.5 (Written, 8 points). a) Write a program S₂ and a precondition P2 such that # [P2]S2[T]. Explain by unfolding the defi- nition of the triple as we saw in the class. b) Have you used a while clause in S₂? If yes, can you provide another S₂ this time without using the while clause? If no, can you provide another S₂ this time with using the while clause? Task 1.6 (Written, 8 points). 2 a) Write a triple for the following program that is valid if and only if the program terminates when the initial value of x is greater than three. while x > 1 do if even(x) then x := 5x + 1 else x := x/2 fi od b) Write another triple for the above program which is valid if and only if the program does not terminate when the initial value of x is less than or equal to three. Task 1.3 (Written, 5 points). Fill in an appropriate precondition such that the following triple is valid. Don't provide a trivial precondition (that is, don't make the precondition a contradiction). Updated 10/4: Added minus sign to postcondition n := -m; while n‡0 do r := r * -3; n := n - 1 od [r = 3-m ] Task 1.4 (Written, 3 points). = Write a precondition P₁ such that the triple = [P₁] x sqrt(x)/y [T] is valid. Don't make your precondition trivial (a contradiction). Explain by unfolding the definition of the triple as we saw in the class. Task 1.5 (Written, 8 points). a) Write a program S₂ and a precondition P2 such that # [P2]S2[T]. Explain by unfolding the defi- nition of the triple as we saw in the class. b) Have you used a while clause in S₂? If yes, can you provide another S₂ this time without using the while clause? If no, can you provide another S₂ this time with using the while clause? Task 1.6 (Written, 8 points). 2 a) Write a triple for the following program that is valid if and only if the program terminates when the initial value of x is greater than three. while x > 1 do if even(x) then x := 5x + 1 else x := x/2 fi od b) Write another triple for the above program which is valid if and only if the program does not terminate when the initial value of x is less than or equal to three.
Expert Answer:
Answer rating: 100% (QA)
Task 13 Appropriate Precondition While there could be multiple valid preconditionsheres one thats nontrivial and ensures the loop eventually terminate... View the full answer
Related Book For
Managerial Economics and Business Strategy
ISBN: 978-0071267441
7th Edition
Authors: Michael R. baye
Posted Date:
Students also viewed these programming questions
-
Given z = == f(x, y), xx(u, v), y=y(u, v), with (3,2) = 5 and y(3,2) = 4, calculate z,(3,2) in terms of some of the values given in the table below. zv(3,2)= = fr(3,2)=2 fy(3,2) = su(3,2) = b yu(3,2)...
-
Suppose that f(5) = 1, f'(5) = 6, g(5) = -8, and g'(5) = 7. Find the following values. (a) (fg)'(5) X (b) (4) (5) (c) (9) (5) X E
-
What personal constructs do you rely on when perceiving the people in this photo?
-
a. Assume that Bangor Co. (a U.S. firm) knows that it will have cash inflows of $900,000 from domestic operations, cash inflows of 200,000 Swiss francs resulting from exports to Swiss operations, and...
-
Many businesses borrow money during periods of increased business activity to finance inventory and trade receivables. Sears Canada Inc. is one of Canada's largest general merchandise retailers. Each...
-
Describe the different types of virtualization.
-
Following are abbreviated income statements for two companies, Ainsley and Bard: Ainsley and Bard produce an identical product and both sell that product at $40. Both companies are searching for ways...
-
The Scorpion King loaned money to the Mummy and his wife, Anck-su-namun. Unfortunately, the Mummy became ill and died before he repaid the loan. After three months, the Scorpion King informed...
-
New York City's Taxi & Limousine Commission has mandated that all licensed city cab owners install new information systems in their cabs. The new state-of-the-art system connects the cabs to a...
-
A food truck with two workers has a deep-fryer that it uses to make doughnuts in addition to other fried foods. Demand has averaged about 35 doughnuts per hour. It takes the first worker 1 minute to...
-
(f) (g) (h) (i) (j) The perigee point of the Molniya 1-44 orbit was at an altitude of 550 km measured from the surface of the Earth. The orbital period of the satellites was set to be half a sidereal...
-
1. Consider the incomplete combustion reaction that you observed with the butane lighter: C4H10(9) + 5 O2(g) 2 CO2(g) +5 H2O(g) + CO(g) + C(s) Assume that the butane is a gas at the time of...
-
a) A passenger car is driving up an incline of 3 degrees at a constant speed of 40 km/h. The vehicle is powered by a 1.5 litre, 4-stroke, SI engine with engine operating range from 1000 (rpm) to 6000...
-
A seasonal food processing industry currently meets its demand for heat and electrical power by purchasing electricity from the local utility and generating heat from a natural gas fired boiler. The...
-
4. (a) A unidirectional carbon fibre reinforced composite has the following properties: E 150 GPa; E2= 8 GPa; G = 10 GPa; v12 = 0.3 where 1 refers to the fibre direction and 2 to the transverse...
-
Suppose that the derivative of a function is df dx 1 18x + 19 Find any antiderivative of the above function. 1 f(x) = In(18x+19) + C 18 Practice another to get more examples of basic antiderivatives...
-
The following selected information was taken from Sun Valley Citys general fund statement of revenues, expenditures, and changes in fund balance for the year ended December 31, 2019: Revenues:...
-
The graph that accompanies this question illustrates two demand curves for a firm operating in a differentiated product oligopoly. Initially, the firm charges a price of $60 and produces 10 units of...
-
Pelican Point Financial Groups clientele consists of two types of investors. The first type of investor makes many transactions in a given year and has a net worth of over $1 million. These investors...
-
Seventy-two percent of the members of the United Food and Commercial Workers Local 655 voted to strike against Stop n Shop in the St. Louis area. In fear of similar union responses, two of Stop n...
-
Suppose that a continuous-time compounding framework is used with a fixed interest rate \(r\). Suppose that the carrying charge per unit of time is proportional to the spot price; that is, the charge...
-
A certain 10-year bond is currently selling for \(\$ 920\). A friend of yours owns a forward contract on this bond that has a delivery date in 1 year and a delivery price of \(\$ 940\). The bond pays...
-
Complete the second half of the proof of the "forward price formula with carrying cost". To construct the arbitrage, go long one unit of a forward and short one unit spot. To execute the short, it is...
Study smarter with the SolutionInn App