Question

The Heaviside step function is a mathematical function defined by h(x) := ( 1 : x ≥ 0 0 : x < ...

The Heaviside step function is a mathematical function defined by h(x) := ( 1 : x ≥ 0 0 : x < 0 that is to say, h(x) is 1 for non-negative x and 0 for negative x. In this question we will prove that the following code computes h(x) if (x >= 0): y = 1 else: y = 0

a) Define a predicate p(x, y), written solely in terms of logical ANDs and ORs, inequalities and equalities, which says that y = h(x). Hint: Create a predicate for each of the two cases in the definition of h(x) and combine them with a logical OR. (1 mark)

b) Write a proof of correctness to show that the code fragment above correctly computes y = h(x). Do this by showing that p(x, y) you defined in the previous part is a post-condition. Hints: As a special case of the assignment rule, if you have an assignment x = E you can take {x = E} as an assertion. Also, you may want to look for inspiration at the proof of correctness for computing max in tutorial 5.

I need answer for part B as i have already done part a thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

-hCt) You have an ascyomed χ°C taka son asertion

Add a comment
Know the answer?
Add Answer to:
The Heaviside step function is a mathematical function defined by h(x) := ( 1 : x ≥ 0 0 : x < ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT