ntm1169@dsacg3.dsac.dla.mil (Mott Given) (09/28/90)
This is a program that will translate Edinburgh style PROLOG syntax to that of IBM PROLOG, to reduce the number of changes you need to make manually. It will not make all the changes necessary to get your program to run under MVS IBM PROLOG, so some changes will need to be made manually. The program is designed to minimize the number of changes you need to make, so in a few cases it may make changes that you should not make. The program was implemented with a software product called File-AID/SPF which runs on IBM or compatible mainframes, using Background File-AID (which allows you to run a batch job in the background). The program is not able to completely and correctly do the translation as File-Aid does not have the power of tools such the UNIX package "awk" (which could be used to implement a similar program if you do not have File-AID). For many extralogical predicates, especially those concerned with I/O, this program only makes part of the changes necessary. IF anyone can think of any suggestions for improvements to the program, I would be interested in hearing from you. Mott Given @ Defense Logistics Agency ,DSAC-TMP, P.O. Box 1605, Bldg. 27 Section 1, Systems Automation Center, Columbus, OH 43216-5002 INTERNET: mgiven@dsac.dla.mil UUCP: ...osu-cis!dsac!mgiven Phone: 614-238-9431 AUTOVON: 850-9431 FAX: 614-238-3214 ---------------------- cut here and upload to mainframe -------------------- //NTMPROLO JOB (USERID,USERDEPT),'IBM PROLOG',CLASS=1, // NOTIFY=USERID,MSGLEVEL=(1,1),MSGCLASS=X //STEP1 EXEC PGM=FILEAID //SYSPRINT DD SYSOUT=* //SYSLIST DD SYSOUT=* //SYSTOTAL DD SYSOUT=* //DD01 DD DSN=YOUR.PROLOG.CODE(MEMBERNAME),DISP=OLD //SYSIN DD * $$DD01 UPDATE REPL=(1,0,X'AD',X'C0'), REPL=(1,0,X'BD',X'D0'), REPL=(1,0,X'4F',X'5A'), REPL=(1,0,C":-",C"<-"), EA=(1,0,C"% ",C"/* "), EA=(1,0,C"! &",C"/ & "), REPL=(1,0,C"& ,",C"& / &"), EA=(1,0,C", ",C" & "), REPL=(1,0,C"K",C"!"), REPL=(1,0,C"'})",C"')"), REPL=(1,0,C"=<",C"<="), REPL=(1,0,C"=>",C">="), REPL=(1,0,C"\==",C"==/"), REPL=(1,0,C"\=",C"=/"), EA=(1,0,C"nl, ",C"nl & "), EA=(1,0,C" !, ",C" / & "), EA=(1,0,C"!,",C"/ & "), EA=(1,0,C"),(",C")Z(") EA=(1,0,C"),",C") & ") EA=(1,0,C")Z(",C"),(") REPL=(1,0,C"abolish",C"delax"), REPL=(1,0,C"assert",C"addax"), REPL=(1,0,C"asserta",C"addax"), REPL=(1,0,C"assertz",C"addax"), REPL=(1,0,C"clause",C"ax"), REPL=(1,0,C"close",C"dcio"), REPL=(1,0,C"create",C"dcio"), REPL=(1,0,C"display",C"writes"), REPL=(1,0,C"edit",C"ed"), REPL=(1,0,C"findall",C"compute"), REPL=(1,0,C"functor",C"axn"), REPL=(1,0,C"halt",C"fin"), REPL=(1,0,C"integer",C"int"), REPL=(1,0,C"listing",C"arg"), REPL=(1,0,C"number",C"num"), REPL=(1,0,C"open",C"dcio"), REPL=(1,0,C"print",C"writex"), REPL=(1,0,C"prstln",C"prst"), REPL=(1,0,C"put(",C"writes('"), REPL=(1,0,C"readlist",C"readli"), REPL=(1,0,C"retract",C"delax"), REPL=(1,0,C"tell",C"dcio"), REPL=(1,0,C"told",C"dcio"), REPL=(1,0,C"writeln({",C"writes('") //
ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (09/30/90)
In article <2574@dsacg3.dsac.dla.mil>, ntm1169@dsacg3.dsac.dla.mil (Mott Given) writes: > This is a program that will translate Edinburgh style PROLOG syntax to > that of IBM PROLOG, to reduce the number of changes you need to make manually. May I respectfully suggest that a better way to translate from Prolog to IBM PROLOG is to write a Prolog program? What you want is something that will read in Prolog code and write out IBM PROLOG code. You will of course want to be wary of "blind" replacement. It would, for example, be asking for trouble to replace 'close' by 'dcio'; consider estimated_distance_to_goal(State, close) % not 'distant' Better still, by using a Prolog program you can translate findall/3 to compute/4 -- do others find it strange that "compute" and "computable expressions" are unrelated? -- using a rule like prolog_to_PROLOG(findall(Template, Generator, List) ,compute(list, Template, Generator1, List) ) :- prolog_to_PROLOG(Generator, Generator1). The thing that puzzles me most is that Chapter 13 of the IBM PROLOG manual states clearly and explicitly in the very first paragraph that IBM PROLOG can process programs written with the Edinburgh syntax and using predicates that are normally part of an [sic] Prolog implementation for the Edinburgh syntax. You can switch freely between syntaxes in your program, and programs written in Edinburgh syntax can use all the built-in predicates and data types of IBM PROLOG. IBM's "Edinburgh" syntax (called 'synt2') isn't _quite Edinburgh syntax, but it's close enough for government work. I note that > REPL=(1,0,C":-",C"<-"), <- and :- are both accepted in *both* syntaxes, and that IBM PROLOG supports abolish/2, assert/1, asserta/1, ... > REPL=(1,0,C"abolish",C"delax"), > REPL=(1,0,C"assert",C"addax"), > REPL=(1,0,C"asserta",C"addax"), so that the most you should have to do to get at them in an IBM PROLOG program is to stick 'built2:' in front of them. The same applies to pretty well all the other predicates listed in the message. see/1 and tell/1 are provided. open/ and create/ aren't, but then there is no (de facto or ISO) standard predicate called create/. Admittedly, the manual I have is for Version 1 Release 1 on VM/SP, but if IBM's MVS release of IBM PROLOG differs significantly from IBM's VM/SP release, other Prolog vendors will have difficulty keeping the smiles off their faces. -- Fixed in the next release.
lhe@sics.se (Lars-Henrik Eriksson) (10/01/90)
In article <2574@dsacg3.dsac.dla.mil> ntm1169@dsacg3.dsac.dla.mil (Mott Given) writes: > //NTMPROLO JOB (USERID,USERDEPT),'IBM PROLOG',CLASS=1, > // NOTIFY=USERID,MSGLEVEL=(1,1),MSGCLASS=X > //STEP1 EXEC PGM=FILEAID > //SYSPRINT DD SYSOUT=* > //SYSLIST DD SYSOUT=* > //SYSTOTAL DD SYSOUT=* > //DD01 DD DSN=YOUR.PROLOG.CODE(MEMBERNAME),DISP=OLD > //SYSIN DD * > $$DD01 UPDATE REPL=(1,0,X'AD',X'C0'), > REPL=(1,0,X'BD',X'D0'), > ...... > // It is reassuring to see that IBM does things the very same way today as they did 14 years ago, when I was an high-school student and punched cards for my first program on an IBM computer... :-( Lars-Henrik Eriksson Internet: lhe@sics.se Swedish Institute of Computer Science Phone (intn'l): +46 8 752 15 09 Box 1263 Telefon (nat'l): 08 - 752 15 09 S-164 28 KISTA, SWEDEN
eric@skorpio.Usask.ca (Eric Neufeld) (10/01/90)
In article <1990Oct1.084152.405@sics.se> lhe@sics.se (Lars-Henrik Eriksson) writes: >In article <2574@dsacg3.dsac.dla.mil> ntm1169@dsacg3.dsac.dla.mil (Mott >Given) writes: >> //NTMPROLO JOB (USERID,USERDEPT),'IBM PROLOG',CLASS=1, >> // NOTIFY=USERID,MSGLEVEL=(1,1),MSGCLASS=X >> //STEP1 EXEC PGM=FILEAID >> //SYSPRINT DD SYSOUT=* >> //DD01 DD DSN=YOUR.PROLOG.CODE(MEMBERNAME),DISP=OLD > >> //SYSIN DD * >> $$DD01 UPDATE REPL=(1,0,X'AD',X'C0'), >> REPL=(1,0,X'BD',X'D0'), > >It is reassuring to see that IBM does things the very same way today as they >did 14 years ago, when I was an high-school student and punched cards for my >first program on an IBM computer... :-( > C'mon! What the world *really* needs is a good Prolog to JCL compiler! :-) :-) :-) :^) ;^)
pgl@cup.portal.com (Peter G Ludemann) (10/03/90)
I'm part of the IBM Prolog development group, so I guess I should try to put the record straight on IBM Prolog. It's a lot better than what some people allege it to be. In fact, I'd go so far as to say that it's the best Prolog on the market in terms of features, performance, and robustness. (But I'm biased ...) --- Disclaimer: the following are my own opinions; they have not been approved by IBM management or IBM lawyers; and I take full responsibility for any mistakes. First of all, there are *two* IBM Prologs. One is now obsolete. It implemented Grant Robert's Waterloo Prolog syntax (although it didn't use Grant's implementation techniques). Remember that this was done back in the Dark Ages when many people had only punched cards for input. So, the standard syntax was UPPER CASE. "Ugggghhhh", I hear you say. So, there was a second syntax called MIXED. It may come as no great surprise that almost everyone used MIXED. In fact, the new IBM Prolog doesn't even support upper-case only input (it doesn't require statement numbers in columns 73-80 either. :-)) So, let's move on to the new IBM Prolog. Its second release has just been released on CMS/SP, CMS/XA, MVS/XA and MVS/ESA (translation: it can exploit up to 2**31 bytes of memory); and has been announced for PS/2. [I really want to tell you some performance numbers, but I'll need legal clearance for that. Suffice it to say that I ran Peter Van Roy's tak benchmark and got speed figures comparable to tak with an optimizing C compiler; and that some benchmarks run in the 2+ mega-LIPS range.] Richard O'Keefe says: > Admittedly, the manual I have is for Version 1 Release 1 on VM/SP, > but if IBM's MVS release of IBM PROLOG differs significantly from > IBM's VM/SP release, other Prolog vendors will have difficulty keeping > the smiles off their faces. First, a minor correction to Richard: your manuals are also for VM/XA. Anyway, you can stop smiling; the MVS release is as compatible as can be after taking into account differences in operating systems (e.g., file naming conventions are different). I can readily pick my CMS programs and run them on MVS. What's more, IBM Prolog is tightly integrated with REXX (the system command language; it's better than C-shell + awk), GDDM (graphics display) and ISPF (dialogue manager); it also has very good facilities for calling and being called by C, Fortran, PL/I, Cobol and assembler and, last but no least, it also integrates well with the SQL/DS and DB2 relational databases. ----- As Richard points out, there is no need to write an "Edinburgh" translator; IBM provides one. IBM provides the user with the ability to tailor the syntax. Suppose that you think that lists should be written {a,b,c} instead of [a,b,c]? No problem. Would you like to use "if" instead of ":-"? Again, no problem. You get two pre-defined syntaxes: IBM standard ("synt1") and Edinburgh ("synt2"). But there's more ... > Better still, by using a Prolog program you can translate findall/3 to > compute/4 ... Why bother? IBM provides a bagof and a setof (it might come as no surprise that they translate almost directly into compute/4 or compute/5). What's more, they pass every evil test that Richard has mentioned about correct behaviour (thank-you Richard: I appreciate people who torture test programs. eally). IBM Prolog also provides user:expand_rule/2 which is a generalization of the usual expand_term/2. So, if you're really hung up on providing a translator, you can have it done for you during "consult". > The thing that puzzles me most is that Chapter 13 of the IBM PROLOG > manual states clearly and explicitly in the very first paragraph that > IBM PROLOG can process programs written with the Edinburgh > syntax and using predicates that are normally part of an [sic] > Prolog implementation for the Edinburgh syntax. > You can switch freely between syntaxes in your program, > and programs written in Edinburgh syntax can use all the > built-in predicates and data types of IBM PROLOG. > IBM's "Edinburgh" syntax (called 'synt2') isn't _quite Edinburgh syntax, > but it's close enough for government work. Coming from Richard, I'll take the "close enough" comment as a great complement. Besides, it's a little difficult know what exactly "Edinburgh" syntax is, what with Quintus, Arity, ALS, C-Prolog et al, not to mention ISO. Anyway, you really can write some predicates in Edinburgh and call them from IBM "standard" syntax (called "synt1"). What's more, you don't need to put built2: in front of all the predicates. If you're in synt2 (Edinburgh), write(X) will do what you expect (that is, you will get built2:write(X) which doesn't put a new-line after the term); if you're in synt1 (IBM), write(X) will get built:write(X) which does put a new-line after the term. It's all done with "priority prefixes" which are automatically switched when syntaxes are changed. The description is in the manual, under the "declare" directive and the "prio_pref" global term. Moreover, you can control in which syntax a term is written. For example, write(f(','(a,b))) from synt1 ==> f(","(a,b)) write(f(','(a,b))) from synt2 ==> f((a,b)) because "," is an operator only in synt2 and because '...' is the delimiter for atoms in synt2 but "..." is the delimiter in synt1. (This is a special case of `meta predicates'.) There are lots more nice features in the implementation, but I've rambled on enough. Feel free to take cheap shots at JCL (I don't use it any more; I use REXX); I think that you'll find cheap shots at IBM Prolog a little more difficult. Flames to me: - Peter Ludemann ludemann@mlpvm1.iinus1.ibm.com (disclaimer: the above are my opinions, and not IBM's)
ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (10/03/90)
In article <34488@cup.portal.com>, pgl@cup.portal.com (Peter G Ludemann) writes: > Besides, it's a little difficult know what exactly "Edinburgh" > syntax is, what with Quintus, Arity, ALS, C-Prolog et al, not to mention ISO. Edinburgh syntax is the syntax that comes from Edinburgh. All you have to do is pick up the public-domain TOKEN.PL and the p[ublic-domain READ.PL and you have what is by definition Edinburgh syntax. Quintus Prolog and SICStus Prolog are both derived from that definition (which was extracted from DEC-10 Prolog), and C Prolog is as compatible with it as a locally deterministic parser can be. With the exception of failure to support bases other than 10 and the very strange ~ syntax for character constants, ALS Prolog syntax is virtually identical to C Prolog. As near as I can make out, ISO Prolog is different for the sake of being different. The current draft still betrays a heavy C influence. I still have daydreams that one day the ISO committee will decide to *standardise* Prolog instead of *reinventing* it. -- Fixed in the next release.
ntm1169@dsacg3.dsac.dla.mil (Mott Given) (10/04/90)
From article <3850@goanna.cs.rmit.oz.au>, by ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe): > In article <2574@dsacg3.dsac.dla.mil>, ntm1169@dsacg3.dsac.dla.mil (Mott Given) writes: > May I respectfully suggest that a better way to translate from Prolog > to IBM PROLOG is to write a Prolog program? I agree with you 100% that a PROLOG translation program would be better than a FILEAID one. I started with the FILEAID one as something that would be much easier to implement. > The thing that puzzles me most is that Chapter 13 of the IBM PROLOG > manual states clearly and explicitly in the very first paragraph that > IBM PROLOG can process programs written with the Edinburgh > syntax and using predicates that are normally part of an [sic] > Prolog implementation for the Edinburgh syntax. IBM MVS PROLOG requires you to implement Edinburgh syntax by individually modifying each aspect of your environment through many "pragma" statements. For example, "pragma(lcomment,1)" allows you to use comments that have more than 1 line (this is shown as an illustration of the granularity of the statements you must specify). The software does not come with any predefined modules or commands that allow you to switch to Edinburgh syntax in a simple way. > I note that >> REPL=(1,0,C":-",C"<-"), > <- and :- are both accepted in *both* syntaxes, and that > IBM PROLOG supports abolish/2, assert/1, asserta/1, ... IBM MVS PROLOG does NOT have abolish/2, assert/1, and asserta/1 defined as built-in predicates in MVS/PROLOG Release 1 Level 0. There are significant differences between the MVS and VM versions of PROLOG.
pgl@cup.portal.com (Peter G Ludemann) (10/05/90)
> The software does not come with any > predefined modules or commands that allow you to switch to Edinburgh syntax > in a simple way. You just enter: <- switch(synt2) . And you're in Edinburgh syntax, with appropriate pragma values already set. You can also easily configure IBM Prolog so that Edinburgh is your default syntax, if you so desire. > IBM MVS PROLOG does NOT have abolish/2, assert/1, and asserta/1 > defined as built-in predicates in MVS/PROLOG Release 1 Level 0. There are > significant differences between the MVS and VM versions of PROLOG. I think that you're refering to the *old*, obsolete MVS Prolog. The *new* IBM Prolog for MVS is Version 1 Release 2. It is a port from CMS (which is why it is very compatible) and it most certainly does have abolish, assert and other Edinburgh predicates. The switch/1 predicate not only changes operator declarations, pragmas and syntax details; it also changes the default prefixes for many built-in predicates (for example, there are two =../2 predicates, with slightly different semantics). The *new* IBM Prolog for MVS became available about 2 weeks ago. ---- I'm not sure that debating the alleged good and bad points of IBM Prolog is an appropriate use of comp.lang.prolog. If you have specific questions or complaints about IBM Prolog, you can send them directly to me: - peter ludemann ludemann@mlpvm1.iinus1.ibm.com