Moven x y z n 0 m is n 1 movem x z y displayxy movem

Info icon This preview shows pages 2–3. Sign up to view the full content.

View Full Document Right Arrow Icon
move(N, X, Y, Z) :- N > 0, M is N - 1, move(M, X, Z, Y), display([X,Y]), move(M, Z, Y, X). Trace the above program using the query hanoi(3) . Show all queries which are generated by the execution and all moves which are printed. You may wish to draw a tree to show this clearly.
Image of page 2

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6. Consider the denotational semantics below: S [[ S 1 ; S 2 ]] store = S [[ S 2 ]] ( S [[ S 1 ]] store ) S [[ V := E ]] store = store [ E [[ E ]] store / V ] S [[ while C loop S end loop ]] store = if C [[ C ]] store then S [[ while C loop S end loop ]] ( S [[ S ]] store ) else store C [[ E 1 > E 2 ]] store = if E [[ E 1 ]] store > E [[ E 2 ]] store then true else false E [[ E 1 + E 2 ]] store = E [[ E 1 ]] store + E [[ E 2 ]] store E [[ E 1 E 2 ]] store = E [[ E 1 ]] store E [[ E 2 ]] store E [[ I ]] store = N [[ I ]] E [[ V ]] store = if store [[ V ]] = then else store [[ V ]] Assume that N returns the integer value of its argument. Given the initial store ( λ V . ) [1/u] [5/y] [5/z], compute the store which results from evaluating S on the program below, showing all steps used in the evaluation. while (u > 0) loop u := u - 1; z := z + y end loop 7. Consider the axioms of assignment, composition, and loop below: Assignment { P [E/V] } V := E { P } Composition { P } S 1 { Q } , { Q } S 2 { R } { P } S 1 ; S 2 { R } Loop { P&B } S { P } { P } while B loop S end loop { P& ¬ B } Prove the correctness of the following program segment. { n = j × (j + 1) / 2 & i 0 } while j != i loop j := j + 1; n := n + j; end loop { n = j × (j + 1) / 2 & i 0 & ¬ (j negationslash = i) } Show all steps used in the proof.
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern