Ruby and Prolog

Anyone had any experience interfacing Prolog with Ruby?

_Kevin

_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" <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://chneukirchen.org

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

···

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?

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

--
Alex

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?

> _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.

···

On 15/10/06, _Kevin <kevin.olbrich@gmail.com> wrote:

On Oct 14, 7:54 pm, "M. Edward (Ed) Borasky" <z...@cesmail.net> wrote:

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 :slight_smile:

Ellie

Eleanor McHugh
Games With Brains

···

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?

----
raise ArgumentError unless @reality.responds_to? :reason

"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: Ruby Quiz - Constraint Processing (#70) (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-talk/199337

(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]

Thanks again, Ed. That helps.

_Kevin

···

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.

Eleanor McHugh 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 :slight_smile:

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! :slight_smile:

···

On 15 Oct 2006, at 10:30, Yacao Wang wrote:

Eleanor McHugh 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 :slight_smile:

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/node/2369

For example:

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

-- Richard

···

On 15 Oct 2006, at 10:30, Yacao Wang wrote: