separability of the lambda calculus and term rewriting
play

Separability of the Lambda Calculus and Term Rewriting Systems - PowerPoint PPT Presentation

Separability of the Lambda Calculus and Term Rewriting Systems Department of Computer Science Kyungsung University Sugwoo Byun 19 August 2003 Contents 1. Head normal form in the -Calculus 2. B ohm trees 3. Separability of the


  1. Separability of the Lambda Calculus and Term Rewriting Systems Department of Computer Science Kyungsung University Sugwoo Byun 19 August 2003

  2. Contents 1. Head normal form in the λ -Calculus 2. B¨ ohm trees 3. Separability of the λ -calculus 4. Sequentiality of the λ -calculus 5. B¨ ohm-out transformation technique 6. Lambda Definability of Term Rewriting Systems 7. Separable Systems 8. Encoding of Separable Systems 9. Correctness Reference: H. Barendregt. The Lambda Calculus: Its Syntax and Semantics . North-Holland. 1984. Separability 03 PL Workshop - 1

  3. Head Normal Form in the λ -calculus • M is a hnf ( head normal form ) if M has the form M ≡ λx 1 · · · x n .yN 1 · · · N k Ω ≡ ( λx.xx )( λx.xx ). λx.Ix Ω has no normal form, but has an hnf λx.x Ω. Each normal form is a hnf. • Consistent Theory Let T be a formal theory with equations as formulas. Then T is consistent if T does not prove every closed equation. • T = { M = N | M, N ∈ Λ K without normal form } . Then T is not consistent. Proof. Let M ≡ λx.xK Ω , N ≡ λx.xS Ω. Then M = N ∈ T . Hence T ⊢ K = MK = NK = S • In λ K-calculus meaningless ⇔ no hnf ⇒ no nf Separability 03 PL Workshop - 2

  4. • In λ I-calculus meaningless ⇔ no nf • Head Reduction If M is of the form M ≡ λx 1 · · · x n . ( λx.M 0 ) M 1 · · · M k n ≥ 0 , k ≥ 1 ( λx.M 0 ) M 1 is called head redex . We write M − → N if a head redex is chosen to be reduced. If the selected h redex is not a head redex, it is an internal redex and its reduction is written as M − → N . i • Standard Reduction. Let ∆ 0 ∆ 1 ∆ 2 σ : M 0 − → M 1 − → M 2 − → · · · be a reduction. σ is called a standard reduction if ∀ i ∀ j < i ∆ i is not a ‘residual’ of a redex to the left of ∆ j . We write M − → N if there is a s Separability 03 PL Workshop - 3

  5. standard reduction σ : M − → N . • Example. λa. ( λb. ( λc.c ) bb ) d − → λa. ( λb.bb ) d − → λa.dd. not standard λa. ( λb. ( λc.c ) bb ) d − → λa. ( λc.c ) dd − → λa.dd. standard → ∗ N , then M − ∗ N such that • Standardization Theorem If M − → s → ∗ → ∗ ∃ Z M − Z − N i h Separability 03 PL Workshop - 4

  6. B¨ ohm Trees → • BT ( M ), the B¨ ohm tree of M ≡ λ x.yM 1 · · · M k – if M is undefined, BT ( M ) = ⊥ → – if M ≡ λ x.y � � BT ( M 1 ) · · · BT ( M k ) • Example – BT ( S ) = λabc.a � � c · · · b | c – BT ( Sa Ω) = λc.a λc.ac (Ω c ) � � c · · · ⊥ Separability 03 PL Workshop - 5

  7. – BT ( Y ) = λf.f | f | . . . ≡ λf.ω f ω f ω f ≡ λx.f ( xx ) ω f ω f = f ( ω f ω f ) Y Separability 03 PL Workshop - 6

  8. Separability of the λ -calculus • Separability. Let T = { M 1 , · · · , M p } be a set of λ -terms. 1. If T ⊆ Λ 0 , then T is called separable if ∀ N 1 · · · N p ∈ Λ ∃ F ∈ Λ FM 1 = N 1 = FM 2 N 2 · · · · · · = FM p N p → → → 2. If T ⊆ Λ, then T is separable if its closure λ x. T = { λ x.M 1 , · · · , λ x.M p } is separable. • Distinct Terms. T is distinct if T consists of one element or some α ∈ Seq is ‘useful’ for T and the ∼ α equivalence classes of elements of T are all distinct. • Let M ≡ λx 1 · · · x n .yM 1 · · · M m and N ≡ λx 1 · · · x n ′ .y ′ M 1 · · · M m ′ . Then M ∼ N iff y ≡ y ′ and n − m = n ′ − m ′ Separability 03 PL Workshop - 7

  9. �∼ ∼ λx.y λy.y λx.x λyz.y | | | � � M M M M N • Separability Theorem . T is separable ⇔ T is distinct Being given a constructive proof, we can find a λ -term F in the separable equations. Separability 03 PL Workshop - 8

  10. Sequentiality of the λ -calculus • The λ -calculus is sequential . “parallel-or” functions cannot be definable in the λ -calculus (by Plotkin 1997). = por x T T = por T x T • The computation of a definable λ -calculus function is sequential rather than parallel (by Berry 1978.) • No F ∈ Λ such that FMN = I if M or N is solvable = unsolvable else Such an F is clearly parallel computable (simultaneously try to find the hnf of M and N ; if you find one, then give output I , else give no output). Separability 03 PL Workshop - 9

  11. B¨ ohm-out Transformation Primitive functions • <M 0 , . . . , M n > ≡ λz.zM 0 · · · M n . • U n i ≡ λx 1 . . . x n .x i (selection). • P n ≡ λx 1 . . . x n . <x 1 , . . . , x n > = λx 1 . . . x n x n +1 .x n +1 x 1 . . . x n (permutation). Algorithm of B¨ ohm-out π α T : a set of λ -terms , α ∈ BT ( M ) 1. π f – transform T into λ -free form. ( ) π f = ( ) x 1 · · · x n . Separability 03 PL Workshop - 10

  12. π f transformation λx 1 . . . x n .y y ⇒ = 1 m 1 m x k x n π f . . . . . . Figure 1: Transformation π f 2. π o – transform T π f into original form. ( ) π o = ( ) a 1 · · · a p +1 [ y := P p ], (a) The head variable at the root Separability 03 PL Workshop - 11

  13. π o transformation (a) The head variable at the root a q +1 y P q ⇒ = = m a m +1 a q +1 1 m a m +1 a q 1 m 1 π o . . . . . . . . . (b) Internal node having a head variable λ� z.y λ� z. P q λ� z.x p +1 . . . x q +1 .x q +1 ⇒ = = 1 1 1 p p p x p +1 x q π o . . . . . . * * . . . * Figure 2: Transformation π o Separability 03 PL Workshop - 12

  14. 3. π s – select one of following success terms. ( ) π s = ( )[ z := U n j ], where α = j · α ′ . π s transformation - select a subterm at j U q z j = ⇒ = π s 1 · · · j 1 · · · j · · · m a m +1 a q m a m +1 a q * * * * Figure 3: Transformation π s 4. Repeat the above procedures with ((( T ) π f ) π o ) π s until α ′ becomes empty. Separability 03 PL Workshop - 13

  15. Lambda Definability of Term Rewriting Systems • Question [RTA‘90] “Which rewrite systems can be directly defined in the λ -calculus? One has to find λ -terms representing rewrite system operators such that a rewrite step in TRS translates to a reduction in the λ -calculus.” • Main Idea 1. Define a separable system : f ( a 11 , a 12 , . . . , a 1 n ) → b 1 f ( a 21 , a 22 , . . . , a 2 n ) → b 2 · · · · · · f ( a m 1 , a m 2 , . . . , a mn ) → b m Let P f = { ( a 11 , a 12 , . . . , a 1 n ), ( a 21 , a 22 , . . . , a 2 n ), · · · , ( a m 1 , a m 2 , . . . , a mn ) } . The f -rules are separable if P f is ‘distinct’. Each element of P f is in a B¨ ohm tree. Separability 03 PL Workshop - 14

  16. 2. Define a homogeneous function φ ( P f ) such that φ ( P f ) is a set of distinct λ -terms. Then, by B¨ ohm’s separability theorem, φ ( f ) is obtained such that s → t implies φ ( s ) → ∗ φ ( t ). Separability 03 PL Workshop - 15

  17. Separable Systems E.g. F ( x, A, B, C, S ( D )) → 1 F ( B, x, A, C, S ( D )) → 2 F ( A, B, x, C, S ( E )) → 3 is separable. Each separable system has a separation tree. Separability 03 PL Workshop - 16

  18. 5 5.1 4 4 3 1 2 2 2 Separation Tree Figure 4: Separation Tree Separability 03 PL Workshop - 17

  19. Encoding of Separable Systems Example A (0 , x ) → x A ( S ( x ) , y ) → S ( A ( x, y )) A separation tree U T = 1 Assume φ c (0) = < 0 > , φ c ( S ) = λx. < 2 , x> . Then, φ p (0 , y ) = < < 0 >, � > , φ p ( S ( x ) , y ) = < < 2 , � >, � > , and α = 1 · 1. The whole encoding π = π 1 · π α · α ′ . • π α · α ′ : B¨ ohm-out terms at α · α ′ • π 1 : pass terms matches with variables at LHS to ones at RHS. Then, φ ( A ) = Y ( λax.x U 2 1 P 2 U 3 1 U 2 1 ( λb. < 2 , ( a < ( x U 2 1 U 2 2 ) , ( x U 2 2 ) > ) > ) ( x U 2 2 )) Separability 03 PL Workshop - 18

  20. Reductions A ( S (0) , 0) → S ( A (0 , 0)) → S (0) are simulated as follows. φ ( A ( S (0) , 0)) = φ ( A ) φ p ( S (0) , 0) = φ ( A ) <φ ( S (0)) , φ (0) > = φ ( A ) < < 2 , < 0 > >, < 0 > > ≡ Y ( λax.x U 2 1 P 2 U 3 1 U 2 1 ( λb. < 2 , ( a < ( x U 2 1 U 2 2 ) , ( x U 2 ) ( x U 2 2 ) > ) > 2 )) < < 2 , < 0 > >, < 0 > > → ∗ < 2 , ( φ ( A ) < < 0 >, < 0 > > ) > → ∗ < 2 , < 0 > (= φ ( S (0)) ) > Separability 03 PL Workshop - 19

  21. Correctness 1. s → ∗ t = ⇒ φ ( s ) → ∗ φ ( t ). 2. Let s include no operator normal term. Then, φ ( s ) → ∗ φ ( t ) = ⇒ s → ∗ t . 3. If s has a normal form, then φ ( s ) has a β -normal form. Separability 03 PL Workshop - 20

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend