Consider the following program (written in pseudo-code)

begin
x:= 0;
y:= 1;
z:= 1;
while y <= n do
x:= x+1;
z:= z+2;
y:= y+z;
od
sqrt := x;
end

Prove the partial correctness of the program with respect to the following predicates:

Pre: {n>=0}

Post: {sqrt2 <= n and n < (sqrt+1)2
)

That is,
{Pre}
begin
x:= 0;
y:= 1;
z:= 1;
while y <= n do
x:= x+1;
z:= z+2;
y:= y+z;
od
sqrt := x;
end
{Post}

To prove the partial correctness of the given program, we need to show that if the program terminates, then the postcondition is satisfied. In other words, we need to show that if the program terminates, then it holds true that sqrt^2 <= n and n < (sqrt+1)^2.

To prove the partial correctness, we will use a loop invariant. A loop invariant is a property that holds true before and after each iteration of a loop.

Let's analyze the given loop in the program:

while y <= n do
x:= x+1;
z:= z+2;
y:= y+z;
od

The loop invariant for this loop is:
"Iterating through the loop, y = 1 + 3 + 5 + ... + (2x-1), while x represents the number of iterations."

Now let's proceed to prove the partial correctness using this loop invariant:

Proof:
1. Initialization: Before the loop starts, x=0, y=1, and z=1. The loop invariant holds since y = 1, which is equal to the sum of odd numbers from 1 to (2*0-1) = -1. So, the loop invariant holds before the first iteration.

2. Maintenance: Assuming the loop invariant holds before an iteration, we need to show that it still holds after the iteration. Let's assume the loop invariant holds before the (k+1)th iteration, where k represents the iteration number.

Now, after the kth iteration:
x = k,
y = 1 + 3 + 5 + ... + (2k-1),
z = 1 + 2k.

After the (k+1)th iteration:
x = k+1,
y = 1 + 3 + 5 + ... + (2k-1) + (2(k+1)-1),
z = 1 + 2(k+1).

We can rewrite y and z as:
y = (1 + 3 + 5 + ... + (2k-1)) + (2(k+1)-1)
= y + (2(k+1)-1),
z = 1 + 2(k+1).

So, after the (k+1)th iteration, the loop invariant still holds:
y = 1 + 3 + 5 + ... + (2(k+1)-1),
x = k + 1.

3. Termination: The loop terminates when y > n. At this point, the loop invariant still holds: y = 1 + 3 + 5 + ... + (2x-1), and y > n. We can conclude that x represents the integer value of sqrt(n).

Now, we need to prove the postcondition: sqrt^2 <= n and n < (sqrt+1)^2.

Since x represents the integer value of sqrt(n) after the loop terminates, we can substitute sqrt with x in the postcondition:

x^2 <= n and n < (x+1)^2

This is the postcondition. We have successfully proven the partial correctness of the program with respect to the given predicates.

Note: The proof assumes that the program terminates. To prove total correctness, we also need to show that the program always terminates.