1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
|
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input test.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
--Copyright The Numerical Algorithms Group Limited 1991.
@
<<*>>=
<<license>>
-- File of recently fixed interpreter bugs
--- eval a polynomial with EXPR substitution values
--- Fixed by SCM, verified on 10/30/90
)clear all
eq1:= A*x**2 + B*x*y + C*y**2 +D*x + E*y + F
eq2:= eval(eq1,[x= xdot*cos(t) - ydot*sin(t), y=xdot*sin(t) + ydot*cos(t)])
-- UTS coercions. Fixed by SCM, verified on 10/30/90
)clear all
taylor exp x
s := %
s::(UTS(EXPR FLOAT, x, 0))
s::(UTS(FLOAT, x, 0))
eval(s,1)
%::(Stream Float)
-- Another bug, fixed by adding UPXS2 package,
s := series(sin(a*x),x=0)
eval(s, 1.0)
s - a*x
-- grand finale, just fixed on 3/23/91
eval(s, 1.0)
-- generalized resolve
-- Fixed (enhanced) by SCM in 3/23/91
)cl all
v := vector [1,2,3]
(1/2)*v
eval(x**2, x=1/2)
eval(x**2, x=0.5)
eval(3**x, x=0.5)
-- overloading interpreter maps on arity
--- Fixed by SCM, verified on 10/30/90
)clear all
f(x) == x+1
f(x,y) == x+y
f 3
f(3,4)
f(5)
f(1,x)
-- targetted function requiring a coercion
--- Fixed by SCM, verified on 10/30/90
)clear all
series(n +-> bernoulli(n)/factorial(n), t=0)
-- in-homogeneous list mapping
--- Fixed by SCM, verified on 10/30/90
)clear all
l := [1,2,-1]
f : INT -> FRAC INT
f x == x
map(f, l)
-- Function args to interpreter functions
--- Fixed by SCM, verified on 10/30/90
)cl all
f: INT -> INT
f x == x+1
u g == g 3
u f
-- category modemap requiring a field to be constructed
--- Fixed by SCM, verified on 10/30/90
)clear all
groebner [x**2 - y, y**3+1]
-- operations requiring polynomials, passed variables
--- Fixed by SCM, verified on 10/30/90
)clear all
factor x
draw(x, x=-1..1)
-- bracket parsing and empty-set types
--- Fixed by SCM, verified on 10/30/90
)clear all
brace [] -- {}
--{}$(List INT)
brace [1] -- {1}
-- The following still doesn't work
union(brace [], brace [1,2]) -- union({}, {1,2})
-- Shouldn't work, but no longer bombs the interpreter
--- Fixed by SCM, verified on 10/30/90
)clear all
)set mes test off
map(variable, [x,y])
)set mes test on
-- Recursive map type analysis bug
--- Fixed by SCM, verified on 10/30/90
)set fun recur off
)clear all
p(n,x) == if n=0 then 1 else (x+n-1)*p(n-1,x)
pp(n,x) == if n=0 then 1 else if n<0 then (-1)**n/p(-n,1-x) else p(n,x)
pp(-1,x) -- should be 1/(x-1)
-- interpret-code mode for iterators is broken
)cl all
f n ==
for i in 1..n repeat
j:=2*i
m:SQMATRIX(j,?):=1
print m
g n ==
j:=2*n
m:SQMATRIX(j,?):=1
print m
g 3
f 3
-- Test interpreter list destructuring
)clear all
mp(x,l) ==
l is [a,:b] =>
a*x**(#b)+ mp(x,b)
0
mp(x, [1,3,4, 2])
mp(x, [1,2,-3, 4])
-- Tests compilation of recursive functions
)clear all
f1 n ==
if n=0 then 1 else if n=1 then 1 else f1(n-1)+f1(n-2)
f2 n ==
m:=n
if n=0 then 1 else if n=1 then 1 else f2(n-1)+f2(n-2)
f3 n ==
n=0 => 1
n=1 => 1
f3(n-1)+f3(n-2)
f4 n ==
m:=n
n=0 => 1
n=1 => 1
m:=n
f4(n-1)+f4(n-2)
f5 n == if n=0 or n=1 then 1 else f5(n-1)+f5(n-2)
[f1 3,f2 3, f3 3,f4 3,f5 3]
-- Input of GDMP types
-- Fixed by SCM on 1/22/91
)cl all
g: GDMP([x,y], INT, DIRPROD(2, NNI)) := x**2 + y
-- has test with variables
-- Fixed by SCM on 1/22/91
)cl all
i := INT
i has Algebra(i)
-- returns in functions
-- Fixed by SCM on 1/22/91
)cl all
f x == if x<0 then return x else x+1
f 2 -- should be 3
f(-2) -- should be -2
-- resolveTT not returning Any
-- Fixed by SCM 1/30/91
)cl all
m = [[1,2],[2,3]] -- Should return type EQ POLY SQMATRIX(2, INT)
[1, "asd"] -- Should be of type List Any
)set mes test off
1+"asd" -- These should both fail in the same way
1/"asd"
)set mes test on
-- Passing type variables to )show
)cl all
t := MPOLY([x,y], INT)
)show t
-- caching nullary functions
)set fun cache all
u == 1
u
)set fun cache 0
-- Interpreter Only mode on collects
-- Fixed by SCM on 3/1/91
factorp: (UP(x,INT),PositiveInteger,PositiveInteger) -> List(UP(x,INT))
factorp(poly,p,e) ==
ppoly:UP(x,PF p):=poly
pl := [rec.factor for rec in factors factor ppoly]
facl:=pl::List(UP(x,INT))
factorp(x**2+x+5,7,1)
-- using "by" with segments
-- Fixed by SCM on 2/14/91
)cl all
b:= 1..10
for i in b by 2 repeat output i
-- DMP resolve bug
-- Fixed by SCM 3/7/91
)cl all
macro RN == FRAC INT
a51:=x+y+z+t+u;
a52:=x*y+y*z+z*t+x*u+t*u;
a53:=x*y*z+y*z*t+x*y*u+x*t*u+z*t*u;
a54:=x*y*z*t+x*y*z*u+x*y*t*u+x*z*t*u+y*z*t*u;
a55:=x*y*z*t*u-1;
arnborg5: List HDMP([x,y,z,t,u],RN):=[a51,a52,a53,a54,a55];
arnborg5l: List DMP([x,y,z,t,u],RN):=[a51,a52,a53,a54,a55];
-- construct in interpret-only mode
-- Fixed by SCM on 3/7/91
)cl all
factorp(poly,p,e) ==
[rec.factor for rec in factors factor (poly::UP(x, PF p))]::List UP(x, INT)
factorp(x**2+x+5,7,1)
-- return in interpret-only mode
-- fixed by SCM 3/11/91
)cl all
f (x) ==
y: PF x := 1
x = 3 => return x
x = 4 => return(-x)
(x+1)
f 3
-- incorrect handling of type of returns
-- fixed by SCM 3/11/91
)cl all
f (x) ==
x = 3 => return x
x = 4 => return(-x)
return (x+1)
f 3
-- SquareMatrix coercion bug
-- Fixed by SCM on 4/3/91
)cl all
s:SQMATRIX(2, INT) := matrix [[1,2],[2,3]]
s::SQMATRIX(2, FRAC INT)
-- SquareMatric resolve bug
)cl all
Mat := SquareMatrix(2, Polynomial Integer)
s:Mat := matrix [[ 2*x + 1, x], [x, 1]]
s**3
%::Polynomial(?)
-- parsing bug
-- Fixed by BURGE on 4/18/91
)cl all
-2**2 -- Should return -4
-- # in constructor arguemnt list bug
-- Fixed by SCM on 4/9/91
)cl all
f: DMP([x,y], INT) := x**2-y**2
coefficient(f, degree f)
-- retract from EXPR to POLY
-- fixed by SCM and SUTOR on 5/1/91
)cl all
x+1::EXPR INT
%::POLY INT
-- fixed by SCM in May
)cl all
solve([[1,2],[2,3]],[-2,3])
-- fixed by several people over a period of time
)cl all
eval(m**2, m=[[1,2],[2,3]])
-- filtering various illegal declarations
)cl all
)set mes test off
r: Ring
w: RF INT
)set mes test on
-- Correct representation of length 1 records
)cl all
r:Record(a: INT) := [1]
-- Fast generation of POLY FLOAT graphics code
)time on
p: POLY FLOAT := (x-1)**30
draw(p, x=-1..1)
)time )off
-- Case broken in interpreter
-- fixed by SCM in early 1991
)cl all
sayBranch x == _
if x case INT then output "Integer Branch" _
else if x case STRING then output "String Branch" _
else if x case FLOAT then output "Float Branch" _
else output "don't know"
x:Union(INT,STRING,FLOAT)
x:=3
sayBranch(x)
-- bug in evaluateType
-- fixed by SCM in May 1991
)cl all
RFI := FRAC POLY INT
g:DMP([x,y], RFI) := a**2*x**2/b**2 - c**2*y**2/d**2
factor g
-- bug in resolveTTSpecial
-- Fixed by SCM 6/2/91
)cl all
f(u:DoubleFloat, v:DoubleFloat):DoubleFloat == u+v
g(u:DoubleFloat, v:DoubleFloat):DoubleFloat == sin(u+v)
h(u:DoubleFloat, v:DoubleFloat):DoubleFloat == u+cos(v)
draw(surface(f,g,h), 0..4, 0..2*%pi)
-- check for package calling from categories
-- fixed by SCM 6/4/91
)cl all
)set mes test off
(1+1)$Ring
)set mes test on
-- UnivariateSeries coercions
-- Fixed by SCM 6/20/91
)cl all
s := series(sin(a*x), x=0)
s - a*x
s - sin(a*x)
-- Complex & AlgebraicNumber coercions
-- fixed by SCM 6/91
)cl all
sin %i
sin sqrt 2
%i*sqrt(2)
sin(%i*sqrt 2)
%i * sin(x)
sin(x/sqrt(2))
-- bug in resolve
-- fixed by SCM 8/12/91
)cl all
)set test msg off
primaryDecomp xx
)set test msg on
-- functions with ADEFs were broken
-- fixwd by SCM 8/9/91
)cl all
f l ==
reduce((x,y) +-> l.1 + x + y, l)
f [10,2,53]
g l ==
(x:INT):INT +-> l.x
w := g [23,1,341,12] ;
w(1) + w(3)
-- w(-1) removed tpd; causes testing to crash
-- coerces RN to PF and POLY to EXPR
-- fixed by SCM 8/9/91
)cl all
a := 2/3
)set mes test off
a::PF 3
)set mes test on
b := x+1
b:: EXPR FLOAT
-- minivector use in coercion functions
)cl all
symbol(s:Symbol,i:Integer):Symbol ==
st0:String:= convert(i)
st0:= concat(string(s),st0)
st0::Symbol
f(a,b) == symbol(a,b)
f('abc,3)
-- coercing undeclared maps to Mapping types
-- fixed by SCM 9/3/91
)cl all
f := operator 'f
y := f(x)
foo(u) == sin(u)
eval(y, 'f, foo)
-- package calling constants
-- fixed by SCM 9/3/91
)cl all
init()$(PF 3)
-- passing ADEFs to functions which require specific mapping types
draw((x,y) +-> x**2 - y**2, -1..1, -1..1)
-- DP bug. Don't know where this came from, but its fixed
-- DP makes problems:
dmp := DMP([u1,u2,u3],Fraction INT)
p : dmp := 2*u1**4*u2*u3
e1 := degree p
-- the following doesn't work
e2 : DirectProduct(3,NonNegativeInteger) := e1
sup(e1,e1)
-- if you give to many infos to the Interpreter it has problems
sup(e1,e1)$DirectProduct(3,NonNegativeInteger)
-- Some other bug.
)clear all
sum:=0
m:=matrix [[1,2],[3,4]]
lastcol:=ncols(m)
for r in 1..nrows(m) repeat
-- interpreter having a value for "row" would cause it to hide
-- the system function
Row:=row(m,r)
for c in 1..lastcol repeat
sum:=sum+Row.c
sum
-- interpOnly mode left things in an incosistent state if it failed twice
-- fixed by SCM
)cl all
splitPoly(f,var) ==
map(g +-> multivariate(g,var),monomials univariate(f,var))
g:=sin(x)+cos(x)
k:=kernels(g).1
)set mes test off
splitPoly([g],k) -- this is an incorrect call
)set mes test on
splitPoly(numer g,k) -- this is a correct call
-- scoping of lambda variables
-- fixed by SCM in March, 1992
)cl all
f x ==
g := (y:DoubleFloat):DoubleFloat +-> y+x
output(y+1)
g(x)
f 3
-- coercing undeclared interpreter function to mapping type with
-- target which need to be coerced.
-- fixed by SCM in March, 1992
)cl all
f x == 1/factorial(x)
series(f, x=0)
-- rule dependencies with dependencies on the operator postion
)cl all
node_a == i1+i2+i3-i5+i6=0
node_b == -i2-i3+i4-i6=0
i1 == va/r1
i2 == (va-vb)/r2
i3 == (va-vb)/r3
i4 == vb/r4
node_a
node_b
ans == solve([node_a,node_b],[va,vb]) -- (*)
x1 == rhs(ans.1.1)
x2 == rhs(ans.1.2)
x1 -- (**)
r1 == 2 -- (***)
x1 -- (****)
-- look for immediate data in operator position
-- fixed in March 1992 by SCM and RSS
"asd" "sdfsdf" "dfgdfg"
-- global variables that change type in a loop.
-- fixed by SCM
)clear all
s := 3.4
while s > 1.0 repeat (s := 1/2; print s)
s
)cl all
f x ==
free s
s := x
while s > 1.0 repeat (s := 1/2; print s)
s
f(3.4)
-- returns in sequences
-- fixed by SCM
t x ==
if x = 1 then (1; return [x])
return [2]
t 1
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}
|