I spent a good number of hours experimenting after reading your last post about thieves etc. Unfortunately since I had two deadlines I didn't have time to finish or to post my work in time. (and also it didn't work completely). This is great stuff, though everyone seems to be talking about databases all of a sudden.

I've looked around at reasoning code for use with Perl several times, though you probably know about the AI tool from NASA (CLIPS, thanks for the link John) and also CYC (also someone linked before I read the thread..). Perhaps you were prodded by a recent news story about Dr. Howard Cross' Problem Knowledge Coupler for medical diagnoses.

What I first tried to do was implement the Who's a Thief problem using Damian Conway's
Quantum Superpositions module, since it sounded like his any() and all() might be useful.
Good for consciousness jokes too :) actually I had tried to apply it with an ingenious but only 80%
implemented (too small to fit in this margin) solution to the question about filling a
table with categories. The neat thing in both cases is that after setting up the data, the final answer usually is only one to three lines of what looks like very intuitive English-like phrasing.

I had difficulty using it, for example I don't think any(actor)->owns{item} syntax worked.
But it was seductive because it looked just like your prolog statements, except for all that punctuation.
I played around with these kinds of statements:

Here $item and $potentialvictim were supposed to be simultaneously multivalued. But (unless I misunderstood) some of this did not work because you actually have to superimpose two multivalued objects to get the superimposition, I think. Otherwise a lot of what you think should happen doesn't.

Then I realized Quantum::Entanglement would be far more useful. This was also pretty difficult conceptually but I found it fascinating. In particular you might want to look at Entanglement's p_func which might be useful as a way to set rules operating on things. Also, the quantumlogic method looks extremely interesting and I haven't even barely looked in its general direction yet.

This would seem to let you easily change the probability of certain events happening. This module is extremely cool and brain bending, I recommend it.

However unless I am wrong (quite possible), since all possibilities need to be well-defined you end up with just a big matrix solver instead of an elegant logic engine. But the need for intersection, union, and probably a "such that" phrase (a pipe in math or haskell, like x|y=1) seem useful. Maybe for/foreach does it but there seems to be quite a lot more cool stuff in Haskell.

So I'd recommend checking out Set::Bag and Set::Scalar/Set::Scalar::Valued which seems pretty powerful and even overrides some symbols so you can take the intersection of sets which would help solve the thief problem. You can say things in Set::Bag like: $rich = owns(x,y) * valuable(y); # intersection

I think a Perl AI engine would be very useful in making interesting services, for example I did some looking around for one when I was planning a product recommendation engine that would help a customer find the right product given certain needs. I'd be much more interested now in being able to ask intelligent questions and get back statistically sorted answers, than to save a hundred thousand facts in a database just yet. Or to have just a little bit of intelligence added to my coding to save me time. Maybe something that knows all the functions I've written and could whip something up in response to a well-typed phrase?

By the way, about Cyc, if you haven't it might be interesting to read some of the messages in the forum in the sourceforge project page. A couple months ago I remember some very interesting questions.

And, have you looked at Haskell and what do you think?

Also, what if we had a project wiki for pm projects?

Finally a few thoughts about your questions, at the risk of stating the obvious..

- making a statement like you did about kudra and merlyn creates possible counterstatements (how many books does merlyn have) for example, which would seem to mean either doing a database search each time, or updating a hash of facts about each object every time you do anything. Perhaps you would like to simulate a universe of objects? It might make queries faster. Hence your pairs note, I'm sure.

- For some reason I think we operate more like the Entanglement routine above and less like SQL. Not subatomically speaking, but that some facts stand out, or your interest is piqued by certain words. Perhaps simulating a person listening to those facts and recording a story about them in a graph would be a viable approach. Plus you could graph it with DataViz! :)

- I like the ability to state questions in perl-friendly phrasing, like $kudra gives $book{learningperl} to $merlyn. And I'd like to have "such that" added to Perl. Looking back at Haskell and even Functional.pm it would seem that a hard mathematical approach is one way to do an interface, while another might be a more linguistic approach.

- I'd like to suggest a general purpose reasoning module that would emphasize useful interface and queries and not speed or volume of facts.

- Also as mentioned above, something which does some of the work for you in Perl development would be extremely useful.
For example, a repository of logic about Perl programming and other development issues, with knowledge about glueing modules together might be a killer. It could chat with you about what you want to build, and.. well you can finish this one yourself. But if a semantic repository is available, TMTOWTDI will reign supreme!

Anyway, something that greatly magnifies the strength of a Perl programmer, and makes perl itself more powerful even in a small way, would have a lot of applications. What are the one or two words you would like to see added to the language?

Hope this has helped stir the coals and not put you to sleep. Much luck!