Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday July 23, 2002
11:15 AM

AI::Perlog

[ #6577 ]

My AI::Perlog is coming along nicely. It's not posted anywhere yet, but maybe I'll have something in about a week? I have boolean responses working fairly well. I can do this:

my $pg = AI::Perlog->new;
$pg->add_fact( owns => qw/ Ovid gold / );
$pg->add_fact( owns => qw/ Yoda grep / );
$pg->owns( 'Ovid', 'gold' ); # returns true
$pg->owns( 'Yoda', 'gold' ); # returns false
$pg->owns( '', 'gold' ); # Does *anyone* own gold? Returns true

Actually, while the above facts work, there is a bug that can create false positives with complex facts. I know what's causing it but the data structure that I need to create to get around it is pretty large and for serious AI systems with millions of facts, it will eat up all of the system's memory. However, I've made the classic "space for time" trade-off and, as a result, this seems to run reasonably fast.

Fixing the first bug has the nice side effect of tremendously simplifying the unification problem, but that's still going to be a tricky one. I need to do some more research into exactly how Prolog handles some of these issues.

One thing I've noticed is that while my data structures are large, they're not complicated (well, to a Perl programmer they're not :), so I am thinking that I may eventually be able to move them to Inline::C to save on space and improve performance. That, however, will probably not happen for quite some time. After I work on unification, I need to see how my planned implementation of rules is going to work.

Meanwhile, I have paying work to attend to. Sigh. The warm beauty of intellectualism shattered by the cold reality of life.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • i usually find clarity using undef vs ''. for instance, i'd write

    $pg->owns( undef, 'gold' );

    instead of

    $pg->owns( '', 'gold' );

    then again, if i wanted a more 'prologgy' syntax, i think i'd create a constant with an undefined value, like

    sub X () {}
    ## or use constant X => undef;

    $pg->owns( X, 'gold' );

    in fact, i think i like the Prolog-like syntax in my last example. that's probably what i'll find myself using.

    hrmmm... what if X is an lvalue subroutine?

    • I think you'll be relatively happy with this. In the auto-generated rules, if an argument is encountered with a false value, such as the empty string or undef, it's ignored (sort of). This means that if you prefer undef, you'll be perfectly free to use it.

      As for $pg->owns( X, 'gold' );, I like the syntax, but forcing a person to predefine all of those constants means that it will be harder for them to generate queries on the fly.

          use constant Who => '';