differential logical relations
play

Differential Logical Relations Joint work with Francesco Gavazzo and - PowerPoint PPT Presentation

Differential Logical Relations Joint work with Francesco Gavazzo and Akira Yoshimizu Ugo Dal Lago IFIP WG 2.2 Annual Meeting , Vienna, September 23rd 2019 Comparing Interacting Programs M N C A C B Comparing Interacting


  1. Differential Logical Relations Joint work with Francesco Gavazzo and Akira Yoshimizu Ugo Dal Lago IFIP WG 2.2 Annual Meeting , Vienna, September 23rd 2019

  2. Comparing Interacting Programs ≡ M N ⇓ ∼ C A C B

  3. Comparing Interacting Programs ≡ M N ⇓ ≡ C M C N

  4. Program Equivalence ◮ Let ≡ ⊆ Λ × Λ be a notion of equivalence. What are the minimal requirements we should put on ≡ ?

  5. Program Equivalence ◮ Let ≡ ⊆ Λ × Λ be a notion of equivalence. What are the minimal requirements we should put on ≡ ? ◮ Adequacy : for every M, N , M ≡ N = ⇒ Obs ( M ) = Obs ( N ) where Obs : Λ → X is the observation function .

  6. Program Equivalence ◮ Let ≡ ⊆ Λ × Λ be a notion of equivalence. What are the minimal requirements we should put on ≡ ? ◮ Adequacy : for every M, N , M ≡ N = ⇒ Obs ( M ) = Obs ( N ) where Obs : Λ → X is the observation function . ◮ Congruence : for every M, N, C , M ≡ N = ⇒ C [ M ] ≡ C [ N ] .

  7. Program Equivalence ◮ Let ≡ ⊆ Λ × Λ be a notion of equivalence. What are the minimal requirements we should put on ≡ ? ◮ Adequacy : for every M, N , M ≡ N = ⇒ Obs ( M ) = Obs ( N ) where Obs : Λ → X is the observation function . ◮ Congruence : for every M, N, C , M ≡ N = ⇒ C [ M ] ≡ C [ N ] . ◮ Examples, the realm of λ -calculus: ◮ The largest adequate congruence, context equivalence [Morris1968]. ◮ Logical relations [Plotkin1973]. ◮ Applicative [Abramsky1990] or open bisimilarity .

  8. Program Equivalence ◮ Let ≡ ⊆ Λ × Λ be a notion of equivalence. What are the minimal requirements we should put on ≡ ? ◮ Adequacy : for every M, N , M ≡ N = ⇒ Obs ( M ) = Obs ( N ) where Obs : Λ → X is the observation function . ◮ Congruence : for every M, N, C , M ≡ N = ⇒ C [ M ] ≡ C [ N ] . ◮ Examples, the realm of λ -calculus: ◮ The largest adequate congruence, context equivalence [Morris1968]. ◮ Logical relations [Plotkin1973]. ◮ Applicative [Abramsky1990] or open bisimilarity . ◮ What if X is a metric space?

  9. Program Distance ◮ Let δ : Λ × Λ → R .

  10. Program Distance ◮ Let δ : Λ × Λ → R . ◮ Adequacy : for every M, N , δ ( M, N ) ≥ δ X ( Obs ( M ) , Obs ( N ))

  11. Program Distance ◮ Let δ : Λ × Λ → R . ◮ Adequacy : for every M, N , δ ( M, N ) ≥ δ X ( Obs ( M ) , Obs ( N )) ◮ Non-Expansiveness : for every M, N, C , δ ( M, N ) ≥ δ ( C [ M ] , C [ N ])

  12. Program Distance ◮ Let δ : Λ × Λ → R . ◮ Adequacy : for every M, N , δ ( M, N ) ≥ δ X ( Obs ( M ) , Obs ( N )) ◮ Non-Expansiveness : for every M, N, C , δ ( M, N ) ≥ δ ( C [ M ] , C [ N ]) ◮ In probabilistic computation, one is naturally lead to observe a quantitative property, and X is simply R .

  13. Program Distance ◮ Let δ : Λ × Λ → R . ◮ Adequacy : for every M, N , δ ( M, N ) ≥ δ X ( Obs ( M ) , Obs ( N )) ◮ Non-Expansiveness : for every M, N, C , δ ( M, N ) ≥ δ ( C [ M ] , C [ N ]) ◮ In probabilistic computation, one is naturally lead to observe a quantitative property, and X is simply R . ◮ But even when computation is deterministic , one could well work with X = R when real numbers are part of the underlying language [ReedPierce2010,AGHKC2017].

  14. An Example

  15. An Example M ID ≡ λx.x M SIN ≡ λx. sin x δ ( M ID , M SIN ) = + ∞

  16. An Example M ID ≡ λx.x M SIN ≡ λx. sin x δ ( M ID , M SIN ) = + ∞

  17. An Example M ID ≡ λx.x M SIN ≡ λx. sin x δ ( M ID , M SIN ) = + ∞

  18. An Example M ID ≡ λx.x M SIN ≡ λx. sin x δ ( M ID , M SIN ) = + ∞ What if the environment feeds the function with values close to 0 , only?

  19. An Example

  20. A Toy Language Types

  21. A Toy Language Types Typing Rules

  22. A Toy Language Types Typing Rules Denotational Semantics

  23. Differential Logical Relations Distance Spaces

  24. Differential Logical Relations Distance Spaces The distance between two pro- grams of type τ → ρ is a func- tion which: ◮ Given an input in � τ � . . . ◮ And a distance in ( | τ | ) . . . ◮ Returns a distance in ( | ρ | ) .

  25. Differential Logical Relations Distance Spaces DLRs as Ternary Relations

  26. Differential Logical Relations Distance Spaces DLRs as Ternary Relations Theorem (Fundamental Lemma, Version I) For every ⊢ M : τ , there is d ∈ ( | τ | ) such that δ τ ( M, d, M ) .

  27. On the Fundamental Lemma — So What? ◮ Why not null distances? ◮ The distance between a program M and itself is null, isn’t it?

  28. On the Fundamental Lemma — So What? ◮ Why not null distances? ◮ The distance between a program M and itself is null, isn’t it? ◮ In fact, this is true only at ground types. ◮ Example : the distance between M ID and itself is something λ � x, ε � .ε . like λ

  29. On the Fundamental Lemma — So What? ◮ Why not null distances? ◮ The distance between a program M and itself is null, isn’t it? ◮ In fact, this is true only at ground types. ◮ Example : the distance between M ID and itself is something λ � x, ε � .ε . like λ ◮ Too weak? ◮ The distance d is arbitrary, and can even be infinite. ◮ In ordinary logical relations, the FL enables compositional reasoning, when applied to the environment, the context.

  30. On the Fundamental Lemma — So What? ◮ Why not null distances? ◮ The distance between a program M and itself is null, isn’t it? ◮ In fact, this is true only at ground types. ◮ Example : the distance between M ID and itself is something λ � x, ε � .ε . like λ ◮ Too weak? ◮ The distance d is arbitrary, and can even be infinite. ◮ In ordinary logical relations, the FL enables compositional reasoning, when applied to the environment, the context. ◮ The same here : ( C, d, C ) ∈ δ τ → REAL C : τ → REAL M, N : τ ( M, e, N ) ∈ δ τ ⇓ ( C [ M ] , d ( � M � , e ) , C [ N ]) ∈ δ REAL

  31. On the Fundamental Lemma — So What? ◮ Why not null distances? ◮ The distance between a program M and itself is null, isn’t it? ◮ In fact, this is true only at ground types. ◮ Example : the distance between M ID and itself is something λ � x, ε � .ε . like λ ◮ Too weak? ◮ The distance d is arbitrary, and can even be infinite. ◮ In ordinary logical relations, the FL enables compositional reasoning, when applied to the environment, the context. ◮ The same here : ( C, d, C ) ∈ δ τ → REAL C : τ → REAL M, N : τ ( M, e, N ) ∈ δ τ ⇓ ( C [ M ] , d ( � M � , e ) , C [ N ]) ∈ δ REAL

  32. On the Fundamental Lemma — So What? ◮ Why not null distances? ◮ The distance between a program M and itself is null, isn’t it? ◮ In fact, this is true only at ground types. ◮ Example : the distance between M ID and itself is something λ � x, ε � .ε . like λ ◮ Too weak? ◮ The distance d is arbitrary, and can even be infinite. ◮ In ordinary logical relations, the FL enables compositional reasoning, when applied to the environment, the context. ◮ The same here : ( C, d, C ) ∈ δ τ → REAL C : τ → REAL M, N : τ ( M, e, N ) ∈ δ τ ⇓ ( C [ M ] , d ( � M � , e ) , C [ N ]) ∈ δ REAL

  33. On the Fundamental Lemma — So What? ◮ Why not null distances? ◮ The distance between a program M and itself is null, isn’t it? ◮ In fact, this is true only at ground types. ◮ Example : the distance between M ID and itself is something λ � x, ε � .ε . like λ ◮ Too weak? ◮ The distance d is arbitrary, and can even be infinite. ◮ In ordinary logical relations, the FL enables compositional reasoning, when applied to the environment, the context. ◮ The same here : ( C, d, C ) ∈ δ τ → REAL C : τ → REAL M, N : τ ( M, e, N ) ∈ δ τ ⇓ ( C [ M ] , d ( � M � , e ) , C [ N ]) ∈ δ REAL

  34. Back to the Example Claim λ � x, y � .y + | x − sin x | , M SIN ) δ REAL → REAL ( M ID , λ

  35. Back to the Example Claim λ � x, y � .y + | x − sin x | , M SIN ) δ REAL → REAL ( M ID , λ Proof. Consider any pairs of real numbers r, s ∈ R such that | r − s | ≤ ε , where ε ∈ R ∞ ≥ 0 . We have that: | sin r − s | = | sin r − r + r − s | ≤ | sin r − r | + | r − s | ≤ | sin r − r | + ε = f ( r, ε ) | sin s − r | = | sin s − sin r + sin r − r | ≤ | sin s − sin r | + | sin r − r | ≤ | s − r | + | sin r − r | ≤ ε + | sin r − r | = f ( r, ε ) . λ � x, y � .y + | x − sin x | . where f = λ

  36. Back to the Example ◮ Now, consider, e.g., the context C = ( λx.x ( xθ ))[ · ] .

  37. Back to the Example ◮ Now, consider, e.g., the context C = ( λx.x ( xθ ))[ · ] . ◮ C can be seen as a term having type τ = ( REALS → REALS ) → REALS . A self-distance d for C can thus be defined as an element of � τ � = � REALS → REALS � × � REALS → REALS � → � REALS � . λ � g, h � .h ( g ( θ ) , h ( θ, 0)) . namely F = λ

Recommend


More recommend