Relational Programming Một thủ tục trong mô hình khai báo sử dụng các đối số đầu vào để tính toán các giá trị của đối số đầu ra của nó. Đây là một chức năng tính toán, theo nghĩa toán học: các kết quả đầu ra được chức năng của các đầu vào. Đối với một tập các giá trị đối số đầu vào, chỉ có một tập hợp các giá trị đối số đầu ra. | Chapter 9 Relational Programming Toward the end of the thirteenth century Ramon Llull Raimundo Lulio or Raymond Lully invented the thinking machine. . The circumstances and objectives of this machine no longer interest us but its guiding principle-the methodical application of chance to the resolution of a problem-still does. - Ramon Llull s Thinking Machine Jorge Luis Borges 1899-1986 In retrospect it can now be said that the ars magna Lulli was the first seed of what is now called symbolic logic but it took a long time until the seed brought fruit this particular fruit. - Postscript to the Universal Library Willy Ley 1957 A procedure in the declarative model uses its input arguments to calculate the values of its output arguments. This is a functional calculation in the mathematical sense the outputs are functions of the inputs. For a given set of input argument values there is only one set of output argument values. We can generalize this to become relational. A relational procedure is more flexible in two ways than a functional procedure. First there can be any number of results to a call either zero no results one or more. Second which arguments are inputs and which are outputs can be different for each call. This flexibility makes relational programming well-suited for databases and parsers in particular for difficult cases such as deductive databases and parsing ambiguous grammars. It can also be used to enumerate solutions to complex combinatoric problems. We have used it to automatically generate diagnostics for a RISC microprocessor the VLSI-BAM 84 193 . The diagnostics enumerate all possible instruction sequences that use register forwarding. Relational programming has also been used in artificial intelligence applications such as David Warren s venerable WARPLAN planner 39 . From the programmer s point of view relational programming extends declarative programming with a new kind of statement called choice . Conceptually the choice statement .