The Fixpoint Combinator in Combinatory Logic

The Fixpoint Combinator in Combinatory Logic

2021-4180-AJS 1 The Fixpoint Combinator in Combinatory Logic – 2 A Step towards Autonomous Real-time Testing of 3 Software? 4 5 Combinatory Logic is an elegant and powerful logical theory that is used 6 in computer science as a theoretical model of computation. Its algebraic 7 structure supports self-application and is Turing-complete. However, 8 contrary to Lambda Calculus, it untangles the problem of substitution, 9 because bound variables are eliminated by inserting specific terms called 10 Combinators. It was introduced by Moses Schönfinkel (Schönfinkel, 11 1924) and Haskell Curry (Curry, 1930). Combinatory Logic uses just one 12 algebraic operation, namely combining two terms, yielding another valid 13 term of Combinatory Logic. Terms in models of Combinatory Logic look 14 like some sort of assembly language for mathematical logic. A Neural Al- 15 gebra, modeling the way we think, constitutes an interesting model of 16 Combinatory Logic. There are other models, also based on the Graph 17 Model (Engeler, 1981), such as software testing. This paper investigates 18 what Combinatory Logic contributes to modern software testing. 19 20 Keywords: combinatory logic, combinatory algebra, autonomous real- 21 time testing, recursion, software testing, artificial intelligence 22 23 24 The Organon 25 26 Aristotle’s legacy regarding formal logic has been transferred to us in a 27 collection of his thoughts compiled into a set of six books called the Orga- 28 non around 40 BCE by Andronicus of Rhodes or others among his followers 29 (Aristoteles, 367-344 BCE). The Organon with its syllogisms was the domi- 30 nant form of Western logic until 19th-century advances in mathematical log- 31 ic. 32 Engeler recently noted the apparent lack of something that we today 33 consider fundamental for axiomatic geometry: relations. The question is 34 why. Aristotle had the means of developing this concept as well; however, 35 he chose not to do so. 36 Aristotle had the means of combining predicates. It is therefore possible 37 to construct an adequate model for Aristotle’ syllogism based on the struc- 38 tures of Combinatory Logic. Relations then become part of the model. 39 Engeler shows that Aristotle had no need for relations because the main 40 model he used – the Euclidean Geometry – does not require relations 41 (Engeler, 2020). 42 43 44 Introduction 45 46 A model of Combinatory Logic is an algebraic structure implementing 47 combinators in a non-trivial way. Such a model is called Combinatory Alge- 1 2021-4180-AJS 1 bra. As a minimum, it contains implementations for the 퐈 combinator (iden- 2 tity), the 퐊 combinator for extracting parts of another term, and the 퐒 com- 3 binator that substitutes parts of a term by some other combinator. Another 4 famous combinator is the Fixpoint Combinator 퐘, explaining recursion and 5 possible infinite iteration. These specific combinators are represented as 6 Constants in the language of Combinatory Logic, whereas other terms may 7 contain Variables. We refer to these general terms as Combinatory Terms 8 (Bimbó, 2012, p. 2). 9 Given a problem as a term 푋 in some suitable model, what should be its 10 solution? A problem is something that displays specific behavior, some- 11 times unpredictable, and produces specific effects, often unwanted. Also, a 12 certain persistence is part of a problem; problems that disappear by them- 13 selves are not particularly exciting. 14 A fixpoint point 퐘푋 with the property that 퐘푋 = 푋(퐘푋), for any 15 term 푋 of Combinatory Logic, is thus something like a solution to the prob- 16 lem. You can apply that solution as many times as deemed necessary and 17 the problem remains stable and confined. 18 When we encounter the problem of how to test a piece of software 푋, 19 and we have a test suite 퐘푋 with the fixpoint property, it looks like a solu- 20 tion to our testing problem. Since we can measure tests, by counting its test 21 size, we can assess what means minimal effort for a test, and thus can get an 22 optimum. 23 The clue to Combinatory Logic is that “everything is a function” – and 24 indeed, a unary function. Whenever anything can be understood as function 25 depending on two variables – 푓(푥, 푦) – it is an application of a unary func- 26 tion 푔 = 푓푥 on a variable 푦. Thus, 푓(푥, 푦) = 푔(푦) = (푓푥)푦 = 푓푥푦; 27 always assuming association to the left. This is known as Currying, convert- 28 ing n-ary functions into a sequence of unary functions. 29 30 31 Combinatory Algebras 32 33 Combinatory Algebras are models of Combinatory Logic (Curry & 34 Feys, 1958) and (Curry, et al., 1972). Such algebras are closed under a com- 35 bination operation 푀푁 for all terms of the algebra 푀, 푁; and two distinct 36 Combinators 퐒 and 퐊 can be defined with the following properties: 37 퐊푃푄 = 푃 (1) 38 39 and 40 퐒푃푄푅 = 푃푄(푃푅) (2) 41 where 푃, 푄, 푅 are elements in the combinatory algebra1. 1The use of variables named 푃, 푄, 푅 is borrowed from Engeler (Engeler, 2020). 2 2021-4180-AJS 1 Thus, the combinator 퐊 acts as projection, and 퐒 is a substitution opera- 2 tor for terms in the combinatory algebra. Like an assembly language, the 퐒- 3 퐊 terms become quite lengthy and are barely readable by humans, but they 4 work fine as a foundation for computer science. 5 The power of these two operators is best understood when we use them 6 to define further, more manageable and more reasonable combinators. 7 Church (Church, 1941) presented a list of functions that can be implemented 8 as combinators, and Zachos investigated them in the settings of Combinato- 9 ry Logic (Zachos, 1978). We present here only a few of them. 10 11 Identity 12 13 The identity combinator is defined as 퐈 ≔ 퐒퐊퐊 (3) 14 Indeed, 퐈푀 = 퐒퐊퐊푀 = 퐊푀(퐊푀) = 푀. Association is to the left. 15 16 Functionality by the Lambda Combinator 17 18 Church’s Lambda Calculus is a formal language that can be understood 19 as a prototype programming language, see (Church, 1941), (Barendregt, 20 1977). 21 Lambda calculus can be expressed by 퐒-퐊 terms. We define recursively 22 the Lambda Combinator 퐋퐱 for a variable 푥 as follows: 23 퐋퐱푥 = 퐈 (4) 퐋퐱푀 = 퐊푀 if 푀 different from 퐱 (5) 퐋퐱푀푁 = 퐒퐋퐱푀(퐋퐱푁) (6) 24 25 The definition (5) holds for any variable term 퐱 in the combinatory al- 26 gebra. We can extend the definition of the Lambda combinator by getting 27 rid of the specific variable 푥. For any combinatory term 푀, the Abstraction 28 Operator 휆푥. is defined on 푀 recursively by applying 퐋퐱 to all sub-terms of 29 푀. Applying 휆푥. 푀 to any other combinatory term 푁 replaces all occurrenc- 30 es of the variable 푥 in the term 푀 by 푁 and is written as (휆푥. 푀)푁. 31 The abstraction operator binds weaker than the combination operator. 32 Thus, 휆푥. binds all variables 푥 in 푀푁, such that we can omit parentheses as 33 in 휆푥. 푀푁 = 휆푥. (푀푁). Lambda abstraction provides a much more read- 34 able and intuitively understandable notation for terms of Combinatory Log- 35 ic. 36 37 The Fixpoint Combinator 38 39 Given any combinatory term 푍, the Fixpoint Combinator 퐘 generates a 40 combinatory term 퐘푍, called Fixpoint of 푍, that fulfills 퐘푍 = 푍 (퐘푍). 41 This means that 푍 can be applied as many times as wanted to its fixpoint 42 and still yields back the same combinatory term. 3 2021-4180-AJS 1 In linear algebra, such fixpoint combinators yield an eigenvector solu- 2 tion to some problem 푍; for instance, when solving a linear matrix. It is 3 therefore tempting to say, that 퐘푍 is a solution for the problem 푍. For more 4 details, consult Fehlmann (Fehlmann, 2016). 5 Using Lambda Calculus notation, the fixpoint combinator can be writ- 6 ten as 퐘: = 휆푓. (휆푥. 푓(푥푥))(휆푥. 푓(푥푥)) (7) 7 8 For a reference see Barendregt (Barendregt, 1984), 9 Translating (7) into an 퐒-퐊 term proves possible but becomes a bit 10 lengthy. 11 By applying (6), (5): 휆푥. 푓(푥푥) = 퐒휆푥. 푓휆푥. 푥푥 휆푥. 푓 = 퐊푓 12 Then applying (6) and (4): 휆푥. 푥푥 = (퐒휆푥. 푥휆푥. 푥) = (퐒퐈퐈) 13 this yields 휆푥. 푓(푥푥) = 퐒(퐊푓)(퐒퐈퐈) 14 and therefore 15 퐘 = 휆푓. (휆푥. 푓(푥푥))(휆푥. 푓(푥푥)) = 휆푓. (퐒(퐊푓)(퐒퐈퐈))(퐒(퐊푓)(퐒퐈퐈)) = 퐒(휆푓. 퐒(퐊푓)(퐒퐈퐈))(휆푓. 퐒(퐊푓)(퐒퐈퐈)) = 퐒(퐒(휆푓. 퐒(퐊푓))휆푓. 퐒퐈퐈)(퐒(휆푓. 퐒(퐊푓))휆푓. 퐒퐈퐈) 16 17 Now solving the remaining 휆-terms: 휆푓. 퐒(퐊푓) = 퐒휆푓. 퐒휆푓. 퐊푓 = 퐒(퐊퐒)(퐒휆푓. 퐊휆푓. 푓) = 퐒(퐊퐒)(퐒(퐊퐊)퐈) 18 considering 휆푓. 퐒 = 퐊퐒 19 and 휆푓. 퐊푓 = 퐒휆푓. 퐊휆푓. 푓 = 퐒(퐊퐊)퐈. 20 21 The latter holds by first applying (6), then (5) and (4). Moreover 22 휆푓. 퐒퐈퐈 = 퐒휆푓. 푺퐈휆푓. 퐈 = 퐒(퐒휆푓. 퐒휆푓. 퐈)(퐊퐈) = 퐒(퐒(퐊퐒)(퐊퐈))(퐊퐈) 23 applying again (6) and (5). 24 Putting things together: 25 퐘 = 휆푓. (휆푥. 푓(푥푥))(휆푥. 푓(푥푥)) = 퐒 (퐒(퐒(퐊퐒)(퐒(퐊퐊)퐈)) (퐒(퐒(퐊퐒)(퐊퐈))(퐊퐈))) 4 2021-4180-AJS (퐒(퐒(퐊퐒)(퐒(퐊퐊)퐈)) (퐒(퐒(퐊퐒)(퐊퐈))(퐊퐈))) 1 2 Applying 퐘 to any combinatory term 푍 now explicitly transports 푍 on 3 the top of the formula and keeps the rest of the structure of 퐘 such that 퐘 can 4 be applied repeatedly. 5 This exercise should give the reader an impression how Combinatory 6 Logic works.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us