Functional and logical programming

The essence of functional programming can be defined as a way of creating programs in which the only action is to call the function, the only way to divide the program into parts is to enter the name of the function, and the only rule of composition is the operator of superposition of functions. The key concept in functional languages is expression. These include constants, structured objects, functions, their bodies, and function calls. A functional programming language consists of: a set of basic functions; classes of constants, actions on which can produce functions; prescriptions that establish the rules for constructing expressions and new functions based on basic or recursively through itself.

The essence of functional programming can be defined as a way of creating programs in which the only action is to call the function

The concept of logical programming is based on the concept of relationship. A logical program is a combination of axioms and rules that determine the relationship between objects and the goal. Program execution is an attempt to prove a logical statement constructed from a program according to the rules defined by the semantics of the language used. The result of the calculations is the derivation of consequences from axioms. The logic program algorithm involves determining and listing the specific properties of objects and the relationships between them, rather than determining the order in which individual steps are performed. This confirms the declarative nature of the logical programming language. Logical programs do not differ in high speed, since the process of their execution is reduced to the construction of direct and inverse chains of reasoning by various search methods.

A program written in a functional language resembles the definition and list of specific features of a task and is a sequence of descriptions of functions and expressions. The expression is calculated in a reduction way, i.e. reducing complex to simple. Calls to the basic functions lead to their replacement with the corresponding values. Calls to functions that are not basic are replaced by their bodies, and their parameters by actual arguments.

Functional programming does not consider memory as a place to store data; it uses the mathematical concept of a variable and a function. Variables temporarily denote program objects. As in mathematics, functions of functional languages map one object to another, and arguments to values.

There are no fundamental differences between constants and functions, i.e. between operations and data. A function may be the result of a call to another function and may be an element of a structured object. When accessing a function, the number of its arguments does not have to coincide with the number of parameters defined in its description.

The first such language was Lisp (LISt Processing - list processing), created in 1959 by John McCarthy. This language is focused on the data structure in the form of a list and allows you to organize the effective processing of large amounts of text information. An essential feature of the language is the uniformity of program structures and data structures: all expressions are written in lists.

Creation of artificial intelligence language PROLOG (PROgramming in LOGic - programming in terms of logic) in 1973 by the French scientist Alan Colmeroe opened a new field - logical programming.

The program in the Prolog language, which is based on a mathematical model of the theory of predicate calculus, is built from a sequence of facts and rules, then a statement is formulated that Prolog will try to prove using the introduced rules. The user only describes the structure of the task, and the internal Prolog mechanism itself seeks a solution using the search and matching methods.