April 3, 2000 Eli Barzilay [Part II]

Size: px
Start display at page:

Download "April 3, 2000 Eli Barzilay [Part II]"

Transcription

1 [Part II] Eli Barzilay April 3, 2000

2 Ideology Break General ideology: duplication of functional information is bad, this is the essence of programming. Consequent: the recursive type alone is not a good solution it means that we duplicate the encoding of term structures that is already part of Nuprl itself. The value Scheme s reflection is: The user shares the implementation s data structures. Also, the eval function is shared. Clarity of the connection between the user s eval and the implementation s eval trivial. Eli Barzilay Reflection & Nuprl 1/32

3 Scheme s Approach When it comes to implementing Scheme, these shortcuts are natural: The implementation uses data structures and code that behaves like Scheme s data structures: why use a different representation and translate back and forth? Even clearer when considering eval: execution of quoted code by eval is expected to be the same as execution of code, so using the same function is the obvious solution. Eli Barzilay Reflection & Nuprl 2/32

4 The Problem with Logic The simplicity of Scheme is not seen in a logical system: We must deal with truth and proofs as well as evaluation. This is hard so: we tend to avoid changing the logic a strong point for using Gödel numbers is that the logic itself is not extended. My intuition: when it comes to an implemented, Scheme s insights are extremely useful because they will make reflection practical (as I will show). Eli Barzilay Reflection & Nuprl 3/32

5 Scheme s Approach Avoid the [double] evil of duplicating function in logic: code representation and evaluation are shared with users. It is trivial to get convinced that eval s implementation is correct assuming that the language implementation is itself correct. Eli Barzilay Reflection & Nuprl 4/32

6 Natural Language Natural language is very different than formal language, but it is still a good source of intuition. There are several indications that we use the same parse mechanism for natural language: Parsing is done in real-time the brain is doing the same mental activity (makes being a simultaneous translator so difficult). If quotations were parsed in a different way we would take them as a different language. Eli Barzilay Reflection & Nuprl 5/32

7 # " % and that Eli Barzilay Reflection & Nuprl 6/32 Nuprl s syntax, semantics and rules). each stage depends on the previous. (For example, defining ""is defined in three stages!assume $ and ", have several parts with some dependencies.!in systems that we are interested in, the definition/design will!assume some system "(any kind of system).!try to understand things following some very general example. General Example

8 ' ) /. - - ( & Eli Barzilay Reflection & Nuprl 7/32 as +, we can do the same and get +,, +,,,, *After all this, we get what we want: since +, is exactly the same etc. the same as+. *Finally, we have +, and now we should show that it is exactly *And continue with +, in +using +, and the same for +,. *So we begin by implementing +, in (terms of) +. ++, a reflected version of *Now we want to get within itself. General Example

9 General Example 4If we want to actually have an infinite chain of such embedded systems, we will have to use some circularity (or an infinite piece of paper). 4This can be achieved using the method described earlier. 4Specifically, a fixed-point construction or implementation shortcuts can do this. Eli Barzilay Reflection & Nuprl 8/32

10 6 8 : 7 5 Eli Barzilay Reflection & Nuprl 9/32 9This is the place that programmers should feel that something is going wrong and that logicians wouldn t necessarily be concerned about it doesn t feel good implementing something that we already did. thing is duplicated! and another complete implementation of : ; in:: the whole 9The problem: we have both a complete implementation of General Example

11 =? FA E D D A C > < Eli Barzilay Reflection & Nuprl 10/32 is one thing that Aitken could have used to reduce some... and finally use itself. wrap these two in an interface that FA can use, show that A B A B and are equivalent to EA DA and, do the same thing until we have A B, C and then use it to continue, for example: equivalent way that we can try to solve this show that some A B is General Example

12 H J O NL O P N I G Eli Barzilay Reflection & Nuprl 11/32 from Linto itself. KBut it is better if don t do anything at all: just make shortcuts KWe could do the same right after we get L M. makes this very unnatural. wrap NL somehow, make sure that is accessible by itself, show that L M L M and are the same as those inl, KTook some work off no need for L M, but still need to: General Example

13 R T XV S Q Eli Barzilay Reflection & Nuprl 12/32 (define user-eval (compose rep impl-eval unrep)) Wrap eval in these: internal eval structures, Write translation functions to (unrep) and from rep the Make sure they are equivalent to Scheme s, Create some new data structures in Scheme, UPartial shortcut: UFull scenario: a complete Scheme parser/interpreter in Scheme. : evaluation function. WV : syntax structures, UThis is exactly what happens in Scheme: General Example: The Scheme Side

14 Z \ [ Y General Example: Conclusion ]Better stop and think before trying to implement a reflected system. ]Exposing some internals of a system into itself is the best way to get reflection. ]This might require some changes to the design of the system since the exposed internals usually use mechanisms that have no equivalent in the world of its users (for example, terms in Nuprl). Eli Barzilay Reflection & Nuprl 13/32

15 _ a ` ^ The Nuprl Side bmy strong intuition here is that this applies perfectly to Nuprl. bthe definition stages we have are basically Syntax, Semantics/Evaluation, Inference rules. bcan split further to a more complex DAG. Eli Barzilay Reflection & Nuprl 14/32

16 d f e c The Nuprl Side gmoreover, such shortcuts should also be useful for the paper implementation the design. ga side-effect effect is that implementation details all pop up in the design stage (because we re mixing the two). ga similar case Nuprl uses its implementation s numbers: Goes down to Lisp numbers. Risk: Nuprl s number behave correctly only if Lisp s numbers are OK. If we d use 0 and succ, we wouldn t be able to do a lot of stuff we can do now. Classic tradeoff. Coq? HOL? Eli Barzilay Reflection & Nuprl 15/32

17 i k poand nm1:q,i:l nmi:l po;y,z. po;y,z. poand j h Term Quotations lthe suggested way of doing quotations was add quote parameter, with a value that indicates the quoted-ness level of the term. lfoo foo quoted (x. (x. respectively. ) is quoted as ) where are lchoosing a quotation mechanism turns out to be a crucial decision looks like this one is The Right Thing. Eli Barzilay Reflection & Nuprl 16/32

18 r t s q Term Quotations: The Hard Way umentioned earlier: use a recursive type definition: an opid and a pair of lists. urelies on having an available type theory, bad for Meta-PRL. urepresentation gets exponentially big when a term is quoted over and over, a Scheme example shows this easily: Original expression: (foo x) Quoted once: (list foo x) Quoted twice: (list list (list quote foo) (list quote x)) Eli Barzilay Reflection & Nuprl 17/32

19 w y x v Term Quotations: The Hard Way zthe user-interface problem can be avoided using appropriate I/O mechanisms. zhowever, it is still as efficient as using 0 and succ for integers. zthe main damage this causes is that it leads the whole implementation down the wrong path Aitken s case. zthe single advantage of this is that the logic is not extended. Eli Barzilay Reflection & Nuprl 18/32

20 ~ 1:q,i:l } { Term Quotations: Another Alternative An example for some suggested quotations that didn t go all the way. This is a good example to get the feeling of implementation shortcuts being much better. Make binding variables of subterms be quoted on their own as more subterms supposed to make binding variables more easily accessible (actually, level-expression variables as well, but these are ignored now.). So the above term is quoted as: foo (x; ƒ ;y;z; ) Now the fun begins... Eli Barzilay Reflection & Nuprl 19/32

21 Š <1,[1;2]>:q,i:l Alternative: Problem #1 ˆFirst of all, we have to be really careful about the representation: in the above quotation there is no way to know which quoted subterms are quoted subterms and which are quoted bindings. ˆSolution: make the quote parameter contain more information that describes the quoted term s binding structure. ˆfoo (x; Œ ;y;z; ) ˆThis, again, depends on type theory for the lists. ˆAlso, pulls toward the recursive type solution (except that the integer quote parameter can prevent exponential blowup). Eli Barzilay Reflection & Nuprl 20/32

22 Ž Eli Barzilay Reflection & Nuprl 21/32 This is a place where using built-in terms pays off easily: such problems do not occur with them since we take advantage of existing design decisions. syntax. I thought about this but then Bob said that the is part of the Also what if all terms were bound terms (so variables are associated differently)? Could do the same. aren t quoted. For example, quote only the in all (x.p) getting all <1,[1]>:q (x;p) where both the x and the P Using this quotation method, it is possible to quote a term without any of its subterms. Alternative: Problem #2

23 œ <1,[1;2]>:q,i:l Eli Barzilay Reflection & Nuprl 22/32 and this has no sense as a quoted term. foo žÿ ; ( ;y;z; ) šso, it is possible to enter: has. unrestricted we can t control what subterms a quoted term šanother problem pops up because these quotes are too Alternative: Problem #3

24 » using: Eli Barzilay Reflection & Nuprl 23/32 make. Another point is that nonsensical quoted terms are harder to level. This is even simpler if the quote parameters have an integer ±² ³ µ ¹º ±» ± ¼ µ ¹º ±² ½ ³³³ quoted level ª«ª«given some internal ª«ª«create for every same functionality wrapping it in quotation level shifters, so It is also easy to get reflected functionality as well use the Exposing internal functionality is very simple. Almost completely independent of the underlying logic. Suggested Quotes: Advantages

25 Á À ¾ Quoted Binding Variables ÂThe decision that binding variables are quoted with their surrounding term makes even more sense. ÂQuoting them means that they have no semantic meaning of their own, but they are still binding occurrences in the quoted level. ÂThis can be demonstrated in Scheme: (lambda (x) x) is a simple list with symbols and a sublist but when we treat this on the quoted level, for example as input to eval, the x will have meaning as a binding variable. Eli Barzilay Reflection & Nuprl 24/32

26 Ä Æ È Å Ã Eli Barzilay Reflection & Nuprl 25/32 and ËËÊ. concept for example, because we cannot distinguish ÈÉÊ É ÇMoreover, we cannot talk about alpha-renaming or any related need to expose any alpha-renaming functionality. ÇThis is adds convenience (higher-level abstraction): there is no lists). alpha renaming automatically (similar to representing sets using ÇDoing this is similar to exposing a term package that handles take equivalence classes over alpha-renaming. ÇWe can continue this: instead of using quoted terms we can Terms with Alpha-Equality

27 Í Ï Ô Ô Î Ì Eli Barzilay Reflection & Nuprl 26/32 when we want to allow some variable to appear. instantiated with different variables, and we have to specify ÐThis means that different pattern variables are can only be instantiated with an that contains a free occurrence of Ò. ÐFor example, the rewrite rule ÑÒÓ ÔÒÕÖ cannot be the one used to specify rewrite rules in Meta-PRL. ÐThis can be added to a smart-substitution mechanism such as cannot do with such an interface (for example, display-forms). auto-alpha-renaming package and see what you can and ÐThe intuition here: think about an implementation with a similar Terms with Alpha-Equality

28 Ø Ú æ å Ù Eli Barzilay Reflection & Nuprl 27/32 älines, compared to a previous çline version). and this cannot be used when in Þáappears (actual version is Ü Ýáâã ÝÞß à Ü ÝÞß à ÛFor example, the Meta-PRL thinning rule looks like happens. ÛUsing this frees us from making sure that no name-capture Terms with Alpha-Equality

29 é ë ê è Terms with Alpha-Equality ìa similar idea appears in Scheme macros. ìthe usual problem is unsafe macros that capture names. ìfor example: (defmacro (swap x y) (let ((tmp,x)) (set!,x,y) (set!,y tmp))) ìad-hock solution: (defmacro (swap x y) (let ((tmp (gensym))) (let ((,tmp,x)) (set!,x,y) (set!,y,tmp)))) ìan attempt at a better solution: the hygiene macro system: (define-syntax swap (syntax-rules () ((swap x y) (let ((tmp x)) (set! x y) (set! y tmp))))) ìthis is, however, limited need some primitive system for some things. Eli Barzilay Reflection & Nuprl 28/32

30 î ð ù should be replaced with one-argument ï í Eli Barzilay Reflection & Nuprl 29/32 a binding variable. ñthis makes it even more obvious that can still be regarded as second-order pattern. except that õ ö ø óò ôõ ö ø ùú ÿþýüû ý ü ò ô ú ó ñand when it does: whenódoes not have a free occurrence of, óò ôõ ö ø ùú ÿþýüû ý ü ò ô ú ó ñwe could say things like: ñthis idea can be carried over to a reflected Nuprl. Terms with Alpha-Equality

31 Terms with Alpha-Equality It makes a lot of sense for such ideas to come from an implementation. Meta-PRL s rule specifications are actually a meta-language that specifies Meta-PRL. Using this not only makes writing correct rules easier it also makes writing invalid rules more difficult, similar to the Scheme hygiene macros: impossible to write a macro that captures a name. There will probably not be any need for a lower-level term representation that will not use alpha-equivalence (hopefully). Eli Barzilay Reflection & Nuprl 30/32

32 Final Thoughts... Some more things that will take too much time: In natural language, we can never use an object, just talk about it for example, logic books refer to objects like Lemma 2.5 on page 245. An equivalent of this would be to make the Nuprl library hold quoted objects. (Not practical since it makes it too opaque). Once we have such quoted object any functionality can be reflected as well internal or not. For example, we can talk about,, etc using a rep/unrep wrapper. A quotify operator must be a built-in operation since it is impossible to know the intensional structure of an extensional object (example: quoting Scheme procedures). Eli Barzilay Reflection & Nuprl 31/32

33 The End Related work:? Conclusions: many. Future work: definitely! Eli Barzilay Reflection & Nuprl 32/32

CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal)

CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal) CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal) What is the Metacircular Evaluator? It is the best part

More information

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered

More information

Functional abstraction

Functional abstraction Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

step is to see how C++ implements type polymorphism, and this Exploration starts you on that journey.

step is to see how C++ implements type polymorphism, and this Exploration starts you on that journey. EXPLORATION 36 Virtual Functions Deriving classes is fun, but there s not a lot you can do with them at least, not yet. The next step is to see how C++ implements type polymorphism, and this Exploration

More information

6.001 Notes: Section 6.1

6.001 Notes: Section 6.1 6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of

More information

Lecture 5 C Programming Language

Lecture 5 C Programming Language Lecture 5 C Programming Language Summary of Lecture 5 Pointers Pointers and Arrays Function arguments Dynamic memory allocation Pointers to functions 2D arrays Addresses and Pointers Every object in the

More information

6.001 Notes: Section 1.1

6.001 Notes: Section 1.1 6.001 Notes: Section 1.1 Slide 1.1.1 This first thing we need to do is discuss the focus of 6.001. What is this course all about? This seems quite obvious -- this is a course about computer science. But

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17 01.433/33 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/2/1.1 Introduction In this lecture we ll talk about a useful abstraction, priority queues, which are

More information

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

5. Introduction to the Lambda Calculus. Oscar Nierstrasz 5. Introduction to the Lambda Calculus Oscar Nierstrasz Roadmap > What is Computability? Church s Thesis > Lambda Calculus operational semantics > The Church-Rosser Property > Modelling basic programming

More information

From the λ-calculus to Functional Programming Drew McDermott Posted

From the λ-calculus to Functional Programming Drew McDermott Posted From the λ-calculus to Functional Programming Drew McDermott drew.mcdermott@yale.edu 2015-09-28 Posted 2015-10-24 The λ-calculus was intended from its inception as a model of computation. It was used by

More information

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion Today s video will talk about an important concept in computer science which is

More information

Meta-programming with Names and Necessity p.1

Meta-programming with Names and Necessity p.1 Meta-programming with Names and Necessity Aleksandar Nanevski Carnegie Mellon University ICFP, Pittsburgh, 05 October 2002 Meta-programming with Names and Necessity p.1 Meta-programming Manipulation of

More information

CSE 505: Concepts of Programming Languages

CSE 505: Concepts of Programming Languages CSE 505: Concepts of Programming Languages Dan Grossman Fall 2003 Lecture 6 Lambda Calculus Dan Grossman CSE505 Fall 2003, Lecture 6 1 Where we are Done: Modeling mutation and local control-flow Proving

More information

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

CS61A Notes Week 1A: Basics, order of evaluation, special forms, recursion

CS61A Notes Week 1A: Basics, order of evaluation, special forms, recursion CS61A Notes Week 1A: Basics, order of evaluation, special forms, recursion Assorted Scheme Basics 1. The ( is the most important character in Scheme. If you have coded in other languages such as C or Java,

More information

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

CSE 341: Programming Languages

CSE 341: Programming Languages CSE 341: Programming Languages Autumn 2005 Lecture 10 Mutual Recursion, Equivalence, and Syntactic Sugar CSE 341 Autumn 2005, Lecture 10 1 Mutual Recursion You ve already seen how multiple functions can

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

Part II Composition of Functions

Part II Composition of Functions Part II Composition of Functions The big idea in this part of the book is deceptively simple. It s that we can take the value returned by one function and use it as an argument to another function. By

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define

Summer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

(Refer Slide Time: 4:00)

(Refer Slide Time: 4:00) Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional

More information

AXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop

AXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop AXIOMS OF AN IMPERATIVE LANGUAGE We will use the same language, with the same abstract syntax that we used for operational semantics. However, we will only be concerned with the commands, since the language

More information

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017

SCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017 SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,

More information

Lecture 1: Overview

Lecture 1: Overview 15-150 Lecture 1: Overview Lecture by Stefan Muller May 21, 2018 Welcome to 15-150! Today s lecture was an overview that showed the highlights of everything you re learning this semester, which also meant

More information

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University Functional Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Historical Origins 2 The imperative and functional models grew out of work

More information

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan MATH 22 Lecture M: 10/14/2003 MORE ABOUT FUNCTIONS Form follows function. Louis Henri Sullivan This frightful word, function, was born under other skies than those I have loved. Le Corbusier D ora innanzi

More information

Handout 9: Imperative Programs and State

Handout 9: Imperative Programs and State 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

More information

Project 5 - The Meta-Circular Evaluator

Project 5 - The Meta-Circular Evaluator MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Spring Semester, 2005 Project 5 - The Meta-Circular

More information

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson

6.184 Lecture 4. Interpretation. Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson 6.184 Lecture 4 Interpretation Tweaked by Ben Vandiver Compiled by Mike Phillips Original material by Eric Grimson 1 Interpretation Parts of an interpreter Arithmetic calculator

More information

The compiler is spewing error messages.

The compiler is spewing error messages. Appendix B Debugging There are a few different kinds of errors that can occur in a program, and it is useful to distinguish between them in order to track them down more quickly. Compile-time errors are

More information

Lecture 3: Recursion; Structural Induction

Lecture 3: Recursion; Structural Induction 15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion

More information

Intro to Haskell Notes: Part 5

Intro to Haskell Notes: Part 5 Intro to Haskell Notes: Part 5 Adrian Brasoveanu October 5, 2013 Contents 1 Curried functions and related issues 1 1.1 Curried functions......................................... 1 1.2 Partially applied

More information

CS61A Summer 2010 George Wang, Jonathan Kotker, Seshadri Mahalingam, Eric Tzeng, Steven Tang

CS61A Summer 2010 George Wang, Jonathan Kotker, Seshadri Mahalingam, Eric Tzeng, Steven Tang CS61A Notes Week 6B: Streams Streaming Along A stream is an element and a promise to evaluate the rest of the stream. You ve already seen multiple examples of this and its syntax in lecture and in the

More information

MITOCW watch?v=kz7jjltq9r4

MITOCW watch?v=kz7jjltq9r4 MITOCW watch?v=kz7jjltq9r4 PROFESSOR: We're going to look at the most fundamental of all mathematical data types, namely sets, and let's begin with the definitions. So informally, a set is a collection

More information

Propositional Logic. Part I

Propositional Logic. Part I Part I Propositional Logic 1 Classical Logic and the Material Conditional 1.1 Introduction 1.1.1 The first purpose of this chapter is to review classical propositional logic, including semantic tableaux.

More information

CS450: Structure of Higher Level Languages Spring 2018 Assignment 7 Due: Wednesday, April 18, 2018

CS450: Structure of Higher Level Languages Spring 2018 Assignment 7 Due: Wednesday, April 18, 2018 CS450: Structure of Higher Level Languages Spring 2018 Assignment 7 Due: Wednesday, April 18, 2018 Taken from assignments by Profs. Carl Offner and Ethan Bolker Part 1 - Modifying The Metacircular Evaluator

More information

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise

CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise If you re not already crazy about Scheme (and I m sure you are), then here s something to get

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

Steven Skiena. skiena

Steven Skiena.   skiena Lecture 22: Introduction to NP-completeness (1997) Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Among n people,

More information

From Syntactic Sugar to the Syntactic Meth Lab:

From Syntactic Sugar to the Syntactic Meth Lab: From Syntactic Sugar to the Syntactic Meth Lab: Using Macros to Cook the Language You Want a V E N E TRUT H Brandeis S PA R T U N T O I T S I N N E R M OS T COMPUTER SCIENCE 21B: Structure and Interpretation

More information

Modules. CS2023 Winter 2004

Modules. CS2023 Winter 2004 Modules CS2023 Winter 2004 Outcomes: Modules C for Java Programmers, Chapter 7, sections 7.4.1-7.4.6 Code Complete, Chapter 6 After the conclusion of this section you should be able to Understand why modules

More information

SFU CMPT Lecture: Week 8

SFU CMPT Lecture: Week 8 SFU CMPT-307 2008-2 1 Lecture: Week 8 SFU CMPT-307 2008-2 Lecture: Week 8 Ján Maňuch E-mail: jmanuch@sfu.ca Lecture on June 24, 2008, 5.30pm-8.20pm SFU CMPT-307 2008-2 2 Lecture: Week 8 Universal hashing

More information

Chapter 2 The Language PCF

Chapter 2 The Language PCF Chapter 2 The Language PCF We will illustrate the various styles of semantics of programming languages with an example: the language PCF Programming language for computable functions, also called Mini-ML.

More information

Project 5 - The Meta-Circular Evaluator

Project 5 - The Meta-Circular Evaluator MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Fall Semester, 2005 Project 5 - The Meta-Circular

More information

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught

More information

Intro to Algorithms. Professor Kevin Gold

Intro to Algorithms. Professor Kevin Gold Intro to Algorithms Professor Kevin Gold What is an Algorithm? An algorithm is a procedure for producing outputs from inputs. A chocolate chip cookie recipe technically qualifies. An algorithm taught in

More information

Pointers. CS2023 Winter 2004

Pointers. CS2023 Winter 2004 Pointers CS2023 Winter 2004 Outcomes: Introduction to Pointers C for Java Programmers, Chapter 8, sections 8.1-8.8 Other textbooks on C on reserve After the conclusion of this section you should be able

More information

Pointers & Arrays. CS2023 Winter 2004

Pointers & Arrays. CS2023 Winter 2004 Pointers & Arrays CS2023 Winter 2004 Outcomes: Pointers & Arrays C for Java Programmers, Chapter 8, section 8.12, and Chapter 10, section 10.2 Other textbooks on C on reserve After the conclusion of this

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 7 Wouter Swierstra 1 Last time Relating evaluation and types How to handle variable binding in embedded languages? 2 DSLs: approaches A stand-alone DSL typically

More information

Banner 8 Using International Characters

Banner 8 Using International Characters College of William and Mary Banner 8 Using International Characters A Reference and Training Guide Banner Support January 23, 2009 Table of Contents Windows XP Keyboard Setup 3 VISTA Keyboard Setup 7 Creating

More information

The Diagonal Lemma: An Informal Exposition

The Diagonal Lemma: An Informal Exposition The Diagonal Lemma: An Informal Exposition Richard G Heck, Jr At the heart of Gödel s incompleteness theorem is the so-called diagonal lemma whose purpose is to allow us to construct self-referential sentences,

More information

Proofwriting Checklist

Proofwriting Checklist CS103 Winter 2019 Proofwriting Checklist Cynthia Lee Keith Schwarz Over the years, we ve found many common proofwriting errors that can easily be spotted once you know how to look for them. In this handout,

More information

Lecture 3: Constructing the Natural Numbers

Lecture 3: Constructing the Natural Numbers Math/CS 120: Intro. to Math Professor: Padraic Bartlett Lecture 3: Constructing the Natural Numbers Weeks 3-4 UCSB 2014 When we defined what a proof was in our first set of lectures, we mentioned that

More information

Bindings & Substitution

Bindings & Substitution Bindings & Substitution Even in our simple language, we encounter repeated expressions. 1 {* {+ 4 2} {+ 4 2}} There are several reasons to eliminate duplicated code. It introduces a redundant computation.

More information

Functional Programming

Functional Programming Functional Programming CS331 Chapter 14 Functional Programming Original functional language is LISP LISt Processing The list is the fundamental data structure Developed by John McCarthy in the 60 s Used

More information

RSA (Rivest Shamir Adleman) public key cryptosystem: Key generation: Pick two large prime Ô Õ ¾ numbers È.

RSA (Rivest Shamir Adleman) public key cryptosystem: Key generation: Pick two large prime Ô Õ ¾ numbers È. RSA (Rivest Shamir Adleman) public key cryptosystem: Key generation: Pick two large prime Ô Õ ¾ numbers È. Let Ò Ô Õ. Pick ¾ ½ ³ Òµ ½ so, that ³ Òµµ ½. Let ½ ÑÓ ³ Òµµ. Public key: Ò µ. Secret key Ò µ.

More information

Implementing Programming Languages

Implementing Programming Languages Out of print; full text available for free at http://www.gustavus.edu/+max/concrete-abstractions.html CHAPTER TEN Implementing Programming Languages 10.1 Introduction The Scheme system you ve been using

More information

User-Centered Design Data Entry

User-Centered Design Data Entry User-Centered Design Data Entry CS 4640 Programming Languages for Web Applications [The Design of Everyday Things, Don Norman, Ch 7] 1 Seven Principles for Making Hard Things Easy 1. Use knowledge in the

More information

Documentation for LISP in BASIC

Documentation for LISP in BASIC Documentation for LISP in BASIC The software and the documentation are both Copyright 2008 Arthur Nunes-Harwitt LISP in BASIC is a LISP interpreter for a Scheme-like dialect of LISP, which happens to have

More information

CITS5501 Software Testing and Quality Assurance Formal methods

CITS5501 Software Testing and Quality Assurance Formal methods CITS5501 Software Testing and Quality Assurance Formal methods Unit coordinator: Arran Stewart May 1, 2018 1 / 49 Sources Pressman, R., Software Engineering: A Practitioner s Approach, McGraw-Hill, 2005

More information

(Refer Slide Time 3:31)

(Refer Slide Time 3:31) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 5 Logic Simplification In the last lecture we talked about logic functions

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Tuesday, February 19, 2013 The lambda calculus (or λ-calculus) was introduced by Alonzo Church and Stephen Cole Kleene in

More information

ISA 562: Information Security, Theory and Practice. Lecture 1

ISA 562: Information Security, Theory and Practice. Lecture 1 ISA 562: Information Security, Theory and Practice Lecture 1 1 Encryption schemes 1.1 The semantics of an encryption scheme. A symmetric key encryption scheme allows two parties that share a secret key

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

A Functional Evaluation Model

A Functional Evaluation Model A Functional Evaluation Model COS 326 Andrew W. Appel Princeton University slides copyright 2013-2015 David Walker and Andrew W. Appel A Functional Evaluation Model In order to be able to write a program,

More information

Lecture 5: The Halting Problem. Michael Beeson

Lecture 5: The Halting Problem. Michael Beeson Lecture 5: The Halting Problem Michael Beeson Historical situation in 1930 The diagonal method appears to offer a way to extend just about any definition of computable. It appeared in the 1920s that it

More information

Database Languages and their Compilers

Database Languages and their Compilers Database Languages and their Compilers Prof. Dr. Torsten Grust Database Systems Research Group U Tübingen Winter 2010 2010 T. Grust Database Languages and their Compilers 4 Query Normalization Finally,

More information

Lesson 4 Typed Arithmetic Typed Lambda Calculus

Lesson 4 Typed Arithmetic Typed Lambda Calculus Lesson 4 Typed Arithmetic Typed Lambda 1/28/03 Chapters 8, 9, 10 Outline Types for Arithmetic types the typing relation safety = progress + preservation The simply typed lambda calculus Function types

More information

RACKET BASICS, ORDER OF EVALUATION, RECURSION 1

RACKET BASICS, ORDER OF EVALUATION, RECURSION 1 RACKET BASICS, ORDER OF EVALUATION, RECURSION 1 COMPUTER SCIENCE 61AS 1. What is functional programming? Give an example of a function below: Functional Programming In functional programming, you do not

More information

CSE 341 Section 7. Eric Mullen Spring Adapted from slides by Nicholas Shahan, Dan Grossman, and Tam Dang

CSE 341 Section 7. Eric Mullen Spring Adapted from slides by Nicholas Shahan, Dan Grossman, and Tam Dang CSE 341 Section 7 Eric Mullen Spring 2017 Adapted from slides by Nicholas Shahan, Dan Grossman, and Tam Dang Outline Interpreting LBI (Language Being Implemented) Assume Correct Syntax Check for Correct

More information

Lecture Notes on Data Representation

Lecture Notes on Data Representation Lecture Notes on Data Representation 15-814: Types and Programming Languages Frank Pfenning Lecture 9 Tuesday, October 2, 2018 1 Introduction In this lecture we ll see our type system in action. In particular

More information

Introduction to Lambda Calculus. Lecture 7 CS /08/09

Introduction to Lambda Calculus. Lecture 7 CS /08/09 Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)

More information

Trombone players produce different pitches partly by varying the length of a tube.

Trombone players produce different pitches partly by varying the length of a tube. Trombone players produce different pitches partly by varying the length of a tube. 7 Variables A variable is a connection between a name and a value.* That sounds simple enough, but some complexities arise

More information

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ October 13, 2004 Lambda Calculus and Type

More information

GOSSIP User Manual gossip-sim

GOSSIP User Manual gossip-sim GOSSIP User Manual gossip-sim Marius Vollmer Copyright c 2000 Marius Vollmer. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission

More information

Fundamental Concepts. Chapter 1

Fundamental Concepts. Chapter 1 Chapter 1 Fundamental Concepts This book is about the mathematical foundations of programming, with a special attention on computing with infinite objects. How can mathematics help in programming? There

More information

Symmetry in Type Theory

Symmetry in Type Theory Google May 29th, 2012 What is Symmetry? Definition Symmetry: Two or more things that initially look distinct, may actually be instances of a more general underlying principle. Why do we care? Simplicity.

More information

Software Paradigms (Lesson 4) Functional Programming Paradigm

Software Paradigms (Lesson 4) Functional Programming Paradigm Software Paradigms (Lesson 4) Functional Programming Paradigm Table of Contents 1 Introduction... 2 2 Evaluation of Functions... 3 3 Compositional (Construct) Operators... 4 4 Some Implementation Issues...

More information

Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book

Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book You are expected to understand and know how to use/do each of these tasks in Flash CS5, unless otherwise noted below. If you

More information

Nano-Lisp The Tutorial Handbook

Nano-Lisp The Tutorial Handbook Nano-Lisp The Tutorial Handbook Francis Sergeraert March 4, 2006 1 Various types of Nano-Lisp objects. There are several type notions and in this documentation only the notion of implementation type (itype

More information

(Refer Slide Time: 00:01:30)

(Refer Slide Time: 00:01:30) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology, Madras Lecture - 32 Design using Programmable Logic Devices (Refer Slide Time: 00:01:30)

More information

Environments

Environments Environments PLAI Chapter 6 Evaluating using substitutions is very inefficient To work around this, we want to use a cache of substitutions. We begin evaluating with no cached substitutions, then collect

More information

You 2 Software

You 2 Software PrismaCards Enter text for languages with exotic fonts You 2 Software http://www.you2.de info@you2.de Introduction To work in PrismaCards and other programs with complex fonts for different languages you

More information

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

STABILITY AND PARADOX IN ALGORITHMIC LOGIC STABILITY AND PARADOX IN ALGORITHMIC LOGIC WAYNE AITKEN, JEFFREY A. BARRETT Abstract. Algorithmic logic is the logic of basic statements concerning algorithms and the algorithmic rules of deduction between

More information

CSE 341 Section 7. Ethan Shea Autumn Adapted from slides by Nicholas Shahan, Dan Grossman, Tam Dang, and Eric Mullen

CSE 341 Section 7. Ethan Shea Autumn Adapted from slides by Nicholas Shahan, Dan Grossman, Tam Dang, and Eric Mullen CSE 341 Section 7 Ethan Shea Autumn 2018 Adapted from slides by Nicholas Shahan, Dan Grossman, Tam Dang, and Eric Mullen Outline Interpreting MUPL Assume Correct Syntax Check for Correct Semantics Evaluating

More information

This file contains an excerpt from the character code tables and list of character names for The Unicode Standard, Version 3.0.

This file contains an excerpt from the character code tables and list of character names for The Unicode Standard, Version 3.0. Range: This file contains an excerpt from the character code tables and list of character names for The Unicode Standard, Version.. isclaimer The shapes of the reference glyphs used in these code charts

More information

Chapter01.fm Page 1 Monday, August 23, :52 PM. Part I of Change. The Mechanics. of Change

Chapter01.fm Page 1 Monday, August 23, :52 PM. Part I of Change. The Mechanics. of Change Chapter01.fm Page 1 Monday, August 23, 2004 1:52 PM Part I The Mechanics of Change The Mechanics of Change Chapter01.fm Page 2 Monday, August 23, 2004 1:52 PM Chapter01.fm Page 3 Monday, August 23, 2004

More information

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:

More information

Dynamic Types , Spring March 21, 2017

Dynamic Types , Spring March 21, 2017 Dynamic Types 15-312, Spring 2017 March 21, 2017 Announcements Homework 4 will be released shortly. Most of it is new, so it s hard to tell how hard we made it. Please start early! Look at what I made

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

Lecture 6: Sequential Sorting

Lecture 6: Sequential Sorting 15-150 Lecture 6: Sequential Sorting Lecture by Dan Licata February 2, 2012 Today s lecture is about sorting. Along the way, we ll learn about divide and conquer algorithms, the tree method, and complete

More information

ClaimSpotter: an Environment to Support Sensemaking with Knowledge Triples

ClaimSpotter: an Environment to Support Sensemaking with Knowledge Triples ClaimSpotter: an Environment to Support Sensemaking with Knowledge Triples Bertrand Sereno, Simon Buckingham Shum & Enrico Motta Knowledge Media Institute The Open University Milton Keynes MK7 6AA, UK

More information

Repetition Through Recursion

Repetition Through Recursion Fundamentals of Computer Science I (CS151.02 2007S) Repetition Through Recursion Summary: In many algorithms, you want to do things again and again and again. For example, you might want to do something

More information

Introduction to the λ-calculus

Introduction to the λ-calculus Announcements Prelim #2 issues: o Problem 5 grading guide out shortly o Problem 3 (hashing) issues Will be on final! Friday RDZ office hours are 11-12 not 1:30-2:30 1 Introduction to the λ-calculus Today

More information