Finding the Precondition

Shinichi72

New member
Joined
Apr 2, 2021
Messages
13
Hello guys, I have answered the weakest precondition. But my teacher told me that my answer is wrong and maybe I have not simplified it yet. Can someone help me to determine what is wrong with my solution



[8:36 PM]
x = 2 * y + x - 1 {x > 11}
Applying the assignment axiom we have the weakest precondition to be
{2 * y + x - 1 > 11}
{2 * y + x > 12}
{2 * y > 12 - x}
{y > 6 - (x/2)}
The weakest precondition is {y > 6 – (x/2)}. What is the simplified form of 6 - (x/2)
 
I don't know about weakest preconditions, but maybe your teacher wanted you to simplify the original equation before using any conditions?

x = 2 * y + x - 1
 
I don't know about weakest preconditions, but maybe your teacher wanted you to simplify the original equation before using any conditions?

x = 2 * y + x - 1
No, I believe the equation represents an assignment of 2 * y + x - 1 to the variable x, not a statement that the two sides are equal. (Sources I checked use ":=" rather than "=".) The x on the left is not the same as the x on the right.

Did the teacher explicitly say that you need to simplify more, or is that your guess? I see nothing wrong with your answer, but then I've never formally studied this subject. Maybe you can show us an example you were given, so we can see if something is wrong in your format.
 
No, I believe the equation represents an assignment of 2 * y + x - 1 to the variable x, not a statement that the two sides are equal. (Sources I checked use ":=" rather than "=".) The x on the left is not the same as the x on the right.

Did the teacher explicitly say that you need to simplify more, or is that your guess? I see nothing wrong with your answer, but then I've never formally studied this subject. Maybe you can show us an example you were given, so we can see if something is wrong in your format.
Yes, you are right that the variable x represents an assignment of 2 * y + x - 1. Well, it's my guess that I need to simplify my final answer because it seems that 6 - (x/2) have a more simplified version? Do you think so? And if yes, then may I know what might be the simplified version of my answer.

If you need a second example to understand it better here it is
2 * (b - 1) - 1 {a > 0}

Applying the assignment axiom we have the weakest precondition to be:

2*(b-1)-1 >0
2*(b-1) >1
2*b > 1+1
2*b>2
b>2/2
b>1
 
Last edited:
If you need a second example to understand it better here it is
2 * (b - 1) - 1 {a > 0}

Applying the assignment axiom we have the weakest precondition to be:

2*(b-1)-1 >0
2*(b-1) >1
2*b > 1+1
2*b>2
b>2/2
b>1

In that example, did you mean "a = 2 * (b - 1) - 1 {a > 0}"? You don't show an assignment!

And are you sure the third line, 2*b > 1+1, is correct? It looks like you didn't distribute the 2!

I was hoping for a correct example you were shown, not one you tried yourself that may be wrong; but also, I was hoping for an example with two variables in the precondition, to see what form is expected in that case, more like your problem. Are there any of those?

Not knowing how this is being taught to you, my own thought had been that they might prefer the form x + 2y > 12. Or maybe it's supposed to be a condition on x rather than y: x > 12 - 2y.

But if the form of the answer, including simplifying, is all that's wrong, I wouldn't have called your answer wrong. I expect the "error" to be something bigger.
 
You example can't be correct.

Note that 2*(b-1) = 2b-1 is Not correct, 2(b-1)=2b-2. It is a 2 you should add to both sides, not a 1 like you did.

2*(b-1)-1 >0
2*(b-1) >1
2*b -2> 1
2*b>2 +1=3
b>3/2


x := 2 * y + x - 1 {x > 11}
2 * y + x - 1>11
2y+x >12

The question at this point is do you solve for x or for y?
It seems that the name of the expression is x and that this expression is greater than 11. OK, I get this part but why would there be an x in the expression as well. That is not good having the same name to represent two things.

2y+x>12
2y>12-x
y> (12-x)/2. Did you teacher make a big deal about getting common denominators?

OR
2y+x>12
x>12-2y
 
In that example, did you mean "a = 2 * (b - 1) - 1 {a > 0}"? You don't show an assignment!

And are you sure the third line, 2*b > 1+1, is correct? It looks like you didn't distribute the 2!

I was hoping for a correct example you were shown, not one you tried yourself that may be wrong; but also, I was hoping for an example with two variables in the precondition, to see what form is expected in that case, more like your problem. Are there any of those?

Not knowing how this is being taught to you, my own thought had been that they might prefer the form x + 2y > 12. Or maybe it's supposed to be a condition on x rather than y: x > 12 - 2y.

But if the form of the answer, including simplifying, is all that's wrong, I wouldn't have called your answer wrong. I expect the "error" to be something bigger.
Oh, I'm sorry that I didn't put the assignment. Here is the complete problem.

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

By the way, this is my first solution when I have first solved the problem

2*(b-1)-1 >0
2*(b-1) >1
2*b -2> 1
2*b>2 +1=3
b>3/2

The weakest precondition is {b > 3/2}. But my teacher told me that it's not correct that is why I didn't the distributive property for my second solution which is the one that I have sent to you. Which is the right one
(Second Solution)
2*(b-1)-1 >0
2*(b-1) >1
2*b > 1+1
2*b>2
b>2/2
b>1.

That is why for this problem.
x = 2 * y + x - 1 {x > 11}
Applying the assignment axiom we have the weakest precondition to be
{2 * y + x - 1 > 11}
{2 * y + x > 12}
{2 * y > 12 - x}
{y > 6 - (x/2)}
The weakest precondition is {y > 6 – (x/2)}.
I don't know If I will use the distributive property or not which is this
{2 * y + x - 1 > 11}
{2 * y + x > 12}
{2 * y > 12 - x}
{y > (12-x)/2}
y>6-x. But my teacher told me that it is wrong
 
Last edited:
You example can't be correct.

Note that 2*(b-1) = 2b-1 is Not correct, 2(b-1)=2b-2. It is a 2 you should add to both sides, not a 1 like you did.

2*(b-1)-1 >0
2*(b-1) >1
2*b -2> 1
2*b>2 +1=3
b>3/2


x := 2 * y + x - 1 {x > 11}
2 * y + x - 1>11
2y+x >12

The question at this point is do you solve for x or for y?
It seems that the name of the expression is x and that this expression is greater than 11. OK, I get this part but why would there be an x in the expression as well. That is not good having the same name to represent two things.

2y+x>12
2y>12-x
y> (12-x)/2. Did your teacher make a big deal about getting common denominators?

OR
2y+x>12
x>12-2y

Here is the complete problem, Sir.
{???} x = 2 * y + x - 1 {x > 11}. And I am searching for the value of Y.
(My solution,but my teacher told me that it's wrong)
x = 2 * y + x - 1 {x > 11}

Applying the assignment axiom we have the weakest precondition to be

{2 * y + x - 1 > 11}

{2 * y + x > 12}

{2 * y > 12 - x}

{y > 6 - (x/2)}

The weakest precondition is {y > 6 – (x/2)}.

I will try your answer if its correct which is this one
2y+x>12
2y>12-x
y> (12-x)/2. I also tried to simplify it into y >6-x, but my teacher told me again that my answer is wrong.
 
You clearly did not read the summary of the guidelines AS YOU WERE TOLD TO DO.

This is apparently a problem in Hoare logic; why would you put it under Arithmetic?

Why would you not tell us what the topic is? There may not even be a helper here who has studied Hoare logic.

Why would you not give us something so we could find out what the notation means?

And why oh why would you wait until post 8 to give us the complete problem, which at least might have indicated that the notation is not that of elementary algebra, but a logical calculus?

You have wasted your time and ours.
 
Last edited:
By the way, this is my first solution when I have first solved the problem

2*(b-1)-1 >0
2*(b-1) >1
2*b -2> 1
2*b>2 +1=3
b>3/2

The weakest precondition is {b > 3/2}. But my teacher told me that it's not correct that is why I didn't the distributive property for my second solution which is the one that I have sent to you. Which is the right one
(Second Solution)
2*(b-1)-1 >0
2*(b-1) >1
2*b > 1+1
2*b>2
b>2/2
b>1.
You're saying that this is supposedly correct? Please tell us what you were taught to explain the nonsense step of not distributing!

As I said when I first jumped in here, I have not studied this topic, but recognized it (with some difficulty); I don't know, and haven't found, details about how this is to be done in a case like yours, but I thought the rules of algebra still applied.

I will try your answer if its correct which is this one
2y+x>12
2y>12-x
y> (12-x)/2. I also tried to simplify it into y >6-x, but my teacher told me again that my answer is wrong.
Please ask your teacher to actually teach you.

And please show us a complete example you were given that involves two variables, ideally an image, so we can see how it is explained.

Also, please show us the entire problem you asked about, including instructions.
 
You clearly did not read the summary of the guidelines AS YOU WERE TOLD TO DO.

This is apparently a problem in Hoare logic; why would you put it under Arithmetic?

Why would you not tell us what the topic is? There may not even be a helper here who has studied Hoare logic.

Why would you not give us something so we could find out what the notation means?

And why oh why would you wait until post 8 to give us the complete problem, which at least might have indicated that the notation is not that of elementary algebra, but a logical calculus?

You have wasted your time and ours.
Oh, I am very sorry for the thing that I have done. I am new to this page, that is why I don't read all the guidelines. Sorry for my mistake. Then may I know that type of topic where should I place my answer on, so no one would be confused
 
You're saying that this is supposedly correct? Please tell us what you were taught to explain the nonsense step of not distributing!

As I said when I first jumped in here, I have not studied this topic, but recognized it (with some difficulty); I don't know, and haven't found, details about how this is to be done in a case like yours, but I thought the rules of algebra still applied.


Please ask your teacher to actually teach you.

And please show us a complete example you were given that involves two variables, ideally an image, so we can see how it is explained.

Also, please show us the entire problem you asked about, including instructions.
I am very sorry Dr. Patterson for my misconduct behavior and for wasting your time. And I truly appreciate your help, even though you didn't know the topic well. I will just try to post my problem on the ADVANCED MATH topic.
 
Last edited:
Read this


I never heard of Hoare logic until an hour ago. Based on what I read at wikipedia, this should go under Advanced Math because it seems to be a logical calculus that is part of proof theory.
 
Top