Question

Compute the weakest precondition for each of the following assignment statements and postconditions: a = 2...

  1. Compute the weakest precondition for each of the following assignment statements and postconditions:

a = 2 * (b - 1) - 1 {a > 0}

b = (c + 10) / 3 {b > 6}

  1. Prove that the following grammar is ambiguous (show 2 trees):

<S> → <A>

<A> → <A> + <A> | <id>

<id> → a | b | c

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

1) i)

a = 2 * (b - 1) - 1 {a > 0}

2 * (b - 1) - 1 > 0

2 * (b - 1) > 1

(b - 1) > 1/2

b > 1/2 + 1

b > 3 / 2

Above is the weakest pre-condition.

1) ii)

b = (c + 10) / 3 {b > 6}

(c + 10) / 3 > 6

(c + 10) > 18

c > 18 - 10

c > 8

Above is the weakest pre-condition.

2)

Above are two parse trees for deriving a string aaa. So, it is ambiguous.

Please up vote. Happy learning!

Add a comment
Know the answer?
Add Answer to:
Compute the weakest precondition for each of the following assignment statements and postconditions: a = 2...
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