[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby and Prolog

Kevin

10/14/2006 11:14:00 PM

Anyone had any experience interfacing Prolog with Ruby?

_Kevin

9 Answers

M. Edward (Ed) Borasky

10/14/2006 11:55:00 PM

0

_Kevin wrote:
> Anyone had any experience interfacing Prolog with Ruby?
>
> _Kevin
>
>
>

What is it you're trying to accomplish? It seems to me, at least on an
open source platform, all you'd need to do would be to install a Prolog
interpreter/compiler, and then build Prolog source with Ruby and "shell
out" to Prolog. Is there something more "intimately interconnected" you
had in mind?

Kevin

10/15/2006 12:36:00 AM

0



On Oct 14, 7:54 pm, "M. Edward (Ed) Borasky" <z...@cesmail.net> wrote:
> _Kevin wrote:
> > Anyone had any experience interfacing Prolog with Ruby?
>
> > _KevinWhat is it you're trying to accomplish? It seems to me, at least on an
> open source platform, all you'd need to do would be to install a Prolog
> interpreter/compiler, and then build Prolog source with Ruby and "shell
> out" to Prolog. Is there something more "intimately interconnected" you
> had in mind?

Probably not. I anticipate that I may need to interface with a
particular Prolog application that a colleague has developed, and since
the extent of my knowlege of prolog consists mostly of how to spell it,
I thought I might enquire about how well it plays with ruby.

Shelling out might be all I need.

Thanks Ed.

_Kevin

M. Edward (Ed) Borasky

10/15/2006 9:51:00 AM

0

Yacao Wang wrote:
> Actually I've been thinking of creating an auto-backtracking engine for
> ruby
> based on the Prolog engine, because it's so much fun to play with
> non-deterministic programming. But I haven't got the time to do it. Has
> anyone have similar ideas or implementations?
>
> On 15/10/06, _Kevin <kevin.olbrich@gmail.com> wrote:
>>
>>
>>
>> On Oct 14, 7:54 pm, "M. Edward (Ed) Borasky" <z...@cesmail.net> wrote:
>> > _Kevin wrote:
>> > > Anyone had any experience interfacing Prolog with Ruby?
>> >
>> > > _KevinWhat is it you're trying to accomplish? It seems to me, at
>> least
>> on an
>> > open source platform, all you'd need to do would be to install a Prolog
>> > interpreter/compiler, and then build Prolog source with Ruby and "shell
>> > out" to Prolog. Is there something more "intimately interconnected" you
>> > had in mind?
>>
>> Probably not. I anticipate that I may need to interface with a
>> particular Prolog application that a colleague has developed, and since
>> the extent of my knowlege of prolog consists mostly of how to spell it,
>> I thought I might enquire about how well it plays with ruby.
>>
>> Shelling out might be all I need.
>>
>> Thanks Ed.
>>
>> _Kevin
>>
>>
>>
>
>

Well ... I just took a look at all the Prolog implementations in
Gentoo's Portage repository. There are about five of them, plus another
package for logic programming called "mercury". All of them appear to be
callable as libraries from C, which means you could wrap them as C
extensions fairly easily with SWIG, or even by hand. As usual, a lot of
this magic works well on Linux, probably almost as well on MacOS and
Solaris, possibly on CygWin and probably with some heavy lifting on
native Windows.

Kevin

10/15/2006 12:52:00 PM

0



On Oct 15, 5:51 am, "M. Edward (Ed) Borasky" <z...@cesmail.net> wrote:
> Yacao Wang wrote:
> > Actually I've been thinking of creating an auto-backtracking engine for
> > ruby
> > based on the Prolog engine, because it's so much fun to play with
> > non-deterministic programming. But I haven't got the time to do it. Has
> > anyone have similar ideas or implementations?
>
> > On 15/10/06, _Kevin <kevin.olbr...@gmail.com> wrote:
>
> >> On Oct 14, 7:54 pm, "M. Edward (Ed) Borasky" <z...@cesmail.net> wrote:
> >> > _Kevin wrote:
> >> > > Anyone had any experience interfacing Prolog with Ruby?
>
> >> > > _KevinWhat is it you're trying to accomplish? It seems to me, at
> >> least
> >> on an
> >> > open source platform, all you'd need to do would be to install a Prolog
> >> > interpreter/compiler, and then build Prolog source with Ruby and "shell
> >> > out" to Prolog. Is there something more "intimately interconnected" you
> >> > had in mind?
>
> >> Probably not. I anticipate that I may need to interface with a
> >> particular Prolog application that a colleague has developed, and since
> >> the extent of my knowlege of prolog consists mostly of how to spell it,
> >> I thought I might enquire about how well it plays with ruby.
>
> >> Shelling out might be all I need.
>
> >> Thanks Ed.
>
> >> _KevinWell ... I just took a look at all the Prolog implementations in
> Gentoo's Portage repository. There are about five of them, plus another
> package for logic programming called "mercury". All of them appear to be
> callable as libraries from C, which means you could wrap them as C
> extensions fairly easily with SWIG, or even by hand. As usual, a lot of
> this magic works well on Linux, probably almost as well on MacOS and
> Solaris, possibly on CygWin and probably with some heavy lifting on
> native Windows.

Thanks again, Ed. That helps.

_Kevin

Eleanor McHugh

10/15/2006 3:11:00 PM

0

On 15 Oct 2006, at 10:30, Yacao Wang wrote:
> Actually I've been thinking of creating an auto-backtracking engine
> for ruby
> based on the Prolog engine, because it's so much fun to play with
> non-deterministic programming. But I haven't got the time to do it.
> Has
> anyone have similar ideas or implementations?

I've been considering implementing Icon-style backtracking for some
time, but I'm always too busy with less interesting (but paid)
projects. Ruby with goal-oriented convenience would certainly rock :)

Ellie

Eleanor McHugh
Games With Brains
----
raise ArgumentError unless @reality.responds_to? :reason



Christian Neukirchen

10/15/2006 6:11:00 PM

0

"_Kevin" <kevin.olbrich@gmail.com> writes:

> Anyone had any experience interfacing Prolog with Ruby?

I have a very basic and still brittle binding to XSB, if you want, I
can post it somewhere.

> _Kevin
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...

M. Edward (Ed) Borasky

10/15/2006 6:47:00 PM

0

Eleanor McHugh wrote:
> On 15 Oct 2006, at 10:30, Yacao Wang wrote:
>> Actually I've been thinking of creating an auto-backtracking engine
>> for ruby
>> based on the Prolog engine, because it's so much fun to play with
>> non-deterministic programming. But I haven't got the time to do it. Has
>> anyone have similar ideas or implementations?
>
> I've been considering implementing Icon-style backtracking for some
> time, but I'm always too busy with less interesting (but paid) projects.
> Ruby with goal-oriented convenience would certainly rock :)
>
> Ellie
>
> Eleanor McHugh
> Games With Brains
> ----
> raise ArgumentError unless @reality.responds_to? :reason
>
>
>
>

I'm starting to wonder, with about half a dozen open-source Prolog
compilers/interpreters, plus the performance tuned Mercury environment,
why one would want to "do Prolog tasks in Ruby?" The original poster was
interested mostly in integrating Ruby with a specific Prolog app, and
most likely could accomplish his goal with either "system" or something
enclosed in backticks.

And for people who want to truly marry Ruby with Prolog, or for that
matter any other open-source language, most of them are written in C and
have well-defined interfaces to other things written in C, such as the
Ruby interpreter. Of course, a lot of this magic only works on
GNU/Linux, but hey, that's why a lot of us *love* GNU/Linux!

Render unto Ruby what is Ruby's ... render unto Prolog what is Prolog's
(or Mercury's), and render unto R what is R's. They're *all* better than
Java! :)

richard.j.dale@gmail.com

10/15/2006 7:20:00 PM

0

Eleanor McHugh wrote:
> On 15 Oct 2006, at 10:30, Yacao Wang wrote:
> > Actually I've been thinking of creating an auto-backtracking engine
> > for ruby
> > based on the Prolog engine, because it's so much fun to play with
> > non-deterministic programming. But I haven't got the time to do it.
> > Has
> > anyone have similar ideas or implementations?
>
> I've been considering implementing Icon-style backtracking for some
> time, but I'm always too busy with less interesting (but paid)
> projects. Ruby with goal-oriented convenience would certainly rock :)
I've started working on Prolog as a Ruby DSL, but haven't got anything
actually releasable yet. I wrote about what it will look like in a blog
here:

http://www.kdedevelopers.org...

For example:

female(mary)
likes(mary, wine)
likes(john, X) << [female(X), likes(X, wine)]

-- Richard

Daniel Martin

10/17/2006 1:22:00 AM

0

"Yacao Wang" <yacaowang@gmail.com> writes:

> Actually I've been thinking of creating an auto-backtracking engine for ruby
> based on the Prolog engine, because it's so much fun to play with
> non-deterministic programming. But I haven't got the time to do it. Has
> anyone have similar ideas or implementations?

You might be interested in looking through the solution to ruby quiz
#70: http://www.rubyquiz.com/q... (Constraint Processing)

Among other things, that contains a ruby implementation of amb.

A minimalist approach to doing backtracking in ruby was used in my
de-optimized solution to Ruby Quiz #84:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...

(Backtracking is bundled into the `flip_coin' and `reflip' methods)

--
s=%q( Daniel Martin -- martin@snowplow.org
puts "s=%q(#{s})",s.map{|i|i}[1] )
puts "s=%q(#{s})",s.map{|i|i}[1]