DOC PREVIEW
U of I CS 241 - Programming Languages and Compilers

This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Programming Languages andCompilers (CS 421)Elsa L Gunter2112 SC, UIUChttp://www.cs.uiuc.edu/class/fa06/cs421/Based in part on slides by Mattox Beckman, as updatedby Vikram Adve and Gul AghaElsa L. GunterNatural Semantics• Similar to transition semantics except– Transition semantics is relationbetween individual steps ofcomputation– Natural semantics is relation betweencomputation state and final result• Rules look like (C, m) ⇓ m’• Always want Lemma: (C,m) -->* m’ iff (C, m) ⇓ m’Elsa L. GunterPicture• Transition semantics(C1,m1) --> (C2,m2) --> (C3,m3) --> … --> m• Natural Semantics (C1,m1) ⇓ mElsa L. GunterNatural Semantics of AtomicExpressions• Same as Transition• Identifiers: (I,m) ⇓ m(I)• Numerals are values: (N,m) ⇓ N• Booleans: (true,m) ⇓ true (false ,m) ⇓ falseElsa L. GunterBooleans:(B, m) ⇓ false (B, m) ⇓ true (B’, m) ⇓ b(B & B’, m) ⇓ false (B & B’, m) ⇓ b (B, m) ⇓ true (B, m) ⇓ false (B’, m) ⇓ b(B or B’, m) ⇓ true (B or B’, m) ⇓ b(B, m) ⇓ true (B, m) ⇓ false(not B, m) ⇓ false (not B, m) ⇓ trueElsa L. GunterRelations(E, m) ⇓ U (E’, m) ⇓ V U ~ V = b(E ~ E’, m) ⇓ b• By U ~ V = b, we mean does (themeaning of) the relation ~ hold on themeaning of U and V• May be specified by a mathematicalexpression/equation or rules matchingU and VElsa L. GunterArithmetic Expressions(E, m) ⇓ U (E’, m) ⇓ V U op V = N(E op E’, m) ⇓ Nwhere N is the specified value for U op VElsa L. GunterCommands(skip, m) ⇓ m(E,m) ⇓ V(I::=E,m) ⇓ m[I <-- V ](C,m) ⇓ m’ (C’,m’) ⇓ m’’(C;C’, m) ⇓ m’’Elsa L. GunterIf Then Else Command(B,m) ⇓ true (C,m) ⇓ m’(if B then C else C’ fi, m) ⇓ m’(B,m) ⇓ false (C’,m) ⇓ m’(if B then C else C’ fi, m) ⇓ m’Elsa L. GunterWhile Command(B,m) ⇓ false(while B do C od, m) ⇓ m(B,m)⇓true (C,m)⇓m’ (while B do C od, m’)⇓m’’(while B do C od, m) ⇓ m’’Elsa L. GunterExample (2,{x->7})⇓2 (3,{x->7}) ⇓3 (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓{x- >7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ?Elsa L. GunterExample (2,{x->7})⇓2 (3,{x->7}) ⇓3 (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓? ⇓{x- >7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample (2,{x->7})⇓2 (3,{x->7}) ⇓3 ? > ? = ? (2+3, {x->7})⇓5(x,{x->7})⇓? (5,{x->})⇓? (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓? ⇓{x- >7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓? ⇓{x- >7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓{x- >7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓ ? .(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓?(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓ ? {x- >7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample ? + ? = ? (2,{x->7})⇓? (3,{x->7}) ⇓? 7 > 5 = true (2+3, {x->7})⇓?(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓? .(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample 2 + 3 = 5 (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓?(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓ ?{x->7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample 2 + 3 = 5 (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓? {x->7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ ? {x->7, y->5}Elsa L. GunterExample 2 + 3 = 5 (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7}(x > 5, {x -> 7})⇓true ⇓ {x->7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓? {x->7, y->5}Elsa L. GunterExample 2 + 3 = 5 (2,{x->7})⇓2 (3,{x->7}) ⇓3 7 > 5 = true (2+3, {x->7})⇓5(x,{x->7})⇓7 (5,{x->})⇓5 (y:= 2 + 3, {x-> 7} (x > 5, {x -> 7})⇓true ⇓ {x->7, y->5}(if x > 5 then y:= 2 + 3 else y:=3 + 4 fi, {x -> 7}) ⇓ {x->7, y->5}Elsa L. GunterLet in Command(E,m) ⇓V (C,m[x<-V]) ⇓ m’(let


View Full Document

U of I CS 241 - Programming Languages and Compilers

Documents in this Course
Process

Process

28 pages

Files

Files

37 pages

File I/O

File I/O

52 pages

C Basics

C Basics

69 pages

Memory

Memory

23 pages

Threads

Threads

14 pages

Lecture

Lecture

55 pages

C Basics

C Basics

24 pages

Signals

Signals

27 pages

Memory

Memory

45 pages

Threads

Threads

47 pages

Threads

Threads

28 pages

LECTURE

LECTURE

45 pages

Threads

Threads

30 pages

Threads

Threads

55 pages

Files

Files

37 pages

SIGNALS

SIGNALS

22 pages

Files

Files

37 pages

Threads

Threads

14 pages

Threads

Threads

13 pages

Load more
Download Programming Languages and Compilers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Programming Languages and Compilers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Programming Languages and Compilers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?