For what it is worth, I wrote that code, but over 35 years ago.
I am sure I would write it differently today, but I could probably
help someone figure it out, if necessary.
The style of Lisp has changed (at least my personal style); I
think the Mathematica pattern matching design could
be mimicked in a revision in several ways: adding a predicate to
be applied to the whole match, combining the declaration and use
of pattern variables is probably neater. e.g. in Mathematica this
rule might be s[i_Integer].s[j_Integer] -> s[j].s[i]/; i<j
or something like that, which is neater.
Andrej Vodopivec wrote:
>Hi,
>
>the third argument would be nicer but this example can also be done with
>
>(%i1) greaterthan(i,j) := integerp(j) and is(i<j);
>(%o1) greaterthan(i,j):=integerp(j) and is(i<j)
>(%i2) matchdeclare(i, integerp);
>(%o2) done
>(%i3) matchdeclare(j, greaterthan(i));
>(%o3) done
>(%i4) tellsimpafter(s[i]^^2, 1);
>(%o4) [^^rule1,simpncexpt]
>(%i5) tellsimpafter(s[i].s[j],-s[j].s[i]);
>(%o5) [.rule1,simpnct]
>(%i6) factor(expand(sum(s[i],i,0,9)^^5));
>(%o6) 100*(s[9]+s[8]+s[7]+s[6]+s[5]+s[4]+s[3]+s[2]+s[1]+s[0])
>
>HTH,
>Andrej
>
>On 3/20/06, Mike Thomas <miketh at paradigmgeo.com> wrote:
>
>
>>Hi everyone.
>>
>>By inference from the following web page:
>>
>> http://www.clifford.org/anonftp/clf-alg/software/macsyma.txt
>>
>>Macsyma per se apparently has the ability to add a condition (as a third
>>argument) to tellsimpafter and used as follows:
>>
>>=====================================================================
>>Problem: Expand (s9 + s8 + s7 + s6 + s5 + s4 + s3 + s2 + s1 + s0 )^5
>>in an algebra where 1/2 ( si . sj + sj . si ) = delta(i,j)
>>
>>/* Define the two simplification rules. */
>>(c1) matchdeclare([i,j],integerp)$
>>
>>(c2) tellsimpafter(s[i]^^2,1)$
>>
>>(c3) tellsimpafter(s[i].s[j],-s[j].s[i],i>j)$
>>
>>/* Optional: compile rules for speed. */
>>(c4) compile_rule(all)$
>>
>>/* Compute the result. */
>>(c5) factor(expand(sum(s[i],i,0,9)^^5))
>>
>>(d5) 100 (s + s + s + s + s + s + s + s + s + s )
>> 9 8 7 6 5 4 3 2 1 0
>>=====================================================================
>>
>>
>>Looking at the function "proc-$tellsimpafter" in "src/matcom.lisp"
>>Maxima does not do anything with that third argument.
>>
>>Is there a way to add this kind of functionality without rewiring
>>"proc-$tellsimpafter"?
>>
>>If it comes to rewiring, is there some documentation of the means by
>>which a new rule is added, where it is stored and how it is fired?
>>
>>Would there be any pitfalls attached to such an addition?
>>
>>Is there a utility function in Maxima which could be used for compiling
>>such a test into whatever internal form is required?
>>
>>Cheers
>>
>>Mike Thomas.
>>
>>_______________________________________________
>>Maxima mailing list
>>Maxima at math.utexas.edu
>>http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>>
>>
>
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima
>
>