Pattern matching - new user question



Hi

I'm a new user of Maxima and I'm interested in using it for calculations in
Bayesian probability theory and information theory.  I'm trying to get my
head around how to implement new simplifier rules, in order to be able to
manipulate probability expressions.

I'm sort-of getting there, but the rules I've defined don't seem to match
subexpressions in the way I expect them to.  Presumably I'm missing
something.  Here is an example showing the sort of thing I'm trying to do,
and the way in which it isn't working:

(%i1) infix("|",50,50);
(%o1) |

 "(a|b)" is to be read as P(a|b), or the probability of a given b.  This is
my preferred notation for Bayesian probability theory.

Since we're talking about Bayesian probability theory, a and b stand for
statements of logic that may or may not be true.

(%i2) matchdeclare([AA,BB,CC],all);
(%o2) done

(%i3) defrule(bayes, (AA|BB and CC), (BB|AA and CC)*(AA|CC)/(BB|CC));
(%o3) bayes:AA | BB and CC->((AA | CC)*(BB | AA and CC))/BB | CC

 The above is Bayes' theorem as a maxima rule.  The following works fine:

(%i4) bayes( a | b and c);
(%o4) ((a | c)*(b | a and c))/b | c

 ...but it doesn't want to match subexpressions:

(%i5) bayes( (a | b and c) * x);
(%o5) false

 this doesn't work either:

(%i6) apply1( (a|b and c)*x, bayes);
(%o6) (a | b and c)*x

Can anybody point out what I'm doing wrong?

Thanks in advance,
Nathaniel