Énigme combinatoire!

12

Introduction: logique combinatoire

La logique combinatoire (CL) est basée sur des choses appelées combinateurs , qui sont essentiellement des fonctions. Il existe deux combinateurs de base "intégrés" Set K, qui seront expliqués plus loin.

Associativité gauche

CL est associatif à gauche , ce qui signifie que les parenthèses (contenant des éléments) qui sont à l'extrême gauche de la paire d'anthères de parenthèses le contenant peuvent être supprimées, avec ses éléments libérés. Par exemple, quelque chose comme ceci:

((a b) c)

Peut être réduit à

(a b c)

Où se (a b)trouve à l'extrême gauche du support le plus grand ((a b) c), il peut donc être retiré.

Un exemple beaucoup plus grand d'association à gauche (les crochets sont des explications):

  ((a b) c ((d e) f (((g h) i) j)))
= (a b c ((d e) f (((g h) i) j)))   [((a b) c...) = (a b c...)]
= (a b c (d e f (((g h) i) j)))     [((d e) f...) = (d e f...)]
= (a b c (d e f ((g h i) j)))       [((g h) i) = (g h i)]
= (a b c (d e f (g h i j)))         [((g h i) j) = (g h i j)]

Les supports peuvent également être réduits lorsque plusieurs paires s'enroulent autour des mêmes objets. Exemples:

((((a)))) -> a
a ((((b)))) -> a b
a (((b c))) -> a (b c) [(b c) is still a group, and therefore need brackets.
                        Note that this doesn't reduce to `a b c`, because
                        `(b c)` is not on the left.]

Builtins

CL a deux combinateurs "intégrés", Set K, qui peuvent commuter des objets (combinateurs simples, ou un groupe de combinateurs / groupes enroulés autour de crochets) comme ceci:

K x y = x
S x y z = x z (y z)

x, yet zpeut remplacer n'importe quoi.

Un exemple de Set Ksont comme suit:

  (S K K) x [x is a stand-in for anything]
= S K K x   [left-associativity]
= K x (K x) [S combinator]
= x         [K combinator]

Un autre exemple:

  S a b c d
= a c (b c) d [combinators only work on the n objects to the right of it,
               where n is the number of "arguments" n is defined to have -
               S takes 3 arguments, so it only works on 3 terms]

Les exemples ci-dessus sont des instructions CL normales, dans lesquelles l'instruction ne peut pas être évaluée plus avant et atteint un résultat final en un temps limité. Il existe des instructions non normales (qui sont des instructions CL qui ne se terminent pas et continueront d'être évaluées pour toujours), mais elles ne relèvent pas de la portée du défi et n'auront pas besoin d'être couvertes.

Si vous voulez en savoir plus sur CL, lisez cette page Wikipedia .

Tâche:

Votre tâche consiste à créer des combinateurs supplémentaires, compte tenu du nombre d'arguments et de ce à quoi il correspond en entrée, ce qui est donné comme suit:

{amount_of_args} = {evaluated}

{amount_of_args}est un entier positif égal au nombre d'arguments, et se {evaluated}compose de:

  • arguments jusqu'à la quantité d'arguments, avec 1le premier argument, 2le deuxième, etc.
    • Vous êtes assuré que les nombres d'arguments supérieurs au nombre d'arguments (donc un 4quand {amount_of_args}est seulement 3) n'apparaîtront pas {evaluated}.
  • supports ()

Voici donc des exemples d'entrées:

3 = 2 3 1
4 = 1 (2 (3 4))

La première entrée demande un combinateur (disons R) avec trois arguments ( R 1 2 3), qui évalue ensuite:

R 1 2 3 -> 2 3 1

La deuxième entrée le demande (avec un nom de combinateur A):

A 1 2 3 4 -> 1 (2 (3 4))

Compte tenu de l'entrée dans ce format, vous devez renvoyer une chaîne de S, Ket ()qui, lorsqu'elle est substituée par un nom de combinateur et exécutée avec des arguments, renvoie la même instruction évaluée que le {evaluated}bloc lorsque le bloc de commande est substitué en arrière pour ce nom de combinateur.

L'instruction de combinateur de sortie peut voir ses espaces supprimés et les crochets externes supprimés, de sorte que quelque chose comme (S K K (S S))peut être transformé en SKK(SS).

Si vous voulez tester les sorties de votre programme, @aditsu a fait un analyseur logique combinatoire (qui inclut S, K, Iet même d' autres comme Bet C) ici .

But:

Puisqu'il s'agit d'un , l'objectif de ce défi est d'atteindre le plus petit nombre d'octets possible en sortie, compte tenu de ces 50 cas de test . Veuillez mettre vos résultats pour les 50 cas de test dans la réponse, ou créer une boîte à pâte (ou quelque chose de similaire) et publier un lien vers cette boîte à pâte.

En cas d'égalité, la première solution l'emporte.

Règles:

  • Votre réponse doit renvoyer une sortie CORRECT - donc étant donné une entrée, elle doit retourner la sortie correcte selon la définition de la tâche.
  • Votre réponse doit sortir dans une heure sur un ordinateur portable moderne pour chaque cas de test.
  • Tout codage en dur des solutions est interdit. Cependant, vous êtes autorisé à coder en dur jusqu'à 10 combinateurs.
  • Votre programme doit renvoyer la même solution à chaque fois pour la même entrée.
  • Votre programme doit renvoyer un résultat valide pour toute entrée donnée, pas seulement des cas de test.
clismique
la source
Comment pouvez-vous vous assurer que les gens ne voleront pas les combinateurs trouvés dans d'autres réponses?
Fatalize
@Fatalize Cela ne devrait pas trop d'importance, car les gens peuvent s'inspirer des réponses des autres et s'appuyer sur cela pour créer de meilleures réponses.
clismique
En parlant d'inspiration, je remarque que lorsque le résultat souhaité ne contient pas de 1, vous pouvez soustraire 1de tout, puis envelopper la solution pour cette réponse K(). Exemple: Solution pour 2 -> 1is K, donc solution pour 3 -> 2is KK, solution pour 4 -> 3is K(KK)etc.
Neil

Réponses:

8

Haskell , score 5017

Ceci combine l'algorithme le plus stupide possible pour l'élimination de l'abstraction ((λ x . X ) = I; (λ x . Y ) = K y ; (λ x . M N ) = S (λ x . M ) (λ x . N ) ) avec un optimiseur de judas utilisé après chaque application. La règle d'optimisation la plus importante est S (K x ) (K y ) ↦ K ( xy ), ce qui empêche l'algorithme de toujours exploser de façon exponentielle.

L'ensemble de règles est configuré comme une liste de paires de chaînes, il est donc facile de jouer avec de nouvelles règles. En plus de la réutilisation de l'analyseur d'entrée à cet effet, S, K et I sont également acceptés dans les combinateurs d'entrée.

Les règles ne sont pas appliquées sans condition; au lieu de cela, les anciennes et les nouvelles versions sont conservées et les versions sous-optimales ne sont élaguées que lorsque leur longueur dépasse celle de la meilleure version de plus d'une constante (actuellement 3 octets).

Le score est légèrement amélioré en traitant I comme un combinateur fondamental jusqu'à ce que l'étage de sortie le réécrit dans SKK. De cette façon, KI = K (SKK) peut être raccourci de 4 octets à SK en sortie sans confondre le reste des optimisations.

{-# LANGUAGE ViewPatterns #-}

import qualified Data.IntMap as I
import qualified Data.List.NonEmpty as N
import System.IO

data Term
  = V Int
  | S
  | K
  | I
  | A (N.NonEmpty (Int, Term, Term))
  deriving (Show, Eq, Ord)

parse :: String -> (Term, String)
parse = parseApp . parse1

parseApp :: (Term, String) -> (Term, String)
parseApp (t, ' ':s) = parseApp (t, s)
parseApp (t, "") = (t, "")
parseApp (t, ')':s) = (t, ')' : s)
parseApp (t1, parse1 -> (t2, s)) =
  parseApp (A (pure (appLen (t1, t2), t1, t2)), s)

parse1 :: String -> (Term, String)
parse1 (' ':s) = parse1 s
parse1 ('(':(parse -> (t, ')':s))) = (t, s)
parse1 ('S':s) = (S, s)
parse1 ('K':s) = (K, s)
parse1 ('I':s) = (I, s)
parse1 (lex -> [(i, s)]) = (V (read i), s)

ruleStrings :: [(String, String)]
ruleStrings =
  [ ("1 3(2 3)", "S1 2 3")
  , ("S(K(S(K1)))(S(K(S(K2)))3)", "S(K(S(K(S(K1)2))))3")
  , ("S(K(S(K1)))(S(K2))", "S(K(S(K1)2))")
  , ("S(K1)(K2)", "K(1 2)")
  , ("S(K1)I", "1")
  , ("S(S(K1)2)(K3)", "S(K(S1(K3)))2")
  , ("S(SI1)I", "S(SSK)1")
  ]

rules :: [(Term, Term)]
rules = [(a, b) | (parse -> (a, ""), parse -> (b, "")) <- ruleStrings]

len :: Term -> Int
len (V _) = 1
len S = 1
len K = 1
len I = 3
len (A ((l, _, _) N.:| _)) = l

appLen :: (Term, Term) -> Int
appLen (t1, S) = len t1 + 1
appLen (t1, K) = len t1 + 1
appLen (K, I) = 2
appLen (t1, t2) = len t1 + len t2 + 2

notA :: Term -> Bool
notA (A _) = False
notA _ = True

alt :: N.NonEmpty Term -> Term
alt ts =
  head $
  N.filter notA ts ++
  [A (N.nub (a N.:| filter (\(l, _, _) -> l <= minLen + 3) aa))]
  where
    a@(minLen, _, _) N.:| aa =
      N.sort $ do
        A b <- ts
        b

match :: Term -> Term -> I.IntMap Term -> [I.IntMap Term]
match (V i) t m =
  case I.lookup i m of
    Just ((/= t) -> True) -> []
    _ -> [I.insert i t m]
match S S m = [m]
match K K m = [m]
match I I m = [m]
match (A a) (A a') m = do
  (_, t1, t2) <- N.toList a
  (_, t1', t2') <- N.toList a'
  m1 <- match t1 t1' m
  match t2 t2' m1
match _ _ _ = []

sub :: I.IntMap Term -> Term -> Term
sub _ S = S
sub _ K = K
sub _ I = I
sub m (V i) = m I.! i
sub m (A a) =
  alt $ do
    (_, t1, t2) <- a
    pure (sub m t1 & sub m t2)

optimize :: Term -> Term
optimize t = alt $ t N.:| [sub m b | (a, b) <- rules, m <- match a t I.empty]

infixl 5 &

(&) :: Term -> Term -> Term
t1 & t2 = optimize (A (pure (appLen (t1, t2), t1, t2)))

elim :: Int -> Term -> Term
elim n (V ((== n) -> True)) = I
elim n (A a) =
  alt $ do
    (_, t1, t2) <- a
    pure (S & elim n t1 & elim n t2)
elim _ t = K & t

paren :: String -> Bool -> String
paren s True = "(" ++ s ++ ")"
paren s False = s

output :: Term -> Bool -> String
output S = const "S"
output K = const "K"
output I = paren "SKK"
output (V i) = \_ -> show i ++ " "
output (A ((_, K, I) N.:| _)) = paren "SK"
output (A ((_, t1, t2) N.:| _)) = paren (output t1 False ++ output t2 True)

convert :: Int -> Term -> Term
convert 0 t = t
convert n t = convert (n - 1) (elim n t)

process :: String -> String
process (lex -> [(n, lex -> [((`elem` ["=", "->"]) -> True, parse -> (t, ""))])]) =
  output (convert (read n) t) False

main :: IO ()
main = do
  line <- getLine
  putStrLn (process line)
  hFlush stdout
  main

Essayez-le en ligne!

Production

  1. S (KS) K
  2. S (K (SS (KK))) (S (KK) S)
  3. S (K (SS)) (S (KK) K)
  4. S (K (SS (KK))) (S (KK) (S (KS) (S (K (S (SKK))) K))))
  5. S (K (S (K (SS (SK))))) (S (K (SS (SK))) (S (SKK) (SKK)))
  6. KK
  7. S (K (S (S (KS) (S (K (S (SKK))) K)))) (S (KK) K)
  8. S (K (SS (K (S (KK) (S (SKK) (SKK))))))) (S (SSK (KS)) (S (S (KS) (S (KK) (S (KS) K))) (K (S (K (S (SSK))) K))))
  9. S (K (S (KK))) (S (K (S (S (SKK) (SKK)))) K)
  10. SK
  11. S (KS) (S (KK) (S (K (SS)) (S (KK) K)))
  12. S (K (SS (K (S (KK) K)))) (S (KK) (S (KS) (S (SSK (KS)) (S (K (SS)) (S (KK) K) ))))
  13. S (K (S (K (S (K (SS (KK)))) (S (KK) S))))) (S (K (SS (KK))) (S (KK) (S (KS) (S (K (S (SKK))) K))))
  14. S (K (S (K (S (K (SS (KK)))) (S (KK) S))))) (S (K (S (SKK))) K)
  15. S (K (S (K (S (KS) K))))) (S (KS) K)
  16. S (K (S (KS) K))
  17. S (K (S (K (S (K (SS (K (S (S (KS)) (S (KK) (SSK))) (K (S (SKK) (SKK))))))) (S (KK) (S (KS) K)))))) (S (K (SS (K (SSK))))) S (KK) (S (KS) (S (KK) (SSK))))) )
  18. SSS (KK)
  19. KK
  20. S (KK) (S (KK) (S (S (KS) K) (S (K (S (SKK)))) (S (K (S (SKK))) K))))
  21. S (S (KS) (S (KK) (S (KS) (S (KK) (S (K (SS)) (S (KK) K))))))) (K (S (K (S ( S (KS) (S (K (S (SKK))) K)))) (S (KK) K))))
  22. S (KK)
  23. S (KS) (S (KK) (S (KS) (S (KK) (S (K (SS)) (S (KK) K))))))
  24. S (K (S (K (S (KS) K))))) (S (K (S (S (KS) (S (KK) (S (K (SS)) (S (KK) K)))) ))) (S (KK) (S (K (SS)) (S (KK) K)))))
  25. S (KS) (S (KK) (S (KS) K))
  26. S (S (KS) (S (KK) (S (KS) (S (KK) (S (K (S (K (SS (KK)))))) (S (KS) (S (KK) (S (SSK (KS)) (S (KS) (S (SKK) (SKK))))))))))) (K (S (S (KS) (S (K (S (K (S (KS) ) (S (K (S (KS) (S (K (S (SKK))) K)))))))) (S (K (S (SKK))) K))) (S (K ( S (K (S (KK) K)))) (S (K (S (SKK))) K))))
  27. S (K (S (K (S (K (SS (K (S (K (S (S (KS)) (S (K (S (SKK))) K))))) (S (KK) K)) ))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K (SS))) (S (KK) K))))) (S ( KK) (S (KS) (S (KK) (S (K (SS)) (S (KK) K)))))))
  28. K (S (KK))
  29. S (K (S (K (S (K (S (K (S (KS) K))))) (S (K (S (S (KS) (S (KK) (S (K (SS))) ( S (KK) K)))))) K))))) (S (K (S (S (KS) (S (KK) (S (K (SS)) (S (KK) K)))) ))) (S (KK) (S (K (SS)) (S (KK) K)))))
  30. S (KK) (S (K (SSS (KK)))))
  31. K (SSS (KK))
  32. S (K (SS (K (S (S (KS) (S (KK) (S (KS) K)))) (K (S (K (S (SKK))) K)))))) (S (KK) (S (KS) (SS (S (S (KS) (S (KK) (S (KS) (S (K (S (KS) (S (KK) (S (KS) K))))) )))))) (KK))))
  33. S (K (S (K (S (K (S (K (SS (KK)))) (S (KK) S))))))) (S (K (SS (K (S (KK) K)) ))) (S (KK) (SSS (KS))))
  34. S (K (S (K (S (KK) K)))))
  35. S (K (S (K (S (K (S (K (SS (K (S (K (S (SKK))) K)))) (S (KK) (S (KS) (S (KK) (S (K (SS (K (S (K (S (SKK)))) K)))) (S (KK) (S (K (SS)) (S (KK) K))))))) )))))) (S (K (S (S (KS) (S (K (S (SKK))) K)))) (S (KK) K))
  36. S (K (SS (K (S (K (SS (K (S (K (S (SKK)))) K)))) (S (KK) (S (KS) (SS (S (S (KS)) (S (KK) (S (KS) (S (K (S (SKK))) K))))) (KK)))))))) (S (KK) (S (KS) (S ( KK) (S (K (S (K (S (K (S (K (S (K (SS (KK)))) (S (KK) S)))))))))) (S (K (SS (KK))) (S (KK) (S (KS) (S (K (S (KS) (S (KK) (S (KS) K)))))))))))))
  37. S (KK) (S (K (S (K (S (KK) (S (KK) K)))))) (SS (SK)))
  38. K (S (K (SSS (KK))))
  39. S (K (S (K (S (K (S (K (S (K (S (K (S (K (SS (K (S (K (S (K (S (K (S (SKK) ))) K)))) (S (KK) K))))) (S (KK) (S (KS) K)))))) (S (K (SS (K (S (K (SS) )) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K (SS))) (S ( KK) K))))) (S (KK) (S (KS) K)))))))) S (K (SS (K (S (K (SS))) (S (KK) K)) ))) (S (KK) (S (KS) (S (KK) (S (K (SS)) (S (KK) K)))))))
  40. S (K (S (KK))) (S (KS) (S (KK) (S (K (S (KK) (S (KK) K)))))))
  41. S (K (SS (K (S (S (KS) (S (KK) (S (KS) K)))) (K (S (K (S (SKK))) K)))))) (S (KK) (S (KS) (S (KK) (S (K (S (K (S (K (SS (K (S (K (SS))) (S (KK) K))))) (S (KK) (S (KS) K)))))) (S (K (SS (K (S (KK) (S (K (SS)) K)))))) (S (KK) (S ( K (SS)) (S (KK) (S (K (S (K (S (KK) (S (KS) K)))))) (S (KS) K))))))))))
  42. S (K (S (K (S (K (S (K (S (K (S (K (S (K (S (K (S (K (SS) K (S (K (S (S (KS)) (S (K (S (SKK))) K)))) (S (KK) K)))))) (S (KK) (S (KS) K)))))))) (S (K (SS (K (S (K (SS)) (S (KK) K))))) (S (KK) (S (KS) K)))))))) (S (K (SS (K (S ( K (SS)) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K (SS)))) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K (SS))) (S (KK) K))))) (S (KK) (S (KS) (S (KK) (S (K (SS)) (S (KK) K)))))))
  43. K (K (K (K (K (S (KK) (S (KK) (S (K (SS (SK))) (SSK)))))))))
  44. S (KK) (S (K (S (KK) (S (KK) (S (KK) (S (KK) K)))))))
  45. S (K (S (K (S (K (S (K (S (K (S (K (S (K (S (K (S (K (S (K (S (K K (S (S (KS) (S (K (S (SKK))) K)))) (S (KK) K))))) (S (KK) (S (KS) K))))) )) (S (K (SS (K (S (K (SS))) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S ( K (SS (K (S (K (SS))) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K (SS)) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K ( SS)) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K (SS)))) (S (KK) K))))) (S (KK) (S (KS) (S (KK) (S (K (SS)) (S (KK) K)))))))
  46. S (K (S (K (S (K (S (K (S (K (SS (K (S (K (S (K (S (K (S (K (SS (KK))))) (S (KK) (S ( KS) (S (K (S (SKK))) K))))))) (S (KK) (S (KS) (S (KK) (S (SSK (KS))) (S (K (SS )) (S (KK) K)))))))))) (S (KK) (S (KS) (S (KK) (S (K (SS (K (S (KK)) (S (KS) ) (S (KK) (S (K (SS (K (S (KK) (S (KS) K)))))) (S (KK) (S (K (SS)) (S (KK) (S (K (SS (K (S (KK) K))))) (S (KK) S)))))))))))) (S (KK) (S (K (SS)) K)) )))))))) (S (K (SS (K (S (KK)) (S (K (S (S (KS) (S (KK) (S (K (SS))) (S (KK) K)))))) (S (KK) (S (K (SS)) (S (KK) K)))))))) (S (KK) S))))))) (S (K (SS (K (S (K (S (S (KS) (S (KK)) (S (K (SS)) (S (KK) K))))))) (S (KK) (S (K ( SS)) (S (KK) K))))))) (S (KK) (S (KS) (S (KK) (S (K (S (K (S (KS) (S (KK)) ( S (KS) K)))))) (S (KS) (S (KK) (S (K (SS)) (S (KK) K))))))))))
  47. S (K (SS (K (SS (S (S (KS) (S (KK) S)))) (KK))))) (S (KK) (S (KS) (S (K (S (K (S (KS) (S (KK) (S (KS) (S (KK) (S (K (S (K (S (K (SS) K (S (K (S (S (KS)) (S (K) KK) (S (K (SS)) (S (KK) K)))))) (S (KK) (S (K (SS)) (S (KK) K))))))) (S (KK) (S (KS) K)))))))))))))) (S (K (S (S (KS)) (S (KK) (S (K (SS))) (S ( KK) (S (K (S (K (S (KS) K))))) S (K (SS (K (S (K (SS))) (S (KK) K))))) (S ( KK) (S (KS) (S (KK) (S (K (SS)) (S (KK) K)))))))))))))) (S (KK) (S (K (S) (K (S (KK) (S (KS) (S (KK) (S (K (SS (K (S (KK) (S (KS) K))))))) (S (KK) (S (K (SS)) K))))))))) (S (KS) (S (KK) (S (K (SS (K (S (KK) K))))) (S (KK) (S ( KS) (S (SSK (KS)) (S (K (SS (KK)))) (S (KK) (S (KS) (S (K (S (SKK))) K)))))))) ))))))))))
  48. K (S (K (S (KK) (S (K (S (KK) (S (K (S (KK) (S (KK) K)))))))))))
  49. S (KK) (S (K (S (K (S (KK) (S (K (S (K (S (KK)) (S (K (S (K (S (KK)) (S (K (S ( K (S (KK) (S (K (S (KK))) (S (K (S (SKK))) K)))))) (S (K (S (SKK))) K))) ))) (S (K (S (SKK))) K)))))) (S (K (S (SKK))) K)))))) (S (K (S (SKK)))) K))
  50. S (K (S (K (S (K (S (K (S (K (S (KK))))) (S (K (SS (K (S (K (S (S (KS) (S (K ( S (SKK))) K)))) (S (KK) K))))) (S (KK) (S (KS) K)))))))) (S (K (SS (K (S (K (S (K (SS)) (S (KK) K))))) (S (KK) (S (KS) K))))))) (S (K (SS (K (S (K (SS)) ) (S (KK) K))))) (S (KK) (S (KS) (S (KK) (S (K (S (K (S (KK) (S (KK) (S (KK)) (S (KK) K))))))) (S (K (SS)) (S (KK) K))))))))
Anders Kaseorg
la source
Serait-il possible de rendre les expressions auto-optimisées (par exemple S (K x) (K y) = K (x y))?
CalculatorFeline
@CalculatorFeline Je ne comprends pas votre question; S (K x ) (K y ) est automatiquement optimisé en K ( xy ).
Anders Kaseorg
Attendez, ces expressions sont-elles représentées comme des fonctions partiellement appliquées ou autre chose? Si les fonctions sont partiellement appliquées, alors vous pourriez peut-être faire quelque chose comme mon dernier commentaire.
CalculatorFeline
@CalculatorFeline La représentation ressemble, par exemple, à 3 = 1 (2 3) ↦ 2 = S (K1) (S (K2) I) ↦ 2 = S (K1) 2 ↦ 1 = S (S (KS) (S (KK) (K1))) I ↦ 1 = S (S (KS) (K (K1))) I ↦ 1 = S (K (S (K1))) I ↦ 1 = S (K (S (K1) ))) I ↦ 1 = S (K1) ↦ S (KS) (S (KK) I) ↦ S (KS) K. Comme vous pouvez le voir, nous avons déjà utilisé la règle S (K x ) (K y ) ↦ K ( xy ) plusieurs fois, ainsi que les autres dans lesquelles je les ai énumérées ruleStrings. Sinon, la sortie serait exponentiellement plus longue: pour ce petit exemple, nous aurions obtenu S (S (KS) (S (S (KS) (S (KK) (KS)))) (S (S (KS) (S (KK) (KK))) (S (KK) (SKK))))) (S (S (KS) (S (S (KS) (S (KK) (KS)))) ( S (S (KS) (S (KK) (KK))) (SK)))) (S (KK) (SK))) au lieu de S (KS) K.
Anders Kaseorg
5

Somme des longueurs de solution: 12945 8508 5872

Code Haskell qui prend les lignes d'entrée de stdin et ne se soucie pas si le séparateur est =ou ->:

data E=S|K|V Int|A E E deriving Eq

instance Show E where
  showsPrec _ S = showChar 'S'
  showsPrec _ K = showChar 'K'
  showsPrec _ (V i) = shows i
  showsPrec p (A e f) = showParen (p>0) $ showsPrec 0 e . showsPrec 1 f

type SRead a = String -> (a,String) -- a simpler variation of ReadS

parse :: String -> E
parse s = let (e,"")=parseList (s++")") in e
parseList :: SRead E
parseList s = let (l,s')=parseL s in (foldl1 A l,s')
parseL :: SRead [E]
parseL (c:s) | c==' ' = parseL s
             | c==')' = ([],s)
parseL s = let (p,s')=parseExp s; (l,s'')=parseL s' in (p:l,s'')
parseExp :: SRead E
parseExp ('(':s) = parseList s
parseExp s = let [(n,s')]=reads s in (V n,s')

k e = A K e
s e f = A (A S e) f
i = s K K
s3 e f g = A (s e f) g
sk = A S K
ssk e f = A (s3 S K e) f

n `invars` (A e f) = n `invars` e || n `invars` f
n `invars` (V m)   = n==m
_ `invars` _       = False

comb (A e f) = comb e && comb f
comb (V _)   = False
comb _       = True

abstract _ (A (A S K) _) = sk
abstract n e | not (n `invars` e) = k e
abstract n (A e (V _)) | not (n `invars` e) = e
abstract n (A (A (V i) e) (V j)) | n==i && n==j =
                                   abstract n (ssk (V i) e)
abstract n (A e (A f g)) | comb e && comb f =
                                   abstract n (s3 (abstract n e) f g)
abstract n (A (A e f) g) | comb e && comb g =
                                   abstract n (s3 e (abstract n g) f)
abstract n (A (A e f) (A g h)) | comb e && comb g && f==h =
                                   abstract n (s3 e g f)
abstract n (A e f) = s (abstract n e) (abstract n f)
abstract n _ = i

abstractAll 0 e = e
abstractAll n e = abstractAll (n-1) $ abstract n e

parseLine :: String -> (Int,E)
parseLine s = let [(n,s')] = reads s
                  s''=dropWhile(`elem` " =->") s'
              in (n, parse s'')

solveLine :: String -> E
solveLine s = let (n,e) = parseLine s in abstractAll n e

main = interact $ unlines . map (show . solveLine) . lines

Il implémente l'abstraction améliorée des crochets de la section 3.2 de John Tromp: Calcul binaire Lambda et logique combinatoire qui est liée à l'article de Wikipedia sur la logique combinatoire. Les cas spéciaux les plus utiles utilisent uniquement le Scombinateur pour assouplir les sous-termes afin d'éviter l'imbrication profonde des variables. Le cas qui vérifie l'égalité de certains sous-termes n'est nécessaire pour aucun des cas de test. Bien qu'il n'y ait pas de cas particulier pour gérer le Wcombinateur (voir la réponse de Peter), les règles fonctionnent ensemble pour trouver l' SS(SK)expression la plus courte . (J'ai d'abord fait une erreur en essayant d'optimiser les appels internes vers abstract, puis cette Woptimisation n'a pas eu lieu et le résultat global était de 16 octets de plus.)

Et voici les résultats des cas de test:

S(KS)K
S(K(S(K(SS(KK)))K))S
S(K(S(K(SS))K))K
S(K(S(K(S(K(S(K(SS(KK)))K))S))(S(SKK))))K
S(K(S(K(SS(SK)))))(S(K(SS(SK)))(S(SKK)(SKK)))
KK
S(K(S(K(S(S(K(S(KS)(S(SKK))))K)))K))K
S(K(S(K(SS(K(S(KK)(S(SKK)(SKK))))))(S(KS))))(S(K(S(K(S(K(SS(K(S(K(S(SSK)))K))))K))S))K)
S(K(S(K(S(KK)))(S(S(SKK)(SKK)))))K
SK
S(K(S(K(S(K(S(S(KS)(S(KS)))))K))K))K
S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(KK)K))))K))S))(S(KS))))(SS)))K))K
S(K(S(K(S(K(S(K(SS(KK)))K))S))))(S(K(S(K(S(K(S(K(SS(KK)))K))S))(S(SKK))))K)
S(K(S(K(S(K(S(K(S(K(SS(KK)))K))S))))(S(SKK))))K
S(K(S(K(S(K(S(K(S(K(SS(K(S(KS)K))))K))S))K))S))K
S(K(S(KS)K))
S(S(K(S(KS)(S(K(S(KS)(S(KS)))))))(S(K(S(K(S(K(S(K(S(K(SS(K(S(S(K(S(KS)(S(KS))))(S(K(S(K(S(K(SS(K(S(S(KS)(S(K(SS(K(S(SKK)(SKK)))))K))K))))K))S))K))(S(KK)K)))))K))S))K))S))K))(S(K(S(KK)K))K)
S(KK)(S(KK))
KK
S(K(S(KK)K))(S(S(KS)K)(S(K(S(K(S(SKK)))(S(SKK))))K))
S(K(S(K(S(K(S(S(K(S(K(S(K(S(KS)(S(KS))))(S(S(K(S(KS)(S(SKK))))K))))K))K)))K))K))K
S(KK)
S(K(S(K(S(K(S(K(S(S(KS)(S(K(S(KS)(S(KS))))))))K))K))K))K
S(K(S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)K))K))))K))S))(S(K(S(KS)(S(KS)))))))(S(S(KS)(S(KS))))))K))K))K
S(K(S(K(S(KS)K))S))K
S(K(S(K(S(K(S(K(SS(KK)))(S(KS))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(K(S(KS)(S(SKK))))K))))))))(S(SKK))))K)(S(K(S(K(S(K(S(KK)K))))(S(SKK))))K)))))K))S))K))S))K))S))(S(SKK)(SKK)))
S(K(S(K(S(K(S(K(S(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(KS)))))))(S(S(K(S(K(S(K(S(KS)(S(KS))))(S(S(K(S(KS)(S(SKK))))K))))K))K))))K))K))K)))K))K))K))K
K(S(KK))
S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)K))K))))K))S))(S(K(S(KS)(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)K))K))))K))S))(S(K(S(KS)(S(KS)))))))(S(S(KS)(S(KS))))))K))K))K)
S(KK)(S(K(S(KK)(S(KK)))))
K(S(KK)(S(KK)))
S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)))(S(K(S(K(S(K(SS(K(S(K(S(SKK)))K))))K))S))K)))))K))S))K))S))(S(K(S(K(S(K(S(KS)K))S))K)))
S(K(S(K(S(K(S(K(S(K(SS(KK)))K))S))))))(S(K(S(K(S(K(SS(K(S(KK)K))))K))S))(S(KS)))
S(K(S(K(S(KK)K))))
S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(S(K(S(K(S(KS)(S(K(S(K(S(KS)(S(SKK))))K)))))(S(SKK))))K)))K))K))K))))))(S(S(K(S(KS)(S(SKK))))K))))K))K
S(K(S(K(S(K(S(K(S(K(S(K(S(K(SS(KK)))K))S))))))))))(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)))(S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(K(S(KK)))(S(SKK))))K))))K))S))K))S))(S(SKK))))K)))))K))S))K))S))(S(K(S(K(S(K(S(KS)K))S))K))))
S(K(S(KK)(S(K(S(K(S(KK)K))K)))))(SS(SK))
K(S(K(S(KK)(S(KK)))))
S(K(S(K(S(K(S(K(S(K(S(K(S(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))(S(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(KS)))))))(S(S(K(S(K(S(K(S(KS)(S(KS))))(S(S(K(S(KS)(S(SKK))))K))))K))K))))K))K))K))))K))K))K))K))))K))K))K))K))K)))K))K))K))K))K))K
S(K(S(K(S(K(S(KK)(S(K(S(K(S(KK)K))K)))))))S))K
S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)K))K))))K))S))(S(K(S(KS)(S(KS)))))))(S(S(K(S(K(S(KS)K))S))K))))K))))(S(K(S(K(S(K(SS(K(S(K(S(SKK)))K))))K))S))K)))))K))S))K))S))K))S))K))S))K))S))K
S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))(S(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(KS)))))))(S(S(K(S(K(S(K(S(KS)(S(KS))))(S(S(K(S(KS)(S(SKK))))K))))K))K))))K))K))K))))K))K))K))K))))K))K))K))K))K))))K))K))K))K))K))K)))K))K))K))K))K))K))K
K(K(K(K(K(S(K(S(KK)K))(S(K(SS(SK)))(SSK)))))))
S(KK)(S(K(S(K(S(K(S(K(S(KK)K))K))K))K)))
S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))(S(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(KS)))))))(S(S(K(S(K(S(K(S(KS)(S(KS))))(S(S(K(S(KS)(S(SKK))))K))))K))K))))K))K))K))))K))K))K))K))))K))K))K))K))K))))K))K))K))K))K))K))))K))K))K))K))K))K))K)))K))K))K))K))K))K))K))K
S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))))))))(S(K(S(K(S(K(S(K(SS(K(S(K(S(K(S(KK)K))K))K))))K))S))(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)K))K))))K))S))(S(K(S(KS)(S(KS)))))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))(S(K(S(K(S(K(S(K(SS(K(S(KK)K))))K))S))(S(KS)))))))(S(S(K(S(KS)(S(KS))))(S(K(S(K(S(K(S(K(SS(KK)))K))S))(S(SKK))))K)))))K))K))K))))K))K))K))K))K))))K))K))K))K))K))K))K)))K))K))K))K))K))K))K))K))K
S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KK)K))K))K))K))K))K))K))))K))S))(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))))))))(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(K(S(K(S(KK)K))K))K))K))))K))S))(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS)))))))))))))(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)K))K))))K))S))(S(K(S(KS)(S(KS)))))))))))))(S(K(S(K(S(K(S(K(SS(K(S(K(S(KK)K))K))))K))S))(S(K(S(KS)(S(KS)))))))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(SS(K(S(K(S(K(S(K(S(K(S(KK)K))))))))(S(K(S(K(SS(KK)))K))S)))))K))S))K))S))K))S))K))S))(S(KS))))(S(K(S(K(S(K(S(K(SS(KK)))K))S))(S(SKK))))K))
K(S(K(S(KK)(S(K(S(KK)(S(K(S(K(S(KK)K))K)))))))))
S(K(S(K(S(KK)(S(K(S(K(S(K(S(KK)(S(K(S(K(S(K(S(KK)(S(K(S(K(S(K(S(KK)(S(K(S(K(S(K(S(KK)(S(KK))))(S(SKK))))K)))))(S(SKK))))K)))))(S(SKK))))K)))))(S(SKK))))K)))))(S(SKK))))K
S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KK)(S(K(S(K(S(K(S(K(S(KK)K))K))K))K)))))))))))(S(S(K(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(K(S(KS)(S(KS))))))))))(S(S(K(S(K(S(K(S(K(S(KS)(S(K(S(KS)(S(KS)))))))(S(S(K(S(K(S(K(S(KS)(S(KS))))(S(S(K(S(KS)(S(SKK))))K))))K))K))))K))K))K))))K))K))K))K))))K))K))K))K))K
Christian Sievers
la source
3

8486 utilisant S, K, I, W

Explication

L'algorithme standard (comme décrit par exemple dans le chapitre 18 de Pour Mock a Mockingbird ) utilise quatre cas, ce qui correspond aux combinateurs S, K, I = SKK, et simple gauche-association. Je pense que c'est ce que la réponse de Christian met en œuvre. C'est suffisant, mais pas nécessairement optimal, et comme nous sommes autorisés à coder en dur jusqu'à 10 combinateurs, il reste 7 options.

D'autres combinateurs combinatoires bien connus sont

B x y z = x (y z)
C x y z = x z y
W x y = x y y

qui, avec K, constituent une base complète . En SK, ce sont

B = S (K S) K
C = S (S (K (S (K S) K)) S) (K K)
W = S S (S K)

et les SKIrègles dérivent ces mêmes expressions pour Bet C, mais pour Welles dérivent S S (K (S K K)). J'ai donc choisi de mettre Wen œuvre comme un cas particulier.

Programme (CJam)

e# A tests whether argument is an array
{W=!!}:A;

e# F "flattens" an expression by removing unnecessary parentheses, although if the expression is a primitive
e# it actually wraps it in an array
{
  e# A primitive is already flat, so we only need to process arrays
  _A{
    ee{
      ~
      e# Stack: ... index elt
      e# First recurse to see how far that simplifies the element
      F
      e# If it's an array...
      _A{
        e# ... we can drop a level of nesting if either it's the first one (since combinator application
        e# is left-associative) or if it's a one-element array
        _,1=@!|{
          e# The tricky bit is that it might be a string, so we can't just use ~
          {}/
        }*
      }{
        \;
      }?
    }%
  }{a}?
}:F;


qN%{

e# Parse line of input
"->=()"" [[[]"er']+~
e# Eliminate the appropriate variables in reverse order. E eliminates the variable currently stored in V.
\,:)W%{
  e# Flatten current expression
  F

  e# Identify cases; X holds the eXpression and is guaranteed to be non-primitive
  :X
  [
    XVa=                  e# [V]
    Xe_V&!                e# case V-free expression
    X)_A0{V=}?\e_V&!*     e# case array with exactly one V, which is the last element
    X_e_Ve=~)>[VV]=X,2>*  e# case array with exactly two Vs, which are the last two elements
  ]
  1#
  e# Corresponding combinators
  [
    {;"SKK"}              e# I
    {['K\]}               e# K
    {);}                  e# X (less that final V)
    {););['S 'S "SK"]\a+} e# W special-cased as SS(SK) because the general-case algorithm derives SS(K(SKK))
    {['S\)E\E\]}          e# S (catch-all case)
  ]=~
}:EfV

e# Format for output
F
{
  _A{
    '(\{P}%')
  }*
}:P%

oNo}/

Suite de tests en ligne

Sorties générées:

S(KS)K
S(S(KS)(S(KK)S))(KK)
S(K(SS))(S(KK)K)
S(S(KS)(S(KK)(S(KS)(S(K(S(SKK)))K))))(KK)
S(K(S(K(SS(SK)))))(S(K(SS(SK)))(S(SKK)(SKK)))
KK
S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K)
S(S(KS)(S(K(S(KS)))(S(S(KS)(S(KK)(S(KS)K)))(K(S(S(KS)(S(K(S(SKK)))K))(K(SKK)))))))(K(S(KK)(S(SKK)(SKK))))
S(K(S(KK)))(S(K(S(S(SKK)(SKK))))K)
K(SKK)
S(K(S(S(KS)(S(KS)))))(S(KK)(S(KK)K))
S(S(KS)(S(KK)(S(KS)(S(K(S(KS)))(S(K(SS))(S(KK)K))))))(K(S(KK)K))
S(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(S(KS)(S(KK)(S(KS)(S(K(S(SKK)))K))))(KK))))))(K(KK))
S(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(K(S(SKK)))K)))))(K(KK))
S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)K)))))(K(S(KS)K))
S(K(S(KS)))(S(KK))
S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)K)))))(K(S(S(KS)(S(K(S(KS)))(S(S(KS)(S(KK)(S(KS)K)))(K(S(S(KS)(S(S(KS)K)(K(S(SKK)(SKK)))))K)))))(S(KK)K)))))))(S(KK)(S(KK)K))
S(KK)(S(KK))
KK
S(KK)(S(KK)(S(S(KS)K)(S(K(S(SKK)))(S(K(S(SKK)))K))))
S(K(S(S(KS)(S(K(S(KS)))(S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K))))))(S(KK)(S(KK)K))
S(KK)
S(K(S(S(KS)(S(K(S(KS)))(S(K(S(KS))))))))(S(KK)(S(KK)(S(KK)K)))
S(S(KS)(S(KK)(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(KS)))))(S(KK)(S(KK)K))))))))(K(S(KK)(S(KK)K)))
S(KS)(S(KK)(S(KS)K))
S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(SKK)(SKK)))))))))(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(SKK)))))))(S(K(S(K(S(KK)))))(S(K(S(SKK)))K))))))(S(K(S(KK)))(S(K(S(KK)))(S(K(S(SKK)))K))))))))))(K(K(KK)))
S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K))))))(S(KK)(S(KK)K))))))))(S(KK)(S(KK)(S(KK)K)))
K(S(KK))
S(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(S(KS)(S(KK)(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(KS)))))(S(KK)(S(KK)K))))))))(K(S(KK)(S(KK)K))))))))))(K(K(S(KK)(S(KK)K))))
S(KK)(S(K(S(KK)))(S(K(S(KK)))))
K(S(KK)(S(KK)))
S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(KK))))))))))(K(S(K(S(KK)))(S(S(KS)(S(KK)(S(KS)K)))(K(S(K(S(SKK)))K)))))
S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(KK)))))(S(K(S(K(S(KS)))))(S(S(KS)(S(KK)(S(KS)(S(KS)))))(K(S(KK)K))))))))(K(K(KK)))
S(K(S(K(S(KK)))))(S(K(S(KK))))
S(K(S(K(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(SKK)))))(S(K(S(KK)))(S(K(S(SKK)))K)))))))))))(S(K(S(K(S(KK)))))(S(K(S(K(S(KK)))))(S(K(S(K(S(KK)))))(S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K)))))
S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(KK))))))))))(K(S(K(S(KK)))(S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(K(S(SKK)))K))))))(K(S(K(S(KK)))(S(K(S(SKK)))K))))))))))))))(K(K(K(K(KK)))))
S(KK)(S(K(S(KK)))(S(K(S(KK)))(S(K(S(KK)))(SS(SK)))))
K(S(K(S(KK)))(S(K(S(KK)))))
S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K))))))(S(KK)(S(KK)K))))))))(S(KK)(S(KK)(S(KK)K))))))))))(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K)))))
S(K(S(KK)))(S(K(S(K(S(KK)))))(S(K(S(K(S(KK)))))(S(K(S(K(S(KK)))))(S(KS)K))))
S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)K)))))))))))(K(S(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(S(KS)(S(KK)(S(KS)K)))))))(S(K(S(KK)))(S(S(KS)(S(KK)(S(KS)K)))(K(S(K(S(SKK)))K)))))))))))(K(K(S(KK)(S(KK)K))))))
S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K))))))(S(KK)(S(KK)K))))))))(S(KK)(S(KK)(S(KK)K))))))))))(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K))))))
K(K(K(K(K(S(KK)(S(KK)(S(S(KS)(SSK))(K(SKK)))))))))
S(KK)(S(K(S(KK)))(S(K(S(KK)))(S(K(S(KK)))(S(K(S(KK)))(S(KK))))))
S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K))))))(S(KK)(S(KK)K))))))))(S(KK)(S(KK)(S(KK)K))))))))))(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K)))))))
S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))))(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(KK)))))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(K(S(KS)))(S(S(KS)(S(KK)(S(KS)(S(K(S(SKK)))K))))(KK))))))(S(KK)(S(KK)K))))))))(K(K(S(KK)K))))))))))(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))(K(K(K(S(KK)(S(KK)K))))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))))))(K(K(K(K(S(KK)(S(KK)(S(KK)K))))))))))))))))))(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K))))))))
S(S(KS)(S(K(S(KS)))(S(K(S(KK)))(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))))))(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))))(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(K(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))))(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(K(S(K(S(K(S(KS)))))))))(S(K(S(K(S(K(S(K(S(K(S(KS)))))))))))(S(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(KK)(S(KS)(S(K(S(KS)))(S(S(KS)(S(KK)(S(KS)(S(K(S(SKK)))K))))(KK))))))))))))(K(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(KK)))))))(S(S(KS)(S(KK)S))(KK))))))))))))))(K(K(K(K(S(KK)(S(KK)K))))))))))))))))(K(K(K(K(K(S(KK)(S(KK)K))))))))))))))))))(K(K(K(K(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))))))))))))(K(K(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)(S(KK)K)))))))))
K(S(K(S(KK)))(S(K(S(K(S(KK)))))(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(KK))))))))))
S(KK)(S(K(S(KK)))(S(K(S(K(S(KK)))))(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(K(S(KK)))))))))))(S(K(S(K(S(K(S(K(S(K(S(SKK)))))))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(SKK)))))))))(S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(SKK)))))))(S(K(S(K(S(KK)))))(S(K(S(K(S(SKK)))))(S(K(S(KK)))(S(K(S(SKK)))K))))))))))))))
S(K(S(K(S(K(S(KK)))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(K(S(K(S(K(S(KK)))))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(K(S(K(S(KS)))))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(K(S(KS)))))(S(K(S(S(KS)(S(K(S(KS)))(S(K(S(S(KS)(S(K(S(SKK)))K))))(S(KK)K))))))(S(KK)(S(KK)K))))))))(S(KK)(S(KK)(S(KK)K))))))))))(S(KK)(S(KK)(S(KK)(S(KK)K))))))))))
Peter Taylor
la source