1. Introduction
The conception of semantic programming [
1] was developed in the 1970s and 1980s. The main objective of this direction was to create a logical programming language in which programs were given by the basic constructions of mathematical logic such as formulas and terms. A hereditarily finite list superstructure
of the signature
was chosen as the virtual execution device. At first, the programs were
and
-formulas [
2], but this language was Turing-complete [
3].
In 2017, Goncharov proposed considering the programs as the terms and presented the conception of conditional terms [
4]. In the new L
language, L
-programs and L
-formulas were inductively specified through the standard terms and
-formulas of the signature
. The polynomial-computable (p-computable) model
of the signature
was chosen as a virtual execution device. The authors of [
5] showed that any L
-program and L
-formula has a polynomial computational complexity. The question arises as to whether all algorithms of polynomial computational complexity can be represented in this language or in its polynomial-computable extensions. This has been an open problem for several years.
Only in 2021 did Goncharov and Nechesov propose the conception of the p-iterative terms [
6]. Extension of the L
language with p-iterative terms leads to the language L. In [
6], it is shown that the class of all L-programs coincides with the class of all algorithms of a polynomial computational complexity
P.
The main area of application of semantic programming is artificial intelligence. In artificial intelligence, the black box problem [
7] has been around for a long time. Most often, AI gives a result without explaining it. It does not explicitly share how and why it reaches its conclusions. One of the main directions in AI is machine learning [
8]. Most machine learning algorithms implemented using neural networks give a result but do not explain it. Our work is the first step toward the separation of artificial intelligence algorithms in the stage where a result can be logically explained and the stage where a result is given without explanation.
The main objective of this paper is to build a polynomial-computable representation [
9] for multilayer feedforward fully connected neural networks [
10,
11] using the basic elements of the model
. This type of neural network plays a great role in many artificial intelligence algorithms [
12], and such a library for them in the p-complete logical language L is necessary.
2. Preliminaries
The paper uses the results of the theory of semantic programming [
13], which is based on a polynomial-computable hereditarily finite list superstructure
of a finite signature
. The main set of
consists of the hereditarily finite list elements. The signature
consists of the next constant, operations and predicates:
- (1)
: a constant that selects an empty list;
- (2)
: returns the last element of the list or is otherwise;
- (3)
: returns a list without the last element or is otherwise;
- (4)
: returns the ith element of the list or is otherwise;
- (5)
: returns the number of elements in the list;
- (6)
: returns the first element of the list or is otherwise;
- (7)
: returns the second element of the list or is otherwise;
- (8)
: the predicate “to be an element of a list”;
- (9)
: the predicate“to be an initial segment of a list”.
Let us define the conception of L-formulas and L-programs in the basic language L as -formulas and standard terms of the signature , respectively.
The language L
is defined as an inductive extention of the basic language L
with conditional terms of the following form:
The conceptions of the L-formula, L-program and p-iterative term are defined as follows.
Basis of induction: Any L-program is an L-program, and any L-formula is an L-formula.
Induction step: Let
be an L-program and
be an L-formula, where there is a constant
such that for any
w, the following inequality is true:
The notation
means the L-program
g is applied
i times:
Suppose that there is a constant
such that for any
, the following is true:
The notation of the p-iterative term [
6] is defined as follows:
The L-program definitions in the inductive step are as follows:
is an L-program, where are L-programs and is an L-formula;
is an L-program, where are L-programs and are L-formulas;
is an L-program, where and are L-programs
The L-formula definitions in the inductive step are as follows:
is an L-formula, where are L-programs;
is an L-formula, where and are L-programs;
, , , are L-formulas, where , are L-formulas
, are L-formulas, where t is an L-program, is an L-formula and .
Theorem 1 ((Solution to the problem P = L) [
6])
. Let be a p-computable hereditarily finite list superstructure of the finite signature σ. Then, the following are true:- (1)
Any L-program has polynomial computational complexity.
- (2)
For any p-computable function, there is a suitable L-program that implements it.
In the current work, we modify the conception of the p-iterative term, and instead of the inequality , we require fulfillment of some conditions for an L-program g and L-formula .
Suppose the L-program
for a fixed
and some polynomial
are defined as follows:
where
and the following conditions are fulfilled (up to a permutation):
- (1)
;
- (2)
, for all .
The next lemma almost completely repeats the proof of Theorem 1 from [
6]. The same length and complexity estimates are used:
Lemma 1. The termfrom Equation (3) with conditions (1–2) from Equation (4) on g is a p-computable function.
3. Neural Networks
This work will consider multilayer feedforward fully connected neural networks of the type in [
10] (see also [
14,
15]), which has one incoming layer, one output layer and several hidden layers. For simplicity of presentation, we will assume that there are no bias neurons in such neural networks. However, all results of this work for neural networks with bias neurons are also valid.
For example, such a neural network with one hidden layer has the following form:
By default, for all neurons of the neural network, the activation function will be a sigmoid of the form:
The derivative of this function has the form:
Consider the approximation [
16] for the function
as the Taylor series expansion up to nine terms of the form:
Denote the function
f as the sigmoid approximation, which uses the Taylor series from Equation (
5) for
. In addition, denote
as an approximation for a derivative function
:
Remark 1. andare p-computable functions.
Let
be a standard pair numbering function:
Let us define the notation for the mth neuron in kth layer of the neural network
N as
. Each neuron has the following list representation:
where
is a constant symbol in a signature
for an activation function and
are the weights of the synapses which occur from neuron
to neuron
.
Neuron
of the output layer has the form:
Let us define the p-computable predicate
which selects the list encodings of the neurons. A characteristic function for this predicate is defined as follows:
where
is a condition term from Equation (
1) and
has the following form:
For some layer with a number
i for our neural network, we can define the following code:
Let us define the p-computable predicate
which selects a layer. A characteristic function for this predicate is defined as follows:
where
has the form:
Then, the following code is the list encoding for neural network
:
Let us define the p-computable predicate
which selects a list encoding of the neural network. A characteristic function for this predicate is defined as follows:
where
has the form:
Remark 2. Any neural network N is uniquely restored from the list encoding .
Consider the p-computable hereditarily finite list superstructure
of the signature
where neural networks are encoded as elements in
.
Let
a be the number. Then, we define a function × as follows:
Remark 3. × is a p-computable function.
Let us define the function ⊎ as follows:
Remark 4. ⊎ is a p-computable function.
Let us define the operation ⊗ as follows:
where
and where
and
Lemma 2. ⊗ is a p-computable function.
Proof. We prove this lemma using the construction of the p-iterative term . Let us define the operation of the L-program g for the non-output layer as follows:
where
and on the
jth step, we have
where the notation
means that the list function
is applied
j times:
Using Remarks 3 and 4, we find that g is a p-computable function.
The L-formula
is defined as follows:
Conditions (1–2) from Equation (
4) for the p-iterative term
are met, and therefore, by Lemma 1 the operation ⊗ is a p-computable function where
is non-output layer.
If
is an output layer, then
□
Let us define the operation
W as follows:
where
,
is the incoming signals and
is the outputs of the output layer neurons:
Lemma 3. W is a p-computable function.
Proof. We prove this fact by construction of a p-iterative term . The function g is defined as follows:
The construction g implies that g is a p-computable function.
The L-formula is defined as .
Conditions (1–2) from Equation (
4) for the p-iterative terms
are met, and therefore, by Lemma 1, the function
W is a p-computable function. □
Let us define the function
O as follows:
where
represents the neuron outputs for the
ith layer:
Lemma 4. O is a p-computable function.
Proof. The proof almost repeats the proof of Lemma 3 □
The backpropagation [
17,
18] algorithm will be used to configure the neural network. First, it is necessary to find the coefficients as follows:
where
is a target output for the jth neuron of the output layer.
The corrective weights are defined by the formula:
where
is a learning rate (some fixed constant ordinary from
).
Let be an input and be the neuron outputs for the ith layer.
Let us define the function
as follows:
where
:
Lemma 5. Δ is a p-computable function.
Proof. We build the p-iterative term , which simulates the operation of a function Δ as follows:
The L-formula
is defined as follows:
Conditions (1–2) from Equation (
4) for the p-iterative term
are met, and therefore, by Lemma 1 the operation
is a p-computable function. □
When all the parameters for weight correction are found, the weights can be changed using the formula:
Let us define the function
T as follows:
where the weights of the neurons
are derived from the weights of the neurons
by adding
, where
:
Lemma 6. T is a p-computable function.
Proof. The proof of this lemma is achieved by constructing a suitable p-iterative term as well as Lemma 5. □
The following theorem statement follows automatically from Remarks 3 and 4 and Lemmas 2–6:
Theorem 2. Let of the signature σ be a p-computable model.
Then, of the signature is a p-computable model.
7. Conclusions
This paper shows a constructive method for polynomial-computable representation of neural networks in the p-complete logical programming language L. Now, we can add a library for neural networks to the p-complete language L, which will allow us to implement algorithms both using a logical language and neural networks. Neural networks play a great role in any direction of AI, so this p-computable representation will help expand the expressive power of our core language L.
Since accuracy, speed and a logical explanation of the result are important criteria for the implementation of artificial intelligence algorithms, the given p-complete logical programming language L solves artificial intelligence problems much better than a similar implementation in Turing-complete languages. Moreover, in this language, there is no halting problem, which is very important for the stability and reliability of software solutions.
The main applications of this result are blockchains, smart contracts, robotics and artificial intelligence. Moreover, these results will be applied in the conception of building smart cities [
21], where almost all possible options for artificial intelligence are involved: image recognition, data mining, machine learning, neural networks, smart contracts, robotics, finance based on cryptocurrencies and blockchains.