1 Hoare triples Task 1.1 (Written, 10 points). Let s = while i < x do...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1 Hoare triples Task 1.1 (Written, 10 points). Let s = while i < x do x := x * i; i := i + 1 od. For each of the following, is the triple satisfied or unsatisfied in the given state? Explain why by unfolding the definition as we saw in the class. Note that some of these are partial correctness triples and others are total correctness. a) {i = 1, x = 6} =[ i < x ] s [ i = x ] b) {i= -1, x = 5} = {i < x} s {i ≥ 0^x ≤ 0} c) {i=1, x = 0} = {i < x} s {i=x} d) {i=1,x=2} = {x = k} s {x = k!} e) {i = 1, x = 6} = {T} s {]k.x = k!} Task 1.2 (Written, 6 points). Consider program s in the previous task. For each of the following triples, say if it's valid (satisfied in all states or not). If not, provide a counterexample and then fix either the precondition, or the postcondition or the statement to make the triple valid. Don't make your change trivial (that is, don't make the precondition a contradiction, the postcondition a tautology or the statement soemthing that always errors or diverges). a) {T} s {x > 0} b) {x = k} s {x = k} c) [i=1^x=k^x>0] s[i= k^x=k! ] 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). [_ ] n := -m; while n ‡ 0 do r := r * −3; n := n − 1 od [ r = 3m ] 1 Hoare triples Task 1.1 (Written, 10 points). Let s = while i < x do x := x * i; i := i + 1 od. For each of the following, is the triple satisfied or unsatisfied in the given state? Explain why by unfolding the definition as we saw in the class. Note that some of these are partial correctness triples and others are total correctness. a) {i = 1, x = 6} = [ i < x ] s [ i = x ] b) {i= -1, x = 5} = {i < x} s {i≥ 0 ^x ≤ 0} c) {i = 1,x = 0} = {i < x} s {i = x} d) {i=1,x=2} = { x = k} s { x = k!} e) {i = 1, x = 6} = {T} s {]k.x = k!} Task 1.2 (Written, 6 points). Consider program s in the previous task. For each of the following triples, say if it's valid (satisfied in all states or not). If not, provide a counterexample and then fix either the precondition, or the postcondition or the statement to make the triple valid. Don't make your change trivial (that is, don't make the precondition a contradiction, the postcondition a tautology or the statement soemthing that always errors or diverges). a) {T} s {x > 0} b) {x = k} s { x = k} c) [i=1^x=k^x> 0 ] s[i= k^x=k! ] 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). [_ ] n := -m; while n ‡ 0 do r := r * −3; n := n — 1 od [ r = 3m ] 1 Hoare triples Task 1.1 (Written, 10 points). Let s = while i < x do x := x * i; i := i + 1 od. For each of the following, is the triple satisfied or unsatisfied in the given state? Explain why by unfolding the definition as we saw in the class. Note that some of these are partial correctness triples and others are total correctness. a) {i = 1, x = 6} =[ i < x ] s [ i = x ] b) {i= -1, x = 5} = {i < x} s {i ≥ 0^x ≤ 0} c) {i=1, x = 0} = {i < x} s {i=x} d) {i=1,x=2} = {x = k} s {x = k!} e) {i = 1, x = 6} = {T} s {]k.x = k!} Task 1.2 (Written, 6 points). Consider program s in the previous task. For each of the following triples, say if it's valid (satisfied in all states or not). If not, provide a counterexample and then fix either the precondition, or the postcondition or the statement to make the triple valid. Don't make your change trivial (that is, don't make the precondition a contradiction, the postcondition a tautology or the statement soemthing that always errors or diverges). a) {T} s {x > 0} b) {x = k} s {x = k} c) [i=1^x=k^x>0] s[i= k^x=k! ] 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). [_ ] n := -m; while n ‡ 0 do r := r * −3; n := n − 1 od [ r = 3m ] 1 Hoare triples Task 1.1 (Written, 10 points). Let s = while i < x do x := x * i; i := i + 1 od. For each of the following, is the triple satisfied or unsatisfied in the given state? Explain why by unfolding the definition as we saw in the class. Note that some of these are partial correctness triples and others are total correctness. a) {i = 1, x = 6} = [ i < x ] s [ i = x ] b) {i= -1, x = 5} = {i < x} s {i≥ 0 ^x ≤ 0} c) {i = 1,x = 0} = {i < x} s {i = x} d) {i=1,x=2} = { x = k} s { x = k!} e) {i = 1, x = 6} = {T} s {]k.x = k!} Task 1.2 (Written, 6 points). Consider program s in the previous task. For each of the following triples, say if it's valid (satisfied in all states or not). If not, provide a counterexample and then fix either the precondition, or the postcondition or the statement to make the triple valid. Don't make your change trivial (that is, don't make the precondition a contradiction, the postcondition a tautology or the statement soemthing that always errors or diverges). a) {T} s {x > 0} b) {x = k} s { x = k} c) [i=1^x=k^x> 0 ] s[i= k^x=k! ] 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). [_ ] n := -m; while n ‡ 0 do r := r * −3; n := n — 1 od [ r = 3m ]
Expert Answer:
Answer rating: 100% (QA)
This appears to be an exercise related to Hoare logic which is used in computer science to reason about the correctness of computer programs Lets work ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
1.Each individual contributes to the companys image. Reflect on the significance of this statement for a companys customer care management. 2. Like individuals, companies too have business etiquette...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Quality Athletics Company produces a wide variety of sports equipment. Its newest division, Golf Technology, manufactures and sells a single product AccuDriver, a golf club that uses global...
-
A cable company decides to provide Internet access over cable in a neighborhood consisting of 5000 houses. The company uses a coaxial cable and spectrum allocation allowing 100 Mbps downstream...
-
When does a string belong to the set A of bit strings defined recursively by A 0x1 A if x A, where is the empty string?
-
Repeat Problem 7.18 for a Kevlar \(^{\circledR} /\) epoxy composite having lamina properties as follows: Problem 7.18 An antisymmetric angle-ply \([+\theta /-\theta]\) laminate is to be made of...
-
a. Identify the equilibrium outcome(s) in each of the three payoff tables. b. In each table, predict the exact outcome that will occur and explain your reasoning. c. In Table III, suppose the column...
-
Write a MIPS assembly code with minimum possible assembly instructions for the following C++.. Assume that the variables num1, num2 and num3 are already saved in some MIPS registers. if (x > 0 && y...
-
The Walton Toy Company manufactures a line of dolls and a sewing kit. Demand for the company's products is increasing, and management requests assistance from you in determining an economical sales...
-
Which of the following services is an attest engagement? A) An examination of internal controls. B) A review of prospective financial information. OC) A compilation engagement where the accountant...
-
Based on the weekly reading related to Technology: Ethics and Social Responsibility Issues - What are the ways in which a company can manage the growth of technology and leverage technological...
-
a CMAA is crating an encounter form for a patient's appointment upon check-in. Whcih of the following information should the assistnt include on the form? a) debit balance b) Credit balance c)...
-
Which information concerning periodic statements and coupon books is true? A. If the servicer uses periodic statements, each statement must be sent reasonably promptly after the previous payment date...
-
An example illustrating how the equity method can result in manipulation of financial results is the case of Sunbeam Corporation. Sunbeam employed various manipulative tactics, including the use of...
-
Under the temporal method of translation, a foreign entity Multiple choice question. can have a net asset or a net liability balance sheet exposure. always has a net liability balance sheet exposure....
-
1 Acme Lumber Products 2 Wood Glue Usage (in pounds) 3 4 5 6 7 1-Jan-2005 2-Jan-2005 3-Jan-2005 4-Jan-2005 5-Jan-2005 6-Jan-2005 7-Jan-2005 8-Jan-2005 9-Jan-2005 10-Jan-2005 11-Jan-2005 12-Jan-2005...
-
Consider the combustion of methanol below. If 64 grams of methanol reacts with 160 grams of oxygen, what is the CHANGE in volume at STP. 2CH3OH(g) + 3O2(g) 2CO2(g) + 4H2O(1) The volume decreases by...
-
During 2012, Palo Fiero purchases the following property for use in his manufacturing business: Palo uses the accelerated depreciation method under MACRS, if available, and does not make the election...
-
In June of 2012, Maureen's house is vandalized during a long-term power failure after a hurricane hit the city. The president of the United States declares Maureen's city a disaster area as a result...
-
Skyler is covered by his company's health insurance plan. The health insurance costs his company $3,500 a year. During the year, Skyler is diagnosed with a serious illness and the health insurance...
-
\(X\) is the number of bits in error in the next four bits transmitted. What is the expected value of the square of the number of bits in error? Now, \(h(X)=X^{2}\). Therefore, \[ \begin{aligned}...
-
Data 2.7 on page 95 introduces the dataset HollywoodMovies, which contains information on more than 900 movies that came out of Hollywood between 2007 and 2013. One of the variables is the budget (in...
-
Correlation between height and weight for players on the 2014 Brazil World Cup Team, using data from all 23 players on the roster. State whether the quantity described is a parameter or a statistic...
Study smarter with the SolutionInn App