Re: It seems that I found prolog in prolog



newser.bbs@xxxxxxxxxxxxxxxxx wrote:
Cesar Rabak wrote:
Did you read what's written in these pages:
> http://www2.info.ucl.ac.be/people/PVR/aquarius.html
http://www.info.ucl.ac.be/people/PVR/user_manual.ps
http://www2.info.ucl.ac.be/people/PVR/Peter.thesis/Peter.thesis.html

Not completely. I'd like to and check the interpreter part of the
source
codes , for the input buffer . Because I want to find the way of
auto-key-in , as I mentioned before.

You are seriously confused if you are worrying about input buffers.

Try to learn to distinguish these 3 things:

1. sequences of characters (in a file, or typed in by a user)
2. Prolog data structures (compound terms, lists, numbers, ...)
3. fragments of Prolog programs (goals, clauses, queries)

You go from (1) to (2) using a Prolog parser. Every Prolog system
comes with a parser, and the read-family of predicates is an
interface to this parser, so you don't need to worry about it.

You go from (2) to (1) using the write-family of predicates.

You go from (2) to (3) by using either the call/1 predicate
(which turns a data structure into a goal), or the likes of
assert (which turns a data structure into a program clause).

To a limited extent, you can go from (3) to (2) using clause/2,
but you will hardly ever need this.

Armed with this background, you may try to understand how a
Prolog toplevel-loop can be implemented:

toplevel :-
write('?- '),
read_term(Query, [variable_names(NameVarPairs)]),
(
call(Query),
write(NameVarPairs),
get_char(Command),
Command \= (;)
->
write(yes)
;
write(no)
),
nl,
toplevel.


-- Joachim
[PS: yes, I know this is normally done with a failure-driven loop]
.



Relevant Pages

  • Re: OO versus RDB
    ... There is a very simple mapping from RM to PROLOG. ... a representation based on predicates, ... 'connection' comes from the fact that PROLOG stores rules about facts ...
    (comp.object)
  • Re: OO versus RDB
    ... There is a very simple mapping from RM to PROLOG. ... store knowledge using predicates. ... applied to a physical representation of a relational model. ...
    (comp.object)
  • Re: Prolog, memory management and memory leaks
    ... It depends on what you mean by a memory leak. ... Did the programmer mess up, ... the Prolog implementation you are working with). ... non-deterministic predicates in not always perfect. ...
    (comp.lang.prolog)
  • Re: Cross-Compiler development (MasterProlog/SWI/SICStus)
    ... In most Prolog applications, there are usually a small set of ... top predicates and a bigger number of auxiliary predicates. ... of the object encapsulating them. ... the configuration file for your Prolog compiler, ...
    (comp.lang.prolog)
  • Re: What should the semantics of hierarchical modules be?
    ... > Brian Hulley wrote: ... >>>the pure Prolog. ... But Prolog) Predicates are global and there are no objects or types to ... and write "foo" and let prolog discover what I meant by searching" ...
    (comp.lang.prolog)