

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Programming Languages; Subject: Computer Science; University: University of Alabama - Birmingham; Term: Spring 2005;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Due Thursday, March 10, 2005
derive([rule(e, [e, +, t]), rule(e, [t]), rule(t, [t, *, f]), rule(t, [f]), rule(f, [’(’, e, ’)’]), rule(f, [id])], e, [1, 3, 6, 4, 6, 2, 4, 6], ParseTree) ⇒ ParseTree = parsetree(e, [parsetree(e, [parsetree(t, [parsetree(f, [id])])]), +, parsetree(t, [parsetree(t, [parsetree(f, [id])]), *, parsetree(f, [id])])])
derive([rule(e, [e, +, e]), rule(e, [e, *, e]), rule(e, [’(’, e, ’)’]), rule(e, [id])], e, [1, 4, 2, 4, 4]) ⇒ ParseTree = parsetree(e, [parsetree(e, [id]), +, parsetree(e, [parsetree(e, [id]), *, parsetree(e, [id])])])
u := 1; v := 0; while (v < y) loop u := u * x; v := v + 1; end loop;
Using the axiomatic semantics of Core, show that the assertion {y ≥ 0 } S {u = xy} is correct. Hint: Use the loop invariant u = xv^ & v ≥ 0. The consequence rules may be used to force the other rules into a form consistent with this loop invariant. (You should analyze the program to understand why this loop invariant was chosen.)