Ruby and Prolog

M

M. Edward (Ed) Borasky

_Kevin said:
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?
 
K

_Kevin

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

M. Edward (Ed) Borasky

Yacao said:
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?

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

_Kevin

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
 
E

Eleanor McHugh

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
 
M

M. Edward (Ed) Borasky

Eleanor said:
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

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! :)
 
R

richard.j.dale

Eleanor said:
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/node/2369

For example:

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

-- Richard
 
D

Daniel Martin

Yacao Wang said:
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/quiz70.html (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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top