Congruence of Bisimulation in a Non-Deterministic Call-By-Need Lambda Calculus

Similar documents
Congruence of Bisimulation in a Non-Deterministic Call-By-Need Lambda Calculus

Simulation in the Call-by-Need Lambda-Calculus with letrec

How to Prove Similarity a Precongruence in Non-Deterministic Call-by-Need Lambda Calculi

Simulation in the Call-by-Need Lambda-Calculus with Letrec, Case, Constructors, and Seq

A Call-by-Need Lambda-Calculus with Locally Bottom-Avoiding Choice: Context Lemma and Correctness of Transformations

Towards Correctness of Program Transformations Through Unification and Critical Pair Computation

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

Appendix of Safety of Nöcker s Strictness Analysis

SIMULATION IN THE CALL-BY-NEED LAMBDA-CALCULUS WITH LETREC, CASE, CONSTRUCTORS, AND SEQ

Solutions to Exercises. Solution to Exercise 2.4. Solution to Exercise 2.5. D. Sabel and M. Schmidt-Schauß 1

Extending Abramsky s Lazy Lambda Calculus: (Non)-Conservativity of Embeddings

Extending Abramsky s Lazy Lambda Calculus: (Non)-Conservativity of Embeddings

Probabilistic Applicative Bisimulation and Call-by-Value Lam

On Conservativity of Concurrent Haskell

An introduction to process calculi: Calculus of Communicating Systems (CCS)

Observational Semantics for a Concurrent Lambda Calculus with Reference Cells and Futures

Diagrams for Meaning Preservation

On Coinduction and Quantum Lambda Calculi

A Call-by-Need Lambda Calculus with Scoped Work Decorations

Normal Form Simulation for McCarthy s Amb

The Permutative λ-calculus

Bisimulation and coinduction in higher-order languages

λ S : A Lambda Calculus with Side-effects

Encoding Induction in Correctness Proofs of Program Transformations as a Termination Problem

Operationally-Based Theories of Program Equivalence

MAKING THE UNOBSERVABLE, UNOBSERVABLE.

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

Proving Soundness of Extensional Normal-Form Bisimilarities

Type Systems Winter Semester 2006

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

Blame and Coercion: Together Again for the First Time

CBV and CBN. Eduardo Bonelli. TP para LP 2012C1 1/55

Computational Soundness of a Call by Name Calculus of Recursively-scoped Records. UMM Working Papers Series, Volume 2, Num. 3.

Pattern Matching of Compressed Terms and Contexts and Polynomial Rewriting

Strong normalization of a symmetric lambda calculus for second order classical logic

Command = Value Context. Hans-Dieter Hiep. 15th of June, /17

Observing Success in the Pi-Calculus

Categories, Proofs and Programs

Contextual equivalence

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

Making the unobservable, unobservable

Techniques. Contextual equivalence

Observational Semantics for a Concurrent Lambda Calculus with Reference Cells and Futures

Simply Typed Lambda-Calculi (II)

Environmental Bisimulations for Probabilistic Higher-Order Languages

Step-Indexed Logical Relations for Probability

Equations, contractions, and unique solutions

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

A Behavioral Congruence for Concurrent Constraint Programming with Nondeterministic Choice

Correctness of an STM Haskell Implementation

Communication and Concurrency: CCS

Simply Typed Lambda Calculus

3.2 Equivalence, Evaluation and Reduction Strategies

A Complete, Co-Inductive Syntactic Theory of Sequential Control and State

On Correctness of Buffer Implementations in a Concurrent Lambda Calculus with Futures

Information Flow Inference for ML

Algorithms for Extended Alpha-Equivalence and Complexity

Skew and ω-skew Confluence and Infinite Normal Forms

Streams and Coalgebra Lecture 2

arxiv: v3 [quant-ph] 4 Jan 2010

Typed Arithmetic Expressions

THE STRONG INVARIANCE THESIS

Simulation and Bisimulation over Multiple Time Scales in a Behavioral Setting

Dipartimento di Informatica Università degli Studi di Verona

On Coinductive Equivalences for Higher-Order Probabilistic Functional Programs

Call-by-value solvability, revisited

Refined Environment Classifiers

Type Inference. For the Simply-Typed Lambda Calculus. Peter Thiemann, Manuel Geffken. Albert-Ludwigs-Universität Freiburg. University of Freiburg

Lazy Strong Normalization

On Böhm Trees and Lévy-Longo Trees in π-calculus

Intersection Types and Lambda Theories

Strong Normalization as Safe Interaction

Relating Reasoning Methodologies in Linear Logic and Process Algebra

Operational Semantics Using the Partiality Monad

Variations of the Turing Machine

Classical Combinatory Logic

Parametric Polymorphism and Operational Improvement

A semantic framework for open processes

A Semantic Framework for Open Processes

An Automatic Theorem Prover for Relation Algebras

A Bisimulation-Like Proof Method for Contextual Properties in Untyped λ-calculus with References and Deallocation

A Differential Model Theory for Resource Lambda Calculi - Part II

Strong Normalization for Guarded Types

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

Universität Augsburg. Institut für Informatik. Bisimulation on Speed: Lower Time Bounds. Gerald Lüttgen and Walter Vogler.

A subexponential lower bound for the Random Facet algorithm for Parity Games

Toward a General Rewriting-Based Framework for Reducibility

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus

Communication and Concurrency: CCS. R. Milner, A Calculus of Communicating Systems, 1980

Sub-λ-calculi, Classified

forty-two XLII Equivalent Computers? Lecture 40: Computing with Glue and Photons What is 42? cuarenta y dos Meaning of Numbers Meaning of Numbers

Coinductive big-step operational semantics

A theory of reflexive computation based on soft intuitionistic logic

Equivalence of Algebraic λ -calculi extended abstract

Universität Augsburg

About Typed Algebraic Lambda-calculi

Concurrency theory. proof-techniques for syncronous and asynchronous pi-calculus. Francesco Zappa Nardelli. INRIA Rocquencourt, MOSCOVA research team

The structural λ-calculus

On Typability for Rank-2 Intersection Types with Polymorphic Recursion

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

Transcription:

Congruence of Bisimulation in a Non-Deterministic Call-By-Need Lambda Calculus Matthias Mann Johann Wolfgang Goethe-Universität, Frankfurt, Germany Congruence of Bisimulation p. 1/21

Lambda Calculi and Equality Abramsky ( 90) Ariola, Felleisen, Wadler, et al. ( 95) Kutzner, Schmidt- Schauß ( 98) Moran, Sands, Carlsson ( 99) Howe ( 89, 96) deterministic, call-by-name deterministic, call-by-need (let) non-deterministic, call-by-need (let) non-deterministic, call-by-need, letrec, case class of languages, no sharing Bisimulation = Contextual Equiv. Conversion Contextual Equiv. Contextual Equiv. Bisimulation = Contextual Equiv. Congruence of Bisimulation p. 2/21

λ ND = non-determinism + sharing Congruence proof non-trivial language Λ ND simple: E ::= V (λx.e) (E E) (let x = E in E) (pick E E) Congruence of Bisimulation p. 3/21

λ ND = non-determinism + sharing Congruence proof non-trivial language Λ ND simple: E ::= V (λx.e) (E E) (let x = E in E) (pick E E) λ ND Congruence of Bisimulation p. 3/21

λ ND = non-determinism + sharing Congruence proof non-trivial language Λ ND simple: E ::= V (λx.e) (E E) (let x = E in E) (pick E E) n c λ ND Congruence of Bisimulation p. 3/21

λ ND = non-determinism + sharing Congruence proof non-trivial language Λ ND simple: E ::= V (λx.e) (E E) (let x = E in E) (pick E E) n Approximation c λ ND λ Congruence of Bisimulation p. 3/21

λ ND = non-determinism + sharing Congruence proof non-trivial language Λ ND simple: E ::= V (λx.e) (E E) (let x = E in E) (pick E E) Approximation n c λ ND λ S λ b Congruence of Bisimulation p. 3/21

λ ND = non-determinism + sharing Congruence proof non-trivial language Λ ND simple: E ::= V (λx.e) (E E) (let x = E in E) (pick E E) Approximation n c λ ND λ S λ b ND = Congruence of Bisimulation p. 3/21

Reduction Rules of the λ ND -Calculus let x = (let y = t y in t x ) in s llet let y = t y in (let x = t x in s) (let x = t x in s) t lapp let x = t x in (s t) (λx.s) t lbeta let x = t in s let x = λy.r in D[x] cp let x = λy.r in D[λy.r] (llet) (lapp) (lbeta) (cp) pick s t ndl s pick s t ndr t (nd) Congruence of Bisimulation p. 4/21

Non-Determinism and Sharing Sharing like in functional programming languages: Rule (cp) only copies abstractions Avoid duplication of work Congruence of Bisimulation p. 5/21

Non-Determinism and Sharing Sharing like in functional programming languages: Rule (cp) only copies abstractions Avoid duplication of work, in particular of non-deterministic choice points: (λx.x + x) (pick a b) lbeta let x = pick a b in x + x instead of (λx.x + x) (pick a b) β pick a b + pick a b Congruence of Bisimulation p. 5/21

Non-Determinism and Sharing Sharing like in functional programming languages: Rule (cp) only copies abstractions Avoid duplication of work, in particular of non-deterministic choice points: (λx.x + x) (pick a b) lbeta let x = pick a b in x + x instead of (λx.x + x) (pick a b) β pick a b + pick a b Necessary to equate e.g. λx.(2 x) and λx.(x + x) Congruence of Bisimulation p. 5/21

Convergence in λ ND Normal-order reduction n is unique up to (nd) Weak Head Normal Form (WHNF): L R [λx.s] let-environments: L R ::= [ ] let x = e in L R Convergence: t L R[λx.s] def t n L R[λx.s] Congruence of Bisimulation p. 6/21

Normal-Order Reduction in λ ND Example: (λx.x) ( (λy.(λz.q)) r ) Congruence of Bisimulation p. 7/21

Normal-Order Reduction in λ ND Example: (λx.x) ( (λy.(λz.q)) r ) Congruence of Bisimulation p. 7/21

Normal-Order Reduction in λ ND Example: (λx.x) ( (λy.(λz.q)) r ) n, lbeta let x = ((λy.(λz.q)) r) in x Congruence of Bisimulation p. 7/21

Normal-Order Reduction in λ ND Example: (λx.x) ( (λy.(λz.q)) r ) n, lbeta let x = ((λy.(λz.q)) r) in x n, lbeta let x = (let y = r in (λz.q)) in x Congruence of Bisimulation p. 7/21

Normal-Order Reduction in λ ND Example: (λx.x) ( (λy.(λz.q)) r ) n, lbeta let x = ((λy.(λz.q)) r) in x n, lbeta let x = (let y = r in (λz.q)) in x n, llet let y = r in (let x = (λz.q) in x) Congruence of Bisimulation p. 7/21

Normal-Order Reduction in λ ND Example: (λx.x) ( (λy.(λz.q)) r ) n, lbeta let x = ((λy.(λz.q)) r) in x n, lbeta let x = (let y = r in (λz.q)) in x n, llet let y = r in (let x = (λz.q) in x) n, cp let y = r in (let x = (λz.q) in (λz.q)) is a Weak Head Normal Form Congruence of Bisimulation p. 7/21

Congruences and Program Transformations Congruence of Bisimulation p. 8/21

Equality and Preorders Contextual Equivalence s ΛND, c t def s ΛND, c t t ΛND, c s Contextual Preorder s ΛND, c t def C : C[s] = C[t] Congruence of Bisimulation p. 9/21

Equality and Preorders Contextual Equivalence s ΛND, c t def s ΛND, c t t ΛND, c s Contextual Preorder s ΛND, c t def C : C[s] = C[t] Similarity? ΛND, b ΛND, c for ΛND, b as gfp of s ΛND, b t s L s [λx.s ] = ( t L t [λx.t ] r : (L s [λx.s ]) r ΛND, b (L t [λx.t ]) r ) Congruence of Bisimulation p. 9/21

Counter-Example: Shift let over λ Not correct w.r.t. c in the λ ND -calculus! Congruence of Bisimulation p. 10/21

Counter-Example: Shift let over λ Not correct w.r.t. c in the λ ND -calculus! For the terms s λw.let v = pick K K2 in v t let v = pick K K2 in λw.v Congruence of Bisimulation p. 10/21

Counter-Example: Shift let over λ Not correct w.r.t. c in the λ ND -calculus! For the terms s λw.let v = pick K K2 in v t let v = pick K K2 in λw.v s ΛND, c t holds because of C[s] C[t] with C let f = [ ] in ((f K) (f K) Ω Ω K) Congruence of Bisimulation p. 10/21

Counter-Example: Shift let over λ Not correct w.r.t. c in the λ ND -calculus! For the terms s λw.let v = pick K K2 in v t let v = pick K K2 in λw.v s ΛND, c t holds because of C[s] C[t] with C let f = [ ] in ((f K) (f K) Ω Ω K) But: s ΛND, b t since s and t both WHNF s and r : s r ΛND, b t r Congruence of Bisimulation p. 10/21

From the λ ND - to the λ -calculus let x = (let y = t y in t x ) in s llet let y = t y in (let x = t x in s) (let x = t x in s) t lapp let x = t x in (s t) (λx.s) t lbeta let x = t in s let x = λy.r in D[x] cp let x = λy.r in D[λy.r] (llet) (lapp) (lbeta) (cp) pick s t ndl s pick s t ndr t (nd) Congruence of Bisimulation p. 11/21

From the λ ND - to the λ -calculus let x = (let y = t y in t x ) in s llet let y = t y in (let x = t x in s) (let x = t x in s) t lapp let x = t x in (s t) (λx.s) t lbeta let x = t in s let x = λy.r in D[x] cp let x = λy.r in D[λy.r] (llet) (lapp) (lbeta) (cp) pick s t ndl s pick s t ndr t (nd) s stop λ if s (stop) Congruence of Bisimulation p. 11/21

From the λ ND - to the λ -calculus let x = (let y = t y in t x ) in s llet let y = t y in (let x = t x in s) (let x = t x in s) t lapp let x = t x in (s t) (λx.s) t lbeta let x = t in s let x = λy.r in D[x] cp let x = λy.r in D[λy.r] (llet) (lapp) (lbeta) (cp) pick s t ndl s pick s t ndr t (nd) s stop λ if s (stop) Congruence of Bisimulation p. 11/21

From the λ ND - to the λ -calculus let x = (let y = t y in t x ) in s llet let y = t y in (let x = t x in s) (let x = t x in s) t lapp let x = t x in (s t) (λx.s) t lbeta let x = t in s let x = s in t cpa λ t[s/x] where s λz.q or s (llet) (lapp) (lbeta) (cpa) pick s t ndl s pick s t ndr t (nd) s stop λ if s (stop) Congruence of Bisimulation p. 11/21

From the λ ND - to the λ -calculus let x = (let y = t y in t x ) in s llet let y = t y in (let x = t x in s) (let x = t x in s) t lapp let x = t x in (s t) (λx.s) t lbeta let x = t in s let x = s in t cpa λ t[s/x] where s λz.q or s (llet) (lapp) (lbeta) (cpa) pick s t ndl s pick s t ndr t (nd) s stop λ if s (stop) Congruence of Bisimulation p. 11/21

From the λ ND - to the λ -calculus (let x = t x in s) t lapp let x = t x in (s t) (λx.s) t lbeta let x = t in s let x = s in t cpa λ t[s/x] where s λz.q or s (lapp) (lbeta) (cpa) pick s t ndl s pick s t ndr t (nd) s stop λ if s (stop) Congruence of Bisimulation p. 11/21

Approximation Reduction in λ Howe s method: Treatment of rule (llet) avoided Special constant to cut off evaluation Test for pure abstractions instead of WHNF s Surface contexts S: No hole under λ Congruence of Bisimulation p. 12/21

Approximation Reduction in λ Howe s method: Treatment of rule (llet) avoided Special constant to cut off evaluation Test for pure abstractions instead of WHNF s Surface contexts S: No hole under λ Convergence using λ -reductions in surface contexts: s λx.t def s S λ λx.t Notation: val(s) = {λx.t s λx.t} Congruence of Bisimulation p. 12/21

Bisimulation in the λ -Calculus Similarity b is the greatest fixed point w.r.t. s b t λx.s : ( s λx.s = λy.t : (t λy.t r : r Λ 0 = (λx.s) r b (λy.t) r) ) Congruence of Bisimulation p. 13/21

Bisimulation in the λ -Calculus Similarity b is the greatest fixed point w.r.t. s b t λx.s : ( s λx.s = λy.t : (t λy.t r : r Λ 0 = (λx.s) r b (λy.t) r) ) Bisimilarity: s b t def s b t t b s Congruence of Bisimulation p. 13/21

Example revisited: Shift let over λ s λw.let v = pick K K2 in v val(s) = {s} t let v = pick K K2 in λw.v let v = K in λw.v cpa λw.k val(t) = {λw.k, λw.k2} let v=[ ] in..., ndl Congruence of Bisimulation p. 14/21

Example revisited: Shift let over λ s λw.let v = pick K K2 in v val(s) = {s} t let v = pick K K2 in λw.v let v=[ ] in..., ndl let v = K in λw.v cpa λw.k val(t) = {λw.k, λw.k2} Therefore s b t, i.e. s and t are not bisimilar: ((s Ω) Ω) K ((s Ω) K) Ω but (((λw.k) Ω) Ω) K but (((λw.k2) Ω) K) Ω Congruence of Bisimulation p. 14/21

Similarity and Contextual Preorder Main Theorem: Similarity b is a precongruence in λ Due to correspondence of convergence in λ and λ ND : Theorem: The similarity b in the λ -calculus coincides with the contextual preorder ΛND, c in the λ ND -calculus Congruence of Bisimulation p. 15/21

Proof Structure Congruence of Bisimulation p. 16/21

Similarity a Precongruence Open extension o b via closing let-environments Howe s precongruence candidate: x b b = x o b b τ(a i ) b b = a i b a i τ(a i ) b o b Infer b b o from r S, a λ s r b t = s b t which is shown for every reduction rule (a) Congruence of Bisimulation p. 17/21

Howe: Substitution Lemmas Essential for proving reduction rules stable under b All terms in Howe s original no sharing: s b s t b t = s[t/x] b s [t /x] In λ only terms which may be copied: s b s = s[ /x] b s [ /x] s b s λy.t b λy.t = s[λy.t/x] b s [λy.t /x] Close interplay with rule (cpa) in proof Congruence of Bisimulation p. 18/21

Kutzner: Reduction Diagrams Complete Sets of Commuting and Forking Diagrams p a r p a r b b b b s a t s a t Congruence of Bisimulation p. 19/21

Kutzner: Reduction Diagrams Complete Sets of Commuting and Forking Diagrams p a r p a r b b b b s a t s a t Forking diagrams: (lbeta), (cpa) sound w.r.t. b Transform n -sequences into S λ -sequences and vice versa with commuting diagrams, e.g.: S, cpa λ n, a n, llet n, a S, cpa λ Congruence of Bisimulation p. 19/21

Conclusion Similarity b is a precongruence in λ and therefore equals contextual preorder Λ, c Contextual preorders ΛND, c and Λ, c coincide Congruence of Bisimulation p. 20/21

Conclusion Similarity b is a precongruence in λ and therefore equals contextual preorder Λ, c Contextual preorders ΛND, c and Λ, c coincide Bisimilarity a proof tool for contextual equivalence in a non-deterministic call-by-need lambda-calculus Congruence of Bisimulation p. 20/21

Future Work Extend to calculus with constructors and case Bisimulation highly non-deterministic: Arrange for better proof search strategy Regard must -convergence in definition of c pick behaves bottom-avoiding because of may - convergence only: Compare with amb-calculi Develop SOS rule format according to proof method Congruence of Bisimulation p. 21/21