Adding GADTs to OCaml the direct approach
|
|
|
- Homer Parrish
- 9 years ago
- Views:
Transcription
1 Adding GADTs to OCaml the direct approach Jacques Garrigue & Jacques Le Normand Nagoya University / LexiFi (Paris)
2 Garrigue & Le Normand Adding GADTs to OCaml 1 Generalized Algebraic Datatypes Algebraic datatypes allowing different type parameters for different cases Similar to inductive types of Coq et al. type _ expr = Int : int -> int expr Add : (int -> int -> int) expr App : ( a -> b) expr * a expr -> b expr App (Add, Int 3) : (int -> int) expr Able to express invariants and proofs Also provide existential types
3 Garrigue & Le Normand Adding GADTs to OCaml 2 Previous work (in OCaml) Work by Pottier and Régis-Gianas on type inference for GADTs. Stratified type inference for generalized algebraic data types [POPL06]. Separate type inference for GADTs from the core of the language Uses propagation and constraint resolution for GADTs Preliminary implementation of propagation, never merged We choose a more direct approach.
4 Garrigue & Le Normand Adding GADTs to OCaml 3 GADT support Many examples require polymorphic recursion available since OCaml 3.12, originally for GADTs Pattern matching allows refining types use local abstract types Combining the two in a new syntax let rec eval : type t. t expr -> t = function Int n -> n (* t = int *) Add -> (+) (* t = int -> int -> int *) App (f, x) -> eval f (eval x) (* polymorphic recursion *) val eval : a expr -> a = <fun> eval (App (App (Add, Int 3), Int 4));; - : int = 7
5 Garrigue & Le Normand Adding GADTs to OCaml 4 Why use local abstract types? OCaml has two kinds of type variables: Unification variables, with scope the whole function let f x (y : a) = (x : a) + 1 val f : int -> int -> int Explicitly quantified universal variables, with scope limited to the annotation. Their goal is to allow unification of type schemes. let f : a. a -> _ = fun x -> (1 : a) val f : a -> int Neither of them can be used as universal expression-scoped variable, such as available in Standard ML. Rather than introduce a 3rd kind of type variables, we choose to reuse local abstract types.
6 Garrigue & Le Normand Adding GADTs to OCaml 5 Type annotations creating new types The syntax let rec f : type t 1... t n.τ = body is actually a short-hand for let rec f : α 1... α n.[α 1...α n /t 1...t n ]τ = fun (type t 1 )... (type t n ) (body : τ) It defines a recursively polymorphic function, whose type variables are visible as locally abstract types.
7 Garrigue & Le Normand Adding GADTs to OCaml 6 Application to polytypic functions Intuitively, the following is type sound: let rec neg : a. a -> a = function (n : int) -> -n (b : bool) -> not b (a, b) -> (neg a, neg b) x -> x val neg : a -> a For languages showing an early commitment to types, two problems: (but this is ok for FLP languages) Requires runtime type information Requires a default case to be exhaustive GADTs can express both
8 Garrigue & Le Normand Adding GADTs to OCaml 7 Tagged encoding Traditional sum types, but the parameter provides information about the contents. type _ data = Int : int -> int data Bool : bool -> bool data Pair : a data * b data -> ( a * b) data let rec neg : type a. a data -> a data = function Int n -> Int (-n) Bool b -> Bool (not b) Pair (a, b) -> Pair (neg a, neg b) Guarantee that the result is of the same kind as the input.
9 Garrigue & Le Normand Adding GADTs to OCaml 8 Tagless encoding Tags do not need to be inside the data itself. type _ ty = Tint : int ty Tbool : bool ty Tpair : a ty * b ty -> ( a * b) ty let rec print : type a. a ty -> a -> string = fun t d -> match t, d with Tint, n -> string_of_int n Tbool, b -> if b then "true" else "false" Tpair (ta, tb), (a, b) -> Printf.sprintf "(%s, %s)" (print ta a) (print tb b) Need to allow left-to-right dependencies in pattern-matching.
10 Garrigue & Le Normand Adding GADTs to OCaml 9 Other applications There is already a large literature of algorithms using GADTs. Data structures enforcing invariants E.g. balanced trees (c.f. Tim Sheard et al.) Typed syntax E.g. encodings of lambda-terms and evaluators (ibidem) Parsing Menhir is supposed to be GADT ready. I.e., one can generate efficient type parsers using GADTs DSLs for any kind of application: GUI, database...
11 Garrigue & Le Normand Adding GADTs to OCaml 10 Type inference Obtaining sound type inference for GADTs is not difficult. Intuitively, one just needs to use a special kind of unification, able to refine universal type variables, when pattern-matching GADT constructors. However, making it complete for some definite specification is more difficult.
12 Garrigue & Le Normand Adding GADTs to OCaml 11 Unification for GADTs Distinguish normal variables and refinable variables. The former are traditional unification variables, the latter can be represented as local abstract types. Pattern-matching may instantiate refinable variables. Need to proceed left to right, to handle dependencies. Outside of pattern-matching, they behave as abstract types. Forget this instantiation when moving to the next case.
13 Garrigue & Le Normand Adding GADTs to OCaml 12 The difficulties Cannot use OCaml type variables Luckily, local abstract types were added in 3.12, and adding an equation to an abstract type is easy Unification should not share internal nodes Sharing might be invalidated when we forget equations Cannot handle objects and polymorphic variants They both require structural sharing We keep compatibility when there are no equations Principality/completeness are lost Recovered partially by controlling propagation Must restrict co-variance and contra-variance Exhaustiveness of pattern-matching is harder to check
14 Garrigue & Le Normand Adding GADTs to OCaml 13 Variance Instantiated parameters are not allowed to have a variance If this were allowed, we could have this code type - a t = C : < m : int > -> < m : int > t let eval : type a. a t -> a = fun (C x) -> x val eval : a t -> a let a = C (object method m = 5 end) val a : < m : int > t = <object> let b = (a :> < m : int ; n : bool > t) val b : < m : int ; n : bool > t = <object> let c = eval b val c : < m : int ; n : bool > = <object>
15 Garrigue & Le Normand Adding GADTs to OCaml 14 Exhaustiveness One should be able to omit impossible cases. let rec equal : type a. a data -> a data -> bool = fun a b -> match a, b with Int m, Int n -> m - n = 0 Bool b, Bool c -> if b then c else not c Pair(a1,a2), Pair(b1,b2) -> equal a1 b1 && equal a2 b2 Typing guarantees that a and b are of the same kind, so there is no need to handle other cases. Done by generating the other cases, and checking whether they may happen. The algorithm is sound but not complete.
16 Garrigue & Le Normand Adding GADTs to OCaml 15 Subtleties of exhaustiveness Usual type inference checks which types are unifiable We need to know which types are incompatible Unfortunately, some types are neither: type (_,_) eq = Eq : ( a, a) eq module M : sig type t and u val eq : (t,u) eq end = struct type t = int and u = int let eq = Eq end match M.eq with Eq -> "here t = u!"
17 Garrigue & Le Normand Adding GADTs to OCaml 16 Incompatibility Unrelated to unification, we define an incompatibility relation. Two types are incompatible if: they are structurally different (e.g. function vs. tuple) for datatype definitions, their representations are incompatible (private types are also in this category) for abstract types, both declarations must be either in the initial environment (i.e. Pervasives) or in the current module Without the clause about the initial environment, we wouldn t even be able to distinguish int and bool! In patterns, unification does not fail when we cannot prove incompatibility, but equations are only added for refinable variables.
18 Garrigue & Le Normand Adding GADTs to OCaml 17 Completeness As it is well-known, type inference for GADTs is not complete. In the absence of type annotations, pattern-matching branches have incompatible types. let eval = function Int n -> n Add -> (+) Error: This pattern matches values of type (int -> int -> int) expr but a pattern was expected which matches values of type int expr However, we do not want to put type annotations directly on the pattern-matching construct.
19 Garrigue & Le Normand Adding GADTs to OCaml 18 Propagation of type information Our idea is to track the validity of type information through sharing, like we did for first-class polymorphism. A type node is safe if it is not shared with the environment. Thanks to instantiation, safety is propagated through polymorphic functions. C[match e 0 with p 1 e 1... p n e n ] Type information is propagated bidirectionally: we infer the type for e 0, and keep the safe part to type patterns For each case p i e i we type e i using the equations generated by typing p i we canonicalize the resulting type (and other types shared with the environment), expanding all equations we unify with the safe part of the type inferred for C s hole
20 Garrigue & Le Normand Adding GADTs to OCaml 19 Subtle points about canonicalization type _ t = I : int t let f1 (type a) (x : a t) y = let y = (y : a) in (* safe type annotation *) match x with I -> (y : a) (* a canonicalized to int *) val f : a t -> a -> int let f2 (type a) (x : a t) y = let r = match x with I -> (y : a) in ignore (y : a); (* y has type int *) r let f3 (type a) (x : a t) y = ignore (y : a); (* unsafe type annotation *) match x with I -> (y : a) f1 succeeds, but f2 fails. Since there is no propagation in f3, it must fail too.
21 Garrigue & Le Normand Adding GADTs to OCaml 20 How to canonicalize properly Canonicalization of types depends on where they were defined a canonicalizes to int only if we had the equation a = int at the annotation point but canonicalization may occur in another context Implementation using OCaml s type level mechanism levels grow when we enter binding constructs for every equation in the environment, remember its level only use an equation if the level of the type is at least the level of the equation generalized types get duplicated at use sites canonicalize a type when we lower its level (already done for local modules)
22 Garrigue & Le Normand Adding GADTs to OCaml 21 How principal? Due to our use of canonicalization, we cannot hope for real principality If we require some derivations to be minimal (i.e. infer the most general type), then we can recover principality. (Similar to first-class polymorphism with value restriction) Good symmetry properties: changing the order of subexpressions should not change the outcome of type inference. Small drawback: due to canonicalization, type annotations inside a branch of pattern-matching do not help typing its result.
23 Garrigue & Le Normand Adding GADTs to OCaml 22 Inference power Up to now, all examples could be typed without adding annotations inside functions. Could type almost all examples in the Omega Tutorial [1], adding only function types, and omitting all impossible cases. (Since we do not have Omega s type level functions, some examples cannot be expressed) [1] Tim Sheard and Nathan Linger: Programming In Omega. Notes from the 2nd Central European Functional Programming School, 2007.
24 Garrigue & Le Normand Adding GADTs to OCaml 23 Comparison to Wobbly Types (i.e. GHC 6) Glasgow Haskell had already GADTs for 7 years. Wobbly types are the original approach. Come in two versions. the original version is very close to what we do, but described in terms of unification and substitution rather than sharing. Propagation is weaker in the basic system, but gets stronger with smart application, so the power seems close [POPL 06] version is simpler, wobbliness being a property of terms rather than types, but this makes propagation weaker Using sharing makes possible a somehow cleaner specification.
25 Garrigue & Le Normand Adding GADTs to OCaml 24 Comparison to OutsideIn (i.e. GHC 7) GHC 7 uses a constraint-based approach to inference, which allows good properties. Proceeds by first typing the function ignoring all match cases, then propagating external information to type them. The types they infer are always principal in the naive type system (but not complete). This is not our case, since canonicalization may choose between two different types (in a deterministic way). Like us, complete with respect to a specification. In some cases, able to infer types without any type annotation. This seems very powerful, but requires a reimplementation of type inference.
26 Garrigue & Le Normand Adding GADTs to OCaml 25 Non-principal example The following example is taken from OutsideIn. type _ t = T1 : int -> bool t T2 : a t let test (type a) (x : a t) r = match x with T1 n -> n > 0 T2 -> r val test : a t -> bool -> bool The type we infer here is not principal since the following type, which is not comparable, would also be valid: val test : a t -> a -> a Note that while OutsideIn rightly rejects this example, GHC 7 accepts it for practical reasons :-)
27 Garrigue & Le Normand Adding GADTs to OCaml 26 What is principality about Principality has two roles. When a solution is principal, this guarantees that there is no ambiguity about its choice. Important for Haskell, but OCaml has untyped semantics. When we also have weakening with respect to hypotheses, this allows modular type inference. Γ e : τ and Γ Γ implies Γ e : τ However, inference systems for GADTs lack weakening. If we don t care about ambiguity, principality modulo some minimal derivations is not really worse than full principality.
28 Garrigue & Le Normand Adding GADTs to OCaml 27 Future improvements Allow giving names to freshly introduced existential types Currently there is no way to give names locally. Make the typing more principal An idea (with Didier Rémy) is to keep track of which equations have been used for a type. See inferred types as sets of related types. Do not allow an inferred type to escape to an environment where it would be incoherent. This recovers principality with respect to the naive type system, and could permit sharing for objects and variants.
29 Garrigue & Le Normand Adding GADTs to OCaml 28 Enjoy About the implementation: Code is already in the trunk, for the next release of OCaml: svn checkout Examples: testsuite/tests/typing-gadts test.ml : basic cases omega07.ml : examples translated from Omega Do not forget to use ocaml -principal for predictable behavior!
Practical Generic Programming with OCaml
Practical Generic Programming with OCaml Jeremy Yallop LFCS, University of Edinburgh ML Workshop 2007 Instead of this... type α tree = Node of α Branch of (α tree) (α tree) val show_tree : (α string) (α
Translating a Subset of OCaml into System F. Jonatha Protzenk under the dire ion of François Po ier
Translating a Subset of OCaml into System F Jonatha Protzenk under the dire ion of François Po ier June I Some background 1 Motivations Contents I Some background 2 1 Motivations 2 2 A high-level description
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
Regression Verification: Status Report
Regression Verification: Status Report Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung 2013-12-11 1/22 Introduction How to prevent regressions in software
Type Inference for First-Class Messages with Match-Functions
Type Inference for First-Class Messages with Match-Functions Paritosh Shroff Scott F. Smith Johns Hopkins University {pari, scott}@cs.jhu.edu Abstract Messages that can be treated as first-class entities
POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful
POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful RALF HINZE Institute of Information and Computing Sciences Utrecht University Email: [email protected] Homepage: http://www.cs.uu.nl/~ralf/
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
OutsideIn(X) Modular type inference with local assumptions
Under consideration for publication in J. Functional Programming 1 OutsideIn(X) Modular type inference with local assumptions 11 April 2011 Dimitrios Vytiniotis Microsoft Research Simon Peyton Jones Microsoft
Anatomy of Programming Languages. William R. Cook
Anatomy of Programming Languages William R. Cook Copyright (C) 2013 2 Chapter 1 Preliminaries Preface What? This document is a series of notes about programming languages, originally written for students
opalang - Rapid & Secure Web Development
opalang - Rapid & Secure Web Development Syllabus Brief History of Web Development Ideas and Goals The Language itself Community Reason for Development Services and Apps written in OPA Future of OPA OPA
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
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
Translating Generalized Algebraic Data Types to System F
Translating Generalized Algebraic Data Types to System F Martin Sulzmann and Meng Wang {sulzmann,wangmeng}@comp.nus.edu.sg School of Computing, National University of Singapore S16 Level 5, 3 Science Drive
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
Introduction to type systems
Introduction to type systems p. 1/5 Introductory Course on Logic and Automata Theory Introduction to type systems [email protected] Based on slides by Jeff Foster, UMD Introduction to type systems
Introduction to tuple calculus Tore Risch 2011-02-03
Introduction to tuple calculus Tore Risch 2011-02-03 The relational data model is based on considering normalized tables as mathematical relationships. Powerful query languages can be defined over such
Towards Interface Types for Haskell
Towards Interface Types for Haskell Work in Progress Peter Thiemann Joint work with Stefan Wehr Universität Freiburg, Germany WG 2.8 Meeting, Nesjavellir, Island, 17.07.2007 What is a type class? A type
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
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,
Semantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
Regular Expressions and Automata using Haskell
Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions
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
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
Testing LTL Formula Translation into Büchi Automata
Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland
Making Standard ML a Practical Database Programming Language
Making Standard ML a Practical Database Programming Language Atsushi Ohori Katsuhiro Ueno Research Institute of Electrical Communication Tohoku University {ohori, katsu}@riec.tohoku.ac.jp Abstract Integrating
Unboxed Polymorphic Objects for Functional Numerical Programming
Unboxed Polymorphic Objects for Functional Numerical Programming Christopher Rodrigues [email protected] Wen-Mei Hwu [email protected] IMPACT Technical Report IMPACT-12-02 University of Illinois at
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
Describing, manipulating and pricing financial contracts: The MLFi language
Describing, manipulating and pricing financial contracts: The MLFi language Centre for Financial Research, Judge Institute of Management Cambridge, 14 March 2003 (revised January 2005) Jean-Marc Eber LexiFi,
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
System Description: Delphin A Functional Programming Language for Deductive Systems
System Description: Delphin A Functional Programming Language for Deductive Systems Adam Poswolsky 1 and Carsten Schürmann 2 1 Yale University [email protected] 2 IT University of Copenhagen [email protected]
A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation
PLDI 03 A Static Analyzer for Large Safety-Critical Software B. Blanchet, P. Cousot, R. Cousot, J. Feret L. Mauborgne, A. Miné, D. Monniaux,. Rival CNRS École normale supérieure École polytechnique Paris
CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs
CHAPTER 3 Methods of Proofs 1. Logical Arguments and Formal Proofs 1.1. Basic Terminology. An axiom is a statement that is given to be true. A rule of inference is a logical rule that is used to deduce
Managing Variability in Software Architectures 1 Felix Bachmann*
Managing Variability in Software Architectures Felix Bachmann* Carnegie Bosch Institute Carnegie Mellon University Pittsburgh, Pa 523, USA [email protected] Len Bass Software Engineering Institute Carnegie
How To Type Check For Generalised Algebraic Data Types
Wobbly types: type inference for generalised algebraic data types Technical Report MS-CIS-05-26 Computer and Information Science Department University of Pennsylvania July 2004 Simon Peyton Jones Microsoft
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 [email protected] Meng Wang School
Extensible Effects An Alternative to Monad Transformers
Extensible Effects An Alternative to Monad Transformers Oleg Kiselyov Amr Sabry Cameron Swords Haskell Symposium 2013 Boston, MA Sep 23, 2013 We design and implement a library that solves the long-standing
FreshML: Programming with Binders Made Simple
FreshML: Programming with Binders Made Simple Mark R. Shinwell Andrew M. Pitts Murdoch J. Gabbay Cambridge University Computer Laboratory, Cambridge, CB3 0FD, UK {Mark.Shinwell,Andrew.Pitts,Murdoch.Gabbay}@cl.cam.ac.uk
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)
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,
6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch
6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)
Managing large sound databases using Mpeg7
Max Jacob 1 1 Institut de Recherche et Coordination Acoustique/Musique (IRCAM), place Igor Stravinsky 1, 75003, Paris, France Correspondence should be addressed to Max Jacob ([email protected]) ABSTRACT
InvGen: An Efficient Invariant Generator
InvGen: An Efficient Invariant Generator Ashutosh Gupta and Andrey Rybalchenko Max Planck Institute for Software Systems (MPI-SWS) Abstract. In this paper we present InvGen, an automatic linear arithmetic
recursion, O(n), linked lists 6/14
recursion, O(n), linked lists 6/14 recursion reducing the amount of data to process and processing a smaller amount of data example: process one item in a list, recursively process the rest of the list
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
3. Mathematical Induction
3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)
ECON 459 Game Theory. Lecture Notes Auctions. Luca Anderlini Spring 2015
ECON 459 Game Theory Lecture Notes Auctions Luca Anderlini Spring 2015 These notes have been used before. If you can still spot any errors or have any suggestions for improvement, please let me know. 1
Chapter 13: Query Processing. Basic Steps in Query Processing
Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing
DIFFERENTIABILITY OF COMPLEX FUNCTIONS. Contents
DIFFERENTIABILITY OF COMPLEX FUNCTIONS Contents 1. Limit definition of a derivative 1 2. Holomorphic functions, the Cauchy-Riemann equations 3 3. Differentiability of real functions 5 4. A sufficient condition
Computational Models Lecture 8, Spring 2009
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown Univ. p. 1 Computational Models Lecture 8, Spring 2009 Encoding of TMs Universal Turing Machines The Halting/Acceptance
Syntax Check of Embedded SQL in C++ with Proto
Proceedings of the 8 th International Conference on Applied Informatics Eger, Hungary, January 27 30, 2010. Vol. 2. pp. 383 390. Syntax Check of Embedded SQL in C++ with Proto Zalán Szűgyi, Zoltán Porkoláb
Mathematical Induction
Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How
Syntaktická analýza. Ján Šturc. Zima 208
Syntaktická analýza Ján Šturc Zima 208 Position of a Parser in the Compiler Model 2 The parser The task of the parser is to check syntax The syntax-directed translation stage in the compiler s front-end
Relational Databases
Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 18 Relational data model Domain domain: predefined set of atomic values: integers, strings,... every attribute
Analyse et Conception Formelle. Lesson 5. Crash Course on Scala
Analyse et Conception Formelle Lesson 5 Crash Course on Scala T. Genet (ISTIC/IRISA) ACF-5 1 / 36 Bibliography Simply Scala. Online tutorial: http://www.simply.com/fr http://www.simply.com/ Programming
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
Lecture 9. Semantic Analysis Scoping and Symbol Table
Lecture 9. Semantic Analysis Scoping and Symbol Table Wei Le 2015.10 Outline Semantic analysis Scoping The Role of Symbol Table Implementing a Symbol Table Semantic Analysis Parser builds abstract syntax
Lecture 12: Abstract data types
Lecture 12: Abstract data types Algebras Abstract data types Encapsulation and information hiding Parameterization Algebras Definition Which kinds of data do we want to discuss? What can we do with it?
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
Semester Review. CSC 301, Fall 2015
Semester Review CSC 301, Fall 2015 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration!
Settling a Question about Pythagorean Triples
Settling a Question about Pythagorean Triples TOM VERHOEFF Department of Mathematics and Computing Science Eindhoven University of Technology P.O. Box 513, 5600 MB Eindhoven, The Netherlands E-Mail address:
How To Understand The Theory Of Computer Science
Theory of Computation Lecture Notes Abhijat Vichare August 2005 Contents 1 Introduction 2 What is Computation? 3 The λ Calculus 3.1 Conversions: 3.2 The calculus in use 3.3 Few Important Theorems 3.4 Worked
Programming and Reasoning with Side-Effects in IDRIS
Programming and Reasoning with Side-Effects in IDRIS Edwin Brady 19th October 2014 Contents 1 Introduction 3 1.1 Hello world............................................. 3 1.2 Outline................................................
Chapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products
Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing
Web Data Extraction: 1 o Semestre 2007/2008
Web Data : Given Slides baseados nos slides oficiais do livro Web Data Mining c Bing Liu, Springer, December, 2006. Departamento de Engenharia Informática Instituto Superior Técnico 1 o Semestre 2007/2008
The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).
CHAPTER 5 The Tree Data Model There are many situations in which information has a hierarchical or nested structure like that found in family trees or organization charts. The abstraction that models hierarchical
Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.
Software Testing Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Testing can only reveal the presence of errors and not the
Detecting Pattern-Match Failures in Haskell. Neil Mitchell and Colin Runciman York University www.cs.york.ac.uk/~ndm/catch
Detecting Pattern-Match Failures in Haskell Neil Mitchell and Colin Runciman York University www.cs.york.ac.uk/~ndm/catch Does this code crash? risers [] = [] risers [x] = [[x]] risers (x:y:etc) = if x
Programming Languages Featherweight Java David Walker
Programming Languages Featherweight Java David Walker Overview Featherweight Java (FJ), a minimal Javalike language. Models inheritance and subtyping. Immutable objects: no mutation of fields. Trivialized
1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:
Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of
User guide for the Error & Warning LabVIEW toolset
User guide for the Error & Warning LabVIEW toolset Rev. 2014 December 2 nd 2014 1 INTRODUCTION... 1 2 THE LABVIEW ERROR CLUSTER... 2 2.1 The error description... 3 2.2 Custom error descriptions... 4 3
Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006. Final Examination. January 24 th, 2006
Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006 Final Examination January 24 th, 2006 NAME: Please read all instructions carefully before start answering. The exam will be
Datatype-generic data migrations
Datatype-generic data migrations IFIP WG 21 meeting #73, Lökeberg, Sweden Andres Löh August 31, 2015 The Haskell Consultants Motivation Datatypes evolve Motivation Datatypes evolve Example: data Person
Introduction to Hypothesis Testing
I. Terms, Concepts. Introduction to Hypothesis Testing A. In general, we do not know the true value of population parameters - they must be estimated. However, we do have hypotheses about what the true
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: [email protected] Homepage: http://www.informatik.uni-bonn.de/~ralf
Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance
Introduction to C++ January 19, 2011 Massachusetts Institute of Technology 6.096 Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance We ve already seen how to define composite datatypes
CS106A, Stanford Handout #38. Strings and Chars
CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes
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 [email protected] Abstract Finger Trees
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
Formal Engineering for Industrial Software Development
Shaoying Liu Formal Engineering for Industrial Software Development Using the SOFL Method With 90 Figures and 30 Tables Springer Contents Introduction 1 1.1 Software Life Cycle... 2 1.2 The Problem 4 1.3
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
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
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
Software Engineering Techniques
Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary
Python Evaluation Rules
Python Evaluation Rules UW CSE 160 http://tinyurl.com/dataprogramming Michael Ernst and Isaac Reynolds [email protected] August 2, 2016 Contents 1 Introduction 2 1.1 The Structure of a Python Program................................
Integration of an open source rule engine to enhance the IHTSDO Workbench testing
Integration of an open source rule engine to enhance the IHTSDO Workbench testing Dr. Guillermo Reynoso Dr. Alejandro Lopez Osornio termmed IT Buenos Aires, Argentina 2009 termmed SA Terminology maintenance
Reading 13 : Finite State Automata and Regular Expressions
CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model
Let Should Not Be Generalised
Let Should Not Be Generalised Dimitrios Vytiniotis Microsoft Research Cambridge, UK [email protected] Simon Peyton Jones Microsoft Research Cambridge, UK [email protected] Tom Schrijvers Katholieke
Simple Regression Theory II 2010 Samuel L. Baker
SIMPLE REGRESSION THEORY II 1 Simple Regression Theory II 2010 Samuel L. Baker Assessing how good the regression equation is likely to be Assignment 1A gets into drawing inferences about how close the
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
6.852: Distributed Algorithms Fall, 2009. Class 2
.8: Distributed Algorithms Fall, 009 Class Today s plan Leader election in a synchronous ring: Lower bound for comparison-based algorithms. Basic computation in general synchronous networks: Leader election
11 Multivariate Polynomials
CS 487: Intro. to Symbolic Computation Winter 2009: M. Giesbrecht Script 11 Page 1 (These lecture notes were prepared and presented by Dan Roche.) 11 Multivariate Polynomials References: MC: Section 16.6
HiDb: A Haskell In-Memory Relational Database
HiDb: A Haskell In-Memory Relational Database Rohan Puttagunta Arun Debray Susan Tu CS240H rohanp adebray sctu @stanford.edu June 11, 2014 Abstract We describe our experience implementing an in-memory
Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.
Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science [email protected] Names, Bindings, and Scopes A name is a symbolic identifier used
Parsing Technology and its role in Legacy Modernization. A Metaware White Paper
Parsing Technology and its role in Legacy Modernization A Metaware White Paper 1 INTRODUCTION In the two last decades there has been an explosion of interest in software tools that can automate key tasks
On Understanding Types, Data Abstraction, and Polymorphism
1 Computing Surveys, Vol 17 n. 4, pp 471-522, December 1985 On Understanding Types, Data Abstraction, and Polymorphism Luca Cardelli AT&T Bell Laboratories, Murray Hill, NJ 07974 (current address: DEC
Notes on Complexity Theory Last updated: August, 2011. Lecture 1
Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look
