PROLOG-REQUEST@SU-SCORE.ARPA (06/13/83)
From: Chuck Restivo (The Moderator) <PROLOG-REQUEST@SU-SCORE.ARPA> PROLOG Digest Tuesday, 14 Jun 1983 Volume 1 : Issue 10 Today's Topics: Query - Using Prefix Operators, Applications - Objects, POPLOG Availability ---------------------------------------------------------------------- Date: Sun 12 Jun 83 19:42:35-PDT From: SHardy@SRI-KL.ARPA Subject: Help Needed Using Prefix Operators I'm using Prolog to build a system to help teach first order predicate calculus. I need help in using operators to define the grammar I want. * Does anyone have any suggestions on how I can solve my immediate problem (outlined below). * My problem arises because of weaknesses in the tools PROLOG provides for implementing embedded languages. Does anyone have ideas for improving matters? My specific problem The following is an example of the type of statement my system must be able to process. if (exists x: all y: if person(y) then loves(x, y)) then (all y: if person(y) then (exists x:loves(x, y))) This syntax was chosen because, with suitable operator definitions, it can be manipulated directly; I.e. the above expression is a Prolog term. Here is a first cut at the necessary definitions: :- op(1, fx, [all, exists]). :- op(950, xfy, :). :- op(945, fy, if). :- op(940, xfy, then). The problems with these modes are: * They accept too many things as legal, for example 'if if x'. This doesn't bother me too much. * They ''mis-parse'' apparently legal things. For example: if all x:happy(x) then arrived(utopia) gets parsed as: (if all x):happy(x) then arrived(utopia). Of course, I could get this particular expression parsed right by lowering the precedence of ':' to below that of 'if' and 'then', but then expressions like the following would cause problems instead: all x:if human(x) then mortal(x) I don't suppose I'm the first person to face this particular problem. Does anyone have a simple solution for me? Currently, I'm thinking of writing a conversion program that takes input from the user and then re-arranges it using transformation rules such as: (if all X):P then Q ---> if (all X:P) then Q Has anyone tried this approach? Why not use DCG's While Prolog is a fantastic language for writing symbolic manipulation programs, the two tools for defining new grammars have serious weaknesses. This is a great pity because domain specific grammars often make programs much much clearer. In my case, for example, the rules for conversion to conjunctive normal form are very clear: not(all X:P) ---> exists X:P. However, using OP to define new grammars is too complicated. With over ten types of operator it's hard just to see the implications of a set of defintions. I have to use DISPLAY to find out how something has been parsed, then edit the OP defintions and then use DISPLAY again. Anyhow, operator precedence languages are not that powerful - for example, you couldn't use them to define the syntax of Prolog lists. On the other hand, definite clause grammars are not integrated into Prolog. You can't define a grammar using DCGs and then use it to help write your Prolog program. Getting syntax error messages is hard. You have to duplicate a lot of code - such as the lexical analyser and operator precedence parser. In fact, DCGs have more of the flavor of a user-group library routine than of a carefully thought out feature of the language. Specifically I'd like to see two things: (1) The ability to make simple extensions to the syntax of Prolog itself beyond the capabilities provided by operators. For my program now, I'd rather not be hacking precedences, or writing lexical analysers, I'd just like to be able to write things like: newsyntax all X:P. newsyntax if P then Q. (2) I'd like the internals of the Prolog system to be more accessible, especially the routines for reading and writing. That way, DCGs could be a one page library procedure and I could write my own version if I didn't like the one supplied. I might also be able to write "newsyntax.pl" as a new user group library routine!! -- Steve Hardy, Teknowledge ------------------------------ Date: Tuesday, 7 Jun 1983 19:20-PDT From: Narain at Rand-Unix Subject: Reply to Abbott "p" is equivalent to "q" means: 1) When a call to "p" is made, all clauses under "p" as well as under "q" must be tried. 2) When a call to "q" is made, all clauses under "q" as well as under "p" must be tried. The first condition can be expressed by writing: p(X):-q(X). If the second condition is expressed as: q(X):-p(X) an infinite loop will result. Instead this last clause is modified, so that whenever a call to "q" is made, bodies of all clauses under "p" will be tried except the body of the clause p(X):-q(X). This is done by writing: q(X):-clause(p(X),Body),not Body=q(X),Body. Instead of computing which clauses to use at run-time, one may, at compile-time assert new clauses under "p" each of which has the body of a distinct clause under "q". Similarly new clauses are asserted under "q". -- Sanjai ------------------------------ Date: Sun 12 Jun 83 19:44:10-PDT From: SHardy@SRI-KL.ARPA Subject: Prolog For The Vax Implementation For VAX/VMS The Sussex Poplog system is a multi-language programming environment for AI tasks. It includes: (a) A native mode Prolog compiler, compatible with the Clocksin and Mellish book. The system supports floating point arithmetic. (b) A POP-11 compiler. POP-11 and Prolog programs may share data structures and may call each other as subroutines; they may also co-routine with each other. (POP is the British derivative of LISP; functionally equivalent to Lisp, it has a more conventional syntax.) (c) VED, an Emacs like extendible editor, is part of the run time system. VED is written in POP-11 and so can easily be extended. It can also be used for input (e.g. simple menus) and for output (simple cellular graphics). VED and the compilers share memory, making for a well integrated programming environment. (d) Subroutines written in other languages, e.g. Fortran, may be linked in as new built in predicates. Prolog's complex architecture was designed to help build blackboard systems working on large amounts of numerical data. The intention is that Fortran (or a similar language) be used for array processing; POP-11 will be used for manipulating agendas and other procedurally oriented tasks and Prolog will be used for logical inference. However, the components of Prolog can be used individually without knowledge of the other components. To some users, Poplog is simply a powerful text editor, to others it just a Prolog system. Poplog has been adopted, along with Franz LISP and DEC-20 Prolog, as part of the "common software base" for the IKBS program (Britain's response to The Fifth Generation). The system is being transported to the PERQ and Motorola 68000, as well as being converted for VAX/UNIX. Although full details haven't yet been announced, the system will be commercially supported. The license fee will be approx $10,000 with maintenance approx. $1,000 per annum. For more details, write to: Dr Aaron Sloman Cognitive Studies Programme University of Sussex Falmer, Brighton, ENGLAND (273) 606755 -- Steve Hardy, Teknowledge ------------------------------ End of PROLOG Digest ********************