Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K. is lazy: Der Process (durch Epizeuxis) #50

Open
hornc opened this issue Nov 17, 2020 · 5 comments
Open

K. is lazy: Der Process (durch Epizeuxis) #50

hornc opened this issue Nov 17, 2020 · 5 comments

Comments

@hornc
Copy link

hornc commented Nov 17, 2020

A Kafkaesque, esoteric, Nano NaNoGenMo, Meow inspired epizeuxical "lengthy work of fiction" attempt in Lazy-K.

It may not be possible to bring the final code length under 256 characters of SKI combinators to make this 'Nano', but I'll try.

This began as an attempt to understand SKI combinator calculus by programming "something practical" using it.

An initial version of the code that produces the exactly 50K word long text comes in at 1276 bytes (not nano :( ) is:

K(IS(SI(K(S(K(S(S(KS)K)(S(S(KS)K)I)))(S(S(KS)K)I(S(S(KS)K)(SII(S(S(KS)K)I)))))))(K(S(SI(K(S(S(KS)K)(S(K(S(S(KS)K)(SII(S(S(KS)K)I))))(S(S(KS)K)I(S(S(KS)K)(S(S(KS)K)I)))))))(K(S(SI(K(S(K(S(S(KS)K)I))(S(SII)I(S(S(KS)K)I)))))(K(S(SI(K(S(S(KS)K)(S(K(SII(S(S(KS)K)I)))(S(S(KS)K)(S(S(KS)K)I(S(S(KS)K)(SII(S(S(KS)K)I)))))))))(K(S(SI(K(S(S(KS)K)(S(K(S(S(KS)K)I))(S(S(KS)K)(S(K(S(S(KS)K)I))(S(S(KS)K)(SII(S(S(KS)K)(S(S(KS)K)I))))))))))(K(S(S(KS)K)(S(S(KS)K)I)(S(S(KS)K)(S(S(KS)K)I(S(S(KS)K)(SII(S(S(KS)K)I))))(S(S(KS)K)(S(K(S(S(S(KS)K))(SII)(S(S(KS)K)I)))(S(K(S(S(KS)K)I))(S(S(KS)K)(SII(S(S(KS)K)I)))))(S(K(S(K(S(SI(K(S(K(S(S(KS)K)I))(S(SII)I(S(S(KS)K)I)))))))K))(S(K(S(K(S(SI(K(S(K(SII(S(S(KS)K)I)))(SII(S(S(KS)K)(S(S(KS)K)I))))))))K))(S(K(S(K(S(SI(K(S(SII)I(S(S(KS)K)I)(S(S(KS)K))(S(SII)(S(S(KS)K))(S(S(KS)K)I)))))))K))(S(K(S(K(S(SI(K(S(S(KS)K)(S(S(KS)K)I(S(S(KS)K)(S(K(S(S(KS)K)I))(S(S(KS)K)(SII(S(S(KS)K)I)))))))))))K))(S(K(S(K(S(SI(K(S(S(KS)K)I(S(S(KS)K)(S(K(S(S(KS)K)I))(S(S(KS)K)(SII(S(S(KS)K)I))))))))))K))(S(K(S(SI(K(S(S(KS)K)(S(SII)I(S(S(KS)K)I))(S(S(KS)K))(SII(S(S(KS)K)(S(S(KS)K)I))))))))K))))))))(S(SI(K(S(S(KS)K)(S(S(KS)K)I)(S(S(KS)K)I))))(K(S(SI(K(S(S(KS)K)(S(K(S(S(KS)K)(SII(S(S(KS)K)I))))(S(S(KS)K)I(S(S(KS)K)(S(S(KS)K)I)))))))(K(K(SII(SII(S(S(KS)K)I)))))))))))))))))))

Plan:

  • Attempt to reduce hardcoded text by accepting input -- Church encoded ASCII values take up a lot of space. This seems like the best bet for reducing code size.
  • If I can't make input work, or if it the input processing code is still way more that 256 bytes, I will create a internationalised suite of generators to produce the same "novel" in a variety of languages. Planned translations: English, German, French, Latin, and Spanish.
  • Ideal goal: have the language selection handled in Lazy-K, but I doubt I'm going to manage that.

Inspirational quote:

"A short while later, K. was lying in his bed. He very soon went to sleep, but before
he did he thought a little while about his behaviour, he was satisfied
with it but felt some surprise that he was not more satisfied."

Important note on pronunciation: For the purposes of this project, 'K.' refers to Franz Kafka's fictional character Josef K., and is to be pronounced as the German letter: 'kah'.

@hornc
Copy link
Author

hornc commented Nov 17, 2020

at 1376 bytes, the hardcoded German translation (or original?):

K(S(SI(K(S(K(S(S(KS)K)(S(S(KS)K)I)))(S(S(KS)K)I(S(S(KS)K)(SII(S(S(KS)K)I)))))))(K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SI(K(S(S(KS)K)(S(S(KS)K)I)(S(S(KS)K)I))))(K(S(SI(K(S(S(KS)K)(S(K(S(S(KS)K)(SII(S(S(KS)K)I))))(S(S(KS)K)I(S(S(KS)K)(S(S(KS)K)I)))))))(K(K(SII(SII(S(S(KS)K)I)))))))))))))))))))))

@hornc
Copy link
Author

hornc commented Nov 19, 2020

repo is live here: https://github.com/hornc/K-IS

samples and documentation to come soon...

@hornc
Copy link
Author

hornc commented Nov 19, 2020

Some sample (truncated) output:

K-IS_en.lazy:

K. is lazy, lazy, lazy, lazy, lazy, lazy, ... lazy, lazy, lazy, lazy, lazy, lazy, lazy.

K-IS_la.lazy:

K. piger, piger, piger, piger, piger, pige ... r, piger, piger, piger, piger, piger est.

K-IS_de.lazy:

K. ist faul, faul, faul, faul, faul, faul, ... faul, faul, faul, faul, faul, faul, faul.

and coming soon:

K-IS_existential_oulipo.lazy:

K. is, is, is, is, is, is, is, is, is, is, ... , is, is, is, is, is, is, is, is, is, is.

@hornc
Copy link
Author

hornc commented Nov 19, 2020

I noticed the original code K(S(SI(K... could be modified to K(IS(SI(K... without changing the functionality, which suggests a further (Oulipian?) version of the novel, where "K. is sick, sick, sick ..." is the novel, produced from combinators which begin the same way.

The existential Oulipian (in that the novel only contains letters present in the lazy K source, i.e. S, K, and I) text above is probably my best chance at making a 'nano' version.

Unfortunately producing the protagonist's one-letter-one-punctuation-symbol name takes 188 bytes in Lazy-K:

S(K(
  S(K(
  S(SI(K(S(K(S(S(KS)K)(S(S(KS)K)I)))(S(S(KS)K)I(S(S(KS)K)(SII(S(S(KS)K)I)))))))))
K))(
  S(K(
  S(SI(K(S(S(KS)K)(S(K(S(S(KS)K)(SII(S(S(KS)K)I))))(S(S(KS)K)I(S(S(KS)K)(S(S(KS)K)I)))))))))
K)

I tried optimising the string output to use a 'function' to try and compress commonalities in the characters, and succeeded in increasing the size to about 300 bytes. That was interesting, but not very helpful. There isn't much to compress over two characters, the function may be able to save something over longer strings, but there's no way to get anything much happening in this language in under 256 characters.

Since the Unlambda notation of Lazy-K has only four symbols each could be encoded in 2 bits:
` 00
I 01
K 10
S 11

Dividing the byte-size of the Unlambda representation of a Lazy-K source file (which tends to be smaller than the combination bracketed version) by 4 is a way to get something down to a theoretical byte size. The existential_oulipo version is a candidate for a minimalism there.

@hugovk hugovk added the preview label Nov 19, 2020
@hornc
Copy link
Author

hornc commented Nov 30, 2020

November is running out, I have a bunch of versions as PDF output: https://github.com/hornc/K-IS/tree/master/output

I'm struggling to write everything up in a way that makes sense, which is the problem I had last year.

The 'nano' attempt 'K.`s I: an Existential Oulipean Trial by Epizeuxis' is not an unqualified success -- I managed to produce a reduced scope 50k word novel in exactly 1024 bytes of Unlambda syntax Lazy-K . Lazy-K is NOT a golfing language, that is about as small as any program that produces output can get.

Using the information-bit-compression trick mentioned above it can be compressed down to 256 bytes if we accept that each source-symbol represents 2-bits of information. I did manage to golf down the Scheme code used to generate that to 256 bytes, which I was pleased about. Combined, that feels like it counts for something.

Die Krankheit is a kind of phonetic pattern poem of Lazy-K source code, which generates a thematically related 50k word novel. This one I wrote directly in Lazy-K after figuring out the basic structure using the previous Scheme Lazy-K generator. It has lots of redundant Identity combinators and whitespace to creatively emphasise the theme.

There is a bunch of other languages there and a few other variations I am planning to complete. Please feel free to correct any of my grammar or translations. I used Google translate cross references with other sources, but have probably made mistakes. The same qualities that made this 'novel' easy to code in something as awkward as Lazy-K also made it (theoretically) easy to translate into many languages, so once I had established the limits of Lazy-K, this project became more of an excercise in comparative linguistics.

The base version is very simple, but hopefully the range of translations make it more interesting. I'm most pleased with the Hittite version, and would love someone to proofread it for me to let me know how close I got to what I was attempting.

If there is anything to say about 2020, at least I can say I generated a fifty-thousand word novel in Hittite using combinator calculus... Thanks @dariusk and @hugovk for hosting again!

repo again: https://github.com/hornc/K-IS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants