PADL 041 Implementing Cut Elimination: A case study of simulating dependent types in Haskell Chiyan Chen Dengping Zhu Hongwei Xi Boston University.

Slides:



Advertisements
Similar presentations
Type-based termination analysis with disjunctive invariants Dimitrios Vytiniotis, MSR Cambridge with Byron Cook (MSR Cambridge) and Ranjit Jhala (UCSD)
Advertisements

Kathleen Fisher cs242 Reading: “Concepts in Programming Languages”, Chapter 6.
Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal.
Proofs and Programs Wei Hu 11/01/2007. Outline  Motivation  Theory  Lambda calculus  Curry-Howard Isomorphism  Dependent types  Practice  Coq Wei.
Cs776 (Prasad)L4Poly1 Polymorphic Type System. cs776 (Prasad)L4Poly2 Goals Allow expression of “for all types T” fun I x = x I : ’a -> ’a Allow expression.
Current Techniques in Language-based Security David Walker COS 597B With slides stolen from: Steve Zdancewic University of Pennsylvania.
Imperative Programming with Dependent Types Hongwei Xi University of Cincinnati.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
Pedigree Types Yu David Liu, Johns Hopkins University / SUNY Binghamton Scott F. Smith, Johns Hopkins University July 7, IWACO’08.
1 Dependent Types for Termination Verification Hongwei Xi University of Cincinnati.
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Object Orientation Chapter SixteenModern Programming Languages, 2nd ed.1.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
CSE-321 Programming Languages Predicative Polymorphic -Calculus POSTECH May 23, 2007 박성우.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Distributed Meta- Programming Rui Shi, Chiyan Chen and Hongwei Xi Boston University.
Type Checking.
Compiler Construction
Modular Type Classes Derek Dreyer Robert Harper Manuel M.T. Chakravarty POPL 2007 Nice, France.
1 Meta-Programming through Typeful Code Representation Chiyan Chen and Hongwei Xi Boston University.
Dependently Typed Pattern Matching Hongwei Xi Boston University.
Facilitating Program Verification with Dependent Types Hongwei Xi Boston University.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Chapter 15 Other Functional Languages. Copyright © 2007 Addison-Wesley. All rights reserved. Functional Languages Scheme and LISP have a simple syntax.
01/17/20031 Guarded Recursive Datatype Constructors Hongwei Xi and Chiyan Chen and Gang Chen Boston University.
Catriel Beeri Pls/Winter 2004/5 type reconstruction 1 Type Reconstruction & Parametric Polymorphism  Introduction  Unification and type reconstruction.
Advanced Programming Handout 9 Qualified Types (SOE Chapter 12)
0 PROGRAMMING IN HASKELL Chapter 6 - Recursive Functions Most of this should be review for you.
10 September Implementing Staged Computation Chiyan Chen and Hongwei Xi Boston University.
0 PROGRAMMING IN HASKELL Chapter 6 - Recursive Functions.
Distributed Meta- Programming (To appear GPCE’06) Rui Shi, Chiyan Chen and Hongwei Xi Boston University.
PADL041 A Typeful Approach to Object- Oriented Programming with Multiple Inheritance Chiyan Chen, Rui Shi, Hongwei Xi Computer Science Dept. Boston.
1 Type Type system for a programming language = –set of types AND – rules that specify how a typed program is allowed to behave Why? –to generate better.
Type Inference: CIS Seminar, 11/3/2009 Type inference: Inside the Type Checker. A presentation by: Daniel Tuck.
Generic Programming with Dependent Types Stephanie Weirich University of Pennsylvania.
Comp 245 Data Structures Software Engineering. What is Software Engineering? Most students obtain the problem and immediately start coding the solution.
Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: “Concepts in Programming Languages”, Revised Chapter 6 - handout.
CSE 425: Data Types II Survey of Common Types I Records –E.g., structs in C++ –If elements are named, a record is projected into its fields (e.g., via.
1 COMP313A Functional Programming (1). 2 Main Differences with Imperative Languages Say more about what is computed as opposed to how Pure functional.
Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages.
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
1 Alex Proctor and Brian Lee for CSCI 431 at UNCA, Fall 2002 ML (Meta Language) a brief introduction Alex Proctor and Brian Lee For CSCI 431 at the University.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
Non-interference in Constructive Authorization Logic Deepak Garg and Frank Pfenning Carnegie Mellon University.
CS6133 Software Specification and Verification
Implementing a Dependently Typed λ -Calculus Ali Assaf Abbie Desrosiers Alexandre Tomberg.
12/9/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from.
Advanced Functional Programming Tim Sheard 1 Lecture 17 Advanced Functional Programming Tim Sheard Oregon Graduate Institute of Science & Technology Lecture:
COMP 412, FALL Type Systems II C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Haskell Introduction CSCE 314 Spring CSCE 314 – Programming Studio Historical Background 1930s: Alonzo Church develops the lambda calculus, a simple.
Higher-Order Encodings in Intensional Type Theory Edwin Westbrook Rice University.
Dr. M. Al-Mulhem Introduction 1 Chapter 6 Type Systems.
Functional Programming
Type Checking and Type Inference
Programming Languages and Compilers (CS 421)
What is a Functional Language?
ML: a quasi-functional language with strong typing
Haskell Chapter 2.
PROGRAMMING IN HASKELL
PROGRAMMING IN HASKELL
A Modality for Safe Resource Sharing and Code Reentrancy
Objective caml Daniel Jackson MIT Lab for Computer Science 6898: Advanced Topics in Software Design March 18, 2002.
Background In his classic 1972 paper on definitional interpreters, John Reynolds introduced two key techniques: Continuation-passing style - Makes.
PROGRAMMING IN HASKELL
Compiler Construction
Compiler Construction
Drew Wyborski Programming Languages
Presentation transcript:

PADL 041 Implementing Cut Elimination: A case study of simulating dependent types in Haskell Chiyan Chen Dengping Zhu Hongwei Xi Boston University

PADL 042 Types Very helpful in programming practice: Document programmers’ intentions. Statically assure program invariants and catch program errors. Two directions of evolution: Assign more refined types to programs: from simple types to dependent types. Type more programs: from simple types to polymorphic types.

PADL 043 Polymorphic Types vs. Dependent Types Polymorphic types are more widely used than dependent types in practice: Facilitated by Hindley-Milner style type inference. Languages with parametric polymorphism: ML, Haskell Languages with dependent types: Dependent ML (DML), Cayenne.

PADL 044 Haskell A versatile language with a variety of advanced type features: Polymorphic recursion. Higher ranked polymorphic types. Existential types. Type classes. … … Pure type inference is no longer supported.

PADL 045 Simulating Dependent Types in Haskell Types for type index expressions. Explicit equality on types for implicit equality on index expressions. Existential datatypes for dependent datatypes. Polymorphic recursion for polymorphism over index expressions.

PADL 046 What Is This Paper About? A large variety of “cute” examples exist in the literature that make use of similar techniques to simulate dependent types However, we have strong doubts about the viability of this practice, and the paper uses an interesting example to provide a critique.

PADL 047 Define Type Equality in Haskell data EQ a b = EQcon (a -> b) (b -> a) fstEQ :: EQ (a1, a2) (b1, b2) -> EQ a1 b1 fstEQ (EQcon to from) = let bot = bot in EQcon (\x -> fst (to (x, bot))) (\x -> fst (from (x, bot))) sndEQ :: EQ (a1, a2) (b1, b2) -> EQ a2 b2 idEQ :: EQ a a symEQ :: EQ a b -> EQ b a transEQ :: EQ a b -> EQ b c -> EQ a c pairEQ :: EQ a1 b1 -> EQ a2 b2 -> EQ (a1, a2) (b1, b2) reflexivity symmetry transitivity constructor introduction constructor elimination

PADL 048 Constructor Elimination Is Not Always Implementable data T a b = T a fstTEQ :: EQ (T a1 a2) (T b1 b2) -> EQ a1 b1 sndTEQ :: EQ (T a1 a2) (T b1 b2) -> EQ a2 b2 Can be implemented Cannot be implemented

PADL 049 Constructor Elimination Is Not Always Implementable data T a b = T (a -> b) fstTEQ :: EQ (T a1 a2) (T b1 b2) -> EQ a1 b1 sndTEQ :: EQ (T a1 a2) (T b1 b2) -> EQ a2 b2 Cannot be implemented Can be implemented

PADL 0410 Use Type Equality toEQ :: EQ a b a -> b toEQ (EQcon to from) = to fromEQ :: EQ a b -> b -> a fromEQ (EQcon to from) = from

PADL 0411 Intuitionistic Propositional Logic (IPL)

PADL 0412 Sequent Calculus for IPL

PADL 0413 Sequent Calculus for IPL

PADL 0414 Cut Elimination

PADL 0415 Type Equality on Constructors

PADL 0416 Explicit Proofs for Type Equalities to (INone pf) = INone (transEQ (transEQ (symEQ pf2) pf) (pairEQ idEQ pf1)) EQ g1 g2IN a1 g1EQ a1 a2EQ g1 (g’, a1)EQ g2 (g’, a1)EQ g2 g1EQ (g’, a1) (g’, a2) EQ g2 (g’, a2) IN a2 g2

PADL 0417 Type Equality on Constructors

PADL 0418 Conclusion Simulate a restricted form of dependent types Type equality for constructor elimination is not always implementable. Practicality Cannot simulate sorts in dependent type systems. It is expected that only identity function can inhabit a type of the form EQ a b (although this cannot be guaranteed by the type system of Haskell). Why bother to define them? Constructing explicit proofs for type equalities in programs is exceedingly tedious. Small changes to a program may result in the need for global reconstruction of proofs for type equalities. EQ Int Bool type EQ a b =  f. f a -> f b (Baars and Swierstra 02)