tuProlog + Logtalk

Tips and tricks when running Logtalk using other back-end Prolog compilers

Moderator: Paulo Moura

Post Reply
amoun
Posts: 2
Joined: Mon Jun 23, 2008 10:40 am

tuProlog + Logtalk

Post by amoun » Mon Jun 23, 2008 12:21 pm

Hi,

i am looking for a way to use logtalk in tuprolog. tuprolog is a 100% java based prolog compiler which allows the easy access of java objects from prolog and the other way around.

Currently I am developing a chat application based on artificial intelligence which contains prolog as well as java code. Much as i find it powerful using those languages together there are some limits which could be overcome by implementing oop in prolog.

My Question is, how difficult is it to implement logtalk in tuprolog. How should i approach on that?

thanks in advance

amoun

Paulo Moura
Logtalk developer
Posts: 453
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: tuProlog + Logtalk

Post by Paulo Moura » Mon Jun 23, 2008 3:09 pm

Hi!

TuProlog lacks a number of built-in predicates (specified in the ISO Prolog standard) that are necessary for Logtalk compatibility. Most of these missing predicates provide functionality that cannot be implemented by a user in plain Prolog. Examples are error handling predicates (catch/3 and throw/1) and input/output predicates (e.g. write_canonical/2, write_term/3, or read_term/3). Thus, a port of Logtalk to TuProlog is not currently feasible.

An alternative for a Java-based Prolog would be JIProlog. There are, however, a number of bugs in the current JIProlog release that preclude using this combination for serious work.

All the best,

Paulo
Paulo Moura
Logtalk developer

amoun
Posts: 2
Joined: Mon Jun 23, 2008 10:40 am

Re: tuProlog + Logtalk

Post by amoun » Fri Jun 27, 2008 8:16 am

well, unfortunately that's not what i wanted to hear. Thing is that i'm developing a language processing software for 2 years. Using tuprolog form the beginning it makes it almost impossible to switch to some other implementation.

tuprolog is made after the edinburgh standard instead of the iso standard. therefore some of the predicates are available but have different names. (e.g. write_canonical -- display). Nevertheless there are some predicates missing.

If i'm be able to find somebody willing to implement those missing predicates into tuprolog, would you be able to write an logtalk configuration for it?

so long,

amoun

Paulo Moura
Logtalk developer
Posts: 453
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: tuProlog + Logtalk

Post by Paulo Moura » Fri Jun 27, 2008 8:50 am

amoun wrote:well, unfortunately that's not what i wanted to hear. Thing is that i'm developing a language processing software for 2 years. Using tuprolog form the beginning it makes it almost impossible to switch to some other implementation.

tuprolog is made after the edinburgh standard instead of the iso standard. therefore some of the predicates are available but have different names. (e.g. write_canonical -- display). Nevertheless there are some predicates missing.
I've serious doubts that the display predicate can replace the write_canonical/2 predicate. But this is only one of several missing predicates.
amoun wrote:If i'm be able to find somebody willing to implement those missing predicates into tuprolog, would you be able to write an logtalk configuration for it?
A configuration file for a new back-end Prolog compiler is easy to write, provided that the compiler provides all the necessary bits. Check the "configs/template.config" and the "configs/NOTES.txt" files for details.

Cheers,

Paulo
Paulo Moura
Logtalk developer

burgessg
Posts: 2
Joined: Thu Sep 18, 2014 1:18 am

Re: tuProlog + Logtalk

Post by burgessg » Thu Sep 18, 2014 8:03 am

I wonder if the answer to this question has changed now.

tuprolog now implements: write term/2 - write term/3 - write/1 - write/2 - writeq/1 -
writeq/2 - write canonical/1 - write canonical/2, as well as the ISO catch/3 and throw/1.

What else was missing?

Paulo Moura
Logtalk developer
Posts: 453
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: tuProlog + Logtalk

Post by Paulo Moura » Thu Sep 18, 2014 8:38 am

Just took a quick look to the latest stable release of tuProlog (2.9.0). All required standard predicates seem to be there. Logtalk 3.x also requires a few de facto (but not official) predicate such as format/2-3 but these can be hacked (for the sole requirements of the Logtalk compiler and runtime). But I didn't find in the tuProlog documentation any predicate library for accessing the operating-system and perform necessary tasks like querying and setting the current directory, creating directories, checking if a file or a directory exists, or accessing environment variables. It's likely possible to define predicates that use the Java API to perform some of maybe even all of these tasks. If you want to try to define these predicates, check the adapters/template.pl file for the details of what's required. But it may be better for you to first contact the tuProlog developers and ask about the feasibility of defining these predicates.
Paulo Moura
Logtalk developer

Paulo Moura
Logtalk developer
Posts: 453
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: tuProlog + Logtalk

Post by Paulo Moura » Thu Sep 18, 2014 9:24 am

After playing a bit with the Prolog calling Java API, the only thing that seems to not be straight-forward is to deal with getting and setting the current directory. The comment to the answer marked as the correct answer in the following StackOverflow question seems to be a doable solution:

http://stackoverflow.com/questions/1900 ... ctory?lq=1
Paulo Moura
Logtalk developer

Paulo Moura
Logtalk developer
Posts: 453
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: tuProlog + Logtalk

Post by Paulo Moura » Thu Sep 18, 2014 10:41 am

Unfortunately, found other required features missing such as the de facto standard predicates between/3, numbervars/3, and predicate_property/2. Nevertheless, committed a first non-functional and incomplete draft of a tuProlog adapter file:

https://github.com/LogtalkDotOrg/logtal ... 924f5b7ebc

It can be used as starting point if tuProlog developers agree to implement missing functionality.
Paulo Moura
Logtalk developer

burgessg
Posts: 2
Joined: Thu Sep 18, 2014 1:18 am

Re: tuProlog + Logtalk

Post by burgessg » Sun Sep 21, 2014 1:47 am

Ok, thanks Paulo, I'll see if I can get them to look at it.

Cheers,
Glenn.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest