Re: Problem to understand "Prolog Vocabulary"



PRO a écrit :
Yes, I believe that the help is possible.
You may think as follows:
1. Clause.
This is an equivalen of a procedure (or function).
It has got the "header" with the name and formal parameters.
Then you normally see the symbol ":-", which you can interpret as the
beginning of the "body" of the procedure (or function).
The "body" in general consists of calls to other procedures (or
functions).
In prolog you refer to those calls as "conditions" or "predicates" or
whatever... .
Now, there is a little trick.
Clause does not return a value.
It either successes or fails.
You can try to simplify it by saying that "clause is a function, which
returns a logical value (true/false)".
However, if a clause fails then the entire computation is reversed back
to the state before the failure and prolog tries to "exercise" other
matching clauses.
It is "sort of" executing a program forward and backward.
2. Goal.
This is quite simple.
It is just a procedure call.
On interactive systems you can usually type if from the keyboard and
therefore debug small parts of your program.
As I mentioned previously, a prolog "procedure (or function)" either
successes or fails.
Therefore after you execute your "goal", prolog tells you the result,
which may be success or failure.
On non-interactive systems (i.e. prolog compilers) a "goal" is usually
the starting point of execution of the program.
Your clauses are "procedures" and your "goal" tells the compiler "where
to start".
3. Fact.
This one has no equivalent in other languages.
A fact is a procedure with the header only.
It has got no body (i.e. it does not call other procedures).
In other words: an empty clause or clause without body.
Prolog gurus will tell you: clause without conditions, you know,
something like "unconditional truth".
The whole story is quite tricky.
A procedure without a body hasn't got much meaning in other languages.
In prolog it is OK, because of the "parameter unification" mechanism,
which I am sure you will like.
4. All the explanation above is a bit simplified "imperative" approach.
I hope that all of you guys, with years of prolog experience, will not
burn me alive for this.

Hope this will help.

BRGDS

Thank you Robert to take your time to explain me all these concepts.

Sincerly
.



Relevant Pages

  • Re: negotiation by failure- list operations
    ... > from other Prolog systems, why it was worth to go through the trouble ... As soon as a clause is typed in it is instantly asserted into ... same full-screen editor window. ... software patents (did you know even tab controls are supposedly ...
    (comp.lang.prolog)
  • Re: Sublists question
    ... Since any of the variables can be s, this clause is certainly true. ... Here is an alternative predicate that does not have that problem. ... What Prolog are you using? ... Anyway, with the new sublist/2 predicate, the query, langford, ...
    (comp.lang.prolog)
  • Re: if statements in prolog
    ... JNY wrote: ... userEntry; so if you meant to "get the value that the user typed into ... Maybe you should tell us which Prolog system you use, ... If the "read" goal is part of a clause and thee ...
    (comp.lang.prolog)
  • Re: Problem to understand "Prolog Vocabulary"
    ... Clause does not return a value. ... It either successes or fails. ... It is "sort of" executing a program forward and backward. ... a prolog "procedure " either ...
    (comp.lang.prolog)
  • Re: New to programming question
    ... Each item in the sequence is assigned to the target_list variable in turn. ... When the items are exhausted, the "now do this last" instructions in the else statement, if present, are executed, and the loop terminates. ... A break statement executed in the first section terminates the WHOLE loop without executing the else clause. ... However, if the name is guessed correctly, then the break statement pulls us completely out of the loop without executing the else clause. ...
    (comp.lang.python)