Fix bug #1097: pattern variable appears in letsimp result
This is an ancient bug that was present in Macsyma.
(%i1) matchdeclare ([a, b, c], true)$
(%i2) let (f(a,b)^c, g(a,b)^c)$
(%i3) letsimp (f(x,y)^z);
(%o3) g(a,b)^z
The bug is in NISMATCH. In the case where the pattern expression
has a non-empty arg list, there are calls to NISARGSCHECKER and
NISEXPOCHECK. The former takes arg lists and an alist of
substitutions and returns an updated alist of substitutions based
on the arg lists (this returned alist could be NIL, representing
failure). The latter takes exponents and an alist of substitutions
and returns either a ratio or an updated alist of substitutions
based the exponents (again NIL could be returned, representing
failure).
The bug is in the case where both NISARGSCHECKER and NISEXPOCHECK
return an alist of successful substitutions. Both of these functions
find the correct substitutions, but effectively only the substitutions
from NISEXPOCHECK are used. The substitutions from NISARGSCHECKER are
not used, which is why the pattern variables show up in the args of
the final expression returned by letsimp.
Now we call NISARGSCHECKER to get an updated alist and then pass that
alist to NISEXPOCHECK. The we proceed based on whether or not
NISEXPOCHECK returns a ratio or an updated alist.
No problems with the test suite or share test suite. New tests have
been added to rtest12. Also two older rtest12 tests now pass when
were previously expected to fail (these tests were added based on
this same bug report).