Pola: a language for PTIME Programming. Mike Burrell, Robin Cockett, Brian Redmond LCC 2009

Size: px
Start display at page:

Download "Pola: a language for PTIME Programming. Mike Burrell, Robin Cockett, Brian Redmond LCC 2009"

Transcription

1 Pola: a language for PTIME Programming Mike Burrell, Robin Cockett, Brian Redmond LCC 2009

2 Pola overview Allows for general inductive data types And coinductive as well! Breaks variables into two separate worlds Player Affine Opponent Drives recursion

3 Inductive world Allow constructing typical inductive data types data Nat c = Zero : c Succ : c c data List(a) c = Nil : c Cons : a, c c E.g., [a, b] = Cons(a, Cons(b, Nil)) data Tree(a) c = Leaf : a c Node : c, c c Function application, but no recursion!

4 iszero :: Nat Bool; iszero = x.case x of { Zero.True; Succ( ).False }; isempty :: List(a) Bool; isempty = lst.case lst of { Nil.True; Cons(, ).False }; isempty([2, 3]) False

5 Safe recursion The fold construct introduces a safe recursive function What s being folded over must be in the opponent world Everything else in the fold must be in the player world x must be of a universal type add :: Nat Nat Nat; add = x y.fold f(x, y) as { Zero.n; y)) } in f(x, y ); mul :: Nat, Nat Nat; mul = x, y.fold f(x) as { Zero.Zero; f(m)) } in f(x, y );

6 Opponent and player world f = a.fold f(a, b) as { No restrictions in the opponent world.... f(m, b)) } in f(a, Zero);

7 Opponent and player world f = a.fold f(a) as {... } in f(a ); f = a.fold f(a) as {... } in f(a ); f = a.fold f(a) as {... } in f(succ(zero));

8 No exponential mul :: Nat, Nat Nat; exp = x, y.fold f(x) as { Zero.Succ(Zero); f(m)) } in f(x, y );

9 No exponential mul :: Nat, Nat Nat; exp = x, y.fold f(x) as { Zero.Succ(Zero); f(m)) } in f(x, y );

10 Opponent/player round-up Generally no restrictions in the opponent world, but... The opponent context must stay constant within a safe recursion! The player world is restrictive No duplicating! Variables can t be brought to the opponent world

11 Γ,x: X x : X id o Γ,y : Y y : Y id p Γ t : Y Γ,x: X t : Y weak o Γ t : Y Γ,y : Y t : Y weak p Γ t : X Γ,x: X t : Y Γ t [t/x] :Y cut o Γ 1 t : Y Γ 2,y : Y t : Y Γ 1, 2 t [t/y] :Y cut p Γ t : Y Γ, () : 1 t : Y Γ t : Y Γ, () : 1 t : Y Γ () : 1 Γ,x 1 : X 1,x 2 : X 2 t : Y Γ, (x 1,x 2 ):X 1 X 2 t : Y Γ,y 1 : Y 1,y 2 : Y 2 t : Y Γ, (y 1,y 2 ):Y 1 Y 2 t : Y Γ 1 t 1 : Y 1 Γ 2 t 2 : Y 2 Γ 1, 2 (t 1,t 2 ):Y 1 Y 2 Table 1. The basic logic of safety.

12 player types A, a new player type D(A) is added, together with rules for its constructors C i (see table 2). An inductive data type is introduced into the basic Γ t : F i (D(A),A) Γ C i (t) :D(A) cons i {Γ y i : F i (D(A),A), t i : Y } i=1,...,k 8 9 >< C 1 (y 1 ).t 1 >= Γ y : D(A), case y of. >: >; : Y C k (y k ).t k case 8 < Γ,z : D(A) w : Γ, C f : C, Ẽ Y. : y i : F i (D(A),A) y i : F i (C, A), w : Ẽ t i : Y 9 = ; i=1,...,k 8 >< C 1 (y 9 1@y 1 ).t 1 >= Ẽ fold f(z, w) as. >: >; in f(z, w ):Y C k (y k@y k ).t k Table 2. Judgements for fixed points and safe inductive folding. logic of safety with a specification of the form: data D(A) C = {C i : F i (C, A) C} i=1,...,k

13 Peeks Why can t we duplicate in the player world? We could duplicate recursive calls! Definitely not polynomial anymore! What if we don t want to use a value, just peek at it?

14 iszero = x.case x of { Zero.True; Succ(-).False }; callfifnotzero = x.case x of { Zero.Zero; Succ(-).f(x) };

15 iszero = x.case x of { Zero.True; Succ(-).False }; callfifnotzero = x.case x of { Zero.Zero; Succ(-).f(x) }; callfifnotzero = x.case x of { Zero.Zero; Succ(x ).f(succ(x )) };

16 Peeking peek is semantically the same as a case Typing is different Only anonymous patterns Player variables in callfifnotzero = x. peek x of { Zero.Zero; Succ( ).f(x) }; subject can be reused

17 Coinductive world data c Prod(a, b) = P1 : c a P2 : c b E.g., P1( ( P1 : 3 ; P2 : hello ) ) 3 data c Fn(a, b) = Eval : c, a b E.g., Eval( ( Eval : x. Succ(x) ), 3) 4

18 map :: Fn(a, b), List(a) List(b); map = f, l.fold g(l) as { Nil.Nil; Cons(x, xs).cons(eval(f, x), g(xs)) } in g(l ); map( ( Eval : x.succ(x) ), [3, 4]) [4, 5]

19 Safe recursion data c InfList(a) = Head : c a Tail : c c; naturalnumbers :: InfList(Nat); naturalnumbers =.unfold g(x) as ( Head : x; Tail : g(succ(x)) ) in g(zero); Head(Tail(Tail(naturalNumbers))) 2

20 data c InfTree = Left : c c Right : c c; infinitetree :: InfTree; infinitetree =.unfold g() as ( Left : g(); Right : g() ) in g();

21 data c InfTree = Left : c c Right : c c; infinitetree :: InfTree; infinitetree =.unfold g() as ( Left : g(); Right : g() ) in g(); fold f(x, t) as { Zero.t; Right(t)) } in f(n, infinitetree);

22 12 Γ t : D(A/B) A i Γ D i (t) :G i (D(A/B),B) dest i {Γ,a i : A i t i : G i (D(A/B),B)} i=1...k 0 1 D 1 : a 1.t 1 B D k : a k.t k C A : D(A/B) record Γ ỹ : Γ, C g : Ẽ C 8 < : Ẽ unfold g(ỹ) as. a i : A i, ỹ : Ẽ t i : G i (C, B) 0 1 D 1 : a 1.t 1 D k : a k.t k 9 = ; i=1,...,k C A in g(ỹ ):D(A/B) Table 4. Judgements for destruction, records and safe coinductive unfolding. to a corresponding destructor, together with a value for the variable a i, that computation proceeds by evaluating the appropriate term t i. Example Pola programs using coinductive types are given in figure 4. The type of the function pmap is A B,L(A) L(B) and it simply applies the player function f to every element of the list. This shows that the list function is

23 Polynomial completeness The power of Pola exacts equals PTIME Pola can compute any PTIME algorithm We can compute a fixed polynomial from the size of the input One level of safe recursion per degree of the polynomial Use that to drive the recursion simulating a Turing machine

24 Polynomial completeness Any Pola program is in PTIME Everything in the player world is constant time A single fold is linear in the size of its input Nested folds are polynomial in the size of their input fold f(x) of { Nil.Zero; Cons(y, g(z) of { Nil.Zero; Cons(, ).Zero in g(ys ) in f(x )

25 Polynomials can be assigned to terms inductively by the following rules. In fact, the derivation of the polynomial associated to a term mimics the derivation of the term by the proof rules. x = x (opponent variable) y = 0 (player variable) (t 1,t 2 ) = t 1 + t 2 t[t /x] = t [ t /x] (opponent cut) t[t /y] = t + t (player cut) () =0 C(t) = t +1 case y of {C i (y i).t i } = max i t i [y/y i ] peek y of {C i ( ).t i } = max i t i fold f(z, w) as { } in f(z, w ) = f(z, w ) f(z, w) = z case z of {C i (y i).t i } unfold g(ỹ) as ( ) in g(ỹ ) =0 ( ) = 0 (record) D(t, t ) = {t} + t + t (destruction) where { } is identical to except that: {unfold g(ỹ) as (D 1 : a 1.t 1 ; ; D k : a k.t k ) in g(ỹ )} = max t i i {(D 1 : a 1.t 1 ; ; D k : a k.t k )} = max t i i {D(t, t )} = {t} where has the same inductive definition as except that f(z, w) =0 for each recursive call to f. One can show by induction on the proof rules that if x 1 : X 1,..., x n : X n y 1 : Y 1,..., y m : Y m t : Y is derivable then t is a polynomial in x 1,..., x n. One can then show that whenever t evaluates to e, e t + y y m For example, addition on unary numbers is defined in Pola by x : Nat y :

26 Pola wrap-up Unifies work of Hofmann, Bellantoni and Cook, etc. Aims to be general, practical PTIME language Inductive data types, coinductive data types Peeking at values Implementation nearing stability

27 Thank you.

ON FIRST-ORDER CONS-FREE TERM REWRITING AND PTIME

ON FIRST-ORDER CONS-FREE TERM REWRITING AND PTIME ON FIRST-ORDER CONS-FREE TERM REWRITING AND PTIME CYNTHIA KOP Department of Computer Science, Copenhagen University e-mail address: kop@diku.dk Abstract. In this paper, we prove that (first-order) cons-free

More information

Typed Arithmetic Expressions

Typed Arithmetic Expressions Typed Arithmetic Expressions CS 550 Programming Languages Jeremy Johnson TAPL Chapters 3 and 5 1 Types and Safety Evaluation rules provide operational semantics for programming languages. The rules provide

More information

Generic Accumulations for Program Calculation

Generic Accumulations for Program Calculation Generic Accumulations for Program Calculation Mauro Jaskelioff Facultad de Cs. Exactas, Ingeniería y Agrimensura Universidad Nacional de Rosario Rosario - Argentina mauro@fceia.unr.edu.ar December 2004

More information

Predicative Copying and Polynomial Time

Predicative Copying and Polynomial Time Clifford Lectures 2002 Predicative Copying and Polynomial Time 1 Predicative Copying and Polynomial Time Samson Abramsky Clifford Lectures 2002 Predicative Copying and Polynomial Time 2 Background: Implicit

More information

Notes on Inductive Sets and Induction

Notes on Inductive Sets and Induction Notes on Inductive Sets and Induction Finite Automata Theory and Formal Languages TMV027/DIT21 Ana Bove, March 15th 2018 Contents 1 Induction over the Natural Numbers 2 1.1 Mathematical (Simple) Induction........................

More information

Inductive types and identity types

Inductive types and identity types 1 / 49 Inductive types and identity types Michael Shulman February 7, 2012 3 / 49 Type constructors For every type constructor, we have rules for: 1 Constructing types 2 Constructing terms in those types

More information

Operational Semantics Using the Partiality Monad

Operational Semantics Using the Partiality Monad page.1 Operational Semantics Using the Partiality Monad Nils Anders Danielsson (Göteborg) Shonan Meeting 026: Coinduction for computation structures and programming languages The research leading to these

More information

An introduction to (co)algebra and (co)induction

An introduction to (co)algebra and (co)induction 1 An introduction to (co)algebra and (co)induction 1.1 Introduction Algebra is a well-established part of mathematics, dealing with sets with operations satisfying certain properties, like groups, rings,

More information

Implicit Computational Complexity

Implicit Computational Complexity Implicit Computational Complexity Simone Martini Dipartimento di Scienze dell Informazione Università di Bologna Italy Bertinoro International Spring School for Graduate Studies in Computer Science, 6

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017 Formal proofs; Simple/strong induction; Mutual induction; Inductively defined sets; Recursively defined functions. Lecture 3 Ana Bove

More information

The syntactic guard condition of Coq

The syntactic guard condition of Coq The syntactic guard condition of Coq Bruno Barras February 2, 2010 Overview 1 Theory Basic criterion Extensions 2 Algorithm Efficiency 3 Discussion 4 Attic A short history of the syntactic guard criterion

More information

Quantum Functional Programming Language & Its Denotational Semantics

Quantum Functional Programming Language & Its Denotational Semantics Quantum Functional Programming Language & Its Denotational Semantics Ichiro Hasuo Dept. Computer Science University of Tokyo Naohiko Hoshino Research Inst. for Math. Sci. Kyoto University Talk based on:

More information

A categorical model for a quantum circuit description language

A categorical model for a quantum circuit description language A categorical model for a quantum circuit description language Francisco Rios (joint work with Peter Selinger) Department of Mathematics and Statistics Dalhousie University CT July 16th 22th, 2017 What

More information

Focusing on Binding and Computation

Focusing on Binding and Computation Focusing on Binding and Computation Dan Licata Joint work with Noam Zeilberger and Robert Harper Carnegie Mellon University 1 Programming with Proofs Represent syntax, judgements, and proofs Reason about

More information

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007 CSE 230: Winter 2007 Principles of Programming Languages Lecture 12: The λ-calculus Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2 Several evaluation

More information

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.

More information

Non size-increasing computation. Martin Hofmann LMU München Geocal 06 Luminy, Feb. 2006

Non size-increasing computation. Martin Hofmann LMU München Geocal 06 Luminy, Feb. 2006 1 Non size-increasing computation Martin Hofmann LMU München Geocal 06 Luminy, 9.-10. Feb. 2006 2 Main result of these talks Description: The system LFPL ω is a linearly typed functional language with

More information

When is a function a fold or an unfold?

When is a function a fold or an unfold? When is a function a fold or an unfold? Jeremy Gibbons University of Oxford Graham Hutton University of Nottingham Thorsten Altenkirch University of Nottingham April 29, 2002 Abstract We give a necessary

More information

COMPLEXITY HIERARCHIES AND HIGHER-ORDER CONS-FREE TERM REWRITING

COMPLEXITY HIERARCHIES AND HIGHER-ORDER CONS-FREE TERM REWRITING COMPLEXITY HIERARCHIES AND HIGHER-ORDER CONS-FREE TERM REWRITING CYNTHIA KOP AND JAKOB GRUE SIMONSEN Department of Computer Science, Copenhagen University e-mail address: {kop,simonsen}@di.ku.dk Abstract.

More information

The Power of Non-Determinism in Higher-Order Implicit Complexity

The Power of Non-Determinism in Higher-Order Implicit Complexity The Power of Non-Determinism in Higher-Order Implicit Complexity Characterising Complexity Classes using Non-deterministic Cons-free Programming Cynthia Kop and Jakob Grue Simonsen Department of Computer

More information

Element x is R-minimal in X if y X. R(y, x).

Element x is R-minimal in X if y X. R(y, x). CMSC 22100/32100: Programming Languages Final Exam M. Blume December 11, 2008 1. (Well-founded sets and induction principles) (a) State the mathematical induction principle and justify it informally. 1

More information

Soft Linear Logic and the Polynomial Hierarchy (Extended Abstract)

Soft Linear Logic and the Polynomial Hierarchy (Extended Abstract) Soft Linear Logic and the Polynomial Hierarchy (Extended Abstract) Brian F. Redmond Department of Computing, Mathematics and Statistical Sciences Grande Prairie Regional College 10726-106 Avenue, Grande

More information

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus Course 2D1453, 200607 Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Typing λterms The uptyped λcalculus

More information

CS294-9 September 14, 2006 Adam Chlipala UC Berkeley

CS294-9 September 14, 2006 Adam Chlipala UC Berkeley Interactive Computer Theorem Proving Lecture 4: Inductively- Defined Predicates CS294-9 September 14, 2006 Adam Chlipala UC Berkeley 1 Administrivia The course registration database has been updated so

More information

Modeling and reasoning with I-polynomial data types

Modeling and reasoning with I-polynomial data types Modeling and reasoning with I-polynomial data types Peter Padawitz, TU Dortmund, Germany September 1, 2017 (actual version: http://fldit-www.cs.uni-dortmund.de/ peter/ifip2016.pdf) 1 Road map Some examples

More information

Programming Languages

Programming Languages CSE 230: Winter 2010 Principles of Programming Languages Lecture 10: Programming in λ-calculusc l l Ranjit Jhala UC San Diego Review The lambda calculus is a calculus of functions: e := x λx. e e 1 e 2

More information

Type Systems as a Foundation for Reliable Computing

Type Systems as a Foundation for Reliable Computing Type Systems as a Foundation for Reliable Computing Robert Harper Carnegie Mellon University Summer School on Reliable Computing University of Oregon July, 2005 References These lectures are based on the

More information

Principles of Program Analysis: Control Flow Analysis

Principles of Program Analysis: Control Flow Analysis Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms First-Order Logic 1 Syntax Domain of Discourse The domain of discourse for first order logic is FO structures or models. A FO structure contains Relations Functions Constants (functions of arity 0) FO

More information

Parallelism and Machine Models

Parallelism and Machine Models Parallelism and Machine Models Andrew D Smith University of New Brunswick, Fredericton Faculty of Computer Science Overview Part 1: The Parallel Computation Thesis Part 2: Parallelism of Arithmetic RAMs

More information

Interpretation of stream programs:

Interpretation of stream programs: Author manuscript, published in "21st International Symposium on Algorithms and Computation - ISAAC 2010 (2010)" Interpretation of stream programs: characterizing type 2 polynomial time complexity Hugo

More information

(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F:

(2) (15pts) Using Prolog, implement a type-checker for the following small subset of System F: CS 6371 Advanced Programming Languages Sample Spring 2018 Final Exam This sample final exam is LONGER than a real final exam (to give you more practice problems) and has a medium difficulty level. You

More information

Metatheory of Recursive Types

Metatheory of Recursive Types Design Principles of Programming Languages Metatheory of Recursive Types Zhenjiang Hu, Haiyan Zhao, Yingfei Xiong Peking University, Spring Term, 2016 提醒 : 课程项目 6 月 8 日课程项目报告 每组报告 20 分钟, 提问 5 分钟 组队的同学请介绍每名成员的贡献

More information

Domain theory and denotational semantics of functional programming

Domain theory and denotational semantics of functional programming Domain theory and denotational semantics of functional programming Martín Escardó School of Computer Science, Birmingham University MGS 2007, Nottingham, version of April 20, 2007 17:26 What is denotational

More information

Corecursion and coinduction: what they are and how they relate to recursion and induction. Mike Gordon

Corecursion and coinduction: what they are and how they relate to recursion and induction. Mike Gordon Corecursion and coinduction: what they are and how they relate to recursion and induction Mike Gordon 1 Contents Preface 3 Summary 4 Data, codata, constructors and destructors............... 4 Recursion

More information

Grammatical resources: logic, structure and control

Grammatical resources: logic, structure and control Grammatical resources: logic, structure and control Michael Moortgat & Dick Oehrle 1 Grammatical composition.................................. 5 1.1 Grammar logic: the vocabulary.......................

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Mathias Vorreiter Pedersen November 13, 2015 1 Recalling the untyped lambda calculus 1.1 Syntax t ::= x λ x. t t t 1.2 Evaluation x x t t λx.t λx.t t 1 t 1 t 2 t 2 t 1 t 2

More information

Outline. A recursive function follows the structure of inductively-defined data.

Outline. A recursive function follows the structure of inductively-defined data. Outline A recursive function follows the structure of inductively-defined data. With lists as our example, we shall study 1. inductive definitions (to specify data) 2. recursive functions (to process data)

More information

Operationally-Based Theories of Program Equivalence

Operationally-Based Theories of Program Equivalence Operationally-Based Theories of Program Equivalence Andrew Pitts Contents 1 Introduction : : : : : : : : : : : : : : : : : : : : : : : : : : : : 241 2 Contextual Equivalence : : : : : : : : : : : : : :

More information

Induction and Recursion

Induction and Recursion Induction and Recursion Prof. Clarkson Fall 2016 Today s music: Dream within a Dream from the soundtrack to Inception by Hans Zimmer Review Previously in 3110: Behavioral equivalence Proofs of correctness

More information

The L Machines are very high-level, in two senses:

The L Machines are very high-level, in two senses: What is a Computer? State of the machine. CMPSCI 630: Programming Languages An Abstract Machine for Control Spring 2009 (with thanks to Robert Harper) Internal registers, memory, etc. Initial and final

More information

A fully abstract semantics for a nondeterministic functional language with monadic types

A fully abstract semantics for a nondeterministic functional language with monadic types A fully abstract semantics for a nondeterministic functional language with monadic types Alan Jeffrey 1 School of Cognitive and Computing Sciences University of Sussex, Brighton BN1 9QH, UK alanje@cogs.susx.ac.uk

More information

Elements of Category Theory

Elements of Category Theory Elements of Category Theory Robin Cockett Department of Computer Science University of Calgary Alberta, Canada robin@cpsc.ucalgary.ca Estonia, Feb. 2010 Functors and natural transformations Adjoints and

More information

Implicit Computational Complexity

Implicit Computational Complexity Implicit Computational Complexity Simone Martini Dipartimento di Scienze dell Informazione Università di Bologna Italy Bertinoro International Spring School for Graduate Studies in Computer Science, 6

More information

Programming with classical quantum datatypes

Programming with classical quantum datatypes Programming with classical quantum datatypes Robin Cockett & Brett Giles (robin,gilesb)@cpsc.ucalgary.ca University of Calgary FMCS 2006, Programming with classical quantum datatypes p. 1/49 Yet another

More information

Principles of Program Analysis: A Sampler of Approaches

Principles of Program Analysis: A Sampler of Approaches Principles of Program Analysis: A Sampler of Approaches Transparencies based on Chapter 1 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis Springer Verlag

More information

Code Generation for a Simple First-Order Prover

Code Generation for a Simple First-Order Prover Code Generation for a Simple First-Order Prover Jørgen Villadsen, Anders Schlichtkrull, and Andreas Halkjær From DTU Compute, Technical University of Denmark, 2800 Kongens Lyngby, Denmark Abstract. We

More information

Abstract Interpretation II

Abstract Interpretation II Abstract Interpretation II Semantics and Application to Program Verification Antoine Miné École normale supérieure, Paris year 2015 2016 Course 11 13 May 2016 Course 11 Abstract Interpretation II Antoine

More information

Lecture 7: Dynamic Programming I: Optimal BSTs

Lecture 7: Dynamic Programming I: Optimal BSTs 5-750: Graduate Algorithms February, 06 Lecture 7: Dynamic Programming I: Optimal BSTs Lecturer: David Witmer Scribes: Ellango Jothimurugesan, Ziqiang Feng Overview The basic idea of dynamic programming

More information

Lecture Notes on Data Abstraction

Lecture Notes on Data Abstraction Lecture Notes on Data Abstraction 15-814: Types and Programming Languages Frank Pfenning Lecture 14 October 23, 2018 1 Introduction Since we have moved from the pure λ-calculus to functional programming

More information

A Hierarchy of Ramified Theories around PRA

A Hierarchy of Ramified Theories around PRA A Hierarchy of Ramified Theories around PRA Elliott J. Spoors and Stanley S. Wainer 1 (Leeds UK) Logic Colloquium 2012, Manchester. 1 Later parts of this work were done while the second author visited

More information

Lecture 3 (Notes) 1. The book Computational Complexity: A Modern Approach by Sanjeev Arora and Boaz Barak;

Lecture 3 (Notes) 1. The book Computational Complexity: A Modern Approach by Sanjeev Arora and Boaz Barak; Topics in Theoretical Computer Science March 7, 2016 Lecturer: Ola Svensson Lecture 3 (Notes) Scribes: Ola Svensson Disclaimer: These notes were written for the lecturer only and may contain inconsistent

More information

Types and Programming Languages (15-814), Fall 2018 Assignment 4: Data Representation (Sample Solutions)

Types and Programming Languages (15-814), Fall 2018 Assignment 4: Data Representation (Sample Solutions) Types and Programming Languages (15-814), Fall 2018 Assignment 4: Data Representation (Sample Solutions) Contact: 15-814 Course Staff Due Tuesday, October 16, 2018, 10:30am This assignment is due by 10:30am

More information

Notes on ordinals and cardinals

Notes on ordinals and cardinals Notes on ordinals and cardinals Reed Solomon 1 Background Terminology We will use the following notation for the common number systems: N = {0, 1, 2,...} = the natural numbers Z = {..., 2, 1, 0, 1, 2,...}

More information

Complexity: moving from qualitative to quantitative considerations

Complexity: moving from qualitative to quantitative considerations Complexity: moving from qualitative to quantitative considerations Textbook chapter 7 Complexity Theory: study of what is computationally feasible (or tractable) with limited resources: running time (main

More information

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008

CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 CMSC 336: Type Systems for Programming Languages Lecture 10: Polymorphism Acar & Ahmed 19 February 2008 Contents 1 Polymorphism 1 2 Polymorphic λ-calculus: Syntax 1 3 Static Semantics 2 4 Dynamic Semantics

More information

Type Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth

Type Systems. Today. 1. What is the Lambda Calculus. 1. What is the Lambda Calculus. Lecture 2 Oct. 27th, 2004 Sebastian Maneth Today 1. What is the Lambda Calculus? Type Systems 2. Its Syntax and Semantics 3. Church Booleans and Church Numerals 4. Lazy vs. Eager Evaluation (call-by-name vs. call-by-value) Lecture 2 Oct. 27th,

More information

M ::= x M M x = M M :: M x :: x

M ::= x M M x = M M :: M x :: x Mini-ML expressions M ::= x variable true boolean values false if M then M else M conditional lx (M) function abstraction MM function application let x = M in M local declaration nil nil list M :: M list

More information

Principle of Mathematical Induction

Principle of Mathematical Induction Advanced Calculus I. Math 451, Fall 2016, Prof. Vershynin Principle of Mathematical Induction 1. Prove that 1 + 2 + + n = 1 n(n + 1) for all n N. 2 2. Prove that 1 2 + 2 2 + + n 2 = 1 n(n + 1)(2n + 1)

More information

Arithmetical Hierarchy

Arithmetical Hierarchy Arithmetical Hierarchy 1 The Turing Jump Klaus Sutner Carnegie Mellon University Arithmetical Hierarchy 60-arith-hier 2017/12/15 23:18 Definability Formal Systems Recall: Oracles 3 The Use Principle 4

More information

Arithmetical Hierarchy

Arithmetical Hierarchy Arithmetical Hierarchy Klaus Sutner Carnegie Mellon University 60-arith-hier 2017/12/15 23:18 1 The Turing Jump Arithmetical Hierarchy Definability Formal Systems Recall: Oracles 3 We can attach an orcale

More information

A first order divided difference

A first order divided difference A first order divided difference For a given function f (x) and two distinct points x 0 and x 1, define f [x 0, x 1 ] = f (x 1) f (x 0 ) x 1 x 0 This is called the first order divided difference of f (x).

More information

QF101: Quantitative Finance August 22, Week 1: Functions. Facilitator: Christopher Ting AY 2017/2018

QF101: Quantitative Finance August 22, Week 1: Functions. Facilitator: Christopher Ting AY 2017/2018 QF101: Quantitative Finance August 22, 2017 Week 1: Functions Facilitator: Christopher Ting AY 2017/2018 The chief function of the body is to carry the brain around. Thomas A. Edison 1.1 What is a function?

More information

SLD-Resolution And Logic Programming (PROLOG)

SLD-Resolution And Logic Programming (PROLOG) Chapter 9 SLD-Resolution And Logic Programming (PROLOG) 9.1 Introduction We have seen in Chapter 8 that the resolution method is a complete procedure for showing unsatisfiability. However, finding refutations

More information

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications NICTA Advanced Course Theorem Proving Principles, Techniques, Applications λ 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic, natural

More information

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures CS 6110 S18 Lecture 21 Products, Sums, and Other Datatypes 1 Introduction In this lecture, we add constructs to the typed λ-calculus that allow working with more complicated data structures, such as pairs,

More information

CMSC 631 Program Analysis and Understanding Fall Type Systems

CMSC 631 Program Analysis and Understanding Fall Type Systems Program Analysis and Understanding Fall 2017 Type Systems Type Systems A type system is a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according

More information

INDUCTIVE DEFINITION

INDUCTIVE DEFINITION 1 INDUCTIVE DEFINITION OUTLINE Judgements Inference Rules Inductive Definition Derivation Rule Induction 2 META-VARIABLES A symbol in a meta-language that is used to describe some element in an object

More information

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK

Roy L. Crole. Operational Semantics Abstract Machines and Correctness. University of Leicester, UK Midlands Graduate School, University of Birmingham, April 2008 1 Operational Semantics Abstract Machines and Correctness Roy L. Crole University of Leicester, UK Midlands Graduate School, University of

More information

Space Complexity. Huan Long. Shanghai Jiao Tong University

Space Complexity. Huan Long. Shanghai Jiao Tong University Space Complexity Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/ chen/

More information

Predicate Logic - Undecidability

Predicate Logic - Undecidability CS402, Spring 2016 Undecidable Problems Does the following program halts? (1) N : n, total, x, y, z (2) n GetUserInput() (3) total 3 (4) while true (5) for x 1 to total 2 (6) for y 1 to total x 1 (7) z

More information

(Ordinary) mathematical induction is a way to prove things about natural numbers. We can write it as a rule: φ(0) x. φ(x) φ(succ(x)) x.

(Ordinary) mathematical induction is a way to prove things about natural numbers. We can write it as a rule: φ(0) x. φ(x) φ(succ(x)) x. 1 Ordinary Induction (Ordinary) mathematical induction is a way to prove things about natural numbers. We can write it as a rule: φ(0) x. φ(x) φ(succ(x)) x. φ(x) where φ(x) is a statement involving a number

More information

On Elementary Linear Logic and polynomial time (Extended Abstract)

On Elementary Linear Logic and polynomial time (Extended Abstract) On Elementary Linear Logic and polynomial time (Extended Abstract) Patrick Baillot ENS Lyon, Université de Lyon, LIP (UMR 5668 CNRS-ENSL-INRIA-UCBL) 1 Introduction Linear logic (LL) [Gir87] has been used

More information

Technische Universität München Department of Computer Science. Joint Advanced Students School 2009 Propositional Proof Complexity.

Technische Universität München Department of Computer Science. Joint Advanced Students School 2009 Propositional Proof Complexity. Technische Universität München Department of Computer Science Joint Advanced Students School 2009 Propositional Proof Complexity May 2009 Frege Systems Michael Herrmann Contents Contents ii 1 Introduction

More information

Advanced topic: Space complexity

Advanced topic: Space complexity Advanced topic: Space complexity CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2016 1/28 Review: time complexity We have looked at how long it takes to

More information

Lecture 23: More PSPACE-Complete, Randomized Complexity

Lecture 23: More PSPACE-Complete, Randomized Complexity 6.045 Lecture 23: More PSPACE-Complete, Randomized Complexity 1 Final Exam Information Who: You On What: Everything through PSPACE (today) With What: One sheet (double-sided) of notes are allowed When:

More information

0.1 Random useful facts. 0.2 Language Definition

0.1 Random useful facts. 0.2 Language Definition 0.1 Random useful facts Lemma double neg : P : Prop, {P} + { P} P P. Lemma leq dec : n m, {n m} + {n > m}. Lemma lt dec : n m, {n < m} + {n m}. 0.2 Language Definition Definition var := nat. Definition

More information

Chapter 11: Automated Proof Systems (1)

Chapter 11: Automated Proof Systems (1) Chapter 11: Automated Proof Systems (1) SYSTEM RS OVERVIEW Hilbert style systems are easy to define and admit a simple proof of the Completeness Theorem but they are difficult to use. Automated systems

More information

Theory of Computation

Theory of Computation Theory of Computation Unit 4-6: Turing Machines and Computability Decidability and Encoding Turing Machines Complexity and NP Completeness Syedur Rahman syedurrahman@gmail.com Turing Machines Q The set

More information

Classes of Boolean Functions

Classes of Boolean Functions Classes of Boolean Functions Nader H. Bshouty Eyal Kushilevitz Abstract Here we give classes of Boolean functions that considered in COLT. Classes of Functions Here we introduce the basic classes of functions

More information

Exercise sheet 6: Review Corrections. Turing machines

Exercise sheet 6: Review Corrections. Turing machines Exercise sheet 6: Review Corrections Turing machines 1. Consider a k-head Turing machine having a single tape and k heads; more than one head can be on the same cell at a time. At each move, the TM will

More information

Infinite and Finite Model Theory Part II

Infinite and Finite Model Theory Part II Infinite and Finite Model Theory Part II Anuj Dawar Computer Laboratory University of Cambridge Lent 2002 3/2002 0 Finite Model Theory Finite Model Theory motivated by computational issues; relationship

More information

Induction; Operational Semantics. Fall Software Foundations CIS 500

Induction; Operational Semantics. Fall Software Foundations CIS 500 CIS 500 Software Foundations Fall 2005 Induction; Operational Semantics CIS 500, Induction; Operational Semantics 1 Announcements Review recitations start this week. You may go to any recitation section

More information

Complexity Theory 112. Space Complexity

Complexity Theory 112. Space Complexity Complexity Theory 112 Space Complexity We ve already seen the definition SPACE(f(n)): the languages accepted by a machine which uses O(f(n)) tape cells on inputs of length n. Counting only work space NSPACE(f(n))

More information

Nunchaku: Flexible Model Finding for Higher-Order Logic

Nunchaku: Flexible Model Finding for Higher-Order Logic Nunchaku: Flexible Model Finding for Higher-Order Logic Simon Cruanes, Jasmin Blanchette, Andrew Reynolds Veridis, Inria Nancy https://cedeela.fr/~simon/ April 7th, 2016 1 / 21 Summary Introduction Nunchaku

More information

INAPPROX APPROX PTAS. FPTAS Knapsack P

INAPPROX APPROX PTAS. FPTAS Knapsack P CMPSCI 61: Recall From Last Time Lecture 22 Clique TSP INAPPROX exists P approx alg for no ε < 1 VertexCover MAX SAT APPROX TSP some but not all ε< 1 PTAS all ε < 1 ETSP FPTAS Knapsack P poly in n, 1/ε

More information

SEPARATING NOTIONS OF HIGHER-TYPE POLYNOMIAL-TIME. Robert Irwin Syracuse University Bruce Kapron University of Victoria Jim Royer Syracuse University

SEPARATING NOTIONS OF HIGHER-TYPE POLYNOMIAL-TIME. Robert Irwin Syracuse University Bruce Kapron University of Victoria Jim Royer Syracuse University SEPARATING NOTIONS OF HIGHER-TYPE POLYNOMIAL-TIME Robert Irwin Syracuse University Bruce Kapron University of Victoria Jim Royer Syracuse University FUNCTIONALS & EFFICIENCY Question: Suppose you have

More information

Depending on equations

Depending on equations Depending on equations A proof-relevant framework for unification in dependent type theory Jesper Cockx DistriNet KU Leuven 3 September 2017 Unification for dependent types Unification is used for many

More information

Chapter 1: Constraints. Constraints. Constraints. Constraint Logic Programming. Peter Stuckey 1

Chapter 1: Constraints. Constraints. Constraints. Constraint Logic Programming. Peter Stuckey 1 Chapter 1: Constraints What are they, what do they do and what can I use them for. Constraints What are constraints? Modelling problems Constraint solving ree constraints Other constraint domains Properties

More information

On Additive Polynomials

On Additive Polynomials On Additive Polynomials Zachary Scherr 1 Preliminaries The purpose of this article is to explore the following question: Question 1. Let K be a field. For which f(z) K[z] does f(a+b) = f(a)+f(b) for all

More information

Midterm Exam Types and Programming Languages Frank Pfenning. October 18, 2018

Midterm Exam Types and Programming Languages Frank Pfenning. October 18, 2018 Midterm Exam 15-814 Types and Programming Languages Frank Pfenning October 18, 2018 Name: Andrew ID: Instructions This exam is closed-book, closed-notes. You have 80 minutes to complete the exam. There

More information

A note on monotone real circuits

A note on monotone real circuits A note on monotone real circuits Pavel Hrubeš and Pavel Pudlák March 14, 2017 Abstract We show that if a Boolean function f : {0, 1} n {0, 1} can be computed by a monotone real circuit of size s using

More information

Functional Programming with Coq. Yuxin Deng East China Normal University

Functional Programming with Coq. Yuxin Deng East China Normal University Functional Programming with Coq Yuxin Deng East China Normal University http://basics.sjtu.edu.cn/ yuxin/ September 10, 2017 Functional Programming Y. Deng@ECNU 1 Reading materials 1. The Coq proof assistant.

More information

Recursion and Intro to Coq

Recursion and Intro to Coq L02-1 Recursion and Intro to Coq Armando Solar Lezama Computer Science and Artificial Intelligence Laboratory M.I.T. With content from Arvind and Adam Chlipala. Used with permission. September 21, 2015

More information

5. The Primitive Recursive Function

5. The Primitive Recursive Function 5. The Primitive Recursive Function URM and TM based on universal programming languages. In this and the next section we introduce a third model of computation. It is given as a set of partial functions

More information

Chapter 1: Constraints

Chapter 1: Constraints Chapter 1: Constraints What are they, what do they do and what can I use them for. 1 Constraints What are constraints? Modelling problems Constraint solving Tree constraints Other constraint domains Properties

More information

GATE EC Previous Year Solved Paper

GATE EC Previous Year Solved Paper GATE EC Previous Year Solved Paper GATE 2017 is just round the corner. Engineering Mathematics is a highly scoring portion in GATE. A basic understanding of the concepts and a thorough practice is enough

More information

2.7.1 Foundations of Proof Systems

2.7.1 Foundations of Proof Systems 2.7.1 Foundations of Proof Systems Exam 2017-2018 1 Warming up... Question 1 Give a proof in natural deduction of the following proposition : ( f = (g = h)) = (( f = g) = ( f = h)). Solution. f (g h);

More information

Automatic Deduction for Theories of. Algebraic Data Types. Igor A. Chikanian

Automatic Deduction for Theories of. Algebraic Data Types. Igor A. Chikanian Automatic Deduction for Theories of Algebraic Data Types by Igor A. Chikanian A dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy Department of Computer

More information

GTI. Undecidability. Total Recall 3. Halting. Undecidability. A. Ada, K. Sutner Carnegie Mellon University. Spring 2018

GTI. Undecidability. Total Recall 3. Halting. Undecidability. A. Ada, K. Sutner Carnegie Mellon University. Spring 2018 GTI Undecidability A. Ada, K. Sutner Carnegie Mellon University Spring 2018 1 Cardinality Halting Undecidability Total Recall 3 A set A is finite countably infinite uncountable bijection {0, 1,..., n 1}

More information