Jump to content

B, C, K, W system

From Wikipedia, the free encyclopedia

The B, C, K, W system is a variant of combinatory logic that takes as primitive the combinators B, C, K, and W. This system was discovered by Haskell Curry in his doctoral thesis Grundlagen der kombinatorischen Logik, whose results are set out in Curry (1930).

It has expressive power equivalent to that of S, K, I system. Both systems are fully interchangeable.

When compiling to combinators, an implementation may equally choose one system or the other, or both, as it helps shorten the encodings of functions. For example, the encodings of C exclusively in terms of S,K,I, as well as of S in B,C,W,K are long and complicated, as can be seen below, while their corresponding computational machine implementations are equally trivial. It can be worth it to add additional interpretation rules, allowing for much shorter code which can lead to more efficient execution.

Definition

[edit]

The combinators are defined as follows:

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

Intuitively,

  • B x y is the composition of x and y;
  • C x is x with the flipped arguments order;
  • K x is the "constant x" function, which discards the next argument;
  • W duplicates its second argument for the doubled application to the first. Thus, it "joins" its first argument's two expectations for input into one.

Connection to other combinators

[edit]

In recent decades, the SKI combinator calculus, with only two primitive combinators, K and S, has become the canonical approach to combinatory logic. B, C, and W can be expressed in terms of S and K as follows:

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

Another way is, having defined B as above, to further define C = S(BBS)(KK) and W = CSI.

Going the other direction, SKI can be defined in terms of B, C, K, W as:

  • I = W K
  • K = K
  • S = B (B (B W) C) (B B) = B (B W) (B B C).[1]

Also of note, Y combinator has a short expression in this system, as Y = BU(CBU) = BU(BWB) = B(W(WK))(BWB), where U = WI = SII is the self-application combinator.

Using just two combinators, B and W, an infinite number of fixpoint combinators can be constructed,[2] one example being B(WW)(BW(BBB)), discovered by R. Statman in 1986.

Connection to intuitionistic logic

[edit]

The combinators B, C, K and W correspond to four well-known axioms of sentential logic:

AB: (BC) → ((AB) → (AC)),
AC: (A → (BC)) → (B → (AC)),
AK: A → (BA),
AW: (A → (AB)) → (AB).

Function application corresponds to the rule modus ponens:

MP: from AB and A infer B.

The axioms AB, AC, AK and AW, and the rule MP are complete for the implicational fragment of intuitionistic logic. In order for combinatory logic to have as a model:

See also

[edit]

Notes

[edit]
  1. ^ Raymond Smullyan (1994) Diagonalization and Self-Reference. Oxford Univ. Press: 344, 3.6(d) and 3.7.
  2. ^ Larry Wos, William McCune (September 1988). "Searching for Fixed Point Combinators by Using Automated Theorem Proving: A Preliminary Report" (PDF). Argonne National Laboratory. Retrieved December 12, 2024., p.77

References

[edit]
[edit]