пятница, 10 июля 2009 г.

Comparison

Efficiency. Choosing the type of analysis (top down or bottom-up) depends on the configuration tree, which carried out a search. If, on average, each element should be a larger number of elements, rather than precede, the analysis of top-down (or the reverse analysis) would be more effective and vice versa. Consider the extreme case. Assume that the search area forms a tree with a vertex in the initial state. Then, using the direct approach, we will have to search for virtually the entire tree, while the opposite approach - only in its linear part.



Comparison and unification. In systems with a set of logical rules, or systems analysis to select direct or reverse the chain of analysis affects the degree of difficulty of the comparison. A direct chain analysis of the system is constantly subject to new facts that have no free variables. Thus constantly compares the background, it is likely with free variables, with the facts that do not have such.

On the other hand, systems with a backward chain analysis of the honor of asking specific questions. If the rules are set out in the logic of predicates and not the logic of judgments, then a comparison is made between the question of variable in the investigation of variables. Secondary queries can contain variables, so in general the system with the opposite chain analysis should be designed in such a way that they could compare two character structures, each of which can contain variables, which would require the creation of an algorithm unification.

среда, 8 июля 2009 г.

Systems with embedded rules.

Consider the direct and inverse chain analysis on the example of an imaginary set of rules on how to spend an evening. The rules are as usual, antecedent located on the left, as a consequence - the right, due to all regulations are met, a review is conducted in parallel.
1. A good movie on TV + Early morning meetings no later films ®
2. Early morning meetings do not + We need to work late ® Jobs
3. We need to work + required documents ® Work in the office
4. Later films ® Do not sleep late
5. Work late ® Do not sleep late
6. Work late ® Return to the office
7. Work in the office ® Return to the office



For example, Rule 1 states that if the TV is a good movie and I have tomorrow early morning meetings do not, then I follow the regime of "later a movie".
Consider the first example of direct chain analysis. Assume that the system has received initial information that the sooner tomorrow utorm I do not have meetings. Activated rules 1 and 2. Assume further that the system received a message that I need to work on. Active Rule 3 and Rule 2 is called and vypolnyaetya, whence the conclusion that I was in a "work late", with the result that triggered and implemented rules 5 and 6. As a result, the system is that I should go back to the office and do not sleep late.


Now consider the same problem with the use of a chain of analysis. Assume that the system has received background information that I do not have a meeting tomorrow morning, but I need more work, then it (the system) was asked whether I go back to the office. This request activates the rules 6 and 7. In turn, there is the question "Working late" or "Work in the office? This enabled the rules 2 and 3, and the question is "Early in the morning meetings do not," "We need to work" or "required documents"? The first two antecedent are satisfied, so rule 2 will be called and executed, which would entail the satisfaction of antecedent "Working late, call and execution of rule 6, in which the system will come to the conclusion that I should go back to the office.



Please note that the direct parsing generated more consequences, and if the reverse - requests. Since in both cases used the same data, in the course of the analysis performed by the same rules, but activated different.

понедельник, 6 июля 2009 г.

Examples 2

Construe a bottom-up begins with the words in the sentence. Again, the analysis is conducted from left to right, and first applied the rule with the lowest number. So, the first word of first sentence "they" refers to the background of rule 9, which after the issuing the statement that "they" is a pronoun (PRO). Then the rule 3 and shall issue, that "they" is the NP. NP corresponds background of 1 and 5, but none of these rules are not yet due, so the analysis moves to the "are". You rule 11 (despite the fact that Rule 12 is also due, it was not performed in accordance with the rule of the sequence of rules). Then the rule 10, 8 and 2 (Fig. 3a). At this stage, further analysis of the sequence of NP + AUX + ADJ + NP is impossible, so we return to the last due, but not yet implemented the rule, ie to rule 4. Analysis of the sequence of NP + AUX + NP as possible, so once again with the last due to unfulfilled. Now that rule 13, which gives that "flying" is a V. Then the rules of 6 and 5 (Fig. 3c). Collation posledovatellnosti NP + AUX + VP is not possible, therefore, carried out to 7 and gives the assertion that "are flying" is the VT. Then try to obey rules 1 and 5, to what ends, and syntactic parsing (Fig. 3d).

This example was carried out to compare the mechanisms of syntactic parsing from the bottom up and top down. Establishing a strict order from left to right parsing and numbering of the rules due to the desire to use the most similar algorithm, despite the fact that parsing results were different.

суббота, 4 июля 2009 г.

Examples

Parsing. Let's try to illustrate and explain the difference between parsing top-down and bottom-up by the example sentence "They are flying planes" and a simple grammar, presented in the form of numbered rules:
1. S ® NP VP
2. NP ® N
3. NP ® PRO
4. NP ® ADJ N
5. VP ® VT NP
6. VT ® V
7. VT ® AUX V
8. N ® planes
9. PRO ® they
10. ADJ ® flying
11. AUX ® are
12. V ® are
13. V ® flying

Background are shown on the right side, and investigation - to the left. For example, Rule 1 reads as follows: "If the sequence consists of a nominal group (NP), followed by the verbal group (VP), then this sequence is a sentence (S)."
Syntax parsing top-down begins with the symbol S, which will be the tops of trees indiscriminately. This procedure is equivalent to the procedure of a problem, which is to determine whether a sequence of words offer. Rule 1 states that each proposal is the name of the group (NP), followed by the verbal group (VP). If you have multiple rules, the first thing applies to the lowest number, then it expands from left to right. Thus the next step is to find the first communication, ie NP. First, rule 2 is activated, and then to 8 (Fig. 2a). Since "Planes" are not consistent with the "they", the algorithm is triggered again, and now the first 3 to be activated, and then to 9. Then the algorithm returns to rule 1 and the next goal put the definition of VP. First, activated rules 5, 6, and 12 (Fig. 2b). Further progress in parsing otrzhen in Figure 2 (c, d, e).

Analysis of bottom-up and top-down

"Top down" vs. "Bottom up", "direct" vs. "Reverse", "Manage" vs. "Purpose driven" - three pairs of definitions for terms such as "chain analysis, parsing, syntactic parsing," "logical analysis" and "search." In principle, all these terms reflect a similar attitude, and the difference between them is simply that they are drawn from different subareas of computer science and artificial intelligence (parsing, a system with a set of rules of search engines and systems, aimed at solving problems and etc.)

These contrapositions can be illustrated by the paradigm of search. The main task of any search is to identify the route by which you will move to this position to your goal. If you start the search with the current position and will continue it until natknetes the desired result - so-called direct search or search for a bottom-up. If you mentally put yourself in the place where you want to find yourself on a search and determine a route, heading in the opposite direction, ie where you really are at the moment - is the search in the opposite direction, or by looking down. Please note that by defining the route as a result of a search, you still will get to their goal. Despite the fact that now you're moving forward, this is not a direct search, as search has been carried out previously, in the opposite direction.
The same contrast could be considered an example of systems with embedded rules. Imagine that the rule consists of a set of background and a set of consequences. When the system determines that all the background certain rules are satisfied, this rule is called and executed (executed there, each caused by a rule depends on the particular system). After that, a knowledge base put approval obtained as a result of the rules and comply with the relevant transaction. This process occurs as described above, irrespective of whether the system of direct or inverse logical analysis. To illustrate the differences between them, should separately consider the procedure for activating the rule. Caused only activated rules. Direct logical analysis (upward) when the system adds the new data, they are compared with all the background of all the rules. If the data are consistent with the antecedent of rule, this rule is activated (if it is not yet activated), and if you picked all the background specific rule, it is called. Claims resulting from the implementation of the rules entered in the knowledge base and are regarded as new data are compared with the background and can cause activation of the call and additional rules. In a reverse logical analysis (top down) when you add these rules are not activated. When the system receives a request, it compares with all the consequences of all rules. If the request coincides with the result, this rule is activated, and all of his background are considered as secondary queries, and can cause the activation of additional rules.

When a query matches are not limited to approval of a knowledge base, it receives a response and if the request comes from a background, it is believed that he satisfies the latter. When all the background of a rule are met, the rule is called and executed. When the rules of being a response to requests that it activated, and the other background are satisfied and may be caused by corresponding rules. Please note that the call and execution of rules is always happening in the direct sequence, but unlike the direct analysis of a chain is when a rule is activated.

Sorting Algorithms

Sorting Algorithms

The problem of organizing data from a practical point of view:
advantages and disadvantages of five different methods of sorting.

Sorting is used in all the areas of programming, whether a database or math program.
Practically every sorting algorithm can be divided into three parts:
- A comparison that determines the order pairs of elements;
- Up, swap a couple of elements;
- Actual sorting algorithm that performs the comparison and transfer of elements until the juice of all the elements of the set will not be ordered.
Similar properties have those five sorting algorithms that
discussed below. They are selected from the set of algorithms, because
First, the most frequently used, and secondly, because most of the other algorithms is modified as described here.

The method of the bubble.

(Also called the method of sorting with the choice of exchange).
The idea of this method is reflected in its title. Most elements of the array light "appear" top most "severe" - drown. Algorithmic it could be implemented as follows. We will look through the array of bottom-up "and change the number of elements standing in there when the" bottom "element is less than the" ceiling ". Thus, we vytolknem top most "easy" part of the whole array. Now repeat the whole opera neotsortirovanymi for the remaining N-1 elements (ie, for those who are "below" the first one. As you can see, the algorithm is simple enough, but sometimes observed, it is unsurpassed in its inefficiency. Slightly better, but so vivid is the second method.

Sort choice

At this time, when viewing macciva we will look for the smallest element, comparing it with the first. If the element is found, it will change places with the first. Then repeat the operation, but did not begin with the first element, but with the second. And we will continue this way until rassortiruem entire array.

Shell Method

This method was proposed by Donald Lewis Shell in 1959 The main idea of this algorithm is that at the beginning of yctpanit mass disorder in the array, comparing the far-facing each other elements. As shown, the interval between compared elements (gap) is gradually reduced to one. This means that in the latter stages of the sorting is reduced simply to the transposition of neighboring elements (unless, of course, such changes are necessary).

Method Hoopa

This method, also called the quick sorting (QuickSort), was developed in 1962 (it has developed a Charles Antony Richard Hoare).
The essence of the method is to find such an element of the set to be sorted, which break it into two subsets: those elements that less fissile element, and those that do not lower it. This idea can be realized in many ways.