Re: Problem to understand "Prolog Vocabulary"
- From: "PRO" <robert.wolf@xxxxxxxxxxxxxxxxxxxxxx>
- Date: 19 Oct 2005 16:08:49 -0700
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
.
- Follow-Ups:
- Re: Problem to understand "Prolog Vocabulary"
- From: skweek
- Re: Problem to understand "Prolog Vocabulary"
- References:
- [NEWBIES] Problem to understand "Prolog Vocabulary"
- From: skweek
- [NEWBIES] Problem to understand "Prolog Vocabulary"
- Prev by Date: Prolog problem
- Next by Date: Re: Prolog problem
- Previous by thread: [NEWBIES] Problem to understand "Prolog Vocabulary"
- Next by thread: Re: Problem to understand "Prolog Vocabulary"
- Index(es):
Relevant Pages
|
|