300 likes | 422 Views
Midterm Review. 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. Problem 2. Q1: A derivable rule is admissible.
E N D
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
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:
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."
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:
Problem 3 • Q5: Reduction of mutable references • more complicated example in Section 6.2 • Q6: Store typing judgment • a rule in Section 6.3:
Problem 3 • Q7: Environment semantics • definition and rules in Section 9.2: • Q8: Templates in C++ • A Critical Look at Programming Languages:"Unfortunately, the C++ language bastardizes this concept in its support for templates ..."
Problem 4 • Inductive definition • Inductive function
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
Problem 6: Complete CBN • Answer to Q1: • A typical wrong answer in Q1:
Problem 7 • Q1: Substitution • Q2: Type preservation • good job! • Significant upgrade from PL 2006! • Quizzes are good! • We will have two more quizzes!
CSE-321 Programming LanguagesAbstract Machine E 박성우 POSTECH April 30, 2007
Operational Semantics of -Calculus no substitution explicit analysis of an expression
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.
Abstract Machine E explicit analysis of an expression and no substitution
Outline • Overview V • Abstract machine E • Fixed point construct
Outline • Overview V • Abstract machine E V • Fixed point construct