Nonuniform (Co)datatypes

Size: px
Start display at page:

Download "Nonuniform (Co)datatypes"

Transcription

1 Foundational Nonuniform (Co)datatypes for Higher-Order Logic Jasmin Blanchette Fabian Meier Andrei Popescu Dmitriy Traytel

2 uniform datatype 'a list = Nil Cons 'a ('a list) 1 3 4

3 uniform datatype 'a list = Nil Cons 'a ('a list) 1 3 4

4 uniform datatype 'a list = Nil Cons 'a ('a list) uniform codatatype 'a stream = SCons 'a ('a stream) 1 3 4

5 uniform datatype 'a list = Nil Cons 'a ('a list) uniform codatatype 'a stream = SCons 'a ('a stream) nonuniform datatype 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7))

6 uniform datatype 'a list = Nil Cons 'a ('a list) uniform codatatype 'a stream = SCons 'a ('a stream) nonuniform datatype 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) nonuniform codatatype 'a pstream = PSCons 'a (('a list) pstream) 1 [,3,4] [[5],[6,7,8],[9,10]]

7 What are nonuniform types good for? Mycroft Okasaki pioneering: optimization techniques bootstrapping implicit recursive slowdown theory: data structures finger trees generalized folds advanced (co)iteration Bird Paterson Hinze Matthes Abel Uustalu Abbott Altenkirch Ghani Benton Hur Kennedy McBride Danielsson Hirschowitz Maggesi Naves Spiwack Sozeau 3 practice: proof assistants binders balancing lists finger trees complexity

8 Contribution: enable users of to 1 define nonuniform (co)datatypes define primitively (co)recursive functions 3 prove theorems by nonuniform (co)induction 4

9 Contribution: enable users of to 1 define nonuniform (co)datatypes 'a tm = Var 'a App ('a tm) ('a tm) Lam (('a option) tm) define primitively (co)recursive functions 3 prove theorems by nonuniform (co)induction 4

10 Contribution: enable users of to 1 define nonuniform (co)datatypes 'a tm = Var 'a App ('a tm) ('a tm) Lam (('a option) tm) define primitively (co)recursive functions join :: 'a tm tm => 'a tm join (Var t) = t join (App t u) = App (join t) (join u) join (Lam u) = Lam (join (maptm (λx. case x of None => Var None Some y => maptm Some y) u)) subst σ = join maptm σ 3 prove theorems by nonuniform (co)induction 4

11 Contribution: enable users of to 1 define nonuniform (co)datatypes 'a tm = Var 'a App ('a tm) ('a tm) Lam (('a option) tm) define primitively (co)recursive functions join :: 'a tm tm => 'a tm join (Var t) = t join (App t u) = App (join t) (join u) join (Lam u) = Lam (join (maptm (λx. case x of None => Var None Some y => maptm Some y) u)) subst σ = join maptm σ 3 prove theorems by nonuniform (co)induction subst τ (subst σ s) = subst (subst τ σ) s 4

12 But Coq and Agda Contribution: enable users of to 1 3 define nonuniform (co)datatypes 'a tm = Var 'a App ('a tm) ('a tm) Lam (('a option) tm) have had this built define primitively (co)recursive functions into their logics join :: 'a tm tm => 'a tm join (Var t) = t join (App t u) = App (join t) (join u) join (Lam u) = Lam (join (maptm (λx. case x of None => Var None Some y => maptm Some y) u)) for decades! subst σ = join maptm σ prove theorems by nonuniform (co)induction subst τ (subst σ s) = subst (subst τ σ) s 4

13 But Coq and Agda Contribution: enable users of to 1 define nonuniform (co)datatypes 'a tm = Var 'a App ('a tm) ('a tm) Lam (('a option) tm) foundational have had this built 3 define primitively (co)recursive functions into their logics join :: 'a tm tm => 'a tm join (Var t) = t join (App t u) = App (join t) (join u) join (Lam u) = Lam (join (maptm (λx. case x of None => Var None Some y => maptm Some y) u)) for decades! subst σ = join maptm σ prove theorems by nonuniform (co)induction subst τ (subst σ s) = subst (subst τ σ) s Our approach is new features are reduced to existing features 4

14 Foundations 5

15 Simple Theory of Types Alonzo Church 1940 types: T = ο ι T => T terms: simply typed λ-calculus + few built-in constants 6

16 Higher-Order Logic Mike Gordon 1988 types: T = ο ι T => T 'a (T,,T)κ + nonrecursive type definitions new type T Rep Abs A U existing type terms: simply typed λ-calculus + few built-in constants + Hilbert Choice + nonrecursive constant definitions 7

17 Foundational Uniform (Co)datatypes for Higher-Order Logic Jasmin Blanchette Andrei Popescu Dmitriy Traytel et al. LICS 01 ITP 014 ESOP 015 ICFP 015 ESOP 017 FroCoS 017 8

18 Blanchette, Hölzl, Lochbihler, Panny, Popescu, Traytel ITP 014 9

19 Blanchette, Hölzl, Lochbihler, Panny, Popescu, Traytel ITP 014 9

20 Blanchette, Hölzl, Lochbihler, Panny, Popescu, Traytel ITP 014 9

21 Blanchette, Hölzl, Lochbihler, Panny, Popescu, Traytel ITP 014 9

22 Foundational Nonuniform (Co)datatypes for Higher-Order Logic LICS

23 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7))

24 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem)

25 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem)

26 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7))

27 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6)

28 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6) full 0 (Leaf x) full n l full n r full (n + 1) (Node (l, r))

29 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6) full 0 (Leaf x) full n l full n r full (n + 1) (Node (l, r)) overapproximate the set of all powerlists 'a plist0 = PNil0 PCons0 ('a elem) ('a plist0)

30 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6) full 0 (Leaf x) full n l full n r full (n + 1) (Node (l, r)) overapproximate the set of all powerlists 'a plist0 = PNil0 PCons0 ('a elem) ('a plist0)

31 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6) full 0 (Leaf x) full n l full n r full (n + 1) (Node (l, r)) overapproximate the set of all powerlists 'a plist0 = PNil0 PCons0 ('a elem) ('a plist0) 1 (,3) ((4,5),(6,7)) ((4,5),(6,7)) (,3)

32 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6) full 0 (Leaf x) full n l full n r full (n + 1) (Node (l, r)) overapproximate the set of all powerlists 'a plist0 = PNil0 PCons0 ('a elem) ('a plist0) 1 (,3) ((4,5),(6,7)) ((4,5),(6,7)) (,3) ok n PNil0 full n x ok (n + 1) xs ok n (PCons0 x xs)

33 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6) full 0 (Leaf x) full n l full n r full (n + 1) (Node (l, r)) overapproximate the set of all powerlists 'a plist0 = PNil0 PCons0 ('a elem) ('a plist0) 1 (,3) ((4,5),(6,7)) ((4,5),(6,7)) (,3) ok n PNil0 full n x ok (n + 1) xs ok n (PCons0 x xs) 3 carve out ok powerlists 4 'a plist0 'a plist Rep {xs ok 0 xs} Abs 11

34 'a plist = PNil PCons 'a (('a 'a) plist) 1 (,3) ((4,5),(6,7)) 1 overapproximate the elements of a powerlist 'a elem = Leaf 'a Node ('a elem 'a elem) 1 (,3) ((4,5),(6,7)) ((4,5),6) full 0 (Leaf x) full n l full n r full (n + 1) (Node (l, r)) overapproximate the set of all powerlists 'a plist0 = PNil0 PCons0 ('a elem) ('a plist0) 1 (,3) ((4,5),(6,7)) ((4,5),(6,7)) (,3) ok n PNil0 full n x ok (n + 1) xs ok n (PCons0 x xs) 3 carve out ok powerlists 4 'a plist0 'a plist Rep {xs ok 0 xs} Abs 11 lift constructors PCons x xs = Abs (PCons0 (Leaf x) ( (Rep xs)))

35 General construction supports: multiple recursive occurrences 'a biplist = Nil Cons1 'a (('a list) biplist) Cons 'a (('a 'a) biplist) 1

36 General construction supports: multiple recursive occurrences 'a biplist = Nil Cons1 'a (('a list) biplist) Cons 'a (('a 'a) biplist) multiple type arguments ('a, 'b) tplist = Nil 'b Cons 'a (('a 'a, 'b option) tplist) 1

37 General construction supports: multiple recursive occurrences 'a biplist = Nil Cons1 'a (('a list) biplist) Cons 'a (('a 'a) biplist) multiple type arguments ('a, 'b) tplist = Nil 'b Cons 'a (('a 'a, 'b option) tplist) mutual definitions 'a ptree = Node 'a ('a pforest) 'a pforest = Nil Cons ('a ptree) (('a 'a) pforest) 1

38 General construction supports: multiple recursive occurrences 'a biplist = Nil Cons1 'a (('a list) biplist) mutual definitions Cons 'a (('a 'a) biplist) multiple type arguments ('a, 'b) tplist = Nil 'b Cons 'a (('a 'a, 'b option) tplist) 'a ptree = Node 'a ('a pforest) 'a pforest = Nil Cons ('a ptree) (('a 'a) pforest) codatatypes 'a pstream = PSCons 'a (('a list) pstream) 1

39 General construction supports: multiple recursive occurrences 'a biplist = Nil Cons1 'a (('a list) biplist) mutual definitions Cons 'a (('a 'a) biplist) multiple type arguments ('a, 'b) tplist = Nil 'b Cons 'a (('a 'a, 'b option) tplist) 'a ptree = Node 'a ('a pforest) 'a pforest = Nil Cons ('a ptree) (('a 'a) pforest) codatatypes 'a pstream = PSCons 'a (('a list) pstream) arbitrary bounded natural functors 'a crazy = Crazy 'a ((((('a pstream) fset) crazy) multiset) list) 1

40 Take Home Messages It is tempting to introduce a new hot logic/language for each new feature. But this is not always necessary. The foundational path requires work. But it also saves work elsewhere. (keyword: consistency) 13

41 Foundational Nonuniform (Co)datatypes Bedankt! Higher-Order Logic Vragen? for Jasmin Blanchette Fabian Meier Andrei Popescu Dmitriy Traytel

Foundational Nonuniform (Co)datatypes for Higher-Order Logic

Foundational Nonuniform (Co)datatypes for Higher-Order Logic Foundational Nonuniform (Co)datatypes for Higher-Order Logic Jasmin Christian Blanchette, Fabian Meier, Andrei Popescu, and Dmitriy Traytel Vrije Universiteit Amsterdam, The Netherlands, and Inria & LORIA,

More information

Friends with Benefits

Friends with Benefits Friends with Benefits Jasmin Blanchette, Aymeric Bouzy, Andreas Lochbihler, Andrei Popescu, Dmitriy Traytel To cite this version: Jasmin Blanchette, Aymeric Bouzy, Andreas Lochbihler, Andrei Popescu, Dmitriy

More information

Generalized Iteration and Coiteration for Higher-Order Nested Datatypes

Generalized Iteration and Coiteration for Higher-Order Nested Datatypes Generalized Iteration and Coiteration for Higher-Order Nested Datatypes Mendler rules! Andreas Abel (joint work with Ralph Matthes and Tarmo Uustalu) Slide 1 FoSSaCS 2003 Warsaw, Poland April 8, 2003 Work

More information

Parametricity of Inductive Predicates

Parametricity of Inductive Predicates Proposal for a Master s thesis Parametricity of Inductive Predicates Supervisors: Dr. Andreas Lochbihler, Dr. Dmitriy Traytel Professor: Prof. David Basin Issue date: May 19, 2017 Prerequisites Good skills

More information

Inductive datatypes in HOL. lessons learned in Formal-Logic Engineering

Inductive datatypes in HOL. lessons learned in Formal-Logic Engineering Inductive datatypes in HOL lessons learned in Formal-Logic Engineering Stefan Berghofer and Markus Wenzel Institut für Informatik TU München = Isabelle λ β HOL α 1 Introduction Applications of inductive

More information

Defining Nonprimitively (Co)recursive Functions in Isabelle/HOL

Defining Nonprimitively (Co)recursive Functions in Isabelle/HOL Defining Nonprimitively (Co)recursive Functions in Isabelle/HOL Jasmin Christian Blanchette, Aymeric Bouzy, Andreas Lochbihler, Andrei Popescu, and Dmitriy Traytel 15 August 2018 Abstract This tutorial

More information

From natural numbers to the lambda calculus

From natural numbers to the lambda calculus From natural numbers to the lambda calculus Benedikt Ahrens joint work with Ralph Matthes and Anders Mörtberg Outline 1 About UniMath 2 Signatures and associated syntax Outline 1 About UniMath 2 Signatures

More information

Theorem Proving Principles, Techniques, Applications Recursion

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

More information

Generic Derivation of Induction for Impredicative Encodings in Cedille

Generic Derivation of Induction for Impredicative Encodings in Cedille Generic Derivation of Induction for Impredicative Encodings in Cedille Abstract Denis Firsov Department of Computer Science The University of Iowa Iowa City, IA, USA denis-firsov@uiowa.edu This paper presents

More information

Foundational (Co)datatypes and (Co)recursion for Higher-Order Logic

Foundational (Co)datatypes and (Co)recursion for Higher-Order Logic Foundational (Co)datatypes and (Co)recursion for Higher-Order Logic Julian Biendarra 1, Jasmin Christian Blanchette 2,3( ), Aymeric Bouzy 4, Martin Desharnais 5, Mathias Fleury 3, Johannes Hölzl 6, Ondřej

More information

Generic Programming With Dependent Types: II

Generic Programming With Dependent Types: II Generic Programming With Dependent Types: II Generic Haskell in Agda Stephanie Weirich University of Pennsylvania March 2426, 2010 SSGIP Generic-Haskell style generic programming in Agda Dependently-typed

More information

Friends with Benefits

Friends with Benefits Friends with Benefits Implementing Corecursion in Foundational Proof Assistants Jasmin Christian Blanchette 1,2, Aymeric Bouzy 3, Andreas Lochbihler 4, Andrei Popescu 5,6, and Dmitriy Traytel 4 1 Vrije

More information

Dependent Polymorphism. Makoto Hamana

Dependent Polymorphism. Makoto Hamana 1 Dependent Polymorphism Makoto Hamana Department of Computer Science, Gunma University, Japan http://www.cs.gunma-u.ac.jp/ hamana/ This Talk 2 [I] A semantics for dependently-typed programming [II] A

More information

Friends with Benefits

Friends with Benefits Friends with Benefits Implementing Corecursion in Foundational Proof Assistants Jasmin Christian Blanchette 1,2, Aymeric Bouzy 3, Andreas Lochbihler 4, Andrei Popescu 5,6, and Dmitriy Traytel 4 1 Vrije

More information

arxiv: v1 [cs.pl] 6 Mar 2018

arxiv: v1 [cs.pl] 6 Mar 2018 Efficient Mendler-Style Lambda-Encodings in Cedille Denis Firsov, Richard Blair, and Aaron Stump Department of Computer Science The University of Iowa Iowa City, IA, USA {name-lastname}@uiowa.edu arxiv:1803.02473v1

More information

CSE-321 Programming Languages 2010 Midterm

CSE-321 Programming Languages 2010 Midterm Name: Hemos ID: CSE-321 Programming Languages 2010 Midterm Score Prob 1 Prob 2 Prob 3 Prob 4 Total Max 15 30 35 20 100 1 1 SML Programming [15 pts] Question 1. [5 pts] Give a tail recursive implementation

More information

Autosubst Manual. May 20, 2016

Autosubst Manual. May 20, 2016 Autosubst Manual May 20, 2016 Formalizing syntactic theories with variable binders is not easy. We present Autosubst, a library for the Coq proof assistant to automate this process. Given an inductive

More information

UNIVERSITY OF CALGARY. The Type System for the Message Passing Language MPL. Subashis Chakraborty A THESIS

UNIVERSITY OF CALGARY. The Type System for the Message Passing Language MPL. Subashis Chakraborty A THESIS UNIVERSITY OF CALGARY The Type System for the Message Passing Language MPL by Subashis Chakraborty A THESIS SUBMITTED TO THE FACULTY OF GRADUATE STUDIES IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE

More information

M. Snyder, George Mason University LAMBDA CALCULUS. (untyped)

M. Snyder, George Mason University LAMBDA CALCULUS. (untyped) 1 LAMBDA CALCULUS (untyped) 2 The Untyped Lambda Calculus (λ) Designed by Alonzo Church (1930s) Turing Complete (Turing was his doctoral student!) Models functions, always as 1-input Definition: terms,

More information

Defining (Co)datatypes in Isabelle/HOL

Defining (Co)datatypes in Isabelle/HOL Defining (Co)datatypes in Isabelle/HOL Jasmin Christian Blanchette, Lorenz Panny, Andrei Popescu, and Dmitriy Traytel Institut für Informatik, Technische Universität München 5 December 2013 Abstract This

More information

Mixing Induction and Coinduction

Mixing Induction and Coinduction Draft Mixing Induction and Coinduction Nils Anders Danielsson University of Nottingham nad@cs.nott.ac.uk Thorsten Altenkirch University of Nottingham txa@cs.nott.ac.uk Abstract Purely inductive definitions

More information

Contractive Signatures with Recursive Types, Type Parameters, and Abstract Types

Contractive Signatures with Recursive Types, Type Parameters, and Abstract Types Contractive Signatures with Recursive Types, Type Parameters, and Abstract Types Hyeonseung Im 1, Keiko Nakata 2, and Sungwoo Park 3 1 LRI - Université Paris-Sud 11, Orsay, France 2 Institute of Cybernetics

More information

Universes. Universes for Data. Peter Morris. University of Nottingham. November 12, 2009

Universes. Universes for Data. Peter Morris. University of Nottingham. November 12, 2009 for Data Peter Morris University of Nottingham November 12, 2009 Introduction Outline 1 Introduction What is DTP? Data Types in DTP Schemas for Inductive Families 2 of Data Inductive Types Inductive Families

More information

Vectors are records, too!

Vectors are records, too! Vectors are records, too! Jesper Cockx 1 Gaëtan Gilbert 2 Nicolas Tabareau 2 Matthieu Sozeau 2 1 Gothenburg University, Sweden 2 INRIA, France 21 June 2018 types most popular example 1 data V (A : Set)

More information

A Decision Procedure for (Co)datatypes in SMT Solvers. Andrew Reynolds Jasmin Christian Blanchette IJCAI sister conference track, July 12, 2016

A Decision Procedure for (Co)datatypes in SMT Solvers. Andrew Reynolds Jasmin Christian Blanchette IJCAI sister conference track, July 12, 2016 A Decision Procedure for (Co)datatypes in SMT Solvers Andrew Reynolds Jasmin Christian Blanchette IJCAI sister conference track, July 12, 2016 Satisfiability Modulo Theories (SMT) Solvers Software Verification

More information

Lecture Notes on Data Representation

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

More information

HIGHER-ORDER ABSTRACT SYNTAX IN TYPE THEORY

HIGHER-ORDER ABSTRACT SYNTAX IN TYPE THEORY HIGHER-ORDER ABSTRACT SYNTAX IN TYPE THEORY VENANZIO CAPRETTA AND AMY P. FELTY Abstract. We develop a general tool to formalize and reason about languages expressed using higher-order abstract syntax in

More information

Generic Constructors and Eliminators from Descriptions

Generic Constructors and Eliminators from Descriptions DRAFT Generic Constructors and Eliminators from Descriptions Type Theory as a Dependently Typed Internal DSL Larry Diehl Tim Sheard Portland State University {ldiehl,sheard}@cs.pdx.edu Abstract Dependently

More information

Normalization by hereditary substitutions

Normalization by hereditary substitutions Normalization by hereditary substitutions Chantal Keller INRIA Saclay Île-de-France France keller@lix.polytechnique.fr Thorsten Altenkirch The University of Nottingham United Kingdom txa@cs.nott.ac.uk

More information

Integration of SMT Solvers with ITPs There and Back Again

Integration of SMT Solvers with ITPs There and Back Again Integration of SMT Solvers with ITPs There and Back Again Sascha Böhme and University of Sheffield 7 May 2010 1 2 Features: SMT-LIB vs. Yices Translation Techniques Caveats 3 4 Motivation Motivation System

More information

Coinduction, Corecursion, Copatterns

Coinduction, Corecursion, Copatterns Coinduction, Corecursion, Copatterns Anton Setzer Swansea University, Swansea UK (Joint work with Andreas Abel, Brigitte Pientka, David Thibodeau) Lisbon, 31 January 2013 Anton Setzer Coinduction, Corecursion,

More information

λ calculus is inconsistent

λ calculus is inconsistent Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles

More information

CSE-321 Programming Languages 2012 Midterm

CSE-321 Programming Languages 2012 Midterm Name: Hemos ID: CSE-321 Programming Languages 2012 Midterm Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 14 15 29 20 7 15 100 There are six problems on 24 pages in this exam. The maximum score

More information

Basic Foundations of Isabelle/HOL

Basic Foundations of Isabelle/HOL Basic Foundations of Isabelle/HOL Peter Wullinger May 16th 2007 1 / 29 1 Introduction into Isabelle s HOL Why Type Theory Basic Type Syntax 2 More HOL Typed λ Calculus HOL Rules 3 Example proof 2 / 29

More information

Partiality and Recursion in Interactive Theorem Provers - An Overview

Partiality and Recursion in Interactive Theorem Provers - An Overview Partiality and Recursion in Interactive Theorem Provers - An Overview Ana Bove, Alexander Krauss, Matthieu Sozeau To cite this version: Ana Bove, Alexander Krauss, Matthieu Sozeau. Partiality and Recursion

More information

Representing Cyclic Structures as Nested Datatypes. Makoto Hamana

Representing Cyclic Structures as Nested Datatypes. Makoto Hamana Representing Cyclic Structures as Nested Datatypes Makoto Hamana Department of Computer Science, Gunma University, Japan Joint work with Neil Ghani Tarmo Uustalu Varmo Vene U. Nottingham U. Tallinn U.

More information

Wellfounded Recursion with Copatterns

Wellfounded Recursion with Copatterns Wellfounded Recursion with Copatterns Andreas Abel Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden 25th Nordic Workshop on Programming Theory Tallinn, Estonia

More information

Coq with Classes. Matthieu Sozeau. Journées PPS 2011 September 5th 2011 Trouville, France. Project Team πr 2 INRIA Paris

Coq with Classes. Matthieu Sozeau. Journées PPS 2011 September 5th 2011 Trouville, France. Project Team πr 2 INRIA Paris Coq with Classes Matthieu Sozeau Project Team πr 2 INRIA Paris Journées PPS 2011 September 5th 2011 Trouville, France This talk A quick overview of Coq Elaboration Type Classes Matthieu Sozeau - Coq with

More information

Exercise 1 (2+2+2 points)

Exercise 1 (2+2+2 points) 1 Exercise 1 (2+2+2 points) The following data structure represents binary trees only containing values in the inner nodes: data Tree a = Leaf Node (Tree a) a (Tree a) 1 Consider the tree t of integers

More information

Partiality and Recursion in Interactive Theorem Provers An Overview

Partiality and Recursion in Interactive Theorem Provers An Overview Under consideration for publication in Math. Struct. in Comp. Science Partiality and Recursion in Interactive Theorem Provers An Overview A N A B O V E 1, A L E X A N D E R K R A U S S 2, and M A T T H

More information

Programming with dependent types: passing fad or useful tool?

Programming with dependent types: passing fad or useful tool? Programming with dependent types: passing fad or useful tool? Xavier Leroy INRIA Paris-Rocquencourt IFIP WG 2.8, 2009-06 X. Leroy (INRIA) Dependently-typed programming 2009-06 1 / 22 Dependent types In

More information

Programming Language Concepts: Lecture 19

Programming Language Concepts: Lecture 19 Programming Language Concepts: Lecture 19 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 19, 01 April 2009 Adding types

More information

Isabelle s meta-logic. p.1

Isabelle s meta-logic. p.1 Isabelle s meta-logic p.1 Basic constructs Implication = (==>) For separating premises and conclusion of theorems p.2 Basic constructs Implication = (==>) For separating premises and conclusion of theorems

More information

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine. CMSC 330: Organization of Programming Languages Lambda Calculus Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying or tuples

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying

More information

Representing Cyclic Structures as Nested Datatypes

Representing Cyclic Structures as Nested Datatypes Representing Cyclic Structures as Nested Datatypes Neil Ghani 1, Makoto Hamana 2, Tarmo Uustalu 3, and Varmo Vene 4 1 School of Computer Science and IT, Univ. of Nottingham, Jubilee Campus, Wollaton Road,

More information

Trees. Solution: type TreeF a t = BinF t a t LeafF 1 point for the right kind; 1 point per constructor.

Trees. Solution: type TreeF a t = BinF t a t LeafF 1 point for the right kind; 1 point per constructor. Trees 1. Consider the following data type Tree and consider an example inhabitant tree: data Tree a = Bin (Tree a) a (Tree a) Leaf deriving Show tree :: Tree Int tree = Bin (Bin (Bin Leaf 1 Leaf ) 2 (Bin

More information

Parametricity and Dependent Types

Parametricity and Dependent Types Parametricity and Dependent Types Jean-Philippe Bernardy Patrik Jansson Chalmers University of Technology and University of Gothenburg {bernardy,patrikj}@chalmers.se Ross Paterson City University London

More information

Pretty-Big-Step Semantics

Pretty-Big-Step Semantics Pretty-Big-Step Semantics Arthur Charguéraud Inria Saclay Île-de-France & LRI, Université Paris Sud, CNRS arthur.chargueraud@inria.fr Abstract. In spite of the popularity of small-step semantics, big-step

More information

Running Probabilistic. Programs Backwards

Running Probabilistic. Programs Backwards Running Probabilistic Programs Backwards Neil Toronto * Jay McCarthy David Van Horn * * University of Maryland Vassar College ESOP 2015 2015/04/14 Roadmap Probabilistic inference, and why it s hard 1 Roadmap

More information

Exercise 1 ( = 24 points)

Exercise 1 ( = 24 points) 1 Exercise 1 (4 + 5 + 4 + 6 + 5 = 24 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a =

More information

Normalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types

Normalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types Normalization by Evaluation in the Delay Monad A Case Study for Coinduction via Copatterns and Sized Types Andreas Abel Department of Computer Science and Engineering Chalmers University of Technology

More information

Total Parser Combinators

Total Parser Combinators Total Parser Combinators Nils Anders Danielsson School of Computer Science, University of Nottingham, United Kingdom nad@cs.nott.ac.uk Abstract A monadic parser combinator library which guarantees termination

More information

Toward explicit rewrite rules in the λπ-calculus modulo

Toward explicit rewrite rules in the λπ-calculus modulo Toward explicit rewrite rules in the λπ-calculus modulo Ronan Saillard (Olivier Hermant) Deducteam INRIA MINES ParisTech December 14th, 2013 1 / 29 Motivation Problem Checking, in a trustful way, that

More information

Mendler-style Recursion Schemes for Mixed-Variant Datatypes

Mendler-style Recursion Schemes for Mixed-Variant Datatypes Mendler-style Recursion Schemes for Mixed-Variant Datatypes Ki Yung Ahn Tim Sheard Marcelo P. Fiore kya@cs.pdx.edu sheard@cs.pdx.edu Marcelo.Fiore@cl.cam.ac.uk TYPES 2013 Outline Mendler-style Recursion

More information

Adam Chlipala University of California, Berkeley ICFP 2006

Adam Chlipala University of California, Berkeley ICFP 2006 Modular Development of Certified Program Verifiers with a Proof Assistant Adam Chlipala University of California, Berkeley ICFP 2006 1 Who Watches the Watcher? Program Verifier Might want to ensure: Memory

More information

MLW. Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. March 26, Radboud University Nijmegen

MLW. Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. March 26, Radboud University Nijmegen 1 MLW Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky Radboud University Nijmegen March 26, 2012 inductive types 2 3 inductive types = types consisting of closed terms built from constructors

More information

A Verified Compiler from Isabelle/HOL to CakeML

A Verified Compiler from Isabelle/HOL to CakeML A Verified Compiler from Isabelle/HOL to CakeML Lars Hupel and Tobias Nipkow Technische Universität München lars.hupel@tum.de, nipkow@in.tum.de Abstract. Many theorem provers can generate functional programs

More information

Algebra of Programming using Dependent Types

Algebra of Programming using Dependent Types Algebra of Programming using Dependent Types Shin-Cheng Mu 1, Hsiang-Shang Ko 2, and Patrik Jansson 3 1 Institute of Information Science, Academia Sinica, Taiwan 2 Department of Computer Science and Information

More information

Exercise 1 ( = 18 points)

Exercise 1 ( = 18 points) 1 Exercise 1 (4 + 5 + 4 + 5 = 18 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a = Leaf

More information

On Agda JAIST/AIST WS CVS/AIST Yoshiki Kinoshita, Yoriyuki Yamagata. Agenda

On Agda JAIST/AIST WS CVS/AIST Yoshiki Kinoshita, Yoriyuki Yamagata. Agenda On Agda 2009.3.12 JAIST/AIST WS CVS/AIST Yoshiki Kinoshita, Yoriyuki Yamagata Agenda On Agda Agda as a programming language Agda as a proof system Further information. 2 1 Agenda On Agda Agda as a programming

More information

Pretty-Big-Step Semantics

Pretty-Big-Step Semantics Pretty-Big-Step Semantics Arthur Charguéraud INRIA arthur.chargueraud@inria.fr Abstract. In spite of the popularity of small-step semantics, big-step semantics remain used by many researchers. However,

More information

Exercise 1 ( = 22 points)

Exercise 1 ( = 22 points) 1 Exercise 1 (4 + 3 + 4 + 5 + 6 = 22 points) The following data structure represents polymorphic lists that can contain values of two types in arbitrary order: data DuoList a b = C a (DuoList a b) D b

More information

Inductive Definitions, continued

Inductive Definitions, continued 1 / 27 Inductive Definitions, continued Assia Mahboubi Jan 7th, 2016 2 / 27 Last lecture Introduction to Coq s inductive types: Introduction, elimination and computation rules; Twofold implementation :

More information

Type Theory in Type Theory using Quotient Inductive Types

Type Theory in Type Theory using Quotient Inductive Types Type Theory in Type Theory using Quotient Inductive Types Thorsten Altenkirch University of Nottingham {txa,auk}@cs.nott.ac.uk Ambrus Kaposi Abstract We present an internal formalisation of dependent type

More information

Activity. CSCI 334: Principles of Programming Languages. Lecture 4: Fundamentals II. What is computable? What is computable?

Activity. CSCI 334: Principles of Programming Languages. Lecture 4: Fundamentals II. What is computable? What is computable? Activity CSCI 334: Principles of Programming Languages Lecture 4: Fundamentals II Write a function firsts that, when given a list of cons cells, returns a list of the left element of each cons. ( (a. b)

More information

Programming with (co-)inductive types in Coq

Programming with (co-)inductive types in Coq Programming with (co-)inductive types in Coq Matthieu Sozeau February 3rd 2014 Programming with (co-)inductive types in Coq Matthieu Sozeau February 3rd 2014 Last time 1. Record Types 2. Mathematical Structures

More information

Binders Unbound. Stephanie Weirich Brent Yorgey Tim Sheard. Noah David Yorgey, Sat Sept 17th, 10:24 PM

Binders Unbound. Stephanie Weirich Brent Yorgey Tim Sheard. Noah David Yorgey, Sat Sept 17th, 10:24 PM Binders Unbound Stephanie Weirich Brent Yorgey Tim Sheard Noah David Yorgey, Sat Sept 17th, 10:24 PM From InspiraGon to fv (Var x) = [x] fv (Lam x e) = fv e // [x] fv (App e e ) = fv e ++ fv e data N =

More information

Formalising FinFuns Generating Code for Functions as Data from Isabelle/HOL

Formalising FinFuns Generating Code for Functions as Data from Isabelle/HOL Formalising FinFuns Generating Code for Functions as Data from Isabelle/HOL Andreas Lochbihler Universität Karlsruhe (TH) 17.8.2009, TPHOLs 2009 Motivation I Quickcheck Andreas Lochbihler (Univ. Karlsruhe

More information

A BI-DIRECTIONAL REFINEMENT ALGORITHM FOR THE CALCULUS OF (CO)INDUCTIVE CONSTRUCTIONS

A BI-DIRECTIONAL REFINEMENT ALGORITHM FOR THE CALCULUS OF (CO)INDUCTIVE CONSTRUCTIONS Logical Methods in Computer Science Vol. 8 (1:18) 2012, pp. 1 49 www.lmcs-online.org Submitted May 16, 2011 Published Mar. 2, 2012 A BI-DIRECTIONAL REFINEMENT ALGORITHM FOR THE CALCULUS OF (CO)INDUCTIVE

More information

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ 1 Last time... λ calculus syntax free variables, substitution β reduction α and η conversion

More information

Inductive data types

Inductive data types Inductive data types Assia Mahboubi 9 juin 2010 In this class, we shall present how Coq s type system allows us to define data types using inductive declarations. Generalities Inductive declarations An

More information

ATS: a language to make typeful programming real and fun

ATS: a language to make typeful programming real and fun ATS: a language to make typeful programming real and fun p.1/32 ATS: a language to make typeful programming real and fun Hongwei Xi Boston University Work partly funded by NSF grant CCR-0229480 ATS: a

More information

Defining (Co)datatypes and Primitively (Co)recursive Functions in Isabelle/HOL

Defining (Co)datatypes and Primitively (Co)recursive Functions in Isabelle/HOL Defining (Co)datatypes and Primitively (Co)recursive Functions in Isabelle/HOL Julian Biendarra, Jasmin Christian Blanchette, Martin Desharnais, Lorenz Panny, Andrei Popescu, and Dmitriy Traytel 15 August

More information

λ-calculus Lecture 1 Venanzio Capretta MGS Nottingham

λ-calculus Lecture 1 Venanzio Capretta MGS Nottingham λ-calculus Lecture 1 Venanzio Capretta MGS 2018 - Nottingham Table of contents 1. History of λ-calculus 2. Definition of λ-calculus 3. Data Structures 1 History of λ-calculus Hilbert s Program David Hilbert

More information

Specification, Verification, and Interactive Proof

Specification, Verification, and Interactive Proof Specification, Verification, and Interactive Proof SRI International May 23, 2016 PVS PVS - Prototype Verification System PVS is a verification system combining language expressiveness with automated tools.

More information

Programming Languages Lecture 14: Sum, Product, Recursive Types

Programming Languages Lecture 14: Sum, Product, Recursive Types CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate

More information

Formal Verification of Monad Transformers

Formal Verification of Monad Transformers Formal Verification of Monad Transformers Brian Huffman Institut für Informatik, Technische Universität München huffman@in.tum.de Type constructor classes. In addition to ordinary type classes, Haskell

More information

CSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016

CSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016 CSE-505: Programming Languages Lecture 20.5 Recursive Types Zach Tatlock 2016 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML), but

More information

Calculus of Inductive Constructions

Calculus of Inductive Constructions Calculus of Inductive Constructions Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Calculus of Inductive Constructions

More information

Lecture 14: Recursive Types

Lecture 14: Recursive Types Lecture 14: Recursive Types Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Programming Languages Pratikakis (CSD) Recursive Types CS546, 2018-2019 1 / 11 Motivation

More information

From Types to Sets in Isabelle/HOL

From Types to Sets in Isabelle/HOL From Types to Sets in Isabelle/HOL Extented Abstract Ondřej Kunčar 1 and Andrei Popescu 1,2 1 Fakultät für Informatik, Technische Universität München, Germany 2 Institute of Mathematics Simion Stoilow

More information

Introduction to Co-Induction in Coq

Introduction to Co-Induction in Coq August 2005 Motivation Reason about infinite data-structures, Reason about lazy computation strategies, Reason about infinite processes, abstracting away from dates. Finite state automata, Temporal logic,

More information

CS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 17 Recursive Types Dan Grossman 2012 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML),

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 Summer 2017 1 100 years ago Albert Einstein proposed special theory of relativity in 1905 In the paper On the Electrodynamics of

More information

Safety and Conservativity of Definitions in HOL and Isabelle/HOL

Safety and Conservativity of Definitions in HOL and Isabelle/HOL 1 Safety and Conservativity of Definitions in HOL and Isabelle/HOL ONDŘEJ KUNČAR, Technische Universität München ANDREI POPESCU, Middlesex University London and Institute of Mathematics Simion Stoilow

More information

Polymorphism. Lecture 19 CS 565 4/17/08

Polymorphism. Lecture 19 CS 565 4/17/08 Polymorphism Lecture 19 CS 565 4/17/08 The Limitations of F 1 (simply-typed λ- calculus) In F 1 each function works exactly for one type Example: the identity function id = λx:τ. x : τ τ We need to write

More information

> module Lambda where > import Data.List -- I need some standard list functions

> module Lambda where > import Data.List -- I need some standard list functions Lecture 9 Lambda Calculus We now look at lambda calculus, the theoretical stuff that underlies functional programming. It was introduced by Alonzo Church to formalise two key concepts when dealing with

More information

Inductive Types for Free

Inductive Types for Free Inductive Types for Free Representing Nested Inductive Types using W-types Michael Abbott (U. Leicester) Thorsten Altenkirch (U. Nottingham) Neil Ghani (U. Leicester) Inductive Types for Free p.1/22 Ideology

More information

Interactive Programming in Agda Objects and Graphical User Interfaces

Interactive Programming in Agda Objects and Graphical User Interfaces Under consideration for publication in J. Functional Programming 1 Interactive Programming in Agda Objects and Graphical User Interfaces ANDREAS ABEL Department of Computer Science and Engineering, Gothenburg

More information

CMSC 330: Organization of Programming Languages. Lambda Calculus

CMSC 330: Organization of Programming Languages. Lambda Calculus CMSC 330: Organization of Programming Languages Lambda Calculus 1 100 years ago Albert Einstein proposed special theory of relativity in 1905 In the paper On the Electrodynamics of Moving Bodies 2 Prioritätsstreit,

More information

Theorem-prover based Testing with HOL-TestGen

Theorem-prover based Testing with HOL-TestGen Theorem-prover based Testing with HOL-TestGen Burkhart Wolff 1 1 Université Paris-Sud, LRI, Orsay, France wolff@lri.fr M2R: Test des Systemes Informatiques Orsay, 28 Jan 2010 Outline 1 Revision: Apparent

More information

Haskell Programming with Nested Types: A Principled Approach

Haskell Programming with Nested Types: A Principled Approach Haskell Programming with Nested Types: A Principled Approach Patricia Johann and Neil Ghani ({patricia,ng}@cis.strath.ac.uk) University of Strathclyde, Glasgow, G1 1XH, Scotland Abstract. Initial algebra

More information

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics Overview A normal-order language Strictness Recursion Infinite data structures Direct denotational semantics Transition semantics Lazy (call-by-need) evaluation and its semantics A Normal-Order Language

More information

One Vote for Type Families in Haskell!

One Vote for Type Families in Haskell! Chapter 4 One Vote for Type Families in Haskell! Louis-Julien Guillemette, Stefan Monnier Category: Position Abstract: Generalized Algebraic DataTypes (GADTs) allow programmers to capture important invariants

More information

Bag Equivalence via a Proof-Relevant Membership Relation

Bag Equivalence via a Proof-Relevant Membership Relation Bag Equivalence via a Proof-Relevant Membership Relation Nils Anders Danielsson Chalmers University of Technology and University of Gothenburg Abstract. Two lists are bag equivalent if they are permutations

More information

Modular dependent induction in Coq, Mendler-style. Paolo Torrini

Modular dependent induction in Coq, Mendler-style. Paolo Torrini Modular dependent induction in Coq, Mendler-style Paolo Torrini Dept. of Computer Science, KU Leuven ITP 16, Nancy, 22.08.2016 * The Author left the Institution in April 2016 motivation: cost-effective

More information

Work-in-progress: Verifying the Glasgow Haskell Compiler Core language

Work-in-progress: Verifying the Glasgow Haskell Compiler Core language Work-in-progress: Verifying the Glasgow Haskell Compiler Core language Stephanie Weirich Joachim Breitner, Antal Spector-Zabusky, Yao Li, Christine Rizkallah, John Wiegley May 2018 Verified compilers and

More information

1.3. Conditional expressions To express case distinctions like

1.3. Conditional expressions To express case distinctions like Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a

More information