Actually, on second thoughts, my workaround isn't very helpful since it
applies Bayes' rule exactly once to _every_ subexpression of the form (a|b
and c), whereas to simplify a formula you often want to apply it to just one
of them. So I really do need a way to apply the rule exactly once - and
there also needs to be a way to specify which match it should be applied
to.
Nathaniel
2009/10/1 Nathaniel Virgo <nathanielvirgo at gmail.com>
> Ah, I see. That trace thing is handy.
>
> I've found a workaround to make the rule apply only once - I'm not sure how
> sensible it is but it seems to work for now:
>
> defrule(bayes1, (AA|BB and CC), (BB | _identity(AA and
> CC))*(AA|CC)/(BB|CC));
> defrule(bayes2, _identity(AA), AA);
>
> then
>
> apply1(a|b and c, bayes1, bayes2)
> apply1(%, bayes1, bayes2)
>
> returns the original expression, because the _identity function prevents
> the pattern from being matched twice. I'll continue with this workaround
> and see how far I get.
>
> Thanks,
>
> Nathaniel
>
>
> 2009/10/1 Robert Dodier <robert.dodier at gmail.com>
>
>> On Thu, Oct 1, 2009 at 10:24 AM, Nathaniel Virgo
>>
>> <nathanielvirgo at gmail.com> wrote:
>>
>> > If I type exactly what you wrote it works --- but if I remove the '*x'
>> then
>> > it doesn't:
>> >
>> > (%i6) applyb1( (a|b and c), bayes);
>> > (%o6) ((a | c)*(b | a and c))/b | c
>> >
>> > (%i7) applyb1 (%, bayes);
>> > (%o7) ((a | c)*(b | a and c))/b | c
>>
>> OK, in this case it appears (to judge by what's shown by
>> :lisp (trace $bayes) and then redoing the example) that applyb1
>> applies the rule twice, with zero net effect.
>>
>> As before, it seems desirable to cause exactly one application of
>> the rule. I'll have to think about that.
>>
>> best
>>
>> Robert Dodier
>>
>
>