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

Size: px
Start display at page:

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

Transcription

1 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

2 Introduction Applications of inductive datatypes Data structures (lists, trees,...) Abstract syntax of programming languages (e.g. Bali)... What we want simple user-supplied datatype specification datatype package characteristic properties (induction, recursion,...) Different approaches Axiomatic Desired theorems are introduced as axioms ( danger of introducing inconsistencies) Inherent Concept of inductive definitions is part of the logic (e.g. Coq) Definitional Define datatypes in terms of already existing types, derive characteristic theorems from definition by formal proof 2

3 Definitional packages in Isabelle/HOL constdef axclass coinductive inductive typedef datatype recdef primrec record 3

4 Examples datatype α aexp = If (α bexp) (α aexp) (α aexp) Sum (α aexp) (α aexp) Var α Num nat and α bexp = Less (α aexp) (α aexp) And (α bexp) (α bexp) datatype (α, β)term = Var α App β (((α, β)term)list) datatype (α, β, γ)tree = Atom α Branch β (γ (α, β, γ)tree) datatype α lambda = Var α App (α lambda) (α lambda) Lam (α α lambda) 4

5 Limitations of set-theoretic datatypes Cardinality restrictions (Cantor) datatype t = C (t bool) D ((bool t) bool) E ((t bool) bool) F C, D, E would yield injections of type (t bool) t Dangerous type parameters datatype (α, β, γ)t = C (α set) D (β γ) E (γ list) Caution: α and β are dangerous: α occurs as an argument of non-datatype constructor set β occurs as left argument of (i.e. not strictly positive) datatype δ u = F ((δ u, δ, δ)t) G datatype δ u = F ((δ, δ u, δ)t) G datatype δ u = F ((δ, δ, δ u)t) G 5

6 Admissible datatype specifications datatype (α 1,..., α h )t 1 = C 1 1 τ 1 1,1... τ 1 1,m C 1 k 1 τ 1 k 1,1... τ 1 k 1,m 1 k 1 and (α 1,..., α h )t n = C n 1 τ n 1,1... τ n 1,m n 1... C n kn τ n kn,1... τ n kn,m n kn Types τ j i,i must be admissible. A type τ is admissible iff τ is non-recursive (i.e. does not contain t 1,..., t n ), or τ = σ τ, where σ is non-recursive and τ is admissible, or τ = (α 1,..., α h )t j, where 1 j n, or τ = (τ 1,..., τ h )t, where t is an existing datatype, and τ 1,..., τ h are admissible, and if τ i is recursive, then ith argument of t is not dangerous 6

7 Observation: elements of datatypes are trees A universe for recursive types Leaf :: α (α, β)dtree In0, In1 :: (α, β)dtree (α, β)dtree Pair :: (α, β)dtree (α, β)dtree (α, β)dtree Lim :: (β (α, β)dtree) (α, β)dtree embedding non-recursive occurrences of types modeling distinct constructors modeling constructors with multiple arguments embedding function types (infinitary products) Representing trees in HOL position branching label z} { z } { (α, β)node = ( nat (β + nat)) (α + bool) {z } {z } path node value (α, β)dtree = ((α, β)node)set 7

8 Representing trees in HOL a 1 t = {(f 1, a 1 ), (f 2, a 2 ), (f 3, a 3 )} a 2 a where f1 = 1, 0, 0,... f 2 = 2, 1, 0, 0,... f 3 = 2, 2, 0, 0,... t 1 t 2 Pair t 1 t Pair t 1 t 2 (push (Inr 1) t 1 ) (push (Inr 2) t 2 ) f x 1 f x 2... x 1 x 2 Lim f S {z x. z = push (Inl x) (f x)} 8

9 Constructing an example datatype α list datatype α list = Nil Cons α (α list) Inductive definition of the representing set Nil-rep list-rep ys list-rep Cons-rep y ys list-rep Nil-rep In0 dummy Cons-rep y ys In1 (Pair (Leaf y) ys) HOL type definition Abs-list (Rep-list x) = x Abs-list y list-rep = Rep-list (Abs-list y) = y α list Rep-list x list-rep Rep-list (α, unit)dtree list-rep Constructors Nil Abs-list Nil-rep Cons x xs Abs-list (Cons-rep x (Rep-list xs)) Nil Cons x xs because In0 t In1 t Cons x xs = Cons y ys x = y xs = ys because In1, Pair, Leaf, Abs-list and Rep-list are injective 9

10 lfp F = T {x F x x} Inductive definitions and least fixpoints The Knaster-Tarski theorem If F is monotone then lfp F = F (lfp F ) F y y lfp F y F {x P x} {x P x} lfp F {x P x} (weakind) F (lfp F {x P x}) {x P x} lfp F {x P x} (strongind) list-rep as a least fixpoint F L = {x x = Nil-rep y ys. x = Cons-rep y ys ys L} list-rep = lfp F datatype α list = Nil Cons α (α list) list-rep = F list-rep 10

11 Structural induction α list Induction rule for type α list P Nil x xs. P xs = P (Cons x xs) P xs (list-ind) Induction rule for list-rep Q Nil-rep y ys. Q ys ys list-rep = Q (Cons-rep y ys) ys list-rep = Q ys (list-rep-ind) Derivation of list-ind from list-rep-ind = P (Cons y (Abs-list ys))... = P (Abs-list (Cons-rep y (Rep-list (Abs-list ys)))) y ys. P (Abs-list ys) ys list-rep = P (Abs-list (Cons-rep y ys)) Rep-list xs list-rep = P (Abs-list (Rep-list xs)) P xs 11

12 Primitive recursion α list Recursion combinator list-rec :: β (α α list β β) α list β list-rec f 1 f 2 Nil = f 1 list-rec f 1 f 2 (Cons x xs) = f 2 x xs (list-rec f 1 f 2 xs) Example foldl f a Nil = a foldl f a (Cons x xs) = foldl f (f a x) xs can be defined by foldl λf a xs. list-rec (λf a. a) (λx xs r. (λf a. r f (f a x))) xs f a Inductive definition of function graph list-rel (Nil, f 1 ) list-rel f 1 f 2 (xs, y) list-rel f 1 f 2 (Cons x xs, f 2 x xs y) list-rel f 1 f 2 list-rec f 1 f 2 xs εy. (xs, y) list-rel f 1 f 2 show:!y. (xs, y) list-rel f 1 f 2 (by induction on xs) 12

13 Datatypes with nested recursion (α, β)term Unfolding the datatype specification datatype (α, β)term = Var α App β ((α, β)term-list) and (α, β)term-list = Nil Cons ((α, β)term) ((α, β)term-list) The representing sets term-rep, term-list-rep :: ((α + β, unit)dtree)set) ts term-list-rep In0 (Leaf (Inl a)) term-rep In1 (Pair (Leaf (Inr b)) ts) term-rep In0 dummy term-list-rep t term-rep ts term-list-rep In1 (Pair t ts) term-list-rep Representation function (primitive recursive) Rep-term-list Nil = In0 dummy Rep-term-list (Cons t ts) = In1 (Pair (Rep-term t) (Rep-term-list ts)) Abs-term-list inv Rep-term-list list-rep Abs-list ((α, β)term)list Abs-term-list term-list-rep Rep-list Rep-term-list 13

14 (α, β)term continued Constructors Var a Abs-term (In0 (Leaf (Inl a))) App b ts Abs-term (In1 (Pair (Leaf (Inr b)) (Rep-term-list ts))) Induction a. P (Var a) b ts. Q ts = P (App b ts) Q Nil t ts. P t Q ts = Q (Cons t ts) P t Q ts Primitive recursion term-rec f 1... f 4 (Var a) = f 1 a term-rec f 1... f 4 (App b ts) = f 2 b ts (term-list-rec f 1... f 4 ts) term-list-rec f 1... f 4 Nil = f 3 term-list-rec f 1... f 4 (Cons t ts) = f 4 t ts (term-rec f 1... f 4 t) (term-list-rec f 1... f 4 ts) 14

15 Infinitely branching datatypes (α, β, γ)tree The representing set tree-rep :: ((α + β, γ)dtree)set In0 (Leaf (Inl a)) tree-rep where Funs :: β set (α β)set Funs S {g range g S} g Funs tree-rep In1 (Pair (Leaf (Inr b)) (Lim g)) tree-rep Constructors Atom a Abs-tree (In0 (Leaf (Inl a))) Branch b f Abs-tree (In1 (Pair (Leaf (Inr b)) (Lim (Rep-tree f)))) Structural induction a. P (Atom a) b f. ( x. P (f x)) = P (Branch b f) P t 15

16 Primitive recursion (α, β, γ)tree Recursion combinator tree-rec :: (α δ) (β (γ (α, β, γ)tree) (γ δ) δ) (α, β, γ)tree δ tree-rec f 1 f 2 (Atom a) = f 1 a tree-rec f 1 f 2 (Branch b f) = f 2 b f ((tree-rec f 1 f 2 ) f) Example member c (Atom a) = (a = c) member c (Branch b f) = ( x. member c (f x)) can be defined by member λc. tree-rec (λa. a = c) (λb f f. x. f x) Inductive definition of function graph tree-rel (Atom a, f 1 a) tree-rel f 1 f 2 (Branch b f, f 2 b f f ) tree-rel f 1 f 2 f compose f (tree-rel f 1 f 2 ) where compose :: (α β) (β γ)set (α γ)set compose f R {f x. (f x, f x) R} 16

17 Lessons learned Approaches to theory extension mechanisms definitional The logic of choice? take HOL as is ( simply typed, classical set theory) Layered arrangements of concepts ( deep vs. shallow embedding) extra-logical notion of admissibility extra-logical unfolding System integration Bootstrapping problem: universe dtree depends on types nat, α + β, α β Represent these { types as datatypes } { later! } freeness, primitive recursion, rep-datatype: induction representation function More uniform treatment of types Cooperation of packages: not just logical theory extension, also additional information ( theory data concept) 17

18 Conclusion Achievements Set theoretic construction of mutually recursive nested arbitrarily branching types, together with primitive recursion Knaster-Tarski fixpoint approach Scalable and robust working environment Further work Actual combination of definitional packages Codatatypes (mixing with datatypes?) Non-freely generated types: implement by datatype α t = C α D ((α t)finset) datatype α t = C α D ((α t)list) quotient construction 18

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

λ 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

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

Functional Programming with Isabelle/HOL

Functional Programming with Isabelle/HOL Functional Programming with Isabelle/HOL = Isabelle λ β HOL α Florian Haftmann Technische Universität München January 2009 Overview Viewing Isabelle/HOL as a functional programming language: 1. Isabelle/HOL

More information

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types CS 4110 Programming Languages & Logics Lecture 28 Recursive Types 7 November 2014 Announcements 2 Foster office hours 11-12pm Guest lecture by Fran on Monday Recursive Types 3 Many languages support recursive

More information

Functional Programming and Modeling

Functional Programming and Modeling Chapter 2 2. Functional Programming and Modeling 2.0 2. Functional Programming and Modeling 2.0 Overview of Chapter Functional Programming and Modeling 2. Functional Programming and Modeling 2.1 Overview

More information

Overview. A Compact Introduction to Isabelle/HOL. Tobias Nipkow. System Architecture. Overview of Isabelle/HOL

Overview. A Compact Introduction to Isabelle/HOL. Tobias Nipkow. System Architecture. Overview of Isabelle/HOL Overview A Compact Introduction to Isabelle/HOL Tobias Nipkow TU München 1. Introduction 2. Datatypes 3. Logic 4. Sets p.1 p.2 System Architecture Overview of Isabelle/HOL ProofGeneral Isabelle/HOL Isabelle

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

Partizan Games in Isabelle/HOLZF

Partizan Games in Isabelle/HOLZF Partizan Games in Isabelle/HOLZF Steven Obua Technische Universität München D-85748 Garching, Boltzmannstr. 3, Germany e-mail: obua@in.tum.de, url: http://www4.in.tum.de/~obua Abstract. Partizan Games

More information

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types CS 4110 Programming Languages & Logics Lecture 27 Recursive Types 4 November 2016 Announcements 2 My office hours are at the normal time today but canceled on Monday Guest lecture by Seung Hee Han on Monday

More information

Nonuniform (Co)datatypes

Nonuniform (Co)datatypes Foundational Nonuniform (Co)datatypes for Higher-Order Logic Jasmin Blanchette Fabian Meier Andrei Popescu Dmitriy Traytel uniform datatype 'a list = Nil Cons 'a ('a list) 1 3 4 uniform datatype 'a list

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 CRASH COURSE IN SEMANTICS

A CRASH COURSE IN SEMANTICS LAST TIME Recdef More induction NICTA Advanced Course Well founded orders Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 Well founded recursion Calculations: also/finally {P}... {Q}

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

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

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

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

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

Embedding logics in Dedukti

Embedding logics in Dedukti 1 INRIA, 2 Ecole Polytechnique, 3 ENSIIE/Cedric Embedding logics in Dedukti Ali Assaf 12, Guillaume Burel 3 April 12, 2013 Ali Assaf, Guillaume Burel: Embedding logics in Dedukti, 1 Outline Introduction

More information

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions. CS 6110 S18 Lecture 18 Denotational Semantics 1 What is Denotational Semantics? So far we have looked at operational semantics involving rules for state transitions, definitional semantics involving translations

More information

CSE-321 Programming Languages 2011 Final

CSE-321 Programming Languages 2011 Final Name: Hemos ID: CSE-321 Programming Languages 2011 Final Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 15 15 10 17 18 25 100 There are six problems on 18 pages in this exam, including one extracredit

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

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

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

Preuves Interactives et Applications

Preuves Interactives et Applications Preuves Interactives et Applications Christine Paulin & Burkhart Wolff http://www.lri.fr/ paulin/preuvesinteractives Université Paris-Saclay HOL and its Specification Constructs 10/12/16 B. Wolff - M2

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

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

10 Years of Partiality and General Recursion in Type Theory

10 Years of Partiality and General Recursion in Type Theory 10 Years of Partiality and General Recursion in Type Theory Ana Bove Chalmers University of Technology DTP 10 July 9th 2010 Claims and Disclaims I know that I know nothing Socrates Ana Bove DTP 10 July

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

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

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

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

Functional Programming - 2. Higher Order Functions

Functional Programming - 2. Higher Order Functions Functional Programming - 2 Higher Order Functions Map on a list Apply Reductions: foldr, foldl Lexical scoping with let s Functional-11, CS5314, Sp16 BGRyder 1 Higher Order Functions Functions as 1st class

More information

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1 LAST TIME ON HOL Proof rules for propositional and predicate logic Safe and unsafe rules NICTA Advanced Course Forward Proof Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 The Epsilon

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

Turning inductive into equational specifications

Turning inductive into equational specifications Turning inductive into equational specifications Stefan Berghofer and Lukas Bulwahn and Florian Haftmann Technische Universität München Institut für Informatik, Boltzmannstraße 3, 85748 Garching, Germany

More information

Type-indexed functions in Generic Haskell

Type-indexed functions in Generic Haskell Type-indexed functions in Generic Haskell Johan Jeuring September 15, 2004 Introduction Today I will talk about: a Types of polymorphism. b Type-indexed functions. c Dependencies. Read about b, and c in

More information

a brief introduction to (dependent) type theory

a brief introduction to (dependent) type theory a brief introduction to (dependent) type theory Cory Knapp January 14, 2015 University of Birmingham what is type theory? What is type theory? formal language of terms with types x : A x has type A What

More information

3.7 Denotational Semantics

3.7 Denotational Semantics 3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These

More information

MoreIntro_annotated.v. MoreIntro_annotated.v. Printed by Zach Tatlock. Oct 04, 16 21:55 Page 1/10

MoreIntro_annotated.v. MoreIntro_annotated.v. Printed by Zach Tatlock. Oct 04, 16 21:55 Page 1/10 Oct 04, 16 21:55 Page 1/10 * Lecture 02 Infer some type arguments automatically. Set Implicit Arguments. Note that the type constructor for functions (arrow " >") associates to the right: A > B > C = A

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

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

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

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

We defined congruence rules that determine the order of evaluation, using the following evaluation

We defined congruence rules that determine the order of evaluation, using the following evaluation CS 4110 Programming Languages and Logics Lectures #21: Advanced Types 1 Overview In this lecture we will extend the simply-typed λ-calculus with several features we saw earlier in the course, including

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

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

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

General Bindings and Alpha-Equivalence in Nominal Isabelle

General Bindings and Alpha-Equivalence in Nominal Isabelle General Bindings and Alpha-Equivalence in Nominal Isabelle Christian Urban and Cezary Kaliszyk TU Munich, Germany Abstract. Nominal Isabelle is a definitional extension of the Isabelle/HOL theorem prover.

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

CIS 500 Software Foundations Midterm I

CIS 500 Software Foundations Midterm I CIS 500 Software Foundations Midterm I October 11, 2006 Name: Student ID: Email: Status: Section: registered for the course not registered: sitting in to improve a previous grade not registered: just taking

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

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

Lambda Calculus and Extensions as Foundation of Functional Programming

Lambda Calculus and Extensions as Foundation of Functional Programming Lambda Calculus and Extensions as Foundation of Functional Programming David Sabel and Manfred Schmidt-Schauß 29. September 2015 Lehrerbildungsforum Informatik Last update: 30. September 2015 Overview

More information

Ornaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium

Ornaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium Ornaments in ML Thomas Williams, Didier Rémy Inria - Gallium April 18, 2017 1 Motivation Two very similar functions let rec add m n = match m with Z n S m S (add m n) let rec append ml nl = match ml with

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

Semantics and Concurrence Module on Semantic of Programming Languages

Semantics and Concurrence Module on Semantic of Programming Languages Semantics and Concurrence Module on Semantic of Programming Languages Pietro Di Gianantonio Università di Udine Presentation Module of 6 credits (48 hours), Semantics of programming languages Describe

More information

MoreIntro.v. MoreIntro.v. Printed by Zach Tatlock. Oct 07, 16 18:11 Page 1/10. Oct 07, 16 18:11 Page 2/10. Monday October 10, 2016 lec02/moreintro.

MoreIntro.v. MoreIntro.v. Printed by Zach Tatlock. Oct 07, 16 18:11 Page 1/10. Oct 07, 16 18:11 Page 2/10. Monday October 10, 2016 lec02/moreintro. Oct 07, 16 18:11 Page 1/10 * Lecture 02 Set Implicit Arguments. Inductive list (A: Type) : Type := nil : list A cons : A > list A > list A. Fixpoint length (A: Type) (l: list A) : nat := nil _ => O cons

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

The Typed λ Calculus and Type Inferencing in ML

The Typed λ Calculus and Type Inferencing in ML Notes on Types S. Arun-Kumar Department of Computer Science and Engineering Indian Institute of Technology New Delhi, 110016 email: sak@cse.iitd.ernet.in April 14, 2002 2 Chapter 1 The Typed λ Calculus

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

Programming and Proving in

Programming and Proving in Programming and Proving in = λ β Isabelle HOL α Tobias Nipkow Fakultät für Informatik Technische Universität München 1 Notation Implication associates to the right: A = B = C means A = (B = C) Similarly

More information

Higher-Order Logic. Specification and Verification with Higher-Order Logic

Higher-Order Logic. Specification and Verification with Higher-Order Logic Higher-Order Logic Specification and Verification with Higher-Order Logic Arnd Poetzsch-Heffter (Slides by Jens Brandt) Software Technology Group Fachbereich Informatik Technische Universität Kaiserslautern

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

Fall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam.

Fall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam. Programming Languages Fall 2013 Midterm Exam 10/22/13 Time Limit: 100 Minutes Name (Print): Graduate Center I.D. This is a closed-book, closed-notes exam. Various definitions are provided in the exam.

More information

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic

More information

Pattern Matching and Abstract Data Types

Pattern Matching and Abstract Data Types Pattern Matching and Abstract Data Types Tom Murphy VII 3 Dec 2002 0-0 Outline Problem Setup Views ( Views: A Way For Pattern Matching To Cohabit With Data Abstraction, Wadler, 1986) Active Patterns (

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

Programming and Proving in Isabelle/HOL

Programming and Proving in Isabelle/HOL Programming and Proving in Isabelle/HOL Tobias Nipkow Fakultät für Informatik Technische Universität München 2013 MOD Summer School 1 Notation Implication associates to the right: A = B = C means A = (B

More information

Semantics and Concurrence Module on Semantic of Programming Languages

Semantics and Concurrence Module on Semantic of Programming Languages Semantics and Concurrence Module on Semantic of Programming Languages Pietro Di Gianantonio Università di Udine Presentation Module of 6 credits (48 hours), Semantics of programming languages Describe

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

A Simple Supercompiler Formally Verified in Coq

A Simple Supercompiler Formally Verified in Coq A Simple Supercompiler Formally Verified in Coq IGE+XAO Balkan 4 July 2010 / META 2010 Outline 1 Introduction 2 3 Test Generation, Extensional Equivalence More Realistic Language Use Information Propagation

More information

GENERAL BINDINGS AND ALPHA-EQUIVALENCE IN NOMINAL ISABELLE

GENERAL BINDINGS AND ALPHA-EQUIVALENCE IN NOMINAL ISABELLE GENERAL BINDINGS AND ALPHA-EQUIVALENCE IN NOMINAL ISABELLE Technical University of Munich, Germany e-mail address: urbanc@in.tum.de University of Tsukuba, Japan e-mail address: kaliszyk@cs.tsukuba.ac.jp

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

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions 1 CSCE 314: Programming Languages Dr. Flemming Andersen Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions

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

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

Mechanising a type-safe model of multithreaded Java with a verified compiler

Mechanising a type-safe model of multithreaded Java with a verified compiler Mechanising a type-safe model of multithreaded Java with a verified compiler Andreas Lochbihler Digital Asset (Switzerland) GmbH Andreas Lochbihler 2 = Isabelle λ β HOL α Andreas Lochbihler 3 Timeline

More information

Programs and Proofs in Isabelle/HOL

Programs and Proofs in Isabelle/HOL Programs and Proofs in Isabelle/HOL Makarius Wenzel http://sketis.net March 2016 = Isabelle λ β α Introduction What is Isabelle? Hanabusa Itcho : Blind monks examining an elephant Introduction 2 History:

More information

Lambda calculus. Chapter 2

Lambda calculus. Chapter 2 Chapter 2 Lambda calculus The lambda calculus serves as the basis of most functional programming languages. More accurately, we might say that functional programming languages are based on the lambda calculi

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

Programming Languages Lecture 15: Recursive Types & Subtyping

Programming Languages Lecture 15: Recursive Types & Subtyping CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)

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

Nominal Techniques in Coq

Nominal Techniques in Coq University of Copenhagen, DIKU HIPERFIT Workshop November 16, 2017 Names There are only two hard things in Computer Science: cache invalidation and naming things. Phil Karlton Names There are only two

More information

Shell CSCE 314 TAMU. Haskell Functions

Shell CSCE 314 TAMU. Haskell Functions 1 CSCE 314: Programming Languages Dr. Dylan Shell Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions can

More information

Concrete Semantics. A Proof Assistant Approach. Tobias Nipkow Fakultät für Informatik Technische Universität München

Concrete Semantics. A Proof Assistant Approach. Tobias Nipkow Fakultät für Informatik Technische Universität München Concrete Semantics A Proof Assistant Approach Tobias Nipkow Fakultät für Informatik Technische Universität München 2014-1-26 1 Part I Isabelle 2 Chapter 2 Programming and Proving 3 1 Overview of Isabelle/HOL

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

A Pronominal Account of Binding and Computation

A Pronominal Account of Binding and Computation A Pronominal Account of Binding and Computation Robert Harper Carnegie Mellon University TAASN March 2009 Thanks Thanks to Daniel R. Licata and Noam Zeilberger, my collaborators on this work. Thanks to

More information

Combining Proofs and Programs in a Dependently Typed Language. Certification of High-level and Low-level Programs

Combining Proofs and Programs in a Dependently Typed Language. Certification of High-level and Low-level Programs Combining Proofs and Programs in a Dependently Typed Language Stephanie Weirich University of Pennsylvania July 7, 2014 Certification of High-level and Low-level Programs Zombie A functional programming

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

Modelling General Recursion in Type Theory

Modelling General Recursion in Type Theory Modelling General Recursion in Type Theory Ana Bove Venanzio Capretta July 8, 2002 Abstract Constructive type theory is a very expressive programming language. However, general recursive algorithms have

More information

Less naive type theory

Less naive type theory Institute of Informatics Warsaw University 26 May 2007 Plan 1 Syntax of lambda calculus Why typed lambda calculi? 2 3 Syntax of lambda calculus Why typed lambda calculi? origins in 1930s (Church, Curry)

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

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type

More information

Types Summer School Gothenburg Sweden August Dogma oftype Theory. Everything has a type

Types Summer School Gothenburg Sweden August Dogma oftype Theory. Everything has a type Types Summer School Gothenburg Sweden August 2005 Formalising Mathematics in Type Theory Herman Geuvers Radboud University Nijmegen, NL Dogma oftype Theory Everything has a type M:A Types are a bit like

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

Executing Higher Order Logic

Executing Higher Order Logic Executing Higher Order Logic Stefan Berghofer and Tobias Nipkow Technische Universität München Institut für Informatik, Arcisstraße 21, 80290 München, Germany http://www.in.tum.de/~berghofe/ http://www.in.tum.de/~nipkow/

More information

What s in Main. Tobias Nipkow. December 5, Abstract

What s in Main. Tobias Nipkow. December 5, Abstract What s in Main Tobias Nipkow December 5, 2013 Abstract This document lists the main types, functions and syntax provided by theory Main. It is meant as a quick overview of what is available. For infix

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