Discussion:
Logic Programming
Ovid
2005-01-21 21:34:19 UTC
Permalink
Some on this list have expressed an interest in logic programming, so I
thought you might find http://www.perlmonks.org/index.pl?node_id=424075
of interest.

It's about a Prolog-based predicate logic engine in pure Perl. It
handles unification and backtracking. The write-up is basically an
intro to logic programming. In this, I happen to mention Terrence's
AI::Proplog as only allowing boolean queries. Please let me know if
I'm wrong.

The module won't be on the CPAN for a while as it needs a lot of work
(tests, docs, and tuning), but I do have a download link for the brave.
Just don't flame me for what I don't have :) Feel free to ask
questions.

Cheers,
Ovid

=====
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/
Terrence Brannon
2005-01-22 01:56:55 UTC
Permalink
is basically an intro to logic programming. In this, I
happen to mention Terrence's AI::Proplog as only allowing
boolean queries. Please let me know if I'm wrong.
You might mention the Perl interface to CLIPS:

http://www.ghg.net/clips/CLIPS-FAQ

Which I found much more useable than Prolog.

Also, Artrijus Tang developed an interface to PLT Scheme

http://cpan.uwinnipeg.ca/dist/Inline-MzScheme

which gives us access to Dorai Sitaram's Schelog:

http://www.ccs.neu.edu/home/dorai/schelog/schelog.html
Just don't flame me for what I don't have :) Feel free to
ask questions.
What software design goals will be reached when you complete this
project? How will they overlap/compliment the already powerful work done
in FSA::Rules?
Ovid
2005-01-22 19:39:53 UTC
Permalink
Post by Terrence Brannon
is basically an intro to logic programming. In this, I
happen to mention Terrence's AI::Proplog as only allowing
boolean queries. Please let me know if I'm wrong.
http://www.ghg.net/clips/CLIPS-FAQ
Which I found much more useable than Prolog.
I had not heard about this (or I don't remember it if I did.) However
from http://sourceforge.net/projects/cape/, it appears to be a dead
beta project that's not on the CPAN. Is there more that I am not
seeing?
Post by Terrence Brannon
Also, Artrijus Tang developed an interface to PLT Scheme
http://cpan.uwinnipeg.ca/dist/Inline-MzScheme
http://www.ccs.neu.edu/home/dorai/schelog/schelog.html
Ooh, that's looks very interesting. I'm going to have to check that
out.
Post by Terrence Brannon
What software design goals will be reached when you complete this
project? How will they overlap/compliment the already powerful work
done in FSA::Rules?
First, I'm glad you like FSA::Rules. David and I put a lot of work
into that. Thanks for the nice words.

The intent is to easily bring logic programming to Perl. Eventually, I
want people to be able to write this:

# What this is doing is explained in
# http://www.perlmonks.org/?node_id=424075
use AI::Logic
functors => [qw/append/],
vars => [qw/W X Y Z/],
import => 1; # imports builtins like HEAD(X)

my $logic = AI::Logic->new;
$logic->assert(
append([], X, X),
append([HEAD(W),X],Y,[HEAD(W),Z])
->IF(append(X,Y,Z))
);
$logic->query(append(X,Y,[qw/a b c d/]));
while (my $results = $logic->next) {
my $x = $results->X;
my $y = $results->Y;
print "X is [@$x]. Y is [@$y].\n";
}

Which would print something like:

X is []. Y is [a,b,c,d].
X is [a]. Y is [b,c,d].
X is [a,b]. Y is [c,d].
X is [a,b,c]. Y is [d].
X is [a,b,c,d]. Y is [].

Currently, this is not easy to do in Perl, but the AI::Prolog module
does have the core of the algorithm there and can generate those
results (though not in that format or with that syntax.)

As for how it's different from FSA::Rules, well, FSA::Rules is a state
machine. While I find it rather easy to use (for a state machine), it
didn't seem to map well to the problem state (hah!) at hand. Of
course, if I could figure out a decent way of building a known set of
transitions via states, I could do it with that, but I haven't yet. If
you can figure it out, I'd love to steal -- ahem -- see your code :)

I'll also take a look at Schelog. If Autrijus' work is solid enough
and looks like it will be supported, that could be a nice route to go.
It would also be a lot faster than what I have. Currently (with no
optimizations), it appears to be running about 1000 LIPS (Logical
Inferences Per Second.) That's very slow.

Cheers,
Ovid

=====
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/
Perl Software::Design mailing list
2005-01-23 23:53:57 UTC
Permalink
Post by Ovid
Post by Terrence Brannon
http://www.ghg.net/clips/CLIPS-FAQ
Which I found much more useable than Prolog.
I had not heard about this (or I don't remember it if I did.) However
from http://sourceforge.net/projects/cape/, it appears to be a dead
beta project that's not on the CPAN. Is there more that I am not
seeing?
It's not on CPAN, but there was one I got working back in 2001. I had
to do some searching, but once I found one, it worked fine and I found
it more useable and higher-level than Prolog.
Post by Ovid
Post by Terrence Brannon
What software design goals will be reached when you complete this
project? How will they overlap/compliment the already powerful work
done in FSA::Rules?
First, I'm glad you like FSA::Rules. David and I put a lot of work
into that. Thanks for the nice words.
Sure. The overlap in functionality is that a state machine can be
implemented in 3 Prolog predicates:

http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_14.html
Post by Ovid
The intent is to easily bring logic programming to Perl.
I find it easier to be logical in plain Perl... really. I was rabid
about logic programming, I posted "PPGA - Prolog-Perl Golf
Association: Run-length encoding" here:

http://www.perlmonks.org/index.pl?node_id=93193

and found japhy's perl much easier to work with than my Prolog. And
the last thing I ever want to encounter again are Prolog's red and
green cuts... no fun pruning and debugging search trees just to get
Prolog to search the way you want it to. Prolog was the first logic
language, but not the latest. Mercury:

http://www.cs.mu.oz.au/research/mercury/

keeps itself up to date by participating in programming competitions
and publishing research reports... but to each his own!
--
Carter's Compass: I know I'm on the right track when,
by deleting something, I'm adding functionality.
Ovid
2005-01-24 17:50:43 UTC
Permalink
Post by Perl Software::Design mailing list
Post by Ovid
The intent is to easily bring logic programming to Perl.
I find it easier to be logical in plain Perl... really. I was rabid
about logic programming, I posted "PPGA - Prolog-Perl Golf
http://www.perlmonks.org/index.pl?node_id=93193
All of the replies are imperative in nature. There is no logic
programming in them.

Perhaps I wasn't clear. When I say "logic programming", I really am
referring to logic programming and not imperative programming:
http://en.wikipedia.org/wiki/Logic_programming. Your reference to red
and green cuts suggests to me that you know the difference, so I assume
I am misunderstanding you.

By being able to specify the domain of a problem and a pattern for the
solution rather than the steps necessary to solve the problem, one
acquires a much greater flexibility for solving certain types of
problems. Perl cannot cannot natively do that outside of regular
expressons.

Cheers,
Ovid

=====
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/
Loading...