What is ALF?
Algebraic Logic Functional Programming
There are several types of programming languages used for different purposes. Two well-known types of programming languages are functional and logic. Algebraic Logic Functional (ALF) is a programming language that combines these two types, functional and logic programming. The primary benefit of ALF is in this combination which is a complex process called narrowing. The literature on ALF is very limited therefore requiring some understanding of programming languages similar to ALF. An understanding of Prolog, a very common logic programming language, is essential for using ALF. Understanding how ALF works can highlight its potential benefits in education and research in artificial intelligence.
History of ALF
There is very limited information available on the history of ALF. It was created in 1990 by Rudolf Opalla. It ranks in the top 25% of programming languages. It can be obtained free but must be used only for students, teaching, or researching. It cannot be used for commercial or military purposes. ALF is also part of Carnegie Mellon University’s Artificial Intelligence Repository as an AI programming language. It is predominantly used in universities for teaching and research. ALF runs on Prolog which can be used on all major platforms including Unix, Linux, Mac OS, and Windows.
What is functional programming?
Functional programming is a type or style of programming that is very common. In functions of math, an input value gets modified and results in an output. Programming functions do not necessarily involve mathematics but with input and outputs where data can be modified. The function itself can also be isolated from the rest of the program. This isolation allows modulating or sectioning of the program provides several benefits. Functions in programming also allow easier use of arithmetic processing in programming.
There are benefits and disadvantages to this type of programming. It is quite popular because it improves the readability of the coding. This is increasingly important for coders that work in groups where one section of coding is easily readable by others. Functional programming can decrease the number of coding lines by its modular reusability. Additionally, the sectional aspect becomes easier to test and fix a program in parts.
What is logic programming?
Logic programming focuses on rules, or relationships, to decide whether something is true or false. It is in contrast to the idea of functions where the output depends on the input. Logic programming focuses on the relationships which can occur in the reverse rather than only an input becoming output. Functional programming cannot go from output to input. The goal in logic programming is to help a user find answers by looking at relationships in information.
Prolog programming language
One of the most well-known logic programming languages is Prolog. ALF is not standalone and requires Prolog. Therefore, a good understanding of Prolog is necessary for using ALF. Prolog is also one of the most well-known programming languages for logic programming. Logic programming is central to machine learning or artificial intelligence. Prolog is also used in natural language processing (NLP) where the goal is for computers to understand human languages. NLP is a subfield of artificial intelligence that includes chatbots and human language translations. Prolog is also considered a good problem-solving language and therefore useful for artificial intelligence.
If statements
If statements are very common and useful in many programming languages. A basic understanding of Prolog starts with if statements. An if statement creates a programming “rule,” or relationship, between 2 described objects. The following is a simple and often used coding example in Prolog:
mortal(X) :- man(X).
man(socrates).
The first line is read as “variable X is a mortal if variable X is a man.” The notation “:-” represents the relationship or rule between variable X being mortal, and variable X being a man. The second line creates a rule where something X is mortal only if that same X is also a man.
The second line is read as “Socrates is a man.” This is a simple statement where Socrates is something that can be in place of X. In regards to the if statement, Socrates is a man which satisfies the requirement needed in the first line. A third code can be put to operate the if statement:
?- mortal(Socrates).
true.
The third line is a question for the program, asking if Socrates is a man. The program outputs a statement “true” since the if statement in line 1 is satisfied by line 2. This is the essence of logic programming where relationships or rules allow the program to operate similarly to deductive reasoning.
How does ALF work?
Now that we understand functional and logic programming, we can see how ALF works. ALF was designed to integrate functional and logic programming. The main benefit of ALF over other similar languages is the efficiency in its narrowing process. There is a manual available online that explains how ALF works and reviews several modules. Unfortunately, the manual is written for experienced programmers, not beginners. Furthermore, understanding how the narrowing process itself works in ALF requires high technical knowledge of programming. There is very limited information available to the public about how ALF works. ALF cannot be used without first having a good understanding of Prolog.
Why combine functional and logic programming?
Research has been done for many years in combining functional programming and logic programming. The goal of this combination allows progress in higher-level programming. We first need to understand that basic computing began with inputs of 1s and 0s. The 1s and 0s combined to form letters and numbers, then sentences and stories. Most programmers today do not code with 1s or 0s as this step is “skipped” and automated by the computer. One eventual benefit of combining functional and logic programming is the ability to hide or skip, algorithms. Nowadays, programs are written without the need to spend time on writing Is and Os, and basic algorithms. The process of combing functional and logic programming in ALF is by the narrowing processes. This allows the benefits of functional programming to be applied to logic programming.
What is narrowing?
The narrowing is essential to ALF. It is the process by which functional and logic programming is combined. This is a relatively new concept in programming. There have been many attempts over the past decade to combine functional and logic programming. This allows logic statements such as Socrates is a man, to be processed through functions. The benefits of functions allow more ways of computing, developing ideas, and use of mathematics. The use of mathematics is inherent in ALF with using algebraic functions. However, the specifics of mathematics used is very complex and not discussed in this paper.
It is helpful to understand the process of rewriting. An oversimplified example is in the creation of a multiplication table of 1 x 1, 2 x 2, 2 x 3, etc. Rewriting 1 x 1 as 1, and 2 x 3 as 6 can simplify the data. Lines of codes are necessary to process and “rewrite” the data. The following example is code from a paper explaining narrowing on Prolog:
top(push(E, −)) → E
pop(push(−, S)) → S
Although it is oversimplifying the narrowing process, the above examples show that information that includes unknowns can still be processed. The information “top(push(E,-))” becomes just E. More specifically, the hyphen “−” is a placeholder and can be understood as unknown data. Therefore, unknown data can be processed and simplified to just E. Again, this is an oversimplified explanation and the process is complex. This process generally requires many steps. The many and complex processes also make it useful in cryptography to keep information secure.
The narrowing is similar to rewriting except that narrowing works with unknown data or variables. Narrowing allows rewriting of the described multiple table example such as 3 x unknown as a value. ALF is known to be more efficient in the narrowing process, than other logic programs such as Prolog. This can potentially improve the computing process for integrating functional and logic programming. The narrowing is not for beginners and a more clear example cannot be given in this paper.
Disadvantages of ALF
Quite simply, ALF is designed for researchers with a high level of understanding of programming. This is inherent in how it is freely available but only for students, teachers, and researchers. It is not available for commercial use. There is also no known community support of programmers that use ALF to help share and develop ideas. Much of the research into ALF required supplementary resources on other languages due to a lack of available literature.
Unfortunately, more code examples are not given in this paper. The coding examples in the ALF manual are very complex and meant for experienced programmers. The manual focuses on narrowing processes and other functional capabilities. It does not discuss if or loop statements that are commonly used in other types of programming languages. Even in the Prolog language which ALF is based on, condition and loop statements are not generally used as well.
Popularity
It is difficult to predict its future popularity due to the lack of literature on ALF. It is not among the most used but it is within the top 25%. There are many programming languages, more than 700. It is predicted that more is needed in the future. More specifically, more logical programming languages will be needed in the future such as for business solutions. This suggests that ALF will be used in universities for the foreseeable future in limited popularity.
Prolog has been around for decades and remains in limited popularity today. It is one of the most popular logic programming languages but it is not the most used for AI. Prolog remains useful in solving certain AI problems. It is additionally used in natural language processing which is involved in speech recognition or language-related artificial intelligence. Understanding the applications of Prolog can by extension highlight the usefulness of ALF. It is likely that ALF will remain in limited use just like Prolog as it depends on Prolog. Similarly, ALF can potentially become more useful in the future as technology advances with artificial intelligence.
Takeaway on ALF
ALF is designed to combine functional and logic programming which has existed for many years independent of each other. It achieves this combination through a narrowing process that involves rewriting and processing unknown data. This combination can carry the benefits of functional style into logic programming. Unfortunately, the literature on ALF and how it works is very limited. It is naturally designed for use in research and for those with a high level of technical understanding of programming. An understanding of Prolog is essential for ALF. It is unclear how popular ALF will remain among programmers in the future. Its benefits in researching new ways of programming suggest ALF will remain in use especially for artificial intelligence.