1. Homepage
  2. Homework
  3. CS 440: Programming Languages Assignment: Big-step semantics
This question has been solved

CS 440: Programming Languages Assignment: Big-step semantics

Engage in a Conversation
IITCS 440Programming LanguagesRacketBig-step semantics

IMP Rules CourseNana.COM

CS 440: Programming Languages CourseNana.COM

Assignment: Big-step semantics CourseNana.COM

The following are the big-step semantic rules of the simple imperative language (IMP) as described in class. CourseNana.COM

LITERAL <i,σ>e i when iZ VAR <u,σ>e v if u:=v σ < e1,σ >e v1 < e2,σ >e v2 CourseNana.COM

ARITH CourseNana.COM

< e1 e2, σ >e v1 v2 Figure 1: Arithmetic expressions CourseNana.COM

LITERAL <b,σ>b b if b∈{true,false} VAR <u,σ>b v if u:=v σ < e1,σ >e v1 < e2,σ >e v2 CourseNana.COM

<e1 ve2,σ>b v1 vv2 Figure 2: Boolean expressions CourseNana.COM

SKIP <skip,σ>σ <S1,σ>σ<S2>σ′′ CourseNana.COM

<S1;S2,σ>σ′′
< b,σ >b false < S2,σ >σ CourseNana.COM

< e, σ >e v ASSIGN <x:=e,σ>σ[x:=v] CourseNana.COM

<b,σ>b true <S1,σ>σIF-T <ifbthenS1 elseS2,σ>σ CourseNana.COM

IF-F <ifbthenS1 elseS2,σ>σ<b,σ>b true <S,σ>σ CourseNana.COM

< b,σ >b false WHILE-F <whilebdoS,σ>σ CourseNana.COM

WHILE-T CourseNana.COM

<whilebdoS,σ>σ′′ < while b do S, σ >σ′′ CourseNana.COM

Figure 3: Statements CourseNana.COM

CourseNana.COM

Logistics and Submission CourseNana.COM

Please submit your solutions as a PDF (typed or neatly handwritten!) on Blackboard by the due date. CourseNana.COM

Extending the language CourseNana.COM

(5 points) We wish to add Boolean negation to IMP, via the ! operator. Write down inference rules to describe the big-step semantics of this operator. CourseNana.COM

(10 points) We wish to add for loops to IMP, which will have the form “for v in a0 to a1 do S”, which will run statement S with the variable v taking on values a0 , a0 + 1, ..., a1 . E.g., “for x in 1 to 5 do S” will run S with x taking on values 1, 2, 3, 4, 5, in that order. CourseNana.COM

Write down inference rules to describe the big-step semantics of the for statement. Note that the loop variable is allowed to clash with pre-existing variables, and it may remain in the environment after the loop completes. CourseNana.COM

2 Proofs CourseNana.COM

  1. (5 points) Draw a proof tree for the following assertion:
    < t := a + b; a := b; b := t, {a := 5, b := 10} >⇓ {t := 15, a := 10, b := 15} CourseNana.COM

  2. (5 points) Draw a proof tree for the following assertion:
    < if x > y then m := x 10 else m := y 10, {x := 10, y := 20} >⇓ {x := 10, y := 20, m := 200} CourseNana.COM

  3. Consider the program P = “for x in m to n do sum := sum + x” (which makes use of the for statement defined in the previous section). Note that m and n are not variables, but represent arbitrary integer constants. CourseNana.COM

    1. (a)  (5 points) Describe the environment σsuch that < P, σ0 >σ, where σ0 is an environment which maps all variables to 0. Hint: you may make use of the summation operator (Σ). CourseNana.COM

    2. (b)  (5 points) Write down a program Q using the while statement, which is semantically equivalent to P. CourseNana.COM

    3. (c)  (10 points) Prove that P and Q are equivalent when run in starting state σ0. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
IIT代写,CS 440代写,Programming Languages代写,Racket代写,Big-step semantics代写,IIT代编,CS 440代编,Programming Languages代编,Racket代编,Big-step semantics代编,IIT代考,CS 440代考,Programming Languages代考,Racket代考,Big-step semantics代考,IIThelp,CS 440help,Programming Languageshelp,Rackethelp,Big-step semanticshelp,IIT作业代写,CS 440作业代写,Programming Languages作业代写,Racket作业代写,Big-step semantics作业代写,IIT编程代写,CS 440编程代写,Programming Languages编程代写,Racket编程代写,Big-step semantics编程代写,IITprogramming help,CS 440programming help,Programming Languagesprogramming help,Racketprogramming help,Big-step semanticsprogramming help,IITassignment help,CS 440assignment help,Programming Languagesassignment help,Racketassignment help,Big-step semanticsassignment help,IITsolution,CS 440solution,Programming Languagessolution,Racketsolution,Big-step semanticssolution,