

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
A written assignment for cs415 students, focusing on code layout and operational semantics. The assignment includes questions on drawing the tree of activation records for a call to a recursive function and constructing a derivation for a given piece of code using operational semantics rules. Additionally, students are asked to create operational semantics for new array constructs in cool and modify the operational semantics for the while loop with alternative semantics.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


so, E, S e 1 : Bool(f alse), S 1 so, E, S while e 1 loop e 2 pool : void, S 1 (4)
E(id) = lid S(lid) = v so, E, S ` id : v, S
so, E, S e 1 : Bool(true), S 1 so, E, S 1 e 2 : v, S 2 so, e, S 2 while e 1 loop e 2 pool : void, S 3 so, E, S while e 1 loop e 2 pool : void, S 3
so, E, S e : v, S 1 E(id) = lid S 2 = S 1 [v/lid] so, E, S id โ e : v, S 2
so, E, S e 1 : v 1 , S 1 lnew = newloc(S 1 ) so, E[lnew/id], S 1 [v 1 /lnew] e 2 : v 2 , S 2 so, E, S ` let id : T โ e 1 in e 2 : v 2 , S 2
so, E, S e 1 : Int(n 1 ), S 1 so, E, S 1 e 2 : Int(n 2 ), S 2
v =
Bool(true) if n 1 < n 2 Bool(f alse) if n 1 โฅ n 2
so, E, S ` 2 : Int(2), S
... so, E[lnew /x], S[Int(2)/lnew ] while 1 < x loop x โ x โ 1 pool : void, Sf inal^ (2) so, E, S let x : Int โ 2 in while 1 < x loop x โ x โ 1 pool : void, Sf inal^ (3)