Hi reduce devs,
When I run the following script in Reduce CSL rev 5890 it outputs a file tmp.log.
Line 158 of this file contains the line
g149 := g10**(1/3)$
The term g10 is not defined anywhere.
This problem does not happen when I replace 1/3 with the term k.
Regards.
I take that back. Problem not solved.
I now have a situation where
g10is referenced before it is definedIn your first test file maybe the first thing to say is that without
"optimize" the results are very voluminous but with they are a lot better.
However your "missing definition of g10" looks like a clear-cut bug in the
"scope" package.
The code impleme4nting that seems to date from 1981 and 1983 (see
scope/codopt.red that points to papers that describe how it works) and
it is not clear that the the originators are immediatly available to
investigate! Of course all the code is there in the source tree:
.../reduce-algebra/packages/scope/*.red
and if one idenbtifies key functions it is possible to ask that they
be traced as things go...
tr extbrsea, redcodmat, findhr, addcse;
(or whatever - those are just sample procedure names) so it will be
neecessary to sort of what procedure4s are called in the bad case. This
will be MUCH kess hideous if the example is small!
So what would be really helpful from you both with the "missing g10" case
and your "g10 not defined soon enough" case would be all you can manage to
find as smallest example of bad behaviour as you can.
As a comment to other who may be willing to dive into the code to try to
see what is going in, my attention fell on line around 47 of codmat.red
that reads
for j:=inb:nb do gensym() >>
which seems liks an oddity to me since I do not expect gensym() to have a
side-effect...
I also tried using redpsl rather than redcsl and the "g10" issue is also
there (suggesting this not terribly system dependent) but then all the
upper case letters come out escaped which may or may not be what was
wanted but is certainly another "oddity".
Anyway please see if you can find a tiny example possibly starting by
trimming what you have for so long as bad things remain, but if you can
reduce things yet further bu guessing what in your input triggers problems
using that...
Arthur
On Sun, 22 Jun 2025, videohead wrote:
Eg here is a somewhat trimmed down version. It will be good to see if it
can be cut down yet further...
off fancy,raise,lower;
on echo;
load_package scope;
depend(DvDX, x4, x11);
depend(DvDY, x4, x11);
depend(DvDZ, x4, x11);
F := mat((1,0,0),(0,1,0),(0,0,1)) +
mat((DuDX,DuDY,DuDZ), (DvDX, DvDY,DvDZ),(DwDX,DwDY,DwDZ))/j;
J := det(F);
B := F*tp(F);
B11 := B(1,1);
I1 := B11;
I1bar := I1/J^(2/3);
off nat;
vDI1barDx11 := df(I1bar,x11);
vDI1barDx4 := df(I1bar,x4);
optimize
DI1barDx11 :=: vDI1barDx11,
DI1barDx4 :=: vDI1barDx4;
end;
The
g10problem only appears whenJhas an exponent.No such problem occurs when
I1bar := I1/J;I found a hack. The problem seems to be arise with the divisor in the quotient rule, therefore I optimized it separately as shown below:
No undefined
g10term appears in this case.Thank you. Can you find a smaller thing that goes into I1 (with an
exponent for J) that causes pain? Even the cut-down version I got still
generated somewhat over 100 lines of output. One that failed while
generating just a dozen would be much nicer for somebody who needs to dig
into that code from a cold start to use!
Arthur
On Sun, 22 Jun 2025, videohead wrote:
Yes I have.
Output (excerpt):
g5is now the erring term.Last edit: videohead 2025-06-22
Thank you very much! Thaty now looks small enough that to work through and
try to understand why g5 gets used before it is defined might be
feasible!!!
But with a bit more trial I can shrink it yet further
on echo;
off nat;
load scope;
KK := (DXEY - DXEZ + DYEX)k *
(DXEY - DXEZ + DYEX);
w11 := zx11 / KK;
w4 := zx4 / KK;
optimize
m11 :=: w11,
m4 :=: w4;
end;
For me the output now comes as just 5 lines:
g8 := g3dx$
g3 := (dyex + dx(ey - ez))k$
g6 := dyexg3 - g8ez + g8*ey$
m11 := zx11/g6$
m4 := zx4/g6$
but see that g3 is used before it is set.
It is now too late for me to start investigating the4 path it all takes
and there are several other "distractions" I have over the next few days
so since you managed to find a work-around for your particular case I will
get see about looking into this som emore SOME TIME rather than instantly,
but also maybe it the test case is small enough that somebody else on the
list will feel like diving in...
Arthur