How Combinatory Logic Can Limit Computing Complexity
Total Page:16
File Type:pdf, Size:1020Kb
EPJ Web of Conferences 244, 01009 (2020) https://doi.org/10.1051/epjconf/202024401009 Complexity and Disorder Meetings 2018–2020 How Combinatory Logic Can Limit Computing Complexity Hugolin Bergier1;∗ 1Regis University Abstract. As computing capabilities are extending, the amount of source code to manage is inevitably becoming larger and more complex. No matter how hard we try, the bewildering complexity of the source code always ends up overwhelming its own creator, to the point of giving the appearance of chaos. As a solution to the cognitive complexity of source code, we are proposing to use the framework of Combinatory Logic to construct complex computational concepts that will provide a model of description of the code that is easy and intuitive to grasp. Combinatory Logic is already known as a model of computation but what we are proposing here is to use a logic of combinators and operators to reverse engineer more and more complex computational concept up from the source code. Through the two key notions of computational concept and abstract operator, we will show that this model offers a new, meaningful and simple way of expressing what the intricate code is about. 1 Introduction The point of this paper is to propose a solution to the overwhelming cognitive complexity of source code in In Sept. 26, 2017, an article entitled ”The Coming large applications. By cognitive complexity, we mean a Software Apocalypse” [1] exposed the dangers we’re fac- level of intricacy in the code that makes it too difficult to ing as software implementations are becoming increas- grasp for a human mind. ingly complex: ”Software has enabled us to make the most We are proposing to use the framework of Combina- intricate machines that have ever existed. And yet we have tory Logic to construct complex computational concepts hardly noticed, because all of that complexity is packed as a model of description of the source code that is easy into tiny silicon chips as millions and millions of lines of and intuitive to grasp. Combinatory Logic is already code. But just because we can’t see the complexity doesn’t known as a model of computation but what we are propos- mean that it has gone away (...) Just by editing the text in ing here is to use a logic of combinators and operators to a file somewhere, the same hunk of silicon can become reverse engineer more and more complex computational an autopilot or an inventory-control system. This flexi- concept up from the source code. This will lead to what bility is software’s miracle, and its curse. Because it can we can call a vertical simplification of the computational be changed cheaply, software is constantly changed; and concepts: through progressive layers of complexity, we because it’s unmoored from anything physical it tends to can define high-level concepts from other (less complex) grow without bound. The problem is that we are attempt- concepts without having to use the most primitive compu- ing to build systems that are beyond our ability to intellec- tational concepts, like incrementation or conditionals. To tually manage." the vertical simplification, we will add an horizontal sim- As computing capabilities are extending, the amount plification: given that a concept in Combinatory Logic is of source code to manage is inevitably becoming larger essentially the application of an operator to an operand, and more complex. No matter how hard we try, the be- we can use the combinators to extract a meaningful ab- wildering complexity of the source code always ends up stract computational operator that is simpler to grasp than overwhelming its own creator, to the point of giving the the complex concept it composes. appearance of chaos. Most applications source code has become intrinsically complex for a human being to read, 2 Applicative Languages and Combinatory navigate and comprehend. Logic One needs to step back from the source code in order to look at the big picture. What happens if a developer Combinatory Logic is an applicative language. While tries to step back from the code? Unlike Google Maps, the primitive notions of application, operator and operand zooming in and out on a program source code will radi- belong to applicative languages in general, the notion of cally change the cognitive complexity of the content. The combinator and b-reduction are specific to Combinatory big picture contains simply more data and intricacy than Logic. the small picture. Both the notions that belong to applicative languages in general and to Combinatory Logic in particular play an ∗e-mail: [email protected] important role in what follows. © The Authors, published by EDP Sciences. This is an open access article distributed under the terms of the Creative Commons Attribution License 4.0 (http://creativecommons.org/licenses/by/4.0/). EPJ Web of Conferences 244, 01009 (2020) https://doi.org/10.1051/epjconf/202024401009 Complexity and Disorder Meetings 2018–2020 2.1 Applicative Languages Applicative languages rely on the fundamental oper- Unlike ’>eval’ the relator ’=’ is both symmetrical and ation of applying an operator to an operand in order to static. Indeed, in set theory, the function is given as a set of dynamically produce a result. What distinguishes applica- ordered pairs < x, y > and any image y is coexisting with tive languages from set-theoretical languages is that the the corresponding argument x. application is considered as primitive notion and not as a The result of an application operation is not necessarily notion derivable from that of set. Applicative languages an operand as in the previous example. It can also be a new study operational processes : their construction, function- operator. This fundamental property of the application op- ing and nesting. By choosing to apprehend the applica- eration is called repeatability. An application operation tion of an operator to an operand as a primitive notion, we can produce a new operator which is in turn applicable to place ourselves in a logical framework different from that an operand. For example, the operation squared applied which is used in most modern logic systems. There are to plus-three produces the new plus-three-all-squared op- a variety of applicative languages: the lambda-calculus of eration. Repeatability is a very important characteristic of Church [2]; the combinatorial logic of Curry [3, 4] and applicative systems in our context because, as we men- F. Fitch [5]; the attempts of WVO Quine [6]. In Computer tioned above, we want to be able to understand complex Science, applicative languages correspond to a whole fam- computational concepts as related to other computational ily of programming languages called functional (among concepts, not directly to the actual implementation. which Lisp, Haskell and ML). After having presented the foundations of applicative systems, we will focus on Com- 2.2 Combinatory Logic binatory Logic. As we have just said, the primitive notion of an ap- 2.2.1 Combinators and reduction plicative system is a binary operation, called application. The first argument of the application is called an operator, Combinators are abstract operators that combine the the second argument is called an operand. The value of predefined operators of an application system so as to form this operation is called result or outcome. In an applica- new, more complex, operators. As operators, they are ap- tion operation, an operator f is applied to its operand a to plicable to their operands. The evaluation of a combinator produce the result b. We can simply represent the applica- application is called b-reduction. This evaluation defines tion as follows: the meaning of the combinator, regardless of any exter- f a nal interpretation. The meaning of a combinator is going We call this expression an applicative expression that we to depend on the way it combines its operands through can read “operator f applies to operand a”. When the op- b-reduction: permutation, duplication, composition, dele- eration of application is executed, a result b appears. Be- tion,... Thus, combinators are formal tools endowed with tween the application expression and the result, we intro- an intrinsic semantics [? ]. In other words, the semantics of combinators is not defined by an external interpretation duce a relation, designated by >eval ; we then have: in a model. Combinators are therefore very specific opera- f a >eval b tors in that they are completely reducible to their combina- torial action (that which is performed on their operands). which reads “the operator f applies to the operand a to give One could say that they belong to an additional level of ab- the result b. "The process of getting from operation to straction compared to the operators since their domain of result is called evaluation ; it is expressed by the relation interpretation is not given. Let us now introduce the most ’> ’. The evaluation is a non-symmetrical and dynamic eval common elementary combinators. relation: • Non-symmetrical because it is true that f and a deter- mine b but not the other way around. 2.2.2 Elementary combinators • Dynamic since there are two successive "moments": f a Combinatory Logic fits particularly well the frame- does not coexist with its result b but precedes it. work of Natural Deduction [7] which defines the syntactic Note that these two properties of the evaluation – that rules of formation of the language in same times as its for- the set-theoretic notion of function doesn’t have – are mal semantics through a series of rules of introduction and tightly related to the properties of code execution in com- rules of elimination of the logical operators. puter science. The execution of a program is nothing else Let us take the example of the combinator of compo- that the evaluation of a formal expression.