Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

logical . Consider the following partial grammar with denotational semantics for

ID: 3738630 • Letter: L

Question

logical . Consider the following partial grammar with denotational semantics for statement lists and post-test loops. ? x = { Ms ( , s) ?= (Me (, s) then error if error) for k 1,2,.,n if ( ?k_X) then vk' Me (, s) -> y + { Me ( , s ) z ?= if ( VARMAPfy,s)-= undef OR VARMAP ( z , s)-= undef) then error else VARMAP (y) VARMAP (z) -> y * z { Me (, s) ?= ?E(VARMAP (y,s)-undef OR VARMAP(z,s) undef) then error else VARMAP (y) VARMAP (z) ? [1]; | Ms1 (, s) A case of Ms (, Ms1 ( [1], s) Kstmt> Ms (; s) (continued on next page)

Explanation / Answer

Given:

s = {<a, 10>, <b, 4>, <c, 400>}

loop: do a = a*b while (a<c)

Solution:

initially, a = 10, b=4 and c=400

do, a = a*b,

leads to, a = 10*4, a=40,

condition, a<c, satisfies

after first iteration of loop state s, s = {<a, 40>, <b, 4>, <c, 400>}

now, a=40, b=4, c=400

do, a=a*b,

leads to, a=40*4, a=160

condition, a<c, 160<400, satisfies

after second iteration of loop state, s = {<a, 160>, <b, 4>, <c, 400>}

now, a=160, b=4, c=400

do, a=a*b,

leads to, a=160*4, a=640

condition, a<c, is not satisfied

after completion of loop

state s = {<a, 640>, <b<4>, <c, 400>}