Midterm Review - PowerPoint PPT Presentation

About This Presentation
Title:

Midterm Review

Description:

Q2: Factorial with mutable references. similar example in Section 6.1: ... Q5: Reduction of mutable references. more complicated example in Section 6.2 ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 31
Provided by: sungwo8
Category:

less

Transcript and Presenter's Notes

Title: Midterm Review


1
Midterm Review
2
Problem 1
  • Q1 Tail-recursive factorial
  • Assignment 2
  • Q2 Factorial with mutable references
  • similar example in Section 6.1
  • Q3 Functional representation of sets
  • last year's midterm

3
Problem 2
  • Q1 A derivable rule is admissible.
  • Section 2.3"A derivable rule is certainly
    admissible, but ..."
  • Q3 ?-conversion in Exercise 3.1
  • Q4 Definition of fixed points
  • if f(v) v, then (f o f o ... o f)(v) v.
  • Q6 Type inhabitation
  • Section 5.5

4
Problem 2
  • Q7 Soundness vs. Completeness
  • Section 7.1"... an algorithmic typing judgment
    covers all possible cases of well-typed
    expressions and is thus complete."
  • Q8 Static type system for a safe language
  • TPL page 6"Language safety is not the same
    thing as static type safety."

5
Problem 3
  • Q1 Call-by-name reduction
  • example in Section 3.2
  • Q3 Encoding bool
  • Section 5.3
  • Q4 Fixed point construct
  • Section 5.4

6
Problem 3
  • Q5 Reduction of mutable references
  • more complicated example in Section 6.2
  • Q6 Store typing judgment
  • a rule in Section 6.3

7
Problem 3
  • Q7 Environment semantics
  • definition and rules in Section 9.2
  • Q8 Templates in C
  • A Critical Look at Programming Languages"Unfortu
    nately, the C language bastardizes this concept
    in its support for templates ..."

8
Problem 4
  • Inductive definition
  • Inductive function

9
Problem 5 Logarithm
  • Q1 Fixed point combinator
  • ¼ Can you write an SML function for log?
  • fun log n if n 1 then 0 else 1 (log (n /
    2))
  • Q2 log without the fixed point combinator
  • Idea
  • (8, 0) ! (4, 1) ! (2, 2) ! (1, 3) ! (1, 3) ! (1,
    3) ! (1, 3) ! (1, 3) ! (1, 3)
  • an error in the sample solution

10
Problem 6 Complete CBN
  • Answer to Q1
  • A typical wrong answer in Q1

11
Problem 7
  • Q1 Substitution
  • Q2 Type preservation
  • good job!
  • Significant upgrade from PL 2006!
  • Quizzes are good!
  • We will have two more quizzes!

12
Score Distribution
13
CSE-321 Programming LanguagesAbstract Machine E
???
  • POSTECH
  • April 30, 2007

14
Operational Semantics of ?-Calculus
no substitution
explicit analysis of an expression
15
Key Ideas in Environment Semantics
  • No substitution
  • Delay the substitution v / x e as much as
    possible.
  • store v / x in the environment.
  • proceed to evaluate e.
  • replace x by v only if necessary.
  • A closure stores the values of all free variables
    in a given ?-abstraction.

16
Environment Semantics
17
Abstract Machine E
explicit analysis of an expression and no
substitution
18
Outline
  • Overview V
  • Abstract machine E
  • Fixed point construct

19
Abstract Machine C Environment Semantics
20
States of the Abstract Machine E
21
Definition
22
State Transition
23
State Transition
24
State Transition
25
Example
26
Outline
  • Overview V
  • Abstract machine E V
  • Fixed point construct

27
Reduction Rule
28
fix for creating recursive functions
29
Abstract Syntax and Typing
30
Reduction
Write a Comment
User Comments (0)
About PowerShow.com