A Standard Theory for the Pure Lambda-Value Calculus
Álvaro García-Pérez Pablo Nogueira Paris, September 2014
1 / 18
A Standard Theory for the Pure Lambda-Value Calculus lvaro - - PowerPoint PPT Presentation
A Standard Theory for the Pure Lambda-Value Calculus lvaro Garca-Prez Pablo Nogueira Paris, September 2014 1 / 18 Standard theory in the classical lambda calculus (a.k.a. Barendregts theme) Pure untyped lambda calculus ( K )
Álvaro García-Pérez Pablo Nogueira Paris, September 2014
1 / 18
◮ Pure untyped lambda calculus (λK) with reduction (→∗ β) and
conversion (=β) theories.
◮ Solvability:
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =β I. [Barendregt, 1984]
◮ Unsolvable terms denote ⊥ in D∞ [Wadsworth, 1976]. ◮ H = {M =β N | M, N ∈ Λ0 unsolvables}+ is a lambda theory
[Barendregt, 1984].
◮ D∞ satifies H, i.e., D∞ is sensible [Barendregt, 1984]. ◮ Quasi-leftmost reduction characterises complete strategies
[Hindley and Seldin, 2008].
2 / 18
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =β I. [Barendregt, 1984] M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =β N ∈ NF. [Barendregt, 1971]
3 / 18
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =β I. [Barendregt, 1984]
Ch[M] =β N ∈ NF. [Barendregt, 1971]
Let N ∈ NF. For every M, there exists Ch[ ] such that Ch[N] →∗
β M.
3 / 18
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =β I. [Barendregt, 1984]
Ch[M] =β N ∈ NF. [Barendregt, 1971]
Let N ∈ NF. For every M, there exists Ch[ ] such that Ch[N] →∗
β M.
M is solvable iff it has a head normal form.
3 / 18
A redex R in M ≡ C[R] is needed iff R (or some residual of it) is contracted in every reduction sequence ending in normal form: M ≡ C[R] →β . . . →β N ∈ NF
4 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) N(N))+ N(x) = x− N(λx.B) = (λx.N(B))− N(M N) = (N(M) N(N))−
5 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) N(N))+ N(x) = x− N(λx.B) = (λx.N(B))− N(M N) = (N(M) N(N))− λx.(λy.y (λz.M1))(x M2) λx
λz M1
λt M2
5 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) N(N))+ N(x) = x− N(λx.B) = (λx.N(B))− N(M N) = (N(M) N(N))− (λx.((λy.y + (λz.M−
1 )−)+(x− M− 2 )−)+)+
λx+
λy +
y + λz− M−
1
x− λt− M−
2
5 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) N(N))+ N(x) = x− N(λx.B) = (λx.N(B))− N(M N) = (N(M) N(N))− hs(x) = x hs(λx.B) = λx.hs(B) hs(M N) = hs(M)N bn(x) = x bn(λx.B) = λx.B bn(M N) = bn(M)N λx.(λy.y (λz.M1))(x M2) λx
λz M1
λt M2
5 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) N(N))+ N(x) = x− N(λx.B) = (λx.N(B))− N(M N) = (N(M) N(N))− hr(x) = x hr(λx.B) = λx.hr(B) hr(M N) = bn(M)N bn(x) = x bn(λx.B) = λx.B bn(M N) = bn(M)N λx.(λy.y (λz.M1))(x M2) λx
λz M1
λt M2
5 / 18
HNF ::= x | λx.HNF | HNF Λ λx1 . . . xn.y M1 . . . Mm λx1 λxn
M1 Mm
6 / 18
◮ λV in [Plotkin, 1975] without primitive constants and δ-rules.
N ∈ Val (λx.B)N =βV [N/x]B
(βV )
Val ::= x | λx.Λ
7 / 18
◮ λV in [Plotkin, 1975] without primitive constants and δ-rules.
N ∈ Val (λx.B)N =βV [N/x]B
(βV )
Val ::= x | λx.Λ
◮ Why values as non applications?
An irreducible application may become a divergent term when the free variables in it are substituted by other terms [Plotkin, 1975].
7 / 18
◮ λV in [Plotkin, 1975] without primitive constants and δ-rules.
N ∈ Val (λx.B)N =βV [N/x]B
(βV )
Val ::= x | λx.Λ
◮ Why values as non applications?
An irreducible application may become a divergent term when the free variables in it are substituted by other terms [Plotkin, 1975]. “Preserving confluence by preserving potential divergence”.
7 / 18
◮ Call-by-value solvability [Paolini and Ronchi Della Rocca, 1999]:
M is v-solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =βV I. The order n of a v-unsolvable M informs about the number of preceding lambdas in the term, i.e., M =βV λx1 . . . λxn.B.
◮ The v-unsolvables of order 0 can be equated in a consistent way
[Paolini and Ronchi Della Rocca, 1999].
◮ Domain H constructed from canonical solution of equation
D ∼ = [D →⊥ D]⊥ [Egidi et al., 1991]. The v-unsolvable terms of order 0 denote ⊥ in H.
◮ Standard reduction in λV [Plotkin, 1975] is complete.
Does ‘complete’ imply ‘standard’?
8 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent.
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . .
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆ →∗
βV . . .
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆ →∗
βV . . .
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆ →∗
βV (λy.∆)V ′ ∆
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆ →∗
βV (λy.∆)V ′ ∆
→βV ∆ ∆ ≡ Ω
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆ →∗
βV (λy.∆)V ′ ∆
→βV ∆ ∆ ≡ Ω →βV . . .
9 / 18
Ω and U ≡ (λy.∆)(x I)∆ are observationally equivalent. Consider the context (λx.[ ])V (λx.Ω)V →βV Ω →βV . . . (λx.(λy.∆)(x I)∆)V →βV (λy.∆)(V I)∆ →∗
βV (λy.∆)V ′ ∆
→βV ∆ ∆ ≡ Ω →βV . . .
◮ Differences in sequentiality.
9 / 18
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =βV I. M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =βV N ∈ NFV .
10 / 18
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =βV I.
Ch[M] =βV N ∈ NFV .
. . .
10 / 18
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =βV I.
Ch[M] =βV N ∈ NFV .
. . . The U ≡ (λy.∆)(x I)∆ is a counterexample which is not transformable.
10 / 18
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =βV I [Paolini and Ronchi Della Rocca, 1999].
Ch[M] =βV N ∈ NFV [our research].
. . . The U ≡ (λy.∆)(x I)∆ is a counterexample which is not transformable.
10 / 18
◮ Reconsider definition of solvability in λV :
M is solvable iff there exists Ch[ ] ≡ (λx1 . . . xm[ ])N1 . . . Nn such that Ch[M] =βV N ∈ NFV . solvable = transformable + freezable A term which is freezable into a NFV is also operational relevant!
◮ Generalisation of needed reduction [Barendregt et al., 1987] to λV . ◮ HV = {M =βV N | M, N ∈ Λ0 unsolvables of the same order}+V is
a consistent theory. E.g., HV ⊢ λx.Ω =βv λx.(λy.∆)(x I)∆.
◮ A theory or a model is ω-sensible if it satisfies HV . ◮ Hereditary quasi-chest reduction (see next slides) characterises
complete strategies. Now ‘complete’ implies ‘hereditary quasi-chest’!
11 / 18
M ≡ C[R] is needed iff R (or some residual of it) is contracted in every reduction sequence ending in λV normal form: M ≡ C[R] →βV . . . →βV N ∈ NFV
12 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) N(N))+ N(x) = x− N(λx.B) = (λx.N(B))− N(M N) = (N(M) N(N))−
λx.(λy.y(λz.M1))(x(λt.M2)) λx
λz M1
λt M2
13 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) A(N))+ A(x) = x− A(λx.B) = (λx.B(B))− A(M N) = (A(M) A(N))− B(x) = x− B(λx.B) = (λx.B(B))− B(M N) = (B(M) B(N))−
λx.(λy.y(λz.M1))(x(λt.M2)) λx
λz M1
λt M2
13 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) A(N))+ A(x) = x− A(λx.B) = (λx.B(B))− A(M N) = (A(M) A(N))− B(x) = x− B(λx.B) = (λx.B(B))− B(M N) = (B(M) B(N))−
λx.(λy.y(λz.M1))(x(λt.M2)) λx
λz M1
λt M2
13 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) A(N))+ A(x) = x− A(λx.B) = (λx.B(B))− A(M N) = (A(M) A(N))− B(x) = x− B(λx.B) = (λx.B(B))− B(M N) = (B(M) B(N))−
(λx.(λy.y +(λz.M−
1 )−)+(x−(λt.M− 2 )−)−)+
λx+
λy +
y + λz− M−
1
x− λt− M−
2
13 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) A(N))+ A(x) = x− A(λx.B) = (λx.B(B))− A(M N) = (A(M) A(N))− B(x) = x− B(λx.B) = (λx.B(B))− B(M N) = (B(M) B(N))− rc(x) = x rc(λx.B) = λx.rc(B) rc(M N) = rc(M)bv(N) bv(x) = x bv(λx.B) = λx.B bv(M N) = bv(M)bv(N)
λx.(λy.y(λz.M1))(x(λt.M2)) λx
λz M1
λt M2
13 / 18
P(x) = x+ P(λx.B) = (λx.P(B))+ P(M N) = (P(M) A(N))+ A(x) = x− A(λx.B) = (λx.B(B))− A(M N) = (A(M) A(N))− B(x) = x− B(λx.B) = (λx.B(B))− B(M N) = (B(M) B(N))− ch(x) = x ch(λx.B) = λx.ch(B) ch(M N) = bv(M)bv(N) bv(x) = x bv(λx.B) = λx.B bv(M N) = bv(M)bv(N)
λx.(λy.y(λz.M1))(x(λt.M2)) λx
λz M1
λt M2
13 / 18
CHNF ::= x | λx.CHNF | Stuck WNFV ::= Val | Stuck Val ::= x | λx.Λ Stuck ::= x WNFV | (λx.Λ)Stuck | Stuck WNFV
14 / 18
CHNF ::= x | λx.CHNF | Stuck WNFV ::= Val | Stuck Val ::= x | λx.Λ Stuck ::= x WNFV | (λx.Λ)Stuck | Stuck WNFV λx1 . . . xn. (λyp.Bp) ( . . . ((λy1.B1)(z W 0
1 . . . W 0 m0)W 1 1 . . . W 1 m1)
. . . )W p
1 . . . Mp mp
λx1 λxn
Bp
B1
W 0
1
W 0
m0
W 1
1
W 1
m1
W p
1
W p
mp 14 / 18
(λx.x ∆)(x I)∆ (λx.Ω)
15 / 18
(λx.x ∆)(x I)∆ (λx.Ω)
◮ Mark-test-contract algorithm
◮ Positive subterms checked for solvability, negative subterms checked
◮ Stops anytime a (sub)term is freezable, avoiding to diverge when it is
not transformable.
◮ On-line implementation at
http://babel.ls.fi.upm.es/~agarcia/talks/DomainsXI
15 / 18
◮ Reconsider the definition of solvability in λV . ◮ The λv normal forms informs about sequentiality. ◮ Generalisation of needed reduction to λV . ◮ Hereditary chest reduction characterises complete strategies in λV . ◮ Semi-decision procedure for solvability in λV . ◮ Consistent theory HV equates unsolvables of the same order. ◮ A theory or model is ω-sensible iff it satisfies HV .
16 / 18
Questions:
◮ Fully abstract model w.r.t. HV ? ◮ Böhm trees for λV ?
17 / 18
Questions:
◮ Fully abstract model w.r.t. HV ? ◮ Böhm trees for λV ?
⊥ω ⊥1 ⊥0
17 / 18
Questions:
◮ Fully abstract model w.r.t. HV ? ◮ Böhm trees for λV ?
⊥ω ⊥1 ⊥0
17 / 18
Abramsky, S. (1990). The lazy lambda calculus. In Turner, D. A., editor, Research Topics in Functional Programming, pages 65–116. Addison-Welsey, Reading, MA. Barendregt, Kennaway, Klop, and Sleep (1987). Needed reduction and spine strategies for the lambda calculus. Information and Computation, 75(3):191–231. Barendregt, H. (1984). The Lambda Calculus, Its Syntax and Semantics. North Holland. Barendregt, H. P. (1971). Some Extensional Term Models for Combinatory Logics and Lambda Calculi. Ph.D. thesis, University of Utrecht, Utrecht, NL.
17 / 18
Egidi, L., Honsell, F., and Ronchi della Rocca, S. (1991). The lazy call–by–value λ–calculus. In Tarlecki, A., editor, Proceedings of Mathematical Foundations of Computer Science. (MFCS ’91), volume 520 of LNCS, pages 161–169, Berlin, Germany. Springer. Espírito Santo, J. (2007). Completing Herbelin’s programme. In Typed Lambda Calculi and Applications, 8th International Conference, TLCA 2007, Paris. Hindley, J. and Seldin, J. (2008). Lambda-calculus and combinators, an introduction. Cambridge University Press. Milner, R. (1990). Functions as processes. Research Report 1154, INRIA.
18 / 18
Paolini, L. and Ronchi Della Rocca, S. (1999). Call-by-value solvability. ITA, 33(6):507–534. Plotkin, G. (1975). Call-by-name, call-by-value and the lambda calculus. Theoretical Computer Science, 1:125–159. Wadsworth, C. (1976). The relation between computational and denotational properties for Scott’s D∞ models. Siam J. Comput., 5(3):488–521.
19 / 18
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ ≡ (λy.z)Ω z (recall ∆ ≡ (λx.x x))
17 / 18
(λx.(λy.z)(x ∆))∆ (λx.z)∆ (λy.z)∆ ∆ ≡ (λy.z)Ω z (recall ∆ ≡ (λx.x x))
17 / 18
Chs[ ] ::= [ ] | Chs[ ] Λ | λx.Chs[ ] Chr[ ] ::= [ ] | Cbn[ ] Λ | λx.Chr[ ] Cbn[ ] ::= [ ] | Cbn[ ] Λ
17 / 18
Crc[ ] ::= [ ] | Λ Cbv[ ] | Crc[ ] WNFV | λx.Crc[ ] Cbv[ ] ::= [ ] | Λ Cbv[ ] | Cbv[ ] WNFV Cch[ ] ::= [ ] | Λ Cbv[ ] | Cbv[ ] WNFV | λx.Cch[ ] Cbv[ ] ::= [ ] | Λ Cbv[ ] | Cbv[ ] WNFV
17 / 18
Any strategy which eventually contracts the redices in the head of the active components of a term is complete with respect to normal form.
17 / 18
Any strategy which eventually contracts the redices in the head of the active components of a term is complete with respect to normal form.
Any strategy which eventually contracts the leftmost redex is complete with respect to normal form.
17 / 18
Any strategy which eventually contracts the redices in the head of the active components of a term is complete with respect to normal form.
Any strategy which eventually contracts the leftmost redex is complete with respect to normal form.
Any strategy which is complete with respect to normal form eventually contracts the leftmost redex.
17 / 18
Any strategy which eventually contracts the redices in the head of the active components of a term is complete with respect to normal form.
Any strategy which eventually contracts the leftmost redex is complete with respect to normal form.
Any strategy which is complete with respect to normal form eventually contracts the leftmost redex. (It turns out that the leftmost redex is in positive position with respect to the leftmost active component, and hence it is not discardable!)
17 / 18
Any λV -strategy which eventually contracts the redices in the chest of the active components of a term is complete with respect to λV normal form.
18 / 18
Any λV -strategy which eventually contracts the redices in the chest of the active components of a term is complete with respect to λV normal form.
Any λV -strategy which is complete with respect to λV normal form eventually contracts the redices in the chest of the active components of a term.
18 / 18