Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with SMTP id p9QAxqLC010228 for ; Wed, 26 Oct 2011 12:59:53 +0200 Received: (qmail 15787 invoked by alias); 26 Oct 2011 10:59:47 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 26 Oct 2011 10:59:47 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx111) with SMTP; 26 Oct 2011 12:59:47 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p9QAvq0g024026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 26 Oct 2011 12:57:52 +0200 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p9QA7HEe030285; Wed, 26 Oct 2011 12:57:51 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1895747 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 26 Oct 2011 12:57:51 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p9QAlp0j024955 for ; Wed, 26 Oct 2011 12:47:51 +0200 Received: from neptune.ucc.ie (neptune.ucc.ie [143.239.153.183]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p9QAlb9t020066 for ; Wed, 26 Oct 2011 12:47:41 +0200 Received: from csmvddesktop (csmvddesktop.ucc.ie [143.239.74.97]) (Authenticated sender: dongen) by neptune.ucc.ie (Postfix) with ESMTP id CEF0A2E90A8 for ; Wed, 26 Oct 2011 11:47:36 +0100 (IST) References: <4EA7DB88.7020906@residenset.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.21 (2010-09-15) Message-ID: <20111026105033.GA8500@csmvddesktop> Date: Wed, 26 Oct 2011 11:50:33 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: dongen Subject: Re: S combinator and such To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <4EA7DB88.7020906@residenset.net> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (eXpurgate); Detail=5D7Q89H36p7zYQev1Bv5lawyulDRL8ctFEdtiuMHcPwWIPbh8fW5tKXscxUVR2mxW4g1p bpGawCdRj7XHT8xbYaN3ZBKZAwdv1cWC83nSUqdvEGMFao6a9A99XZ9heJEpj5NMSG+OEfZkIqQe OMKAgYFZpsOUq13IN0bofqRw8Hj5X+azhSF5cbLGtfCfUUlcbTnya/Rx18=V1; X-Resent-By: Forwarder X-Resent-For: rainer.schoepf@gmx.net X-Resent-To: rainer@rainer-schoepf.de Status: R X-Status: X-Keywords: X-UID: 6955 * Lars Hellström [2011-10-26 12:06:00 +0200]: : Continuing my reading up on Lambda calculus and related matters, : I've now gotten to the Combinatory logic : (http://en.wikipedia.org/wiki/Combinatory_logic), which also turns : out to be much easier to understand when one transcribes the whole : thing into LaTeX macros. :-) In particular, there are : : \cs_new:Npn \combinator_I:n #1 { #1 } % AKA \use_i:n : \cs_new:Npn \combinator_K:nn #1 #2 { #1 } % AKA \use_i:nn : \cs_new:Npn \combinator_S:nnn #1 #2 #3 { #1{#3}{ #2{#3} } } : \cs_new:Npn \combinator_B:nnn #1 #2 #3 { #1{ #2{#3} } } : \cs_new:Npn \combinator_C:nnn #1 #2 #3 { #1{#3}{#2} } : : My thought with this mail is mainly to ask whether there are any : more of these (or other standard combinators) that are defined in : LaTeX3 already. I seem to recall some discussion to the effect that : the C combinator might be named \use_i_biii_bii:nnn, but I haven't : seen any occurrence in the source of such _bii_ names (then again, : maybe I'm not looking close enough). Continuing such a naming : scheme, one would arrive at maybe : : \use_i_biibiii:nnn for the B combinator : \use_i_biii_biibiii:nnn for the S combinator : : which does not seem entirely practical... I've been reading this thread for a while and I've used these combinators to implement some simple arithmetic. (IIRC it uses Church Numerals and the arithmetic is called Church Arithmetic.) For example, I could write something like the following (rewritten for readability): X to get copies of X, so <2> a -> aa. + to get , so (<1> + <2>)a -> aaa, - to get , and so on. This is all well understood. You can define any lambda expression (and therefore LaTeX) in terms of the S and K you mention. See for example [Curry:Feys:Craig:68], which also mentions some other names for commonly used combinators. These combinators are __hopelessly__ inefficient. For example, the following definitions are from ``LaTeX and Friends:'' \newcommand\K[2]{#1} \newcommand\S[3]{#1#3{#2#3}} \newcommand\I{\S\K\K} \newcommand\X{\S{\K{\S\I}}{\S{\K\K}\I}} The combinator \X is defined in terms of \S and \K. All it does is swop its (two) arguments, so ``\X ab'' gives ``ba.'' Using ``\Xab'' requires 17 reductions, which is sad because X is pretty simple. @BOOK{Curry:Feys:Craig:68, title = {Combinatory Logic}, author = {Curry, H.\,B. and Feys, R. and Craig W.}, editor = {Heyting, A. and Robinson, A. and Suppes, P. and Motowski, A.}, publisher = {North-Holland}, series = {Studies in Logic {and the Foundations of Mathematics}}, year = {1968}, volume = {I}} Regards, Marc van Dongen