POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful
|
|
- Violet Allison
- 2 years ago
- Views:
Transcription
1 POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful RALF HINZE Institute of Information and Computing Sciences Utrecht University Homepage: March, 2001 (Pick the slides at.../~ralf/talks.html#t23.)
2 A brief outline of the talk Polytypic programming is about making programming easier and more economical. Why? (2 7) How? A programmer s perspective (9 13) How? From an implementor s point of view (15 26) Prerequisites: we use the functional programming language Haskell 98 for the examples. 1
3 Recap : Haskell 98 Haskell 98 is a statically typed language. New types are introduced via data declarations. data List A = nil cons A (List A) Here, List is a type constructor, nil and cons are data constructors. Functions are defined via pattern matching. size :: A. List A Int size nil = 0 size (cons a as) = 1 + size as size is a polymorphic function. 2
4 Polymorphic type systems Many of us (most of us?) will probably agree that static type systems, especially, polymorphic type systems are a good thing. For reasons of Security Flexibility soundness results guarantee that well-typed programs cannot go wrong. polymorphism allows the definition of functions that behave uniformly over all types (such as size). This is an uninteresting talk for addicts of untyped languages. 3
5 However, even polymorphic type systems are sometimes less flexible than one would wish. For instance, it is not possible to define a polymorphic equality function. eq :: T. T T Bool A deep theorem, the parametricity theorem, implies that a function of this type must necessarily be constant roughly speaking, the two arguments cannot be inspected. 4
6 As a consequence, the programmer is forced to program a separate equality function for each type from scratch. Here is how one would define equality for lists. eqlist :: A. (A A Bool) (List A List A Bool) eqlist eqa nil nil = True eqlist eqa nil (cons a 2 as 2 ) = False eqlist eqa (cons a 1 as 1 ) nil = False eqlist eqa (cons a 1 as 1 ) (cons a 2 as 2 ) = eqa a 1 a 2 eqlist as 1 as 2 eqlist is actually an equality transformer. 5
7 Polytypic programming comes to rescue Polytypic programming (also known as generic programming, type parametric programming, shape polymorphism, structural polymorphism) addresses this problem. Basic idea: define the equality function by induction on the structure of types. Note that an instance of eq, such as eqlist, is typically defined by induction on the structure of values. 6
8 Polytypic programs are ubiquitous Equality and comparison functions. Reductions (such as size, sum, listify). Pretty printers (such as Haskell s show function). Parsers (such as Haskell s read function). Data conversion (Jansson and Jeuring, ESOP 99). Digital searching (Hinze, JFP). 7
9 A brief outline of the talk Why? (2 7) How? A programmer s perspective (9 13) How? From an implementor s point of view (15 26) 8
10 Polytypic definitions In order to define a polytypic value it suffices to give instances for the following three data types plus an instance for every primitive type. data 1 = () data A 1 + A 2 = inl A 1 inr A 2 data A 1 A 2 = (A 1, A 2 ) Here, 1 is the unit data type, + is a binary sum, and is a binary product (pairs). 9
11 Polytypic definitions equality For emphasis, the type argument of eq is enclosed in angle brackets. eq{ A } :: A A Bool eq{ 1 } () () = True eq{ Int } i 1 i 2 = eqint i 1 i 2 eq{ A + B } (inl a 1 ) (inl a 2 ) = eq{ A } a 1 a 2 eq{ A + B } (inl a 1 ) (inr b 2 ) = False eq{ A + B } (inr b 1 ) (inl a 2 ) = False eq{ A + B } (inr b 1 ) (inr b 2 ) = eq{ B } b 1 b 2 eq{ A B } (a 1, b 1 ) (a 2, b 2 ) = eq{ A } a 1 a 2 eq{ B } b 1 b 2 This simple definition contains all ingredients needed to derive specializations for arbitrary data types. 10
12 Haskell s type classes Haskell supports overloading, based on type classes. class Eq T where eq :: T T Bool However, overloading is not polytypic programming. For each type, you have to give an explicit instance declaration, containing the code for equality. instance (Eq A) Eq (List A) where eq nil nil = True eq nil (cons a 2 as 2 ) = False eq (cons a 1 as 1 ) nil = False eq (cons a 1 as 1 ) (cons a 2 as 2 ) = eq a 1 a 2 eq as 1 as 2 11
13 deriving However, for a handful of built-in classes Haskell provides special support the so-called deriving mechanism. data List A = nil cons A (List A) deriving (Eq) The deriving (Eq) part tells Haskell to generate the obvious code for equality. Alas, you cannot define your own derivable type classes. 12
14 Derivable type classes Idea: use polytypic definitions to specify default method declarations. class Eq T where eq :: T T Bool eq{ 1 } () () = True eq{ A + B } (inl a 1 ) (inl a 2 ) = eq a 1 a 2 eq{ A + B } (inl a 1 ) (inr b 2 ) = False eq{ A + B } (inr b 1 ) (inl a 2 ) = False eq{ A + B } (inr b 1 ) (inr b 2 ) = eq b 1 b 2 eq{ A B } (a 1, b 1 ) (a 2, b 2 ) = eq a 1 a 2 eq b 1 b 2 This extension is implemented in the Glasgow Haskell Compiler (Version 5.00). 13
15 A brief outline of the talk Why? (2 7) How? A programmer s perspective (9 13) How? From an implementor s point of view (15 26) 14
16 A closer look at Haskell s data construct It features type abstraction. data List A = nil cons A (List A) It features type application. data List A = nil cons A (List A) It features type recursion. data List A = nil cons A (List A) The type language corresponds to the simply typed λ-calculus. 15
17 Kinds and types Kinds can be seen as the types of types. T, U Kind ::= kind of types T U function kind Types. T, U Type ::= C type constant A type variable ΛA. T type abstraction T U type application 16
18 Modelling data types Assuming the following type constants 1 :: (+) :: ( ) :: Fix :: (( ) ( )) ( ), we can rewrite List as a lambda term: List = Fix (ΛL. ΛA. 1 + A L A). 17
19 Specializing: unfolding... We could specialize a polytypic value by unfolding its definition: eq{ List Int } = eq{ 1 + Int List Int } = eq + eq 1 (eq eq Int (eq{ List Int })), where eq 1 () () = True eq + eq A eq B (inl a 1 ) (inl a 2 ) = eq A a 1 a 2 eq + eq A eq B (inl a 1 ) (inr b 2 ) = False eq + eq A eq B (inr b 1 ) (inl a 2 ) = False eq + eq A eq B (inr b 1 ) (inr b 2 ) = eq B b 1 b 2 eq eq A eq B (a 1, b 1 ) (a 2, b 2 ) = eq A a 1 a 2 eq B b 1 b 2. 18
20 ... does not work Consider the following data type. data Power A = zero A succ (Power (A A)) Since the type recursion is nested, unfolding eq s definition will loop. eq{ Power Int } = eq{ Int + Power (Int Int) } = eq + eq Int (eq{ Power (Int Int) }) = eq + eq Int (eq + (eq eq Int eq Int ) (eq{ Power ((Int Int) (Int Int)) })) =... 19
21 Specializing polytypic values Basic idea: Let function follow type. eq{ List Int } = eqlist eqint eq{ Power Int } = eqpower eqint Since List and Power are functions on types, eqlist and eqpower are consequently functions on equality functions: eqlist maps eq{ A } to eq{ List A }. 20
22 Specializing generic values continued In general, the type of eq{ T :: T } is given by eq{ T :: T } :: Equal{ T } T, where Equal{ T } is defined by induction on the structure of kinds. Equal{ } T = T T Bool Equal{ A B } T = A. Equal{ A } A Equal{ B } (T A) eqlist has type Equal{ } List. 21
23 Specializing generic values continued The specialization of eq to types of arbitrary kinds is given by eq{ A } = eq A eq{ C } = eq c eq{ T 1 T 2 } = (eq{ T 1 }) T 2 (eq{ T 2 }) eq{ ΛA. T } = λa. λeq A. eq{ T }. Type application is mapped to value application, type abstraction to value abstraction, and type recursion to value recursion (eq Fix = fix). This is very similar to an interpretation of the simply typed λ-calculus. 22
24 Recap: applicative structures An applicative structure E is a triple (E, app, const) such that E = (E T T Kind), app = (app T,U : E T U (E T E U ) T, U Kind), and const : const E with const(c :: T) E T. 23
25 Recap: environment models An applicative structure E = (E, app, const) is an environment model if it is extensional (app is one-to-one) and if the clauses below define a total meaning function. E C :: T η = const(c ) E A :: T η = η(a) E (ΛA. T ) :: (S T) η = the unique ϕ E S T such that app S,T ϕ δ = E T :: T η(a := δ) E (T U ) :: V η = app U,V (E T :: U V η) (E U :: U η) 24
26 Specialization as an interpretation The applicative structure E = (E, app, const) with E T = (T :: T; Equal{ T } T ) app T,U (F ; f ) (A; a) = (F A; f A a) const(c ) = (C ; eq C ) is an environment model. Here, (T :: T; F T ) denotes a dependent product. 25
27 Benefits Since the definition of app and the interpretation of Fix are the same for all polytypic functions, the polytypic programmer merely has to specify the interpretation of the remaining constants: 1, +,, Int, and so on. We can use the basic proof method of the simply typed λ- calculus, which is based on so-called logical relations to prove properties of polytypic values. 26
28 A brief outline of the talk Why? (2 7) How? A programmer s perspective (9 13) How? From an implementor s point of view (15 26) 27
Ralf Hinze Generic Programs and Proofs
Ralf Hinze Generic Programs and Proofs Bonn, 2000 Für Anja, Lisa und Florian Brief contents 1 Introduction 1 2 Background 15 3 Generic programs 53 4 Generic proofs 87 5 Examples 107 6 Generic Haskell 147
Fun with Phantom Types
1 Fun with Phantom Types RALF HINZE Institut für Informatik III, Universität Bonn Römerstraße 164, 53117 Bonn, Germany Email: ralf@informatik.uni-bonn.de Homepage: http://www.informatik.uni-bonn.de/~ralf
Functional Programming. Functional Programming Languages. Chapter 14. Introduction
Functional Programming Languages Chapter 14 Introduction Functional programming paradigm History Features and concepts Examples: Lisp ML 1 2 Functional Programming Functional Programming Languages The
Deterministic Discrete Modeling
Deterministic Discrete Modeling Formal Semantics of Firewalls in Isabelle/HOL Cornelius Diekmann, M.Sc. Dr. Heiko Niedermayer Prof. Dr.-Ing. Georg Carle Lehrstuhl für Netzarchitekturen und Netzdienste
Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic
Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic Lars Birkedal Rasmus Ejlers Møgelberg Rasmus Lerchedahl Petersen IT University Technical Report Series TR-00-7 ISSN 600 600 February 00
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!
Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)
Lecture 18-19 Data Types and Types of a Language
Lecture 18-19 Data Types and Types of a Language April 29, 2014 Data Types and Types of a Language Data, Data Types and Types Type: Generalities Type Systems and Type Safety Type Equivalence, Coercion
Functional Programming
FP 2005 1.1 3 Functional Programming WOLFRAM KAHL kahl@mcmaster.ca Department of Computing and Software McMaster University FP 2005 1.2 4 What Kinds of Programming Languages are There? Imperative telling
Section 3 Sequences and Limits, Continued.
Section 3 Sequences and Limits, Continued. Lemma 3.6 Let {a n } n N be a convergent sequence for which a n 0 for all n N and it α 0. Then there exists N N such that for all n N. α a n 3 α In particular
On every sheet please give your first name, last name, and matriculation number.
RHEINISCH- WESTFÄLISCHE TECHNISCHE HOCHSCHULE AACHEN LEHR- UND FORSCHUNGSGEBIET INFORMATIK 2 RWTH Aachen D-52056 Aachen GERMANY http://verify.rwth-aachen.de/ LuFG Informatik II Functional Programming Exam,
Aspect-Oriented Programming with Type Classes
Aspect-Oriented Programming with Type Classes Martin Sulzmann School of Computing, National University of Singapore S16 Level 5, 3 Science Drive 2, Singapore 117543 sulzmann@comp.nus.edu.sg Meng Wang School
The countdown problem
JFP 12 (6): 609 616, November 2002. c 2002 Cambridge University Press DOI: 10.1017/S0956796801004300 Printed in the United Kingdom 609 F U N C T I O N A L P E A R L The countdown problem GRAHAM HUTTON
A tutorial on the universality and expressiveness of fold
J. Functional Programming 9 (4): 355 372, July 1999. Printed in the United Kingdom c 1999 Cambridge University Press 355 A tutorial on the universality and expressiveness of fold GRAHAM HUTTON University
Dependent Types at Work
Dependent Types at Work Ana Bove and Peter Dybjer Chalmers University of Technology, Göteborg, Sweden {bove,peterd}@chalmers.se Abstract. In these lecture notes we give an introduction to functional programming
On every sheet please give your first name, last name, and matriculation number.
RHEINISCH- WESTFÄLISCHE TECHNISCHE HOCHSCHULE AACHEN LEHR- UND FORSCHUNGSGEBIET INFORMATIK 2 RWTH Aachen D-52056 Aachen GERMANY http://verify.rwth-aachen.de/ LuFG Informatik II Functional Programming Exam,
Fixed Points of Type Constructors and Primitive Recursion
Fixed Points of Type Constructors and Primitive Recursion Andreas Abel joint work with Ralph Matthes CSL 04 Karpacz, Karkonoski National Park, Poland September 21, 2004 Work supported by: GKLI (DFG), TYPES
Introduction to type systems
Introduction to type systems p. 1/5 Introductory Course on Logic and Automata Theory Introduction to type systems Polyvios.Pratikakis@imag.fr Based on slides by Jeff Foster, UMD Introduction to type systems
Java EE Web Development Course Program
Java EE Web Development Course Program Part I Introduction to Programming 1. Introduction to programming. Compilers, interpreters, virtual machines. Primitive types, variables, basic operators, expressions,
15-150 Lecture 11: Tail Recursion; Continuations
15-150 Lecture 11: Tail Recursion; Continuations Lecture by Dan Licata February 21, 2011 In this lecture we will discuss space usage: analyzing the memory it takes your program to run tail calls and tail
Programming Languages in Artificial Intelligence
Programming Languages in Artificial Intelligence Günter Neumann, German Research Center for Artificial Intelligence (LT Lab, DFKI) I. AI programming languages II. Functional programming III. Functional
Types, Polymorphism, and Type Reconstruction
Types, Polymorphism, and Type Reconstruction Sources This material is based on the following sources: Pierce, B.C., Types and Programming Languages. MIT Press, 2002. Kanellakis, P.C., Mairson, H.G. and
A First Book of C++ Chapter 2 Data Types, Declarations, and Displays
A First Book of C++ Chapter 2 Data Types, Declarations, and Displays Objectives In this chapter, you will learn about: Data Types Arithmetic Operators Variables and Declarations Common Programming Errors
SL-110: Fundamentals of Java Revision 15 October Sun Educational Services Instructor-Led Course Description
Sun Educational Services Instructor-Led Course Description Fundamentals of Java SL-110 The Fundamentals of the Java course provides students, with little or no programming experience, with the basics of
Adding GADTs to OCaml the direct approach
Adding GADTs to OCaml the direct approach Jacques Garrigue & Jacques Le Normand Nagoya University / LexiFi (Paris) https://sites.google.com/site/ocamlgadt/ Garrigue & Le Normand Adding GADTs to OCaml 1
WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?
WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT? introduction Many students seem to have trouble with the notion of a mathematical proof. People that come to a course like Math 216, who certainly
263-2200 Types and Programming Languages
263-2200 Types and Programming Languages 1 / 49 Outline Types Evaluation Rules Typing Rules Properties of the Typing Relation The Inversion Lemma Prolog Implementation Reasoning Involving Types Progress
The Lean Theorem Prover
The Lean Theorem Prover Jeremy Avigad Department of Philosophy and Department of Mathematical Sciences Carnegie Mellon University (Lean s principal developer is Leonardo de Moura, Microsoft Research, Redmond)
Relations: their uses in programming and computational specifications
PEPS Relations, 15 December 2008 1/27 Relations: their uses in programming and computational specifications Dale Miller INRIA - Saclay & LIX, Ecole Polytechnique 1. Logic and computation Outline 2. Comparing
Pretty-big-step semantics
Pretty-big-step semantics Arthur Charguéraud INRIA October 2012 1 / 34 Motivation Formalization of JavaScript with Sergio Maeis, Daniele Filaretti, Alan Schmitt, Martin Bodin. Previous work: Semi-formal
OPERATIONAL TYPE THEORY by Adam Petcher Prepared under the direction of Professor Aaron Stump A thesis presented to the School of Engineering of
WASHINGTON NIVERSITY SCHOOL OF ENGINEERING AND APPLIED SCIENCE DEPARTMENT OF COMPTER SCIENCE AND ENGINEERING DECIDING JOINABILITY MODLO GROND EQATIONS IN OPERATIONAL TYPE THEORY by Adam Petcher Prepared
PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON
PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London
Android Application Development Course Program
Android Application Development Course Program Part I Introduction to Programming 1. Introduction to programming. Compilers, interpreters, virtual machines. Primitive data types, variables, basic operators,
Observational Program Calculi and the Correctness of Translations
Observational Program Calculi and the Correctness of Translations Manfred Schmidt-Schauss 1, David Sabel 1, Joachim Niehren 2, and Jan Schwinghammer 1 Goethe-University, Frankfurt, Germany 2 INRIA Lille,
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction
Chapter 7: Functional Programming Languages
Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language
Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example
Overview Elements of Programming Languages Lecture 12: Object-oriented functional programming James Cheney University of Edinburgh November 6, 2015 We ve now covered: basics of functional and imperative
Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 11
CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note Conditional Probability A pharmaceutical company is marketing a new test for a certain medical condition. According
The Clean programming language. Group 25, Jingui Li, Daren Tuzi
The Clean programming language Group 25, Jingui Li, Daren Tuzi The Clean programming language Overview The Clean programming language first appeared in 1987 and is still being further developed. It was
Midlands Graduate School in the Foundations of Computer Science
Midlands Graduate chool in the Foundations of omputer cience Operational emantics, Abstract Machines, and orrectness Roy L. role University of Leicester, 8th to 12th April 2006 University of Nottingham,
Journal of Functional Programming, volume 3 number 4, 1993. Dynamics in ML
Journal of Functional Programming, volume 3 number 4, 1993. Dynamics in ML Xavier Leroy École Normale Supérieure Michel Mauny INRIA Rocquencourt Abstract Objects with dynamic types allow the integration
Idris, a General Purpose Dependently Typed Programming Language: Design and Implementation
Under consideration for publication in J. Functional Programming 1 Idris, a General Purpose Dependently Typed Programming Language: Design and Implementation EDWIN BRADY School of Computer Science, University
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
Introduction to Proofs
Chapter 1 Introduction to Proofs 1.1 Preview of Proof This section previews many of the key ideas of proof and cites [in brackets] the sections where they are discussed thoroughly. All of these ideas are
CS510 Software Engineering
CS510 Software Engineering Propositional Logic Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-cs510-se
Q1. For the following grammar: S a S b c E E d f E a
Chapter 3 (3.1 3.3) Describing Syntax and Semantics Chapter 4 Lexical and Syntax Analysis Chapter 5 Names, Binding, Type Checking and Scopes Chapter 6 Data Types Chapter 7 Expressions and Assignment Statements
Chapter 15 Functional Programming Languages
Chapter 15 Functional Programming Languages Introduction - The design of the imperative languages is based directly on the von Neumann architecture Efficiency (at least at first) is the primary concern,
The Classes P and NP
The Classes P and NP We now shift gears slightly and restrict our attention to the examination of two families of problems which are very important to computer scientists. These families constitute the
Special Directions for this Test
1 Spring, 2013 Name: (Please do not write your id number!) COP 4020 Programming Languages I Test on Haskell and Functional Programming Special Directions for this Test This test has 7 questions and pages
Type Systems. Luca Cardelli. Digital Equipment Corporation Systems Research Center
Type Systems 1 Introduction Luca Cardelli Digital Equipment Corporation Systems Research Center The fundamental purpose of a type system is to prevent the occurrence of execution errors during the running
VB.NET Programming Fundamentals
Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements
Group number 24 Joni Saarinen Daniel Kullberg
C# Group number 24 Joni Saarinen Daniel Kullberg C# (pronounced C sharp) is a multi paradigm programming language developed by Microsoft. It is primarily an imperative language but support for functional
v w is orthogonal to both v and w. the three vectors v, w and v w form a right-handed set of vectors.
3. Cross product Definition 3.1. Let v and w be two vectors in R 3. The cross product of v and w, denoted v w, is the vector defined as follows: the length of v w is the area of the parallelogram with
Advanced Functional Programming (9) Domain Specific Embedded Languages
Advanced Functional Programming (9) Domain Specific Embedded Languages Advanced Functional Programming (9) Domain Specific Embedded Languages, Universiteit Utrecht http://www.cs.uu.nl/groups/st/ February
Notes: Chapter 2 Section 2.2: Proof by Induction
Notes: Chapter 2 Section 2.2: Proof by Induction Basic Induction. To prove: n, a W, n a, S n. (1) Prove the base case - S a. (2) Let k a and prove that S k S k+1 Example 1. n N, n i = n(n+1) 2. Example
Computing Concepts with Java Essentials
2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Computing Concepts with Java Essentials 3rd Edition Cay Horstmann
Normalization by Evaluation
Normalization by Evaluation Midlands Graduate School in the Foundations of Computer Science Leicester, UK Peter Dybjer Chalmers University of Technology Gothenburg, Sweden 30 March - 3 April, 2009 What
AURA: A language with authorization and audit
AURA: A language with authorization and audit Steve Zdancewic University of Pennsylvania WG 2.8 2008 Security-oriented Languages Limin Jia, Karl Mazurak, Jeff Vaughan, Jianzhou Zhao Joey Schorr and Luke
Type Systems. Luca Cardelli. Microsoft Research
Type Systems Luca Cardelli Microsoft Research 1 Introduction The fundamental purpose of a type system is to prevent the occurrence of execution errors during the running of a program. This informal statement
ML for the Working Programmer
ML for the Working Programmer 2nd edition Lawrence C. Paulson University of Cambridge CAMBRIDGE UNIVERSITY PRESS CONTENTS Preface to the Second Edition Preface xiii xv 1 Standard ML 1 Functional Programming
2. Names, Scopes, and Bindings
2. Names, Scopes, and Bindings Binding, Lifetime, Static Scope, Encapsulation and Modules, Dynamic Scope Copyright 2010 by John S. Mallozzi Names Variables Bindings Binding time Language design issues
Simulation-Based Security with Inexhaustible Interactive Turing Machines
Simulation-Based Security with Inexhaustible Interactive Turing Machines Ralf Küsters Institut für Informatik Christian-Albrechts-Universität zu Kiel 24098 Kiel, Germany kuesters@ti.informatik.uni-kiel.de
MAP-I Programa Doutoral em Informática. Rigorous Software Development
MAP-I Programa Doutoral em Informática Rigorous Software Development Unidade Curricular em Teoria e Fundamentos Theory and Foundations (UCTF) DI-UM, DCC-FCUP May, 2012 Abstract This text presents a UCTF
C++ Keywords. If/else Selection Structure. Looping Control Structures. Switch Statements. Example Program
C++ Keywords There are many keywords in C++ that are not used in other languages. bool, const_cast, delete, dynamic_cast, const, enum, extern, register, sizeof, typedef, explicit, friend, inline, mutable,
Type Classes with Functional Dependencies
Appears in Proceedings of the 9th European Symposium on Programming, ESOP 2000, Berlin, Germany, March 2000, Springer-Verlag LNCS 1782. Type Classes with Functional Dependencies Mark P. Jones Department
Andrew Pitts chapter for D. Sangorgi and J. Rutten (eds), Advanced Topics in Bisimulation and Coinduction, Cambridge Tracts in Theoretical Computer
Andrew Pitts chapter for D. Sangorgi and J. Rutten (eds), Advanced Topics in Bisimulation and Coinduction, Cambridge Tracts in Theoretical Computer Science No. 52, chapter 5, pages 197 232 ( c 2011 CUP)
Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras
Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding
A Propositional Dynamic Logic for CCS Programs
A Propositional Dynamic Logic for CCS Programs Mario R. F. Benevides and L. Menasché Schechter {mario,luis}@cos.ufrj.br Abstract This work presents a Propositional Dynamic Logic in which the programs are
The current topic: Scheme. Announcements. Numeric operators. Review: car, cdr, and cons
The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction Next up: Numeric operators, REPL, quotes, functions, conditionals Types and values
Java SE 8 Programming
Oracle University Contact Us: 1.800.529.0165 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming
[Refer Slide Time: 05:10]
Principles of Programming Languages Prof: S. Arun Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi Lecture no 7 Lecture Title: Syntactic Classes Welcome to lecture
8/31/2012. Object Oriented Software Development. C# classes. C# example class code
Object Oriented Software Development 3. Creating C# classes C# classes Create an OO program by writing classes Need to understand structure and syntax of C# classes Programming language syntax is the set
Math 319 Problem Set #3 Solution 21 February 2002
Math 319 Problem Set #3 Solution 21 February 2002 1. ( 2.1, problem 15) Find integers a 1, a 2, a 3, a 4, a 5 such that every integer x satisfies at least one of the congruences x a 1 (mod 2), x a 2 (mod
Operator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example
Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics
Applied Type System. (Extended Abstract) Hongwei Xi. Boston University. Abstract. The framework Pure Type System (PTS) offers a simple
Applied Type System (Extended Abstract) Hongwei Xi Boston University Abstract. The framework Pure Type System (PTS) offers a simple and general approach to designing and formalizing type systems. However,
CIS 500 Software Foundations Midterm I, Review Questions
CIS 500 Software Foundations Midterm I, Review Questions Untyped lambda calculus 1. (2 points) We have seen that a linear expression likeλx.λy.xyx is shorthand for an abstract syntax tree that can be drawn
First-Class Type Classes
First-Class Type Classes Matthieu Sozeau 1 and Nicolas Oury 2 1 Univ. Paris Sud, CNRS, Laboratoire LRI, UMR 8623, Orsay, F-91405 INRIA Saclay, ProVal, Parc Orsay Université, F-91893 sozeau@lri.fr 2 University
Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:
In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our
Productive Coprogramming with Guarded Recursion
Productive Coprogramming with Guarded Recursion Robert Atkey bob.atkey@gmail.com Conor McBride University of Strathclyde Conor.McBride@strath.ac.uk Abstract Total functional programming offers the beguiling
Racket Style Guide Fall 2016
CS17 Integrated Introduction to Computer Science Hughes Racket Style Guide Fall 2016 Contents 1 Introduction 1 2 Naming 1 3 Formatting 1 4 Equality 4 5 Conditionals 4 5.1 Prefer Cond to If......................................
PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
Theorem Proving in Lean
Theorem Proving in Lean Jeremy Avigad Leonardo de Moura Soonho Kong Version cd852b8, updated at 2016-07-16 00:37:44-0400 2 Copyright (c) 2014 2015, Jeremy Avigad, Leonardo de Moura, and Soonho Kong. rights
discuss how to describe points, lines and planes in 3 space.
Chapter 2 3 Space: lines and planes In this chapter we discuss how to describe points, lines and planes in 3 space. introduce the language of vectors. discuss various matters concerning the relative position
PROGRAM-ing Finger Trees in COQ
PROGRAM-ing Finger Trees in COQ Matthieu Sozeau Univ. Paris Sud, CNRS, Laboratoire LRI, UMR 8623, Orsay, F-91405 INRIA Futurs, ProVal, Parc Orsay Université, F-91893 sozeau@lri.fr Abstract Finger Trees
You know from calculus that functions play a fundamental role in mathematics.
CHPTER 12 Functions You know from calculus that functions play a fundamental role in mathematics. You likely view a function as a kind of formula that describes a relationship between two (or more) quantities.
COMPUTER SCIENCE TRIPOS
CST.98.5.1 COMPUTER SCIENCE TRIPOS Part IB Wednesday 3 June 1998 1.30 to 4.30 Paper 5 Answer five questions. No more than two questions from any one section are to be answered. Submit the answers in five
Termination Checking: Comparing Structural Recursion and Sized Types by Examples
Termination Checking: Comparing Structural Recursion and Sized Types by Examples David Thibodeau Decemer 3, 2011 Abstract Termination is an important property for programs and is necessary for formal proofs
SOLUTIONS TO EXERCISES FOR. MATHEMATICS 205A Part 3. Spaces with special properties
SOLUTIONS TO EXERCISES FOR MATHEMATICS 205A Part 3 Fall 2008 III. Spaces with special properties III.1 : Compact spaces I Problems from Munkres, 26, pp. 170 172 3. Show that a finite union of compact subspaces
Probability Using Dice
Using Dice One Page Overview By Robert B. Brown, The Ohio State University Topics: Levels:, Statistics Grades 5 8 Problem: What are the probabilities of rolling various sums with two dice? How can you
136 CHAPTER 4. INDUCTION, GRAPHS AND TREES
136 TER 4. INDUCTION, GRHS ND TREES 4.3 Graphs In this chapter we introduce a fundamental structural idea of discrete mathematics, that of a graph. Many situations in the applications of discrete mathematics
SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University
SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University Year 2004/2005 1. (a) LM is a language that consists of sentences of L continued
CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards
CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards Course Title: TeenCoder: Java Programming Course ISBN: 978 0 9887070 2 3 Course Year: 2015 Note: Citation(s) listed may represent
WRITING PROOFS. Christopher Heil Georgia Institute of Technology
WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this
Chapter 2: Problem Solving Using C++
Chapter 2: Problem Solving Using C++ 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common
A Tutorial on [Co-]Inductive Types in Coq
A Tutorial on [Co-]Inductive Types in Coq Eduardo Giménez, Pierre Castéran May 1998 August 17, 2007 Abstract This document 1 is an introduction to the definition and use of inductive and co-inductive types
by Mario Fusco mario.fusco@gmail.com twitter: @mariofusco Monadic
by Mario Fusco mario.fusco@gmail.com twitter: @mariofusco Monadic Imperative languages Java C# C / C++ Fortran Add abstractions Scala F# Subtract abstractions Hybrid languages Algol Lisp ML Haskell Functional
Chapter 1 Fundamentals of Java Programming
Chapter 1 Fundamentals of Java Programming Computers and Computer Programming Writing and Executing a Java Program Elements of a Java Program Features of Java Accessing the Classes and Class Members The
Mathematical Induction
Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,
Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game
Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game Directions: In mobile Applications the Control Model View model works to divide the work within an application.
Lecture Notes on Polynomials
Lecture Notes on Polynomials Arne Jensen Department of Mathematical Sciences Aalborg University c 008 Introduction These lecture notes give a very short introduction to polynomials with real and complex