danaxlanguage.blogg.se

Visual prolog vfccbd cnhjr
Visual prolog vfccbd cnhjr





  1. Visual prolog vfccbd cnhjr software#
  2. Visual prolog vfccbd cnhjr code#

The second version also does the same thing as the first one.

Visual prolog vfccbd cnhjr code#

This example shows one important feature of functors: The arguments of a functor can be taken apart and examined using regular Prolog variables and bound values (like the string literal in this example) If you see Line 2 (Look at the side of the comment %Line 2 in the code for the first version), you would notice that we have used an anonymous variable (the underscore) for the first argument of the person functor as we are (in that predicate) not interested in the name of the father. If the variable does match, it checks if the second argument consists of a person functor, whose second argument is the string literal "male". In the first version, the code in Prolog systematically examines each parent fact asserted into the code, and sees if the first logical variable (P) matches that passed down from the predicate head. The logic behind both the versions is the same, but the manner in which the logic is indicated to the Prolog engine is different. Hence the grandfather predicate should be re-written as follows:įather ( P, person ( Name, "male" ) ) :. If you take a look at the grandfather predicate, you would notice that it has a subtle bug: A person would have two grandfathers: one from the mother's side and one from the father's side, but the grandfather predicate as defined earlier would only yield the grandfather on the father's side. Now, you will notice that the results that are yielded are richer than what you got previously (See Tutorial 04: Fundamental Prolog (Part 1)). PIE will now consider the text from the beginning of the line to the caret as a goal to execute. When the caret is placed at the end of the line, press the Enter key on your keyboard. Then, you re-consult the code using Engine -> Reconsult.Īs before, on a blank line in the Dialog window type a goal (without the "?" sign- in front). This time, each person is described with both the person's name and his/her gender, using the person functor, whereas in the earlier tutorial (Fundamental Prolog (Part1)) we were only using the person's name.Īfter you have written the new code, ensure that the PIE engine is reset. If you study the two facts for the father relationship, you would notice that the persons described are richer than what was done before (The earlier code is commented out in-between the tokens /* and */. we need NOT define a predicate or a fact called person for our code to work). Please note that in the PIE (Prolog Inference Engine) that we are using, we can directly use a compound domain without any prior intimation to the Prolog engine (for example. We shall now package our facts using these functors.Īs a compound domain always has a functor, we shall henceforth use the term functor in this tutorial, to represent the respective compound domain.įor now, let us modify the first example of the previous tutorial, so that we use our newly defined functor person. The word person is known as a functor, and the variables are its arguments. Logically, it states that there is some compound domain called person in the system, each of which has two characteristics, represented by the logical variables Name and Gender. Note that the above statement is neither a fact nor a predicate. Thus we had given the following facts to the system: In the first part of this tutorial, we had tried putting together several characteristics of individuals together, (like the name and the gender), by inserting facts into the PIE system that concentrated on entities instead of relationships. What if we need to represent all those characteristics together, instead of representing just their names? That means, we need some mechanism to represent compound domains a collection of simpler domains held together. However, individuals are represented by more characteristics than just their names. Other simple domains would be numbers (e.g.: 123 or 3.14), symbols (e.g.: xyz or chil_10), and characters (e.g.: '5' or 'c'). In the case of the names of the people, the simple domain was a string. The values of the names are simple data types or simple domains. Now "Bill", "John" and "Pam" are just the names of the individuals. In Part 1 of the tutorial, all the people were represented as "Bill", "John" and "Pam" etc. * a lot of extensions: global variables, definite clause grammars (DCG), sockets interface, operating system. with many extensions very useful in practice (global variables, OS interface, sockets.).

Visual prolog vfccbd cnhjr software#

Top Software Keywords Show more Show less







Visual prolog vfccbd cnhjr