Strong Normalization for Guarded Types

Similar documents
Normalization by Evaluation

Realizability Semantics of Parametric Polymorphism, General References, and Recursive Types

Total (Co)Programming with Guarded Recursion

Modal Dependent Type Theory and Dependent Right Adjoints

Categories, Proofs and Programs

Operational Semantics Using the Partiality Monad

Type Systems. Lecture 9: Classical Logic. Neel Krishnaswami University of Cambridge

On the Syntax and Semantics of Quantitative Typing

Weak ω-groupoids in Type Theory

CS522 - Programming Language Semantics

Propositional Logic Language

Part 1: Propositional Logic

A type theory for productive coprogramming via guarded recursion

COMP6463: λ-calculus

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

Beyond First-Order Logic

Step-Indexed Biorthogonality: a Tutorial Example

Sequent Calculus in the Topos of Trees

Normalisation by evaluation

Copatterns Programming Infinite Objects by Observations

Univalent Foundations and Set Theory

Extended Abstract: Reconsidering Intuitionistic Duality

Normalisation by Evaluation for Dependent Types

Typed Arithmetic Expressions

The syntactic guard condition of Coq

Informal Statement Calculus

Toward a General Rewriting-Based Framework for Reducibility

Strong normalisation for focalising system L

Focusing on Binding and Computation

Formalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl)

CS 6110 Lecture 35 Solving Domain Equations 19 April 2013 Lecturer: Andrew Myers

Specification of Core Agda Subtitle

A proof checking kernel for the λπ-calculus modulo

Union of Reducibility Candidates for Orthogonal Constructor Rewriting

Bisimulation and coinduction in higher-order languages

Introduction to Kleene Algebras

From pre-models to models

First In-Class Exam Solutions Math 410, Professor David Levermore Monday, 1 October 2018

Origin in Mathematical Logic

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

Type Systems. Lecture 2 Oct. 27th, 2004 Sebastian Maneth.

Higher Order Containers

CATEGORY-THEORETIC MODELS OF LINEAR ABADI & PLOTKIN LOGIC

Dependent Types and Explicit Substitutions

Deriving natural deduction rules from truth tables (Extended version)

Step-indexed models of call-by-name: a tutorial example

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus

Homotopy and Directed Type Theory: a Sample

Minimal logic for computable functionals

Strong Normalization as Safe Interaction

Concrete Models for Classical Realizability

The Curry-Howard Isomorphism

Proofs and computations

Non- -overlappings TRSs are UN. Stefan Kahrs and Connor Smith University of Kent

Proving Completeness for Nested Sequent Calculi 1

Advanced Lambda Calculus. Henk Barendregt & Giulio Manzonetto ICIS Faculty of Science Radboud University Nijmegen, The Netherlands

Applicative May- and Should-Simulation in the Call-by-Value Lambda Calculus with AMB

A Note on Scope and Infinite Behaviour in CCS-like Calculi p.1/32

Parametricity and excluded middle

On Modal Logics of Partial Recursive Functions

CS611 Lecture 25 Solving Domain Equations 22 October 2007 Lecturer: Andrew Myers

Programming with Higher Inductive Types

Realizable Extensions of Intuitionistic Analysis: Brouwer, Kleene, Kripke and the End of Time

Coinductive big-step semantics and Hoare logics for nontermination

Rota-Baxter Type Operators, Rewriting Systems, and Gröbner-Shirshov Bases, Part II

Propositional and Predicate Logic - V

Coinductive big-step operational semantics

Two papers: a scattered tale. T. Litak, U. of Leicester (still, but not for much more) Tbilisi, July 2012

Sequent Combinators: A Hilbert System for the Lambda Calculus

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

185.A09 Advanced Mathematical Logic

Forcing-based cut-elimination for Gentzen-style intuitionistic sequent calculus

Fuzzy Answer Set semantics for Residuated Logic programs

Natural deduction for propositional logic via truth tables

Names and Symmetry in Computer Science

Program Testing and Constructive Validity

MATH 310 Course Objectives

On the Complexity of the Reflected Logic of Proofs

Complete Partial Orders, PCF, and Control

The lambda calculus with constructors

Exogenous Semantics Approach to Enriching Logics

Classical Combinatory Logic

Introduction to λ-calculus

Wolfgang Jeltsch. Seminar talk at the Institute of Cybernetics Tallinn, Estonia

Reducibility proofs in λ-calculi with intersection types

A Thread Algebra with Multi-level Strategic Interleaving

Normalisation by Evaluation for Dependent Types

Indexed Induction-Recursion

A Behavioural Model for Klop s Calculus

Operational Semantics

Consistency of a Programming Logic for a Version of PCF Using Domain Theory

Multitape Ordinal Machines and Primitive Recursion

Variations on a theme: call-by-value and factorization

Review. Principles of Programming Languages. Equality. The Diamond Property. The Church-Rosser Theorem. Corollaries. CSE 230: Winter 2007

Size-Change Termination and Transition Invariants

arxiv: v1 [cs.lo] 25 May 2009

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

n-dimensional Boolean algebras

Sub-λ-calculi, Classified

3.17 Semantic Tableaux for First-Order Logic

Transcription:

Strong Normalization for Guarded Types Andreas Abel Andrea Vezzosi Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden PLS Seminar ITU, Copenhagen, Denmark 20 August 2014 Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 1 / 19

Introduction Guarded recursive types (Nakano, LICS 2000) (Negative) recursive types in type theory Applications in semantics (abstracting step-indexing) Applications in FRP (causality) This talk: strong normalization Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 2 / 19

Guarded types Types and terms. A, B ::= A B A X µxa t, u ::= x λxt t u next t t u Type equality: congruence closure of µxa = A[µXA/X ]. Typing Γ t : A. Γ t : A Γ next t : A Γ t : (A B) Γ t u : B Γ u : A Γ t : A Γ t : B A = B Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 3 / 19

Reduction Redex contraction t t. (λxt) u t[u/x] next t next u next (t u) Full one-step reduction t t : Compatible closure of. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 4 / 19

Recursion from recursive types Guarded recursion combinator can be encoded. f : A A B := µx. X A = B A x : B = ( B A) x next x : A f (x next x) : A ω := λx. f (x next x) : B A = B Y := ω (next ω) : A Y f (next ω next (next ω)) f (next (ω (next ω))) = f (next Y) Full reduction diverges. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 5 / 19

Restricted reduction Restore normalization: do not reduce under next. Relaxed: reduce only under next up to a certain depth. Family n of reduction relations. t t t n t t n t next t n+1 next t Plus compatibility rules for all other term constructors. n is monotone in n (more fuel gets you further). Goal: each n is strongly normalizing. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 6 / 19

Strong normalization as well-foundedness t sn n if n reduction starting with t terminates. t. t n t = t sn n t sn n sn n is antitone in n, since n occurs negatively. More reductions = less termination. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 7 / 19

Inductive SN Lambda-calculus: u SN x u SN t SN λxt SN t[u/x] u SN (λxt) u u SN u SN With evaluation contexts E ::= E u: SN E SN E u SN u SN E SN E[x] SN t SN λxt SN E[t[u/x]] SN E[(λxt) u] SN u SN Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 8 / 19

Inductive SN (ctd.) Strong contraction t SN t. u SN (λxt) u SN t[u/x] Strong head reduction t SN t. t SN t E[t] SN E[t ] SN with strong head reduction. t SN t t SN t SN Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 9 / 19

SN with guarded types Extending evaluation contexts: E ::= E u next t E Extending strong contraction: u SN n (λxt) u SN n t[u/x] next t next u SN n next (t u) Adding index to strong head reduction: t SN n t E[t] SN n E[t ] Adding rule for introduction: next t SN 0 t SN n t t SN n t SN n t SN n next t SN n+1 SN n is antitone in n. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 10 / 19

Notions of s.n. coincide? Rules for SN n are closure properties of sn n. SN n sn n follows by induction on SN n. Converse sn n SN n does not hold! Counterexamples are ill-typed s.n. terms, e.g., (λx. x) y or (next x) y. Solution: consider only well-typed terms. Proof of t sn n = t SN n by case distinction on t: neutral (E[x]), introduction (λxt, next t), or weak head redex. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 11 / 19

Saturated sets (semantic types) Types are modeled by sets A of s.n. terms. Semantic function space should contain λs and terms that weak head reduce to λs. n-closure A n of A inductively: t A t A n E SN n E[x] A n t SN n t t A n t A n A is n-saturated (A SAT n ) if A n A. Saturated sets are non-empty (contain e.g. the variables). Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 12 / 19

Constructions on semantic types Function space and later : A B = {t t u B for all u A} n A = {next t t A if n > 0} n If A, B SAT n then A B SAT n. 0 A SAT 0. If A SAT n then n+1 A SAT n+1. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 13 / 19

Type interpretation Type interpretation A n SAT n A B n = n n ( A n B n ) A 0 = 0 SN 0 = {next t} 0 A n+1 = n+1 A n µxa n = A[µXA/X ] n By lex. induction on (n, size(a)) where size( A) = 0. Requires recursive occurrences of X to be guarded by a. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 14 / 19

Type soundness Context interpretation: ρ Γ n ρ(x) A n for all (x:a) Γ Identity substitution id Γ n since x A n. Type soundness: if Γ t : A then tρ A n for all n and ρ Γ n. Corollary: t SN n for all n. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 15 / 19

Formalization in Agda Intensional type theory does not support quotients well: in our case, types modulo type equality. = use infinite type expressions instead (coinduction). Only guarded types admit an interpretation. Typing judgement needs to be restricted to guarded types. = use mixed inductive-coinductive representation of types to express guard condition. A, B ::= A B A A, B ::= co A Intensional (propositional) equality too weak for coinductive types. = add an extensionality axiom for our coinductive type. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 16 / 19

Well-typed terms We used intrinsically well-typed terms (data structure indexed by typing context and type expression). Second Kripke dimension (context) required everywhere, e.g., in SN and A. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 17 / 19

Conclusions Strong normalization is a new result, albeit expected. Main focus: Agda formalization. Needed dedication (mostly Andrea s). Forthcoming APLAS 2014 paper (literate Agda, fully machine-checked). Fuzzy hope that HoTT will improve equality situation for coinductive types. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 18 / 19

Acknowledgments Rasmus Møgelberg, for discussions and the present invitation. Lars Birkedal, for a previous invitation that initiated this research. Neel Krishnaswami, for email input. The (other) Agda developers, especially Stevan Andjelkovic for the L A TEXbackend. Abel Vezzosi (Chalmers/GU) SN Guarded Types ITU 2014 19 / 19