# grig/combinators

Fixed markdown.

1 parent 964127c commit be83f787b9642239d56010b7e37ead13936f96a0 committed Mar 4, 2009
Showing with 44 additions and 45 deletions.
1. +24 −24 combinators1-5.md
2. +0 −1 combinators1.md
3. +10 −10 combinators6.md
4. +10 −10 combinators8.md
48 combinators1-5.md
 @@ -1,11 +1,11 @@ -# See http://github.com/raganwald/homoiconic/tree/master/2008-11-12/combinator_chemistry.md +See http://github.com/raganwald/homoiconic/tree/master/2008-11-12/combinator_chemistry.md -** Intro +# Intro sxyz = xz(yz) kxy = x -** Exercises +# Exercises (ss)kkk = sk(kk)k = kk((kk)k) = kkk = k kkk(ss) = k(ss) @@ -35,42 +35,42 @@ A little more advanced exerciaes: is there a molecule, let us called it I, havin Ix = skkx = kx(kx) = x -** New programming exercises: +## New programming exercises: Find combinators M, B, W, L, T such that Mx = xx -*** Solution +### Solution xx = Ix(Ix) = SIIx => M = SII -** B +## B Bxyz = x(yz) -*** Solution +### Solution x(yz) = S?yz, ?z = x. Kxz = x => x(yz) = S(Kx)yz = ((KS)x)(Kx)yz = S(KS)Kxyz B = S(KS)K -** W +## W Wxy = xyy -*** Solution +### Solution xyy = (xy)y = = (xy)(?xy) = (xy)(KIxy) = Sx(KIx)y = Sx((KI)x)y = SS(KI)xy -*** Check: +### Check: SS(KI)xy = Sx(KIx)y = xy(KIxy) = xy(Iy) = xyy W = SS(KI) -** L +## L Lxy = x(yy) -*** Solution +### Solution Lxy = x(yy) = (Kxy)(yy) = S(Kx)yy = (KSx)(Kx)yy = S(KS)Kxyy = S(KS)K(Wxy) @@ -88,43 +88,43 @@ Find combinators M, B, W, L, T such that L = S(S(KS)K)(KM) -*** Check +### Check S(S(KS)K)(KM)xy = S(KS)Kx(KMx)y = S(KS)KxMy = (KSx)(Kx)My = S(Kx)My = (Kxy)(My) = x(My) = x(yy) -*** Another solution +### Another solution x(yy) = Bxyy = (Bx)yy = W(Bx)y = BWBxy -*** check +### check BWBxy = W(Bx)y -- dynamics of B = (Bx)yy -- dynamics of W = Bxyy = x(yy) -** T +## T Txy = yx -*** Solution +### Solution yx = y(Kxy) = (Iy)(Kxy) = SI(Kx)y = (K(SI)x)(Kx)y = S(K(SI))Kxy T = S(K(SI))K Txy = S(K(SI))Kxy = (K(SI)x)(Kx)y = SI(Kx)y = Iy(Kxy) = yx -*** Another +### Another yx = y(Kxy) = SI(Kx)y = B(SI)Kxy -** C +## C Cxyz = xzy -*** Solution 1 +### Solution 1 xzy = xz(Kyz) = Sx(Ky)z = K(Sx)y(Ky)z = S(K(Sx))Kyz = S((KKx)(Sx))Kyz = S(S(KK)Sx)Kyz = ((KS)x)((S(KK)S)x)Kyz @@ -134,23 +134,23 @@ Find combinators M, B, W, L, T such that C = S(S(KS)(S(KK)S))(KK) -*** Solution 2 +### Solution 2 xzy = xz(Kyz) = Sx(Ky)z = B(Sx)Kyz = BBSxKyz = BBSx(KKx)yz = S(BBS)(KK)xyz C = S(BBS)(KK) -** INFINITY +## INFINITY INFINITY dynamically transform into INFINITY itself. -*** Solution +### Solution MM = MM, thus, INFINITY = MM -** S +## S We have seen how to program the blue bird B, the cardinal C and the Warbler W with the kestrel K and the starling S. Could you define the
1 combinators1.md
 @@ -1 +0,0 @@ -Find file: ~/Projects/combinators/[exercises.txt]
20 combinators6.md
 @@ -1,4 +1,4 @@ -* Question: is there a systematic method such that giving any behavior like +Question: is there a systematic method such that giving any behavior like Xxyztuv = x(yx)(uvut) (or what you want) @@ -12,11 +12,11 @@ Well actually I will be rather busy so I give you the definition of a paradoxica First show that for any combinator A there is a combinator B such that AB = B. B is called a fixed point of A. (like the center of a wheel C is a fixed point of the rotations of the wheel: RC = C). It is a bit amazing that all combinators have a fixed point and that is what I propose you try to show. Here are hints for different arguments. 1) Show how to find a fixed point of A (Arbitrary combinator) using just B, M and A. (Mx = xx I recall). 2) The same using just the Lark L (Lxy = x(yy) I recall). Now, a paradoxical combinator Y is just a combinator which applied on that A will give the fixed point of A; that is YA will give a B such that AB = B, that is A(YA) gives YA, or more generally Y is a combinator satisfying Yx = x(Yx). -** Problem: fixed point of A +## Problem: fixed point of A Show that for any combinator A there is a combinator B such that AB = B -*** Solution +### Solution Ax = x, x=? @@ -51,17 +51,17 @@ let X' = SX'', then X' = BSM X = M(BSM) -** Check: +### Check: M(BSM)yz = BSM(BSM)yz = S(M(BSM))yz -Fixpoint of I: +## Fixpoint of I: Ix = x any combinator is a fixpoint of I -Fixpoint of K +## Fixpoint of K Kx = x Kxy = xy = x, that is, x is such that for all y @@ -83,7 +83,7 @@ Search X as M(X') X = M(BKM) -** Fixpoint of B +## Fixpoint of B BX = X @@ -95,17 +95,17 @@ Xyz = M(BBM)yz = BBM(BBM)yz = B(M(BBM))yz = BXyz X = M(BBM) = BBM(BBM) = B(M(BBM)) = BX -** Fixpoint of M +## Fixpoint of M X = M(BMM) Xy = M(BMM)y = BMM(BMM)y = M(M(BMM))y -** Fixpoint of A +## Fixpoint of A X = M(BAM) = BAM(BAM) = A(M(BAM)) = AX -* Y +# Y YA = M(BAM)
20 combinators8.md
 @@ -10,14 +10,14 @@ been replaced by a variable a). This is a traditional (non recursive) exercise. Then YB gives the solution of the recursive equation. (Y is the traditional name for a paradoxical combinator). Exercise: why? -** Solution +## Solution B(YB) = YB B(YB)xyz = xx(YB)(YByy)z = YBxyz let YB = A, then Axyz = xxA(Ayy)z -* exercises +# exercises Find an infinite eliminator E, that is a bird which eliminates all its variables: Ex = E, Exy = E, etc. @@ -31,49 +31,49 @@ Etc. I mean: solve the following equations (little letters like x, y z are put for any combinator, A is put for the precise combinator we are ask searching for): -Ax = A +# Ax = A -** solution +## solution Let's find B such that Bax = a B = K A = YB = YK = SLLK -* Ax = xA +# Ax = xA Bax = xa B = T = B(SI)K A = YB = YT = SLLT -* Axy = Ayx +# Axy = Ayx Baxy = ayx B = C A = YB = YC -* Ax = AAx +# Ax = AAx Bax = aax aax = (aa)x = Max, so B = M, A = YB = YM -* A = AA +# A = AA Ba = aa B = M => A = YM -* Ax = AA +# Ax = AA Xax = aa aa = Ma = K(Ma)x = BKMax X = BKM A = YX = YBKM -* Ax = x(Ax) +# Ax = x(Ax) Bax = x(ax) x(ax) = Ix(ax) = SIax