Interesting algorithm world - algorithm roots (2)

zhaozj2021-02-16  51

I am very happy to meet you, we continue our "interesting algorithm world" trip.

Since the topic of the article is "the root of the algorithm", I hope to take you to see the source of the algorithm world ------ start formalization. Previously mentioned the Church - Tuling Project:

The intuition concept of the algorithm is equal to the graphic algorithm

This is the fundamental of our article. But in a hurry, we have not explained the "Tuling Algorithm", ending the last trip. This time we continued the last scene.

Wide speaking, the map spirit is a gradient structure (or algebraic system). Although you have been last, you know what is an algebra structure, but let's not immediately say the definition of the map spirit. , The problem of that automatic window.

Analysis, this problem is not difficult.

First of all, you should notice that the window can only be one of two states: Off or open! It changes the way the state is collecting environmental information, and then it is necessary to maintain the current state or change it according to a certain control transformation. This control The transformation is the most critical, we can represent it as a table, if assuming:

A: Allowance during the day, the weather is allowed,

B: The night or weather is not allowed.

Then the table is:

| A | B

Off | switch

Open | switch

From this way you are not difficult to imagine the principle of automatic window work. We describe it as follows:

Q is the status signal, the value is "off" or "on", X is environment variable, and the value is A or B (A, B definition as above).

(1) Set the initial state Q ← The state of the window (off or open);

(2) x ← Get an environment variable;

(3) If x is a, do

(3.1) If Q is closed, send "open" signal, q ← open, turn (2);

(3.2) If Q is open, turn (2);

(4) If x is b, do

(4.1) If q is closed, turn (2);

(4.2) If Q is open, send "Off" signal, Q ←, turn (2).

The reason why discussing this problem because it is also a model, a poor automatic model. It is also used to calculate, although its ability is far less than the map spirit; considering its status only limited (such as automatic window), Obviously it does not do a model of the computer.

Despite this, in the literacy analysis of the compilation principle, it is very good in many microcontroller-controlled electronic products.

When discussing it, there is more use of its state diagram, such as the state map in this example:

Similarly, if you formulate it, you can also treat it as an algebra structure (want to think about it, think of the environment variables A and B as an operation). But we will no longer do this, let's see more powerful Model: Figure forever.

The map spirit is similar to the poor automaton, but the map spirit has an unlimited storage. It can do everything that the actual computer can do. As a general model of the computer, in 1936, it was made by Tuling. We have not broken the day far. This model is. (Although I hope to see improved computer basic model in the year of life :)

The map foreground model uses an infinitely long strap as an unlimited storage, it also has a read writing, this read, write, write and move on the belt. As shown below:

At the beginning, there is only an input string on the strap. Other places are empty. When it needs to save the information, write the information on the belt. In order to read an input or write information, the belt may read and write The head moves back to the place where this information is moved. This reading, write and move, the machine keeps calculations until the output is generated. The machine implementation sets two states: Accept or reject the state. If you enter these two states, Produce an output acceptance or rejection; otherwise the machine will continue to perform it, never stop.

Let's look at the example of a map spirit, huh, maybe only such a charm of the beauty.

E.g. Play a small game, use your number keypad 0 key to enter a string, if: 0 is 2 square power (ie 2 ^ n), then you will be hit. J

Then we can describe a TMM TM M, which will be competent (and what I am responsible for when I am handed.

M = "For the input string W:

1) Scan the entire strap from left to right, isolate one 0.

2) If after the first step, only one of the only 0 left is left, then accept it.

3) If after the first step, the tape contains more than one 0, and the number of 0 is odd, then refuses.

4) Let the writing head back to the leftmost end of the strap.

5) Go to the first step. "

This is a map spirit, and you can prove that the algorithm in M ​​can achieve requirements. Of course, we give easy understanding, we give high-level description of the map foreground algorithm. The map spirit has its form of definition, or The status map is described, but it will be quite troubles. We only give the form of a general map forever.

If l indicates a character to the left to move to the left, r to the right.

A Tunnel is a 7-piece group (q, σ, γ, δ, Q0, Q1, Q2), where Q, σ, γ are poor, and

1) Q is the state set.

2) σ is an entered alphabet, excluding special blank symbols.

3) γ is a alphabet, where: ︺︺γ, σ is a subset of γ.

4) Δ: Q × γ → Q × γ × {L, R} is a transfer function.

5) Q0∈Q is the starting state.

6) Q1∈q is accepting state.

7) q2∈q is a refusal state, and Q2 ≠ q1.

The calculation of the map spirit is the read, write and move, the rule, and the rule, such as the other form of the map, or non-deterministic. They are called pictures. The deformation of the Lingling machine. And the original ordinary figure spirit is like this:

Multi-zoning machine, similar to the ordinary figure, just have multiple straps, each with its own read and write head, used to read and write. As shown below:

At the beginning, the input only appears on the first tape, and the other straps are blank. But the transfer function allows all read and write heads to read, write, and move.

It seems that the computing power of the map spirit is stronger than the ordinary figure spirit, but it is right: Their computing power is equivalent! This can prove. But, efficiency is not necessarily.

Non-deterministic map foreground is very easy to understand, at any time, the machine can choose a continuation in a variety of possibilities. It is a class tree, and the different branches correspond to the different possibility of the machine. If a calculation branch causes the acceptance state, accept the input. The same is the same as the multi-zoning machine, its computing power is the same as the ordinary map spirit. Proceed, you can see a calculation theory book.

At this point, do you understand what is a map forever? If so, please use the camera you bring (you can), give the Chuqi-Tuling theory (always saved in your heart), this It is one of our most popular landscapes.

Another part of this article is:

http://www.9cbs.net/develop/read_article.asp?id=20168

转载请注明原文地址:https://www.9cbs.com/read-25429.html

New Post(0)