CIS 500 Software Foundations Midterm I, Review Questions

Size: px
Start display at page:

Download "CIS 500 Software Foundations Midterm I, Review Questions"

Transcription

1 CIS 500 Software Foundations Midterm I, Review Questions

2 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 like this: λx λy apply apply x x y Draw the abstract syntax trees corresponding to the following expressions: (a) a b c (b) (λx.b) (c d) 1

3 2. (10 points) Write down the normal forms of the followingλ terms: (a) (λt.λf. t)(λt.λf.f)(λx. x) (b) (λx.x) (λx.x) (λx.x) (λx.x) (c) λx.x(λx.x) (λx.x) (d) (λx.x(λx.x)) (λx.x(λx.xx)) (e) (λx.xxx)(λx. xxx) 3. (4 points) Recall the following abbreviations from Chapter 5: tru = λt. λf. t fls = λt. λf. f not = λb. b fls tru Complete this definition of a lambda term that takes two church booleans, b and c, and returns the logical exclusive or of b and c. xor = λb. λc. 2

4 4. (8 points) A list can be represented in the lambda calculus by itsfold function. (OCaml s name for this function isfold_right; it is also sometimes calledreduce.) For example, the list [x,y,z] becomes a function that takes two arguments c and n and returns c x(c y (c z n))). The definitions of nil and cons for this representation of lists are as follows: nil = λc. λn. n; cons = λh. λt. λc. λn. c h (t c n); Suppose we now want to define aλ termappend that, when applied to two listsl1 andl2, will append l1 to l2 i.e., it will return aλ term representing a list containing all the elements of l1 and then those of l2. Complete the following definition ofappend. append = λl1. λl2. λc. λn. 5. (6 points) Recall the call by value fixed point combinator from Chapter 5: fix = λf. (λx. f (λy. x x y)) (λx. f (λy. x x y)); We can usefix to write a function sumupto that, given a Church numeralsm, calculates the sum of all the numbers less than or equal to m, as follows. g = λf. λm. (iszro m) (λx. c 0 ) (λx. plus ( (prd m))) tru; sumupto = fix g; Fill in the two omitted subterms. 3

5 Nameless representation of terms 6. (4 points) Suppose we have defined the naming contextγ = a,b,c,d. What are the debruijn representations of the followingλ terms? (a) λx.λy. xyd (b) λx.c(λy.(c y) x)d 7. (4 points) Write down (in debruijn notation) the terms that result from the following substitutions. (a) [0 λ.0]((λ.01)1) (b) [0 λ.01]((λ. 01) 0) 4

6 Typed arithmetic expressions The full definition of the language of typed arithmetic and boolean expressions is reproduced, for your reference, on page (9 points) Suppose we add the following new rule to the evaluation relation: succtrue pred(succ true) Which of the following properties will remain true in the presence of this rule? For each one, write either remains true or else becomes false, plus (in either case) a one sentence justification of your answer. (a) Termination of evaluation (for every termtthere is some normal formt such that t t ) (b) Progress (if t is well typed, then eithertis a value or elset t for somet ) (c) Preservation (if t has typetand t t, then t also has type T) 9. (9 points) Suppose, instead, that we add this new rule to the evaluation relation: t if true thentelse succfalse Which of the following properties remains true? (Answer in the same style as the previous question.) (a) Termination of evaluation (for every termtthere is some normal formt such that t t ) (b) Progress (if t is well typed, then eithertis a value or elset t for somet ) (c) Preservation (if t has typetand t t, then t also has type T) 5

7 10. (9 points) Suppose, instead, that we add a new type, Funny, and add this new rule to the typing relation: iftrue then falseelse false:funny Which of the following properties remains true? (Answer in the same style as the previous question.) (a) Termination of evaluation (for every termtthere is some normal formt such that t t ) (b) Progress (if t is well typed, then eithertis a value or elset t for somet ) (c) Preservation (if t has typetand t t, then t also has type T) 6

8 Simply typed lambda calculus The definition of the simply typed lambda calculus with booleans is reproduced for your reference on page (6 points) Write down the types of each of the following terms (or ill typed if the term has no type). (a) λx:bool.xx (b) λf: Bool Bool. λg:bool Bool. g(f (g true)) (c) λh:bool.(λi:bool Bool. i false) (λk:bool.true) 7

9 Operational semantics 12. (9 points) Recall the rules for big step evaluation of arithmetic and boolean expressions from HW 3. v v t 1 true t 2 v 2 if t 1 then t 2 elset 3 v 2 t 1 false t 3 v 3 if t 1 then t 2 elset 3 v 3 t 1 nv 1 succ t 1 succ nv 1 t 1 0 predt 1 0 t 1 succ nv 1 predt 1 nv 1 t 1 0 iszero t 1 true t 1 succ nv 1 iszerot 1 false The following OCaml definitions implement this evaluation relation almost correctly, but there are three mistakes in the eval function one each in the TmIf, TmSucc, and TmPred cases of the outer match. Show how to change the code to repair these mistakes. (Hint: all the mistakes are omissions.) let rec isnumericval t = match t with TmZero(_) true TmSucc(_,t1) isnumericval t1 _ false let rec isval t = match t with TmTrue(_) true TmFalse(_) true t when isnumericval t true _ false let rec eval t = match t with v when isval v v TmIf(_,t1,t2,t3) (match t1 with TmTrue _ eval t2 TmFalse _ eval t3 _ raise NoRuleApplies) TmSucc(fi,t1) (match eval t1 with nv1 TmSucc (dummyinfo, nv1) _ raise NoRuleApplies) TmPred(fi,t1) (match eval t1 with TmZero _ TmZero(dummyinfo) _ raise NoRuleApplies) TmIsZero(fi,t1) (match eval t1 with TmZero _ TmTrue(dummyinfo) TmSucc(_, _) TmFalse(dummyinfo) _ raise NoRuleApplies) _ raise NoRuleApplies 8

10 9

11 For reference: Untyped boolean and arithmetic expressions Syntax t ::= terms true constant true false constant false if tthen t elset conditional 0 constant zero succ t successor pred t predecessor iszero t zero test v ::= true false nv values true value false value numeric value nv ::= numeric values 0 zero value succ nv successor value T ::= Bool Nat types type of booleans type of numbers Evaluation iftrue then t 2 elset 3 t 2 if falsethen t 2 else t 3 t 3 (E IfTrue) (E IfFalse) t 1 t 1 if t 1 then t 2 elset 3 if t 1 then t 2 elset 3 (E If) t 1 t 1 succt 1 succ t 1 pred0 0 pred (succnv 1 ) nv 1 (E Succ) (E PredZero) (E PredSucc) t 1 t 1 predt 1 pred t 1 iszero 0 true iszero (succnv 1 ) false (E Pred) (E IszeroZero) (E IszeroSucc) t 1 t 1 iszerot 1 iszero t 1 (E IsZero) continued on next page... 10

12 Typing true: Bool false: Bool t 1 :Bool t 2 :T t 3 :T if t 1 then t 2 elset 3 :T 0:Nat t 1 :Nat succ t 1 :Nat t 1 :Nat pred t 1 :Nat t 1 :Nat iszero t 1 :Bool (T True) (T False) (T If) (T Zero) (T Succ) (T Pred) (T IsZero) 11

13 For reference: Simply typed lambda calculus with booleans Syntax t ::= true false if tthen t elset x λx:t.t t t terms constant true constant false conditional variable abstraction application v ::= T ::= true false λx:t.t Bool T T values true value false value abstraction value types type of booleans type of functions Evaluation Typing iftrue then t 2 elset 3 t 2 if falsethen t 2 else t 3 t 3 t 1 t 1 if t 1 then t 2 elset 3 if t 1 then t 2 elset 3 t 1 t 1 t 1 t 2 t 1 t 2 t 2 t 2 v 1 t 2 v 1 t 2 (λx:t 11.t 12 ) v 2 [x v 2 ]t 12 true: Bool false: Bool t 1 :Bool t 2 :T t 3 :T if t 1 then t 2 elset 3 :T x:t Γ Γ x:t Γ,x:T 1 t 2 :T 2 Γ λx:t 1.t 2 :T 1 T 2 Γ t 1 :T 11 T 12 Γ t 2 :T 11 Γ t 1 t 2 :T 12 (E IfTrue) (E IfFalse) (E If) (E App1) (E App2) (E AppAbs) (T True) (T False) (T If) (T Var) (T Abs) (T App) 12

Assignment 1 (100 Points)

Assignment 1 (100 Points) CIS 705 Programming Languages Spring 2010 Assignment 1 (100 Points) Due by 2:30 p.m. on Thursday, February 11 The context for this assignment is Chapters 2-3 of TAPL. Terms The set of terms is inductively

More information

263-2200 Types and Programming Languages

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

More information

CMCS 312: Programming Languages Lecture 3: Lambda Calculus (Syntax, Substitution, Beta Reduction) Acar & Ahmed 17 January 2008

CMCS 312: Programming Languages Lecture 3: Lambda Calculus (Syntax, Substitution, Beta Reduction) Acar & Ahmed 17 January 2008 CMCS 312: Programming Languages Lecture 3: Lambda Calculus (Syntax, Substitution, Beta Reduction) Acar & Ahmed 17 January 2008 Contents 1 Announcements 1 2 Introduction 1 3 Abstract Syntax 1 4 Bound and

More information

Types, Polymorphism, and Type Reconstruction

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

More information

Fun with Phantom Types

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

More information

How To Program In Scheme (Prolog)

How To Program In Scheme (Prolog) The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction Next up: Numeric operators, REPL, quotes, functions, conditionals Types and values

More information

A Tutorial Introduction to the Lambda Calculus

A Tutorial Introduction to the Lambda Calculus A Tutorial Introduction to the Lambda Calculus Raúl Rojas FU Berlin, WS-97/98 Abstract This paper is a short and painless introduction to the λ calculus. Originally developed in order to study some mathematical

More information

Normalization by Evaluation

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

More information

Chapter 7: Functional Programming Languages

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

More information

Symbolic Execution for (Almost) Free: Hijacking an Existing Implementation to Perform Symbolic Execution Joseph P. Near and Daniel Jackson

Symbolic Execution for (Almost) Free: Hijacking an Existing Implementation to Perform Symbolic Execution Joseph P. Near and Daniel Jackson Computer Science and Artificial Intelligence Laboratory Technical Report MIT-CSAIL-TR-2014-007 April 22, 2014 Symbolic Execution for (Almost) Free: Hijacking an Existing Implementation to Perform Symbolic

More information

POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful

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: ralf@cs.uu.nl Homepage: http://www.cs.uu.nl/~ralf/

More information

Summary Last Lecture. Automated Reasoning. Outline of the Lecture. Definition sequent calculus. Theorem (Normalisation and Strong Normalisation)

Summary Last Lecture. Automated Reasoning. Outline of the Lecture. Definition sequent calculus. Theorem (Normalisation and Strong Normalisation) Summary Summary Last Lecture sequent calculus Automated Reasoning Georg Moser Institute of Computer Science @ UIBK Winter 013 (Normalisation and Strong Normalisation) let Π be a proof in minimal logic

More information

Chapter 15 Functional Programming Languages

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,

More information

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

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

More information

Deterministic Discrete Modeling

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

More information

Monads for functional programming

Monads for functional programming Monads for functional programming Philip Wadler, University of Glasgow Department of Computing Science, University of Glasgow, G12 8QQ, Scotland (wadler@dcs.glasgow.ac.uk) Abstract. The use of monads to

More information

Useful Number Systems

Useful Number Systems Useful Number Systems Decimal Base = 10 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Binary Base = 2 Digit Set = {0, 1} Octal Base = 8 = 2 3 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7} Hexadecimal Base = 16 = 2

More information

Termination Checking: Comparing Structural Recursion and Sized Types by Examples

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

More information

A Tutorial on [Co-]Inductive Types in Coq

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

More information

Semantic Analysis: Types and Type Checking

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

More information

Multilinear Programming with Big Data

Multilinear Programming with Big Data Multilinear Programming with Big Data Mihai Budiu Gordon D. Plotkin Microsoft Research Abstract Systems such as MapReduce have become enormously popular for processing massive data sets since they substantially

More information

How To Write A Type System

How To Write A Type System 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

More information

Observational Program Calculi and the Correctness of Translations

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,

More information

How To Understand The Theory Of Computer Science

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

More information

The design recipe. Programs as communication. Some goals for software design. Readings: HtDP, sections 1-5

The design recipe. Programs as communication. Some goals for software design. Readings: HtDP, sections 1-5 The design recipe Readings: HtDP, sections 1-5 (ordering of topics is different in lectures, different examples will be used) Survival and Style Guides CS 135 Winter 2016 02: The design recipe 1 Programs

More information

CS510 Software Engineering

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

More information

Blame for All. Jeremy G. Siek. Amal Ahmed. Robert Bruce Findler. Philip Wadler. Abstract. 1. Introduction

Blame for All. Jeremy G. Siek. Amal Ahmed. Robert Bruce Findler. Philip Wadler. Abstract. 1. Introduction Blame for All Amal Ahmed Indiana University amal@cs.indiana.edu Robert Bruce Findler Northwestern University robby@eecs.northwestern.edu Jeremy G. Siek University of Colorado at Boulder jeremy.siek@colorado.edu

More information

Unembedding Domain-Specific Languages

Unembedding Domain-Specific Languages Unembedding Domain-Specific Languages Robert Atkey Sam Lindley Jeremy Yallop LFCS, School of Informatics, The University of Edinburgh {bob.atkey,sam.lindley,jeremy.yallop}@ed.ac.uk Abstract Higher-order

More information

Programming Languages in Artificial Intelligence

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

More information

Rigorous Software Development CSCI-GA 3033-009

Rigorous Software Development CSCI-GA 3033-009 Rigorous Software Development CSCI-GA 3033-009 Instructor: Thomas Wies Spring 2013 Lecture 11 Semantics of Programming Languages Denotational Semantics Meaning of a program is defined as the mathematical

More information

λ-rbac: PROGRAMMING WITH ROLE-BASED ACCESS CONTROL

λ-rbac: PROGRAMMING WITH ROLE-BASED ACCESS CONTROL Logical Methods in Computer Science Vol.? (?:?) 2???,? pages www.lmcs-online.org Submitted Published date date λ-rbac: PROGRAMMING WITH ROLE-BASED ACCESS CONTROL RADHA JAGADEESAN a, ALAN JEFFREY b, CORIN

More information

Chapter 1. Computation theory

Chapter 1. Computation theory Chapter 1. Computation theory In this chapter we will describe computation logic for the machines. This topic is a wide interdisciplinary field, so that the students can work in an interdisciplinary context.

More information

Bindings, mobility of bindings, and the -quantifier

Bindings, mobility of bindings, and the -quantifier ICMS, 26 May 2007 1/17 Bindings, mobility of bindings, and the -quantifier Dale Miller, INRIA-Saclay and LIX, École Polytechnique This talk is based on papers with Tiu in LICS2003 & ACM ToCL, and experience

More information

Binary Adders: Half Adders and Full Adders

Binary Adders: Half Adders and Full Adders Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order

More information

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 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

More information

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 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)

More information

3.5 RECURSIVE ALGORITHMS

3.5 RECURSIVE ALGORITHMS Section 3.5 Recursive Algorithms 3.5.1 3.5 RECURSIVE ALGORITHMS review : An algorithm is a computational representation of a function. Remark: Although it is often easier to write a correct recursive algorithm

More information

NOTES ON TYPES AND PROGRAMMING LANGUAGES

NOTES ON TYPES AND PROGRAMMING LANGUAGES NOTES ON TYPES AND PROGRAMMING LANGUAGES NEAL PARIKH Abstract. This document aims to serve as a brief outline and concise reference for Types and Programming Languages by B. Pierce. The sections roughly

More information

Type Systems. Luca Cardelli. Microsoft Research

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

More information

OPERATIONAL TYPE THEORY by Adam Petcher Prepared under the direction of Professor Aaron Stump A thesis presented to the School of Engineering of

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

More information

Midlands Graduate School in the Foundations of Computer Science

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,

More information

Computational Semantics, Type Theory, and Functional Programming

Computational Semantics, Type Theory, and Functional Programming Computational Semantics, Type Theory, and Functional Programming I Converting Montague Grammarians into Programmers Jan van Eijck CWI and ILLC, Amsterdam, Uil-OTS, Utrecht LOLA7 Tutorial, Pecs August 2002

More information

An Agda Tutorial. Makoto Takeyama makoto.takeyama@aist.go.jp

An Agda Tutorial. Makoto Takeyama makoto.takeyama@aist.go.jp An Agda Tutorial Misao Nagayama m-nagayama@aist.go.jp Hideaki Nishihara hide.a.kit@ni.aist.go.jp Makoto Takeyama makoto.takeyama@aist.go.jp Research Center for Verification and Semantics (CVS) National

More information

Semantics and Generative Grammar. Quantificational DPs, Part 3: Covert Movement vs. Type Shifting 1

Semantics and Generative Grammar. Quantificational DPs, Part 3: Covert Movement vs. Type Shifting 1 Quantificational DPs, Part 3: Covert Movement vs. Type Shifting 1 1. Introduction Thus far, we ve considered two competing analyses of sentences like those in (1). (1) Sentences Where a Quantificational

More information

The Lean Theorem Prover

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)

More information

Feed-Forward mapping networks KAIST 바이오및뇌공학과 정재승

Feed-Forward mapping networks KAIST 바이오및뇌공학과 정재승 Feed-Forward mapping networks KAIST 바이오및뇌공학과 정재승 How much energy do we need for brain functions? Information processing: Trade-off between energy consumption and wiring cost Trade-off between energy consumption

More information

Algebraic expressions are a combination of numbers and variables. Here are examples of some basic algebraic expressions.

Algebraic expressions are a combination of numbers and variables. Here are examples of some basic algebraic expressions. Page 1 of 13 Review of Linear Expressions and Equations Skills involving linear equations can be divided into the following groups: Simplifying algebraic expressions. Linear expressions. Solving linear

More information

Adding GADTs to OCaml the direct approach

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

More information

Introduction to Type Theory

Introduction to Type Theory Introduction to Type Theory Herman Geuvers Radboud University Nijmegen, The Netherlands Technical University Eindhoven, The Netherlands 1 Overview These notes comprise the lecture Introduction to Type

More information

Advanced Functional Programming (9) Domain Specific Embedded Languages

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

More information

Unit 3 Boolean Algebra (Continued)

Unit 3 Boolean Algebra (Continued) Unit 3 Boolean Algebra (Continued) 1. Exclusive-OR Operation 2. Consensus Theorem Department of Communication Engineering, NCTU 1 3.1 Multiplying Out and Factoring Expressions Department of Communication

More information

(a) We have x = 3 + 2t, y = 2 t, z = 6 so solving for t we get the symmetric equations. x 3 2. = 2 y, z = 6. t 2 2t + 1 = 0,

(a) We have x = 3 + 2t, y = 2 t, z = 6 so solving for t we get the symmetric equations. x 3 2. = 2 y, z = 6. t 2 2t + 1 = 0, Name: Solutions to Practice Final. Consider the line r(t) = 3 + t, t, 6. (a) Find symmetric equations for this line. (b) Find the point where the first line r(t) intersects the surface z = x + y. (a) We

More information

POLYNOMIALS and FACTORING

POLYNOMIALS and FACTORING POLYNOMIALS and FACTORING Exponents ( days); 1. Evaluate exponential expressions. Use the product rule for exponents, 1. How do you remember the rules for exponents?. How do you decide which rule to use

More information

Functional programming languages

Functional programming languages Functional programming languages Part II: abstract machines Xavier Leroy INRIA Rocquencourt MPRI 2-4-2, 2007 X. Leroy (INRIA) Functional programming languages MPRI 2-4-2, 2007 1 / 73 Execution models for

More information

COMPUTER SCIENCE TRIPOS

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

More information

8 Divisibility and prime numbers

8 Divisibility and prime numbers 8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

More information

9.3 OPERATIONS WITH RADICALS

9.3 OPERATIONS WITH RADICALS 9. Operations with Radicals (9 1) 87 9. OPERATIONS WITH RADICALS In this section Adding and Subtracting Radicals Multiplying Radicals Conjugates In this section we will use the ideas of Section 9.1 in

More information

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook. Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

More information

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Why? A central concept in Computer Science. Algorithms are ubiquitous. Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

More information

Maar hoe moet het dan?

Maar hoe moet het dan? Maar hoe moet het dan? Onderzoek naar feedback in interactieve leeromgevingen bij de Faculteit Informatica Johan Jeuring Met bijdragen van Alex Gerdes, Bastiaan Heeren, Josje Lodder, Harrie Passier, Sylvia

More information

Note: This App is under development and available for testing on request. Note: This App is under development and available for testing on request. Note: This App is under development and available for

More information

3201 Computer Networks 2014/2015 Handout: Subnetting Question

3201 Computer Networks 2014/2015 Handout: Subnetting Question Subnetting Questions with Answers Question1: Given the following: Network address: 192.168.10.0 Subnet mask: 255.255.255.224 1. How many subnets? Ans: 6 2. How many hosts? Ans: 30 3. What are the valid

More information

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm MTHSC 412 Section 2.4 Prime Factors and Greatest Common Divisor Greatest Common Divisor Definition Suppose that a, b Z. Then we say that d Z is a greatest common divisor (gcd) of a and b if the following

More information

Boolean Expressions & the if Statement

Boolean Expressions & the if Statement Midterm Results Boolean Expressions & the if Statement September 24, 2007 Average: 91.6 Median: 94 Standard Deviation: 18.80 Maximum: 129 (out of 130) ComS 207: Programming I (in Java) Iowa State University,

More information

Fixed-Point Logics and Computation

Fixed-Point Logics and Computation 1 Fixed-Point Logics and Computation Symposium on the Unusual Effectiveness of Logic in Computer Science University of Cambridge 2 Mathematical Logic Mathematical logic seeks to formalise the process of

More information

Logic in Computer Science: Logic Gates

Logic in Computer Science: Logic Gates Logic in Computer Science: Logic Gates Lila Kari The University of Western Ontario Logic in Computer Science: Logic Gates CS2209, Applied Logic for Computer Science 1 / 49 Logic and bit operations Computers

More information

Parametric Domain-theoretic models of Linear Abadi & Plotkin Logic

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

More information

Fixed Points of Type Constructors and Primitive Recursion

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

More information

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be... What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

More information

Solving Quadratic Equations by Factoring

Solving Quadratic Equations by Factoring 4.7 Solving Quadratic Equations by Factoring 4.7 OBJECTIVE 1. Solve quadratic equations by factoring The factoring techniques you have learned provide us with tools for solving equations that can be written

More information

NLP Lab Session Week 3 Bigram Frequencies and Mutual Information Scores in NLTK September 16, 2015

NLP Lab Session Week 3 Bigram Frequencies and Mutual Information Scores in NLTK September 16, 2015 NLP Lab Session Week 3 Bigram Frequencies and Mutual Information Scores in NLTK September 16, 2015 Starting a Python and an NLTK Session Open a Python 2.7 IDLE (Python GUI) window or a Python interpreter

More information

o-minimality and Uniformity in n 1 Graphs

o-minimality and Uniformity in n 1 Graphs o-minimality and Uniformity in n 1 Graphs Reid Dale July 10, 2013 Contents 1 Introduction 2 2 Languages and Structures 2 3 Definability and Tame Geometry 4 4 Applications to n 1 Graphs 6 5 Further Directions

More information

Boolean Algebra Part 1

Boolean Algebra Part 1 Boolean Algebra Part 1 Page 1 Boolean Algebra Objectives Understand Basic Boolean Algebra Relate Boolean Algebra to Logic Networks Prove Laws using Truth Tables Understand and Use First Basic Theorems

More information

Definitional Interpreters for Higher-Order Programming Languages *

Definitional Interpreters for Higher-Order Programming Languages * Higher-Order and Symbolic Computation, 11, 363 397 1998) c 1998 Kluwer Academic Publishers, Boston. Manufactured in The Netherlands. Definitional Interpreters for Higher-Order Programming Languages * JOHN

More information

CS422 - Programming Language Design

CS422 - Programming Language Design 1 CS422 - Programming Language Design General Information and Introduction Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 General Information Class Webpage and

More information

Ralf Hinze Generic Programs and Proofs

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

More information

Introduction. The Quine-McCluskey Method Handout 5 January 21, 2016. CSEE E6861y Prof. Steven Nowick

Introduction. The Quine-McCluskey Method Handout 5 January 21, 2016. CSEE E6861y Prof. Steven Nowick CSEE E6861y Prof. Steven Nowick The Quine-McCluskey Method Handout 5 January 21, 2016 Introduction The Quine-McCluskey method is an exact algorithm which finds a minimum-cost sum-of-products implementation

More information

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha Algorithm & Flowchart & Pseudo code Staff Incharge: S.Sasirekha Computer Programming and Languages Computers work on a set of instructions called computer program, which clearly specify the ways to carry

More information

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:

More information

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification: Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,

More information

IV.2 (b) Higher level programming concepts for URMs Anton Setzer

IV.2 (b) Higher level programming concepts for URMs Anton Setzer CS 275 Automata and Formal Language Theory Course Notes Additional Material Part IV: Limits of Computation Chapt. IV.2: The URM IV.2 (a) Definition of the URM IV.2 (b) Higher level programming concepts

More information

BRICS. From Interpreter to Compiler and Virtual Machine: A Functional Derivation

BRICS. From Interpreter to Compiler and Virtual Machine: A Functional Derivation BRICS Basic Research in Computer Science BRICS RS-03-14 Ager et al.: From Interpreter to Compiler and Virtual Machine: A Functional Derivation From Interpreter to Compiler and Virtual Machine: A Functional

More information

Gates, Circuits, and Boolean Algebra

Gates, Circuits, and Boolean Algebra Gates, Circuits, and Boolean Algebra Computers and Electricity A gate is a device that performs a basic operation on electrical signals Gates are combined into circuits to perform more complicated tasks

More information

9 Multiplication of Vectors: The Scalar or Dot Product

9 Multiplication of Vectors: The Scalar or Dot Product Arkansas Tech University MATH 934: Calculus III Dr. Marcel B Finan 9 Multiplication of Vectors: The Scalar or Dot Product Up to this point we have defined what vectors are and discussed basic notation

More information

Handout #1: Mathematical Reasoning

Handout #1: Mathematical Reasoning Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or

More information

Home Assignment 4 OCL

Home Assignment 4 OCL Home Assignment 4 OCL This home assignment is about writing formal specifications using the Object Constraint Language. You will exercise formulating conditions/invariants on domain models that go beyond

More information

Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation

Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Abstract This paper discusses methods of joining SAS data sets. The different methods and the reasons for choosing a particular

More information

Linear Types for Continuations

Linear Types for Continuations 1/28 Linear Types for Continuations Alex Simpson LFCS, School of Informatics University of Edinburgh, UK Joint work with: Jeff Egger (LFCS, Edinburgh) Rasmus Møgelberg (ITU, Copenhagen) Linear Types for

More information

Basic Polymorphic Typechecking

Basic Polymorphic Typechecking Science of Computer Programming 8/2 (April 1987) Revised 6/21/88 Basic Polymorphic Typechecking Luca Cardelli AT&T Bell Laboratories, Murray Hill, NJ 07974 (current address: DEC SRC, 130 Lytton Ave, Palo

More information

Forecasting in supply chains

Forecasting in supply chains 1 Forecasting in supply chains Role of demand forecasting Effective transportation system or supply chain design is predicated on the availability of accurate inputs to the modeling process. One of the

More information

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

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

More information

9.2 Summation Notation

9.2 Summation Notation 9. Summation Notation 66 9. Summation Notation In the previous section, we introduced sequences and now we shall present notation and theorems concerning the sum of terms of a sequence. We begin with a

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority) Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the

More information

Introduction to formal semantics -

Introduction to formal semantics - Introduction to formal semantics - Introduction to formal semantics 1 / 25 structure Motivation - Philosophy paradox antinomy division in object und Meta language Semiotics syntax semantics Pragmatics

More information

Intermediate Code. Intermediate Code Generation

Intermediate Code. Intermediate Code Generation Intermediate Code CS 5300 - SJAllan Intermediate Code 1 Intermediate Code Generation The front end of a compiler translates a source program into an intermediate representation Details of the back end

More information

Programmable Logic Controllers Definition. Programmable Logic Controllers History

Programmable Logic Controllers Definition. Programmable Logic Controllers History Definition A digitally operated electronic apparatus which uses a programmable memory for the internal storage of instructions for implementing specific functions such as logic, sequencing, timing, counting,

More information

Well-typed programs can t be blamed

Well-typed programs can t be blamed Well-typed programs can t be blamed Philip Wadler University of Edinburgh Robert Bruce Findler University of Chicago Abstract We introduce the blame calculus, which adds the notion of blame from Findler

More information

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test Math Review for the Quantitative Reasoning Measure of the GRE revised General Test www.ets.org Overview This Math Review will familiarize you with the mathematical skills and concepts that are important

More information

MATLAB Basics MATLAB numbers and numeric formats

MATLAB Basics MATLAB numbers and numeric formats MATLAB Basics MATLAB numbers and numeric formats All numerical variables are stored in MATLAB in double precision floating-point form. (In fact it is possible to force some variables to be of other types

More information