Re: Problem to understand "Prolog Vocabulary"
- From: skweek <skweek_nospam@xxxxxxxxx>
- Date: Thu, 20 Oct 2005 10:44:00 +0200
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 .
- References:
- [NEWBIES] Problem to understand "Prolog Vocabulary"
- From: skweek
- Re: Problem to understand "Prolog Vocabulary"
- From: PRO
- [NEWBIES] Problem to understand "Prolog Vocabulary"
- Prev by Date: Re: [NEWBIES] Problem to understand "Prolog Vocabulary"
- Next by Date: Re: Negation In Prolog
- Previous by thread: Re: Problem to understand "Prolog Vocabulary"
- Next by thread: Re: [NEWBIES] Problem to understand "Prolog Vocabulary"
- Index(es):
Relevant Pages
|
|