Re: Going mad with pattern matching

"Bill Page" <[email protected]>
Newsgroups gmane.comp.mathematics.axiom.user
Message-ID <[email protected]>
Quoting Martin Rubey:

>
> I did now go through your example.  It seems that you hit a bug, but
> fortunately, there is an easy workaround.  THe problem is with rules
> of the form:
>
> rule ...a...b... | p(a,b) == ... 
>
> It seems that in this case, the predicate p is never tested, who knows
> why. The workaround is to use the "suchThat" function. 

Martin, could you please say two words (or a little more?) about
where you found information and examples of how to use suchThat
and ruleset? Sometimes finding out *how* to find out is more
important than the specific answer. 

> Find the modified ruleset below. 
> ... 
> zt:=operator 'zt
>
> help(z,a) ==
>     tmp := z/(z-1)
>     for i in 1..a repeat
>         tmp:=-D(tmp,z)
>     tmp
>

Note that there is a problem in this expression. It does not
correctly compute the ztrans of 'n^a'. 

> myFreeOf? l == freeOf?(l.1, l.2)
>
> r0 := rule zt(f+g,n,z) == zt(f,n,z)+zt(g,n,z)
> r1 := suchThat(rule zt(a*f,n,z) == a*zt(f,n,z), [a, n], myFreeOf?)
> r2 := suchThat(rule zt(a,n,z) == a*z/(z-1), [a, n], myFreeOf?)
> r3 := suchThat(rule zt(a^n,n,z) == z/(z-a), [a, n], myFreeOf?)

That's pretty cool! I've never seen that anywhere before... 

> r4 := rule zt(0,n,z) == 0
> r5 := rule zt(1,n,z) == z/(z-1)
> r6 := rule zt(n,n,z) == z/(z-1)^2
> r7 := rule zt(n^(a | integer?(a) and a>1),n,z) == help(z, a)
>
> ztransrules := ruleset([r0,r1,r2,r3,r4,r5,r6,r7])$Ruleset(INT, INT, EXPR INT)
>

How can one decide on the proper package call to Ruleset?

> ztrans(f,n,z)==ztransrules zt(f,n,z)
>
> ... 

Regards,
Bill Page.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.