Rewrite semantics for guarded recursion with universal quantification over clocks

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

C.S. 430 Assignment 6, Sample Solutions

2 Composition. Invertible Mappings

Example Sheet 3 Solutions

derivation of the Laplacian from rectangular to spherical coordinates

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

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

A Lambda Model Characterizing Computational Behaviours of Terms

Lecture 2. Soundness and completeness of propositional logic

Section 8.3 Trigonometric Equations

EE512: Error Control Coding

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

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

The λ-calculus. Lecturer: John Wickerson. Phil Wadler

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

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

Concrete Mathematics Exercises from 30 September 2016

Homework 3 Solutions

Abstract Storage Devices

Matrices and Determinants

The challenges of non-stable predicates

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Reminders: linear functions

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

Instruction Execution Times

Block Ciphers Modes. Ramki Thurimella

Fractional Colorings and Zykov Products of graphs

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

Durbin-Levinson recursive method

6.3 Forecasting ARMA processes

General 2 2 PT -Symmetric Matrices and Jordan Blocks 1

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Section 7.6 Double and Half Angle Formulas

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

Problem Set 3: Solutions

Lecture 13 - Root Space Decomposition II

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Galatia SIL Keyboard Information

Bounding Nonsplitting Enumeration Degrees

CRASH COURSE IN PRECALCULUS

Statistical Inference I Locally most powerful tests

Other Test Constructions: Likelihood Ratio & Bayes Tests

CS-XXX: Graduate Programming Languages. Lecture 27 Higher-Order Polymorphism. Matthew Fluet 2012

Numerical Analysis FMN011

Space-Time Symmetries

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

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

A Note on Intuitionistic Fuzzy. Equivalence Relation

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

Approximation of distance between locations on earth given by latitude and longitude

Partial Trace and Partial Transpose

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

forms This gives Remark 1. How to remember the above formulas: Substituting these into the equation we obtain with

ORDINAL ARITHMETIC JULIAN J. SCHLÖDER

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

THE CALL-BY-NEED LAMBDA CALCULUS, REVISITED

D Alembert s Solution to the Wave Equation

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

Section 9.2 Polar Equations and Graphs

4.6 Autoregressive Moving Average Model ARMA(1,1)

Finite difference method for 2-D heat equation

Inverse trigonometric functions & General Solution of Trigonometric Equations

Notes on the Open Economy

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

Higher Derivative Gravity Theories

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

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

Chapter 3: Ordinal Numbers

5. Choice under Uncertainty

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

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

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)

Congruence Classes of Invertible Matrices of Order 3 over F 2

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

Models for Probabilistic Programs with an Adversary

Lecture 34 Bootstrap confidence intervals

Tridiagonal matrices. Gérard MEURANT. October, 2008

Right Rear Door. Let's now finish the door hinge saga with the right rear door

Parametrized Surfaces

Heisenberg Uniqueness pairs

PARTIAL NOTES for 6.1 Trigonometric Identities

Ηλεκτρονικός Βοηθός Οδηγού Μοτοσυκλέτας

Areas and Lengths in Polar Coordinates

«Χρήσεις γης, αξίες γης και κυκλοφοριακές ρυθμίσεις στο Δήμο Χαλκιδέων. Η μεταξύ τους σχέση και εξέλιξη.»

F-TF Sum and Difference angle

Areas and Lengths in Polar Coordinates

Second Order Partial Differential Equations

Business English. Ενότητα # 9: Financial Planning. Ευαγγελία Κουτσογιάννη Τμήμα Διοίκησης Επιχειρήσεων

Μηχανική Μάθηση Hypothesis Testing

On the Galois Group of Linear Difference-Differential Equations

Finite Field Problems: Solutions

Case 1: Original version of a bill available in only one language.

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

Figure A.2: MPC and MPCP Age Profiles (estimating ρ, ρ = 2, φ = 0.03)..

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

Homomorphism in Intuitionistic Fuzzy Automata

Χρειάζεται να φέρω μαζί μου τα πρωτότυπα έγγραφα ή τα αντίγραφα; Asking if you need to provide the original documents or copies Ποια είναι τα κριτήρια

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

On a four-dimensional hyperbolic manifold with finite volume

Transcript:

Rewrite semantics for guarded recursion with universal quantification over clocks (Work in progress) Aleš Bizjak 1 Rasmus Møgelberg 2 1 Aarhus University 2 IT University of Copenhagen May 18, 2015

Overview Background Guarded recursion Topos of trees model Multiple clocks and codata New model of clock synchronization Towards rewrite semantics Ensuring termination Computational content of type isomorphisms Generating fresh names of clocks

Background

Productivity Two stream definitions zeros = 0::zeros xs = xs Combining with higher order functions mergef:(int int S(int) S(int)) S(int) S(int) S(int) mergef f x::xs y::ys = f x y (mergef f xs ys)

Capturing productivity in types Introduce modal operator S(int) = µx.int X hd: S(int) int tail: S(int) S(int) cons: int S(int) S(int) Fixed points fix: ( S(int) S(int)) S(int) zeros = fix(λxs.0::xs)

Capturing productivity in types is an applicative functor next: X X : (X Y) X Y Typing mergef mergef:(int int S(int) S(int)) S(int) S(int) S(int) mergef f = fix(λg.λ(x::xs)λ(y::ys).f x y (g xs ys)) where g: (S(int) S(int) S(int))

The topos of trees

The topos of trees (Set ωop ) Objects X (1) r 1 X (2) r 2 X (3)... Example: object of streams of integers S(int) Z π Z 2 π Z 3 π... Define X { } X (1) X (2)... Note that S(int) = Z S(int): Z 1 Z! Z Z Z π Z Z 2 Z π...

Coinductive types via guarded recursive types

A problem S(int) = µx.int X hd: S(int) int tail: S(int) S(int) cons: int S(int) S(int) Computing the second element snd = (λxs.next(hd) tail(xs)): S(int) int How to get rid of?

Guarded recursion vs coinduction in model Guarded recursion useful when constructing streams Would like to use coinductive streams when taking them apart Observation: Limit of guarded recursive streams is set of real streams! Z π Z 2 π Z 3 π...

Multiple clocks Idea due to Atkey and McBride (simply typed setting only) Møgelberg extended it to dependent types using topos of trees model Clock variable context = κ 1,..., κ n etc ; Γ A : Type κ ; Γ κ A : Type fix κ : ( κ X X ) X

Universal quantification over clocks, κ; Γ A : Type κ / fc(γ) ; Γ κ.a : Type, κ; Γ t : A κ / fc(γ) ; Γ Λκ.t : κ.a ; Γ t : κ.a κ ; Γ t[κ ] : A[κ /κ] Clock quantification is right adjoint to clock weakening

Clock synchronisation Previous version of rule for clock application κ, κ / fc(γ, κ.a), κ; Γ A : Type, κ ; Γ, Γ t : κ.a, κ ; Γ, Γ t[κ ] : A[κ /κ] Dissallowed clock synchronisation Clock synchronisation proved consistent using new model.

A new model (MFPS 2015) Type with 0 free clocks is a set Type with 1 free clock is an object in the topos of trees X (1) r 1 X (2) r 2 X (3)... Type with 2 free clocks modelled as diagram of form.... X (1, 3) X (2, 3) X (3, 3) X (3) X (1, 2) X (2, 2) X (3, 2) X (2) X (1, 1) X (2, 1) X (3, 1) X (1)

Type isomorphisms

Structure maps S κ (int) = int κ S κ (int) S(int) = κ.s κ (int) Structure map constructed using series of isomorphisms S(int) = κ.(int κ S κ (int)) = ( κ.int) ( κ. κ S κ (int)) = int ( κ.s κ (int)) = int S(int)

Type isomorphisms in model If κ / fc(a) then κ.a is limit of [[A]] id [[A]] id [[A]] id... So A = κ.a if κ / fc(a) Limit of [[A]](1) [[A]](2) [[A]](3)... Isomorphic to limit of 1 [[A]](1) [[A]](2) [[A]](3)... So κ.a = κ. κ A

Isomorphism κ.a = κ. κ A Left to right definable λ(x: κ.a).λκ.next κ (x[κ]) Unrestricted eliminator for κ unsound: ; Γ t : κ A ; Γ prev κ t : A Implies all types inhabited fix κ (λx : κ A.prev κ x) : A

Isomorphism κ.a = κ. κ A A sound, restricted eliminator for κ : ; Γ t : κ A κ / fc(γ) ; Γ prev κ t : A But type judgement not closed under substitution in Γ

Isomorphism κ.a = κ. κ A Could use explicit substitutions ; Γ t : κ A κ / fc(γ) ρ : Γ Γ ; Γ prev κ ρ.t : A With Γ bound in prev κ ρ.t. We choose the alternative ; Γ t : κ A κ / fc(γ) ; Γ prev κ t : κ.a Binding κ

Isomorphism κ.a = A (for κ / fc(a)) Compare to System F type iso α : Type.int = int In this setting need to add a construct ; Γ t : κ.a κ / fc(a) ; Γ af t : A Pronounced apply at fresh

Rewrite semantics

Rewrite semantics Goals: normalisation and canonical forms Need restriction to prevent infinite unfolding of fix Strategy: Never reduce under next Will not have general confluence (λx.next κ (x))m (λx.next κ (x))n next κ (M) Model ensures that normal forms of type int are unique

Beta reductions (λx.t) s β t[s/x] π 1 s, t β s π 2 s, t β t (Λκ.t) [ κ ] β t[κ /κ] prev κ next κ t β Λκ.t fix κ (t) β t(next κ (fix κ (t))) af Λκ.t β t if κ fc(t)

Example Recall two types of streams S κ (int) = int κ S κ (int) S(int) = κ.s κ (int) Structure maps hd = λxs. af (Λκ.π 1 (xs[κ])) tl = λxs.prev κ (π 2 (xs[κ])) : S(int) int : S(int) S(int) A stream of zeros zeros κ = fix κ (λxs. 0, xs ) : S κ (int) zeros = Λκ.zeros κ : S(int)

Example hd = λxs. af (Λκ.π 1 (xs[κ])) tl = λxs.prev κ (π 2 (xs[κ])) : S(int) int zeros κ = fix κ (λxs. 0, xs ) : S κ (int) zeros = Λκ.zeros κ : S(int) : S(int) S(int) Reducing hd(zeros) β af (Λκ.π 1 (zeros[κ])) β af (Λκ.π 1 (zeros κ )) β af (Λκ.π 1 0, next κ (zeros κ ) ) β af (Λκ.0) β 0

Example hd = λxs. af (Λκ.π 1 (xs[κ])) tl = λxs.prev κ (π 2 (xs[κ])) : S(int) int zeros κ = fix κ (λxs. 0, xs ) : S κ (int) zeros = Λκ.zeros κ : S(int) : S(int) S(int) Reducing tl(zeros) β prev κ (π 2 (zeros[κ])) β prev κ (π 2 (zeros κ )) β prev κ (π 2 ( 0, next κ (zeros κ ) )) β prev κ (next κ (zeros κ )) β Λκ.zeros κ = zeros

Example hd = λxs. af (Λκ.π 1 (xs[κ])) tl = λxs.prev κ (π 2 (xs[κ])) : S(int) int zeros κ = fix κ (λxs. 0, xs ) : S κ (int) zeros = Λκ.zeros κ : S(int) : S(int) S(int) Putting these together hd(tl(zeros)) β hd(zeros) β 0

Commuting conversions

Commuting conversions af Λκ.next κ t c next κ (af Λκ.t) if κ κ af Λκ. t, s c af Λκ.t, af Λκ.s af Λκ.λx.t c λx. af Λκ.t af Λκ.Λκ.t c Λκ. af Λκ.t if κ κ next κ t κ next κ s c next κ (t s) Recall af Λκ.t β t if κ fc(t) Similar to Odersky-style local names Similar to restriction operation in nominal sets

Commuting conversions Needed to ensure progress ( ( ( af prev κ af Λκ.next κ (prev κ next κ 0) [ κ ]))) β af (prev κ next κ( af Λκ.(prev κ next κ 0) [ κ ])) β af Λκ. (af Λκ.(prev κ next κ 0) [ κ ]) β af Λκ. ( af Λκ.(Λκ.0) [ κ ]) β af Λκ. ( af Λκ.0 ) β af Λκ.0 β 0 : int

Conclusions Guarded recursive types in combination with clock quantification useful for programming with codata New model shows clock synchronisation is safe Towards computational content Apply at fresh: ( κ.int) int Commuting conversions: Odersky style local names Partial eliminator for κ Never evaluate under next Future work: theorems about rewrite semantics