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

differential logical relations
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

Comparing Interacting Programs

B C A C ∼ M N ≡ ⇓

slide-3
SLIDE 3

Comparing Interacting Programs

N C M C ≡ M N ≡ ⇓

slide-4
SLIDE 4

Program Equivalence

◮ Let ≡ ⊆ Λ × Λ be a notion of equivalence. What are the

minimal requirements we should put on ≡?

slide-5
SLIDE 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.

slide-6
SLIDE 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].

slide-7
SLIDE 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.

slide-8
SLIDE 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?

slide-9
SLIDE 9

Program Distance

◮ Let δ : Λ × Λ → R.

slide-10
SLIDE 10

Program Distance

◮ Let δ : Λ × Λ → R. ◮ Adequacy: for every M, N,

δ(M, N) ≥ δX(Obs(M), Obs(N))

slide-11
SLIDE 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])

slide-12
SLIDE 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

  • bserve a quantitative property, and X is simply R.
slide-13
SLIDE 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

  • bserve 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].

slide-14
SLIDE 14

An Example

slide-15
SLIDE 15

An Example

MID ≡ λx.x MSIN ≡ λx.sin x δ(MID, MSIN ) = +∞

slide-16
SLIDE 16

An Example

MID ≡ λx.x MSIN ≡ λx.sin x δ(MID, MSIN ) = +∞

slide-17
SLIDE 17

An Example

MID ≡ λx.x MSIN ≡ λx.sin x δ(MID, MSIN ) = +∞

slide-18
SLIDE 18

An Example

MID ≡ λx.x MSIN ≡ λx.sin x δ(MID, MSIN ) = +∞

What if the environment feeds the function with values close to 0, only?

slide-19
SLIDE 19

An Example

slide-20
SLIDE 20

A Toy Language Types

slide-21
SLIDE 21

A Toy Language Types Typing Rules

slide-22
SLIDE 22

A Toy Language Types Typing Rules Denotational Semantics

slide-23
SLIDE 23

Differential Logical Relations Distance Spaces

slide-24
SLIDE 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 (

|ρ| ).

slide-25
SLIDE 25

Differential Logical Relations Distance Spaces DLRs as Ternary Relations

slide-26
SLIDE 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).

slide-27
SLIDE 27

On the Fundamental Lemma — So What?

◮ Why not null distances?

◮ The distance between a program M and itself is null, isn’t

it?

slide-28
SLIDE 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 MID and itself is something

like λ λx, ε.ε.

slide-29
SLIDE 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 MID and itself is something

like λ λx, ε.ε.

◮ 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.

slide-30
SLIDE 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 MID and itself is something

like λ λx, ε.ε.

◮ 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 : τ → REAL M, N : τ (C, d, C) ∈ δτ→REAL (M, e, N) ∈ δτ ⇓ (C[M], d(M, e), C[N]) ∈ δREAL

slide-31
SLIDE 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 MID and itself is something

like λ λx, ε.ε.

◮ 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 : τ → REAL M, N : τ (C, d, C) ∈ δτ→REAL (M, e, N) ∈ δτ ⇓ (C[M], d(M, e), C[N]) ∈ δREAL

slide-32
SLIDE 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 MID and itself is something

like λ λx, ε.ε.

◮ 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 : τ → REAL M, N : τ (C, d, C) ∈ δτ→REAL (M, e, N) ∈ δτ ⇓ (C[M], d(M, e), C[N]) ∈ δREAL

slide-33
SLIDE 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 MID and itself is something

like λ λx, ε.ε.

◮ 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 : τ → REAL M, N : τ (C, d, C) ∈ δτ→REAL (M, e, N) ∈ δτ ⇓ (C[M], d(M, e), C[N]) ∈ δREAL

slide-34
SLIDE 34

Back to the Example

Claim

δREAL→REAL(MID, λ λx, y.y + |x − sin x|, MSIN )

slide-35
SLIDE 35

Back to the Example

Claim

δREAL→REAL(MID, λ λx, y.y + |x − sin x|, MSIN )

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, ε). where f = λ λx, y.y + |x − sin x|.

slide-36
SLIDE 36

Back to the Example

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

slide-37
SLIDE 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. namely F = λ λg, h.h(g(θ), h(θ, 0)).

slide-38
SLIDE 38

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. namely F = λ λg, h.h(g(θ), h(θ, 0)).

◮ This allows for compositional reasoning about program

distances: the overall impact of replacing MSIN by MID can be evaluated by computing F(MID, f) or F(MSIN , f).

slide-39
SLIDE 39

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. namely F = λ λg, h.h(g(θ), h(θ, 0)).

◮ This allows for compositional reasoning about program

distances: the overall impact of replacing MSIN by MID can be evaluated by computing F(MID, f) or F(MSIN , f).

◮ Of course the context C needs to be taken into account, but

  • nce and for all: the functional F can be built without

knowing either MSIN or MID.

slide-40
SLIDE 40

Different Kinds of Distances Hereditarily Null Distances

slide-41
SLIDE 41

Different Kinds of Distances Hereditarily Null Distances

This is much larger than {λ λx, y.0}

slide-42
SLIDE 42

Different Kinds of Distances Hereditarily Null Distances Hereditarily Finite Distances

slide-43
SLIDE 43

Different Kinds of Distances Hereditarily Null Distances Hereditarily Finite Distances

Lemma

Whenever ⊢ M, N : τ, M is logically related to N iff δτ(M, d, N) where d ∈ ( |τ| )0.

slide-44
SLIDE 44

Different Kinds of Distances Hereditarily Null Distances Hereditarily Finite Distances

Lemma

Whenever ⊢ M, N : τ, M is logically related to N iff δτ(M, d, N) where d ∈ ( |τ| )0.

Theorem (Fundamental Lemma, Version II)

For every ⊢ M : τ, there is d ∈ ( |τ| )<∞ such that δτ(M, d, M).

slide-45
SLIDE 45

Conclusions

◮ Other Interesting Results

◮ Differential logical relations are examples of generalized

metric domains, which (contrarily to metric spaces) form a cartesian closed category.

◮ Not only logical relations, but also metric logical relations

can be seen as special kinds of distances.

slide-46
SLIDE 46

Conclusions

◮ Other Interesting Results

◮ Differential logical relations are examples of generalized

metric domains, which (contrarily to metric spaces) form a cartesian closed category.

◮ Not only logical relations, but also metric logical relations

can be seen as special kinds of distances.

δ(x, 0, y) ⇒ x = y δ(x, d, y) ⇒ δ(y, d, x) δ(x, d, y) ∧ δ(y, e, y) ∧ δ(y, f, z) ⇒ δ(x, d + e + f, z)

slide-47
SLIDE 47

Conclusions

◮ Other Interesting Results

◮ Differential logical relations are examples of generalized

metric domains, which (contrarily to metric spaces) form a cartesian closed category.

◮ Not only logical relations, but also metric logical relations

can be seen as special kinds of distances.

◮ Further Work

◮ Capture more expressive constructs and calculi (e.g.

recursion by way of step-indexing).

◮ Higher-order continuity? ◮ Abstracting functional distances by way of step functions. ◮ Make behavioral metrics context-dependent.

slide-48
SLIDE 48

Thank You!

Questions?