Congruence of Bisimulation in a Non-Deterministic Call-By-Need - - PowerPoint PPT Presentation

congruence of bisimulation in a non deterministic call by
SMART_READER_LITE
LIVE PREVIEW

Congruence of Bisimulation in a Non-Deterministic Call-By-Need - - PowerPoint PPT Presentation

Congruence of Bisimulation in a Non-Deterministic Call-By-Need Lambda Calculus Matthias Mann Johann Wolfgang Goethe-Universit at, Frankfurt, Germany Congruence of Bisimulation p. 1/21 Lambda Calculi and Equality Abramsky (90)


slide-1
SLIDE 1

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

Matthias Mann Johann Wolfgang Goethe-Universit¨ at, Frankfurt, Germany

Congruence of Bisimulation – p. 1/21

slide-2
SLIDE 2

Lambda Calculi and Equality

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

Congruence of Bisimulation – p. 2/21

slide-3
SLIDE 3

λ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
  • λ≈

Approximation

  • S

− →λ≈ b ⇓ND = ⇓≈

  • Congruence of Bisimulation – p. 3/21
slide-4
SLIDE 4

Reduction Rules of the λND-Calculus

let x = (let y = ty in tx) in s

llet

− − → let y = ty in (let x = tx in s) (llet) (let x = tx in s) t

lapp

− − → let x = tx in (s t) (lapp) (λx.s) t

lbeta

− − → let x = t in s (lbeta) let x = λy.r in D[x]

cp

− → let x = λy.r in D[λy.r] (cp) pick s t

ndl

− → s pick s t

ndr

− − → t (nd)

Congruence of Bisimulation – p. 4/21

slide-5
SLIDE 5

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

slide-6
SLIDE 6

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

slide-7
SLIDE 7

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

slide-8
SLIDE 8

Congruences and Program Transformations

Congruence of Bisimulation – p. 8/21

slide-9
SLIDE 9

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 ⇓ Ls[λx.s′] = ⇒

  • t ⇓ Lt[λx.t′] ∧

∀r : (Ls[λx.s′]) r ΛND, b (Lt[λx.t′]) r

  • Congruence of Bisimulation – p. 9/21
slide-10
SLIDE 10

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

slide-11
SLIDE 11

From the λND- to the λ≈-calculus

(let x = tx in s) t

lapp

− − → let x = tx in (s t) (lapp) (λx.s) t

lbeta

− − → let x = t in s (lbeta) let x = s in t

cpa

− − →λ≈ t[s/x] where s ≡ λz.q or s ≡ ⊚ (cpa) pick s t

ndl

− → s pick s t

ndr

− − → t (nd) s

stop

− − →λ≈ ⊚ if s ≡ ⊚ (stop)

Congruence of Bisimulation – p. 11/21

slide-12
SLIDE 12

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

slide-13
SLIDE 13

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

slide-14
SLIDE 14

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 ⇓≈ but (((λw.K) Ω) Ω) K ⇓≈ ((s Ω) K) Ω ⇓≈ but (((λw.K2) Ω) K) Ω ⇓≈

Congruence of Bisimulation – p. 14/21

slide-15
SLIDE 15

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 coin- cides with the contextual preorder ΛND, c in the λND-calculus

Congruence of Bisimulation – p. 15/21

slide-16
SLIDE 16

Proof Structure

Congruence of Bisimulation – p. 16/21

slide-17
SLIDE 17

Similarity a Precongruence

Open extension b

  • via closing let-environments

Howe’s precongruence candidate: x b b ⇐ = x b

  • b

τ(ai) b b ⇐ = ai b a′

i ∧ τ(a′ i) b

  • b

Infer b ⊆ b

  • 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

slide-18
SLIDE 18

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

slide-19
SLIDE 19

Kutzner: Reduction Diagrams

Complete Sets of Commuting and Forking Diagrams p

b′

  • a

r b

  • s

a′ t

p

b

  • a

r b′

  • 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

slide-20
SLIDE 20

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

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