logic programming for IRC infobots
kragen at pobox.com
Thu May 19 03:37:02 EDT 2005
Maybe you could build an interesting infobot on top of a Prolog-like
<xentrac!kragen at localhost> blah blahdety blabble blag blocc
becomes a fact:
uttered(xentrac, kragen, localhost, utterance([blah, blahdety, blabble, blag, blocc])).
Now, we might have a rule
utterance(Y) :- uttered(X, kragen, localhost, utterance(Y)).
and perhaps even
utterance([[X, said] | Y]) :- uttered(X, _, _, utterance(Y)).
Perhaps a more interesting case is
utterance(X) :- append(X, [if | Y], Z), utterance(Y), utterance(Z).
utterance(X) :- append(A, [and | B], X), utterance(A), utterance(B).
(Note that Prolog's evaluation order guarantees that these are
useless. I'm not a hip enough Prolog user to know how to fix that...)
Does that take care of the case where someone says
utterance([X, is, ugly, if, X, is, green]).
utterance([san-carlos, is, green]).
? Does it allow us to conclude
utterance([san-carlos, is, ugly]).
? I don't know enough about how Prolog works to know, but I think so.
On English syntax: probably capital letters should not suffice to make
something a variable. Perhaps we could have some standard variable
[someone, he, she, they]
[anyone, he, she, they]
And in queries:
[who, he, she, they]
[whom, he, she, they]
You could probably restrict queries to "Kragen is where?" rather than
allowing "Where is Kragen?". This would probably be most illuminating
if more recent facts were consulted first, and perhaps if the few most
recent relevant facts were mentioned in the answer:
<infobot> I think Kragen is at work, because xentrac said at 10:11, "i am at work"
Probably "Why?" or "Please explain" should elicit further relevant
facts if the querent hasn't talked to anybody else in the interim.
In this kind of context, expressiveness may be less important than
good behavior --- so, for instance, it may be good to do some
breadth-first search in case someone has created an inference loop,
and perhaps to do searches in the background.
For retractions, you could probably employ a "That's wrong" or
"xentrac is wrong" or "nonsense" "command" to retract some previous
assertion that explanations reveal to be leading to incorrect
For extra credit, you could track different people's belief
structures, and try to answer their questions in terms of their own
belief structures. For example, "I believe something if paulv
believes it." For UI hints, you could answer "no" questions with
other people's beliefs. "Paulv might believe Kragen is at work,
More information about the Kragen-tol