I suspect there's a good chance the answer to this is unknown and hard (or at least extremely tedious), but I figured it would be worth asking.

It's well known that the functions $K:=\lambda x.\lambda y.x$ and $S:=\lambda x.\lambda y.\lambda z.xz(yz)$ together generate all functions of lambda calculus.

It's also possible to do it with just a single function, as mentioned here: If we define $U=\lambda x.xSK$, then we can obtain $K=U(U(UU))$, and $S=U(U(U(UU))$, and thus everything.

It's also possible to do this with $V:=\lambda x.xKS$, since $S=VVV$, and $K=V(VVVVV)$.

What I want to know is, picking a reasonable notion of "length", is there any way that is shorter than $U$ or $V$? Let's say for now that the length is the number of occurrences of a variable, including when they're introduced, so e.g., $K$ has a length of 3, $S$ has a length of 7, and $U$ and $V$ each have length 12. (Or is there a usual notion of "length" that's been studied?) Is it possible to do better than 12, and what's the shortest way?

What if we allow for more than one generator and total the lengths? Then the usual set $\{S,K\}$ does it with 10. (Should we add a penalty for using more than one? Well, I guess you could, but I'm not going to define it that way here. I mean, unless people have studied this problem and already doing it that way...). Can this variant be done in fewer than 10, and what's the shortest?

I don't expect there's any easy way to answer the "what's the shortest" question, but I'm hoping maybe that at least if there is a shorter way that someone will know it or find it.


I believe this is related to finding a single axiom base for intuitionistic propositional calculus. There is a web page by Ted Ulrich on the subject, which discusses many such axioms. However, trying to find the shortest single axiom corresponds to trying to find a combinator with the shortest type (as opposed to your goal finding a combinator with the shortest λ-calculus expression).

Edit: You can take those single axioms and ask Djinn (a Haskell theorem prover) to find functions with corresponding types. For example, taking one of the first axioms in Ted Ulrich's web page, you can ask Djinn:

Djinn> ? x :: ((p -> q) -> r) -> (s -> ((q -> (r ->  t)) -> (q -> t)))

and it answers

x :: ((p -> q) -> r) -> s -> (q -> r -> t) -> q -> t
x a _ b c = b c (a (\ _ -> c))

So expression λazbc.bc(a(λy.c)) has the given type, and it is a candidate for a single combinator you're looking for.

(It is not obvious how to express S and K from such a combinator, but it can be recovered from the proof that forumlas (p→(q→r))→((p→q)→(p→r)) and p→(q→p) can be derived from the single axiom.)

This way, you could generate many possible combinators and see how long they are. Most likely you won't find the shortest one, but you might find some that are shorter than the ones you described. If you do, let us know!

  • $\begingroup$ Interesting! So this gets us one of length 9, then. In fact, looking over these examples, I suspect there is a connection between these two notions of length. HI-1 through HI-10 all yield ones of length 9 (by my measure); observe that each of these, being 17 symbols long if you include the C's, are only 9 symbols long if you don't (in general, number of C's has to be 1 less than number of non-C's). HI-11 and HI-12, however, yield ones of length 11. So perhaps (L+1)/2 is a lower bound on the length I'm looking at, where L is the length of the axiom? This seems plausible. $\endgroup$ – Harry Altman Aug 8 '12 at 16:11
  • 1
    $\begingroup$ Furthermore, checking his open problems page, I see there are only 4 possible single axioms of length shorter than 17 that have not been ruled out; all have length 15. Three of them yield functions of length 8, while C2 yields one of length 10. So if my hypothesis above is correct, and if every single-lambda-generator must come from a single axiom (I don't know this area much at all so it's not clear to me whether this is so), then the answer is either 8 or 9. $\endgroup$ – Harry Altman Aug 8 '12 at 16:34
  • $\begingroup$ @HarryAltman The length of propositional formula and the length of a lambda expression that proves it under Curry-Howard isomorphism can be very different. For example, all formulas of the form τ→τ are proved by λx.x, no matter how long τ is. On the other hand, it is known that the Pigeon-hole principle expressed in propositional logic has an exponentially long proof (in our case, an exponentially long λ-term proving it) but only a polynomially long formula. $\endgroup$ – Petr Aug 8 '12 at 17:14
  • $\begingroup$ But is it possible that the length of the formula yields a lower bound on the length of the lambda expression, as I suggested? $\endgroup$ – Harry Altman Aug 8 '12 at 17:36
  • 1
    $\begingroup$ Are you sure there is a composition of this combinator that generates S or K? I tried running a systematic search but couldn't find one. $\endgroup$ – user76284 Nov 6 '17 at 21:39

I like $W = \lambda x.x K S K$ since it makes $K = W W W$ and $S = W (W W)$, although it is longer than either $U$ or $V$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.