A Basic Prolog Implementation in Ruby
Ruby genius Mauricio Fernandez has been playing with an attempt at processing Prolog using Ruby found on a Japanese coding site and has come up with tiny_prolog.rb.
require 'tiny_prolog_ext' # rules # read as "X and Y are siblings if Z is the parent of both" sibling[:X,:Y] < <= [ parent[:Z,:X], parent[:Z,:Y], noteq[:X,:Y] ] parent[:X,:Y] <<= father[:X,:Y] parent[:X,:Y] <<= mother[:X,:Y] # facts: rules with "no preconditions" father["matz", "Ruby"].fact mother["Trude", "Sally"].fact father["Tom", "Sally"].fact father["Tom", "Erica"].fact father["Mike", "Tom"].fact query sibling[:X, "Sally"] # >> 1 sibling["Erica", "Sally"]
If you know what Prolog is, or you have an interest in micro-languages and Ruby, it's well worth a read as Mauricio looks into solving problems using logic that Prolog was designed for.
November 2, 2006 at 1:45 pm
This is a language combination that has drawn looks from several people recently. It might be worth looking at: Jamis Buck's thoughts and Richard Dale's blog post for some additional ideas. Hopefully Maurcio, Jamis, and Richard can spend some time talking through their individual plans and come up with some really cool prolog in Ruby stuff.
November 16, 2006 at 4:54 am
now, how do you write this in Lisp?