Design and implementation of a new Prolog detectio

2022-10-23
  • Detail

Design and implementation of a new Prolog detection algorithm

Prolog (programming in logic) language is essentially different from traditional programming languages. The traditional programming language is based on Feng Neumann computer architecture is based on assignment/data processing. Prolog language is a typical logic programming language, which is based on horn clause. Horn clause is either an assertion (proposition) or a logical implication (inference rule). For the problem provided, the process of realizing the goal of Prolog system is a special linear input digestion process applicable to plastics. The main mechanism of Prolog is pattern matching and backtracking. The search strategy is from top to bottom, from left to right, and the depth first is strictly implemented. Software testing [2, 3] is an important means to improve software reliability, and it is also one of the most active research fields in software engineering. After years of using Prolog language, the author found that contradictions between rules often appear in Prolog programs, and programmers are not easy to find such errors. Therefore, we propose an algorithm to detect the contradiction between rules in Prolog program, which has been implemented in C language. The turbo Prolog system disk is analyzed. As a prolog detection tool, the algorithm has been incorporated into the turbo Prolog system disk. 1 research status of Prolog detection tools the resolution principle proposed by Robinson in 1965 is an important breakthrough in machine theorem proving. In 1972, konwalski and colmerauer designed Prolog at the University of Marseille in France in order to apply computers to machine theorem proving

because the execution of Prolog program is uncertain, the input-output relationship of rules is not as accurate as the process in traditional software, and there are too many ways to activate rules, so path coverage tools cannot be used. At present, there is little research progress in Prolog detection tools at home and abroad. The main achievements are:

1) Lawrence proposed a frame model to describe the prolog program control process

2) Chongqing University proposed an algorithm to detect infinite loops in Prolog program

3) Shapiro proposed algorithm scheduling method

4) Pereira put forward the method of adjusting when the compression force of the sample on the impact tester is too large. 2 contradiction detection algorithm 2.1 data structure

in order to detect contradictions, static testing of the source program is required, and its basis is to transform the source program into a data structure with internal structure

turbo Prolog program is composed of several program segments, each of which is identified by a keyword, including: 1) domain segment; 2) Database predicate description; 3) Predicate description; 4) Facts; 5) Objectives

the data structure of each program segment we designed is as follows:

1) the data structure of the domain segment is as follows (Figure 1) Figure 1 the data structure of the domain segment. In D1, type can be integer, word, character, string, symbol types; The next field is used to link the description of the next type; The period field is the name of a variable that points to this type. In D2, the name field is the variable name of this type; The next field connects variables of the same type description

2) predicate description segment data structure is as follows (Figure 2) Figure 2 predicate description segment data structure figure 3) fact rule domain data structure is as follows (Figure 3) Figure 3 fact rule domain data structure Figure 2.2 implementation principle of contradiction detection algorithm

contradictions between two rules often occur in Prolog programs. Contradictions appear in the reasoning process, which is incomplete for the knowledge base, and it directly affects the reliability of the knowledge base

definition of contradiction:

if two groups of rules draw opposite conclusions under the same conditions, or if two groups of rules draw the same conclusion under contradictory conditions, when used in the processing of glass fiber reinforced materials, we say that these two groups of rules are contradictory, and the situation of multiple rules is the same

generally, there are two rules RI in rules R1, R2,..., RN, and ri+1 leads the future. "The corporate spirit is the same:

ri, a:—— α 1, α 2,…, α n

Ri+1,A:—— β 1, β 2,…, β N

if α 1, β 1 is not a cyclic predicate, and we "substitute" it until it is in the determined state. The sub target sets of rule RI and ri+1 after "substitution" are respectively:

ri( γ 1, γ 2,…, γ n, θ 1, θ 2,…, θ m)

Ri+1,( δ 1, δ 2,…, δ n, θ 1, θ 2,…, θ m)

remove the same sub goals and don't consider them anymore. Only compare the two with the same sub goals. If formally RI has sub goal B and ri+1 has sub goal B, then there is a contradiction between the two sets, that is, RI and ri+1 have contradictions. Otherwise, list the different sub goals in the two rule sub goals, ask the user through man-machine dialogue, and determine whether there is a contradictory predicate from the predicate meaning. 3 Analysis and improvement of Turbo Prolog system disk in order to combine the contradiction detection algorithm as a tool into the turbo Prolog system disk, the following work needs to be done:

(1) add a menu option (debug) to the turbo Prolog system menu

(2) modify the file E in the turbo Prolog system so that it can receive the selection and execute the detection tool

(3) find the memory address of the stored program in the turbo Prolog system, so that the detection program can operate the source program

Copyright © 2011 JIN SHI