Extensional Universal Types for Call-by-Value

Σχετικά έγγραφα
The Simply Typed Lambda Calculus

C.S. 430 Assignment 6, Sample Solutions

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

Finite Field Problems: Solutions

ST5224: Advanced Statistical Theory II

Fractional Colorings and Zykov Products of graphs

Other Test Constructions: Likelihood Ratio & Bayes Tests

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

EE512: Error Control Coding

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Example Sheet 3 Solutions

Lecture 2. Soundness and completeness of propositional logic

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

Every set of first-order formulas is equivalent to an independent set

2 Composition. Invertible Mappings

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

4.6 Autoregressive Moving Average Model ARMA(1,1)

Sequent Calculi for the Modal µ-calculus over S5. Luca Alberucci, University of Berne. Logic Colloquium Berne, July 4th 2008

Reminders: linear functions

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

A Lambda Model Characterizing Computational Behaviours of Terms

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

derivation of the Laplacian from rectangular to spherical coordinates

Practice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1

A Note on Intuitionistic Fuzzy. Equivalence Relation

About these lecture notes. Simply Typed λ-calculus. Types

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

Tridiagonal matrices. Gérard MEURANT. October, 2008

Homework 8 Model Solution Section

Statistical Inference I Locally most powerful tests

Homomorphism in Intuitionistic Fuzzy Automata

Matrices and Determinants

Uniform Convergence of Fourier Series Michael Taylor

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

w o = R 1 p. (1) R = p =. = 1

2. Let H 1 and H 2 be Hilbert spaces and let T : H 1 H 2 be a bounded linear operator. Prove that [T (H 1 )] = N (T ). (6p)

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

Concrete Mathematics Exercises from 30 September 2016

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Second Order Partial Differential Equations

Iterated trilinear fourier integrals with arbitrary symbols

Spherical Coordinates

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

5. Choice under Uncertainty

Distances in Sierpiński Triangle Graphs

Bounding Nonsplitting Enumeration Degrees

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Homework 3 Solutions

Second Order RLC Filters

Lecture 34 Bootstrap confidence intervals

SOLUTIONS TO MATH38181 EXTREME VALUES AND FINANCIAL RISK EXAM

Lecture 15 - Root System Axiomatics

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

ORDINAL ARITHMETIC JULIAN J. SCHLÖDER

Partial Trace and Partial Transpose

Srednicki Chapter 55

Chap. 6 Pushdown Automata

Formal Semantics. 1 Type Logic

Solution Series 9. i=1 x i and i=1 x i.

Notes on the Open Economy

SCITECH Volume 13, Issue 2 RESEARCH ORGANISATION Published online: March 29, 2018

Affine Weyl Groups. Gabriele Nebe. Summerschool GRK 1632, September Lehrstuhl D für Mathematik

Galatia SIL Keyboard Information

TMA4115 Matematikk 3

Abstract Storage Devices

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

Congruence Classes of Invertible Matrices of Order 3 over F 2

Strain gauge and rosettes

Introduction to Type Theory February 2008 Alpha Lernet Summer School Piriapolis, Uruguay. Herman Geuvers Nijmegen & Eindhoven, NL

Inverse trigonometric functions & General Solution of Trigonometric Equations

Durbin-Levinson recursive method

On the Galois Group of Linear Difference-Differential Equations

SOLUTIONS TO MATH38181 EXTREME VALUES AND FINANCIAL RISK EXAM

ΠΤΥΧΙΑΚΗ ΕΡΓΑΣΙΑ ΒΑΛΕΝΤΙΝΑ ΠΑΠΑΔΟΠΟΥΛΟΥ Α.Μ.: 09/061. Υπεύθυνος Καθηγητής: Σάββας Μακρίδης

From the finite to the transfinite: Λµ-terms and streams

Cyclic or elementary abelian Covers of K 4

λρ-calculus 1. each λ-variable is a λρ-term, called an atom or atomic term; 2. if M and N are λρ-term then (MN) is a λρ-term called an application;

If we restrict the domain of y = sin x to [ π, π ], the restrict function. y = sin x, π 2 x π 2

Generating Set of the Complete Semigroups of Binary Relations

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

Parametrized Surfaces

D Alembert s Solution to the Wave Equation

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

Commutative Monoids in Intuitionistic Fuzzy Sets

If we restrict the domain of y = sin x to [ π 2, π 2

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Derivation of Optical-Bloch Equations

Section 8.3 Trigonometric Equations

Dr. D. Dinev, Department of Structural Mechanics, UACEG

ΑΚΑ ΗΜΙΑ ΕΜΠΟΡΙΚΟΥ ΝΑΥΤΙΚΟΥ ΜΑΚΕ ΟΝΙΑΣ ΣΧΟΛΗ ΜΗΧΑΝΙΚΩΝ ΠΤΥΧΙΑΚΗ ΕΡΓΑΣΙΑ

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

Forced Pendulum Numerical approach

Lecture 13 - Root Space Decomposition II

CRASH COURSE IN PRECALCULUS

MATH423 String Theory Solutions 4. = 0 τ = f(s). (1) dτ ds = dxµ dτ f (s) (2) dτ 2 [f (s)] 2 + dxµ. dτ f (s) (3)

Areas and Lengths in Polar Coordinates

Mock Exam 7. 1 Hong Kong Educational Publishing Company. Section A 1. Reference: HKDSE Math M Q2 (a) (1 + kx) n 1M + 1A = (1) =

Transcript:

Extensional Universal Types for Call-by-Value Kazuyuki Asada RIMS 1 July 2008

Overview (2/32) We give: 1. the λ c 2 η -calculus (and λ c 2-calculus): a second-order polymorphic call-by-value calculus with extensional universal types 2. λ c 2 η -models: categorical semantics for λ c 2 η -calculus monadic λ c 2 η -models: categorical semantics for λ c 2 η -calculus with the focus on monadic metalanguages like Haskell 3. relevant parametric models: domain theoretic concrete models of monadic λ c 2 η -models with a reasonable class of monads including: Lifting, Exception, Global State, Input/Output, and List monad

Introduction

Introduction SystemF (4/32) Types σ ::= α b σ σ α.σ ( b: base types ) Terms M ::= x c σ λx σ.m MM Λα.M Mσ (c σ : constans) Typing Rules: All the rules in the λ-calculus, and: Ξ, α Γ M : σ Ξ Γ Λα.M : α.σ (α FTV (Γ)) Ξ Γ M : α.σ Ξ Γ Mτ : σ [τ/α] Axioms: All the axioms in the λ-calculus, and: (Λα.M) σ = M [σ/α] Λα.Mα = M (α FTV (M)) (Girard 1972, Reynolds 1974)

Introduction Polymorphic Encodings (5/32) 1 := α.α α σ τ := α. (σ τ α) α 0 := α.α σ + τ := α. (σ α) (τ α) α α.sigma := β. ( α. (σ β)) β µγ.σ := γ. ((σ γ) γ) νγ.σ := γ. ((γ σ) γ) (α FTV (σ, τ)) (α FTV (σ, τ)) (β α, β FTV (σ))

Introduction Parametricity (6/32) relational parametricity is: (Reynolds 1983) (binary) relations R τ τ between types relational interpretation σ [ R/ α ] of types σ with relations R the parametricity schema: β. u : ( α.σ [ α, β ]). τ. τ. R τ τ. ( uτ ( σ [ R/α, eqβ / β ]) uτ ) linear parametricity is: (Plotkin 1993) relations R τ τ are restricted to admissible relations admissible relations are intuitively subalgebras of product of the two types

Introduction Example of Parametric Reasoning For any u : α.α α, Λα.λa α.a = u α. (λa α.a = uα) α. a: α. (a = uαa) (type η-equality) (η-equality) (7/32) For α and a: α, let Then by parametricity, R := λx α.a α α uα (R R) uα Clearly, Hence ara (uαa) R (uαa) a = uαa

Introduction λ c -calculus and η-equality (8/32) Types Terms Values Evaluation Contexts σ M V E ::= b σ σ σ σ ::= x c σ λx σ.m MM M, M π 1 M π 2 M ::= x c σ λx σ.m V, V π 1 V π 2 V ::= [ ] EM VE E, M V, E π 1 E π 2 E (λx σ.m) V = M [V/x] λx σ.v x = V (x FV (V)) V = (V : ) π i V 1, V 2 = V i (i = 1, 2) π 1 V, π 2 V = V (λm σ.e [m]) M = E [M] (m FV (E)) λ c 2 η -calculus: (Moggi 1988) (Λα.M) σ = M [σ/α] Λα.Mα = M (α FTV (M))

Calculi

Calculi 1 λ c -calculus Types Terms Values Evaluation Contexts x:σ Γ Γ x : σ σ (10/32) M ::= x c σ λx σ.m MM M, M π 1 M π 2 M V E ::= b σ σ σ σ ::= x c σ λx σ.m V, V π 1 V π 2 V Γ, x:σ M : τ Γ c σ : σ Γ λx σ.m : σ τ Γ M : σ Γ N : τ Γ : Γ M, N : σ τ ::= [ ] EM VE E, M V, E π 1 E π 2 E Γ M : σ τ Γ N : σ Γ MN : τ Γ M : σ τ Γ π 2 M : τ Γ M : σ τ Γ π 1 M : σ (λx σ.m) V = M [V/x] λx σ.v x = V (x FV (V)) V = (V : ) π i V 1, V 2 = V i (i = 1, 2) π 1 V, π 2 V = V (λm σ.e [m]) M = E [M] (m FV (E)) (Moggi 1988)

Calculi 1 λ c 2-calculus (11/32) Types σ ::=... α α.σ Values V ::=... Λα.M Terms M ::=... Λα.M Mσ Evaluation Contexts E ::=... Eσ Typing Rules: All the rules in the λ c -calculus, and: Ξ, α Γ M : σ Ξ Γ Λα.M : α.σ (α FTV (Γ)) Ξ Γ M : α.σ Ξ Γ Mτ : σ [τ/α] Axioms: All the axioms in the λ c -calculus (with E extended as above), and: (Λα.M) σ = M [σ/α] Λα.Vα = V (α FTV (V))

Calculi 1 λ c 2 η -calculus (12/32) Types σ ::=... α α.σ Values V ::=... Λα.V Vσ Terms M ::=... Λα.M Mσ Evaluation Contexts E ::=... Eσ Typing Rules: the same as those in the λ c 2-calculus. Axioms: All the axioms in the λ c -calculus (with E extended as above), and: (Λα.M) σ = M [σ/α] Λα.Mα = M (α FTV (M))

Calculi 1 λ c 2-calculus vs. λ c 2 η -calculus λ c 2-calculus: (13/32) Types σ ::=... α α.σ Values V ::=... Λα.M Terms M ::=... Λα.M Mσ Evaluation Contexts E ::=... Eσ (Λα.M) σ = M [σ/α] Λα.Vα = V (α FTV (V)) λ c 2 η -calculus: Types σ ::=... α α.σ Values V ::=... Λα.V Vσ Terms M ::=... Λα.M Mσ Evaluation Contexts E ::=... Eσ (Λα.M) σ = M [σ/α] Λα.Mα = M (α FTV (M)) (cf. ML)

Calculi 1 The Class of Monads (14/32) T ::= γ 1 T T T C νγ.t C T T µγ.t Lifting: Exception: Global State: Input: Output: List: ( ) 1 ( ) E (( ) S ) S µβ. ( ) β U µβ. ( ) (U β) µβ.1 ( ) β

1 Categorical Semantics

Categorical Semantics 1 Polymorphic λ c -models (16/32) Definition 1. A polymorphic λ c -model consists of (i) a cartesian polymorphic fibration, i.e. a fibration p : E B which has products in the base category, generic object Ω and fibred products, (ii) a fibred strong monad T on p satisfying the equalizing requirement fiberwise, and (iii) fibred Kleisli exponentials: E I ( ) X u E I F I (E T ) I (X ( )) u T ( ) u E X F J J E J (E T ) J (u X ( ))

Categorical Semantics 1 λ c 2-model Definition 2. Let p be a polymorphic λ c -model, F Ω be the change-of-base of the Kleisli embedding F along ( ) Ω, and π ( ),Ω be the weakening fibred functor. (17/32) Kleisli simple Ω-products is a fibred right adjoint functor to the composite of F Ω and π ( ),Ω, and a λ c 2-model is a polymorphic λ c -model p which has Kleisli simple Ω-products. π ( ),Ω E p E (Ω) p Ω B F Ω p Ω T E (Ω) T ( ) Ω p E B F p T E T E I π I,Ω u E I Ω F I Ω (E T ) I Ω I (u Ω) T π J,Ω F E J J Ω E J Ω (E T ) J Ω J

Categorical Semantics 1 λ c 2 η -models and Monadic λ c 2 η -models (18/32) Definition 3. A λ c 2 η -model is a polymorphic λ c -model p whose Kleisli fibration p T has simple Ω-products. Definition 4. A monadic λ c 2 η -model is a polymorphic λ c -model such that p and p T has simple Ω-products and the Kleisli embedding F : p p T preserves them. T p p T effect value (identity on objects) F U computation

Categorical Semantics 1 A Characterization of Monadic λ c 2 η -model (19/32) Lemma 5. Let p be a polymorphic λ c -model s.t. p has simple Ω-products. p is a monadic λ c 2 η -model, (i.e., p T has simple Ω-products and F : p p T preserves simple Ω-products,) if and only if the underlying fibred endofunctor of the monad T preserves simple Ω-products. For a λ2-fibration and a fibred strong monad on it satisfying the equalizing requirement, if the underlying endofunctor preserves simple Ω-products, then they form a monadic λ c 2 η -model.

2 Concrete Models

Concrete Models 2 Classes of Monads for Monadic λ c 2 η -models (21/32) T ::= γ 1 T T T C νγ.t (1) T ::= γ 1 T T T C νγ.t C (2) T ::= γ 1 T T T C νγ.t C T T µγ.t (3) (1) universality (2) universality + parametricity (3) universality + parametricity + additional terms (fixed-point operator)

Concrete Models 2 Products and Powers Lemma 6. Let B be a cartesian category, and K be any object of B. (22/32) (1) The subcategory of Fib B consisting of all fibrations having simple K-products, and all fibred functors preserving simple K-products, is cartesian subcategory. (2) Let p be a fibration having simple K-products and fibred finite products. Then the fibred functors : p p p, and 1 : 1 p preserve simple K-products. (3) Moreover assume that p is a fibred CCC. Then for any X over 1 in p, the power fibred functor X ( ) : p p preserves simple K-products.

Concrete Models 2 Final Coalgebras (23/32) Definition 7. For a fibred functor F : q p p, if F has pointwise final coalgebras and the reindexings preserve them, then we can define the final coalgebras fibred functor fcf : q p. Lemma 8. Let B be a cartesian category, K be an object of B, p, q be fibrations having simple K-products, and F : q p p be a fibred functor such that its transposition λf : q p p has final coalgebras as above. Then, if F preserves simple K-products, the fibred functor fc (λf) : q p also preserves simple K-products. (Typically q = p n.)

Concrete Models 2 Constants (24/32) For a λ2-fibration p and any object X over 1, the constant fibred functor X : 1 p preserves simple Ω-products if we assume parametricity. This is possible by all already known types of parametricity including relational parametricity, linear parametricity, and focal parametricity. At this point, we can construct global state monads (( ) S ) S and output monads µβ. ( ) + (U β) ( ) (µβ.1 + (U β)).

Concrete Models 2 Coproducts (25/32) λu: ( α. (σ + τ)). case (u1) of in 0 a in 0 (Λα.case (uα) of in 0 a a in 1 b this case nothing ) in 1 b in 1 (Λα.case (uα) of in 0 a this case nothing in 1 b b ) : α. (σ + τ) α.σ + α.τ We use for this case nothing.

Concrete Models 2 Initial Algebras (26/32) let f : (( α.µβ.1 + σ β) (µβ.1 + α.σ β)) = λu: ( α.µβ.1 + σ β).case (u1) of Nil Nil Cons(a, as ) Cons( Λα.case (uα) of Nil this case nothing Cons(a, as) a, f (Λα.case (uα) of Nil this case nothing Cons(a, as) as ) ) We use a fixed-point operator.

Concrete Models 2 Linear Parametric Models (27/32) p := l! L l! U F T T p p T U T l :a PILL Y model (Birkedal et al. 2008), i.e., λ2-version of linear categories which can also model fixed-point operators Assumption. L preserves simple Ω-products.

Concrete Models 2 Relevant Parametricity (28/32) Contraction term formation rule: and, moreover Ξ Γ;, x : σ, y : σ M : τ Ξ Γ;, x : σ M [ x/y ] : τ ρ adm σ τ M : σ τ σ τ ( M 1 ρ = ) (x : σ, y : τ ).ρ (π 1 M x, y, π 2 M x, y ) adm σ τ

Concrete Models 2 Separated Sums (29/32) Proposition 9. For a model satisfying the assumption thus far, its separated sums preserve simple Ω-products. p 2 L 2 l 2 p U l +

Concrete Models 3 Linearly Initial Algebras (30/32) Proposition 10. For a model l satisfying the assumption thus far, let q be a fibration which has the same base category and generic object Ω as those of l and p, and has simple Ω-products. Then for a fibred functor F : q p p preserving simple Ω-products, if the transposition λf has initial algebras and also final coalgebras, then the linearly initial algebras fibred functor U ia (λf ) : q p also preserves simple Ω-products. q p q U q l q F p L l F p U l ia(λf )

Concrete Models 3 Summary and Example (31/32) T ::= γ 1 T T T C νγ.t C T T µγ.t Theorem 11. For a model l satisfying the assumption thus far, let T be a fibred strong monad on p satisfying the equalizing requirement. If T is constructed inductively as above, then T and the λ2-fibration p form a monadic λ c 2 η -model. Example 12. (PFam (AP(D) ), PFam (AP(D)),...) : the models of linear Plotkin-Abadi logic constructed from domain theoretic PERs (L. Birkedal, R. E. Møgelberg, and R. L. Petersen, 2007)

Conclusion 3 Future Work (32/32) Dependent type theoretical approach is also available. powerset monads? continuations monads? all lifting monads? all commutative relevant monads?