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...
-
An average active person consumes above 2500 Cal a day. (a) What is this in joules? (b) What is this is kilowatt-hours? (c) Your power company charges about a dime per kilowatt-hour. How much would...
-
If the factors that comprise economies of scale were to be placed on a scale from most to least important, what would be their order of importance?
-
For each of the following situations, calculate the \(z\)-statistic \((z)\). a. \(\mathrm{X}^{-}=8.00 ; \mu=5 ; \sigma=6 ; N=16\) b. \(\mathrm{X}^{-}=4.00 ; \mu=2 ; \sigma=8 ; N=25\) c....
-
The following data pertain to British Isles Aggregates Company, a producer of sand, gravel, and cement, for the year just ended. Sales...
-
Write a statement that assigns total_coins with the sum of nickel_count and dime_count. Sample output for 100 nickels and 200 dimes is: 300 Learn how our autograder works 542962 3875132.4x3zqy7 1...
-
TipTop Flight School offers flying lessons at a small municipal airport. The school's owner and manager has been attempting to evaluate performance and control costs using a variance report that...
-
Please use this information to answer the question below: A US firm's expected Accounts Payables from UK due in 90 days Current Spot Rate (SR) for GBP The 90-day Forward Rate for GBP GBP 5,000,000...
-
A golf ball is hit from the tee and travels above level ground. Accounting for air resistance, where is the horizontal location of the peak of the flight: at a position that is less than half the...
-
A rifle is aimed horizontally at a target \(100 \mathrm{~m}\) away, and the bullet leaves the rifle barrel at \(650 \mathrm{~m} / \mathrm{s}\). If the gun is aimed right at the bull's-eye, by how...
-
You leave your house and walk east for \(1.0 \mathrm{~h}\), northeast for \(1.5 \mathrm{~h}\), south for \(1.0 \mathrm{~h}\), and southwest for \(2.5 \mathrm{~h}\), always moving at the same speed....
-
The toy race track in Figure P11.4 has three lanes, and cars cannot change lanes. The centerlines of any two adjacent lanes are 100 mm apart, and the innermost lane has a radius of 1.00 m. (a) If...
-
Your directions on a scavenger hunt map say to walk \(36 \mathrm{~m}\) east, then \(42 \mathrm{~m}\) south, then \(25 \mathrm{~m}\) northwest. With the positive \(x\) direction being east, what is...
-
In C++ Write a Program: Calculate Twitter Followers Marcelo started the week with 12000 Twitter followers. One of his tweets was retweeted by a news outlet, and he gained 35% more followers. Your job...
-
The following items were displayed in the statement of affairs for Lubbock Company: Fully secured liabilities ......... $90,000 Partially secured liabilities ....... 12,000 Unsecured liabilities...
-
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...
-
Do you know about the chart of accounts in your organization as it pertains to information you receive?
-
If you receive reports in the course of your work, do you believe that they are prepared for outside (third party) use or for internal (management) use? What leads you to believe this?
-
If so, is it similar to one of the three formats illustrated in this chapter? If not, how is it different?
Study smarter with the SolutionInn App