1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Partial correctness with 2 while loops

  1. Sep 9, 2013 #1
    1. The problem statement, all variables and given/known data[/b
    Here is a question on proof of partial correctness with 2 while loops
    with Hoare logic

    {True}
    z:=1
    m:=x
    n:=y
    while (n=!0) do
    while (even(n)) do
    m:=m*n
    n:=n/2
    n:=n-1
    z:=z*m
    {z=x^y}


    2. Relevant equations



    3. The attempt at a solution
    I do know how to solve it when there is only 1 loop: finding invariant P and follow the usual steps.

    But I have no idea how to tackle this one. Any help would be appreciated!! thx heaps
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      6.7 KB
      Views:
      52
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: Partial correctness with 2 while loops
  1. For loops problem (Replies: 0)

  2. Do Loops in Fortran 95 (Replies: 0)

Loading...