$SPAD/src/input bugs.input

Timothy Daly December 3, 2016

Abstract

Contents

2

1 License

— license —

--Copyright The Numerical Algorithms Group Limited 1991.

———-

— * —

)set break resume
)spool bugs.output
)set message test on
)set message auto off
)clear all
-- File of Currently active and recently fixed interpreter bugs
--- eval a polynomial with EXPR substitution values
--- Fixed by SCM, verified on 10/30/90
)clear all
--S 1 of 44
eq1:= A*x**2 + B*x*y + C*y**2 +D*x + E*y + F
--R
--R
--R           2                   2
--R   (1)  C y  + (B x + E)y + A x  + D x + F
--R                                                    Type: Polynomial(Integer)
--E 1
--S 2 of 44
eq2:= eval(eq1,[x= xdot*cos(t) - ydot*sin(t), y=xdot*sin(t) + ydot*cos(t)])
--R
--R
--R   (2)
--R            2                       2       2
--R     (A ydot  - B xdot ydot + C xdot )sin(t)
--R   +
--R               2                              2
--R     ((- B ydot  + (2C - 2A)xdot ydot + B xdot )cos(t) - D ydot + E xdot)sin(t)
--R   +
--R            2                       2       2
--R     (C ydot  + B xdot ydot + A xdot )cos(t)  + (E ydot + D xdot)cos(t) + F
--R                                                    Type: Expression(Integer)
--E 2
-- UTS coercions.  Fixed by SCM, verified on 10/30/90

)clear all
--S 3 of 44
taylor exp x
--R
--R
--R   (1)
--R             1  2   1  3    1  4    1   5    1   6     1   7     1    8
--R     1 + x + - x  + - x  + -- x  + --- x  + --- x  + ---- x  + ----- x
--R             2      6      24      120      720      5040      40320
--R   +
--R        1    9      1     10      11
--R     ------ x  + ------- x   + O(x  )
--R     362880      3628800
--R                        Type: UnivariateTaylorSeries(Expression(Integer),x,0)
--E 3
--S 4 of 44
s := %
--R
--R
--R   (2)
--R             1  2   1  3    1  4    1   5    1   6     1   7     1    8
--R     1 + x + - x  + - x  + -- x  + --- x  + --- x  + ---- x  + ----- x
--R             2      6      24      120      720      5040      40320
--R   +
--R        1    9      1     10      11
--R     ------ x  + ------- x   + O(x  )
--R     362880      3628800
--R                        Type: UnivariateTaylorSeries(Expression(Integer),x,0)
--E 4
--S 5 of 44
s::(UTS(EXPR FLOAT, x, 0))
--R
--R
--R   (3)
--R                    2                            3
--R     1.0 + x + 0.5 x  + 0.1666666666 6666666667 x
--R   +
--R                                4                               5
--R     0.0416666666 6666666666 7 x  + 0.0083333333 3333333333 34 x
--R   +
--R                                 6                               7
--R     0.0013888888 8888888888 89 x  + 0.0001984126 9841269841 27 x
--R   +
--R                                   8                                  9
--R     0.0000248015 8730158730 1587 x  + 0.0000027557 3192239858 90653 x
--R   +
--R                                   10      11

--R     0.2755731922 3985890653 E -6 x   + O(x  )
--R                        Type: UnivariateTaylorSeries(Expression(Float),x,0.0)
--E 5
--S 6 of 44
s::(UTS(FLOAT, x, 0))
--R
--R
--R   (4)
--R                    2                            3
--R     1.0 + x + 0.5 x  + 0.1666666666 6666666667 x
--R   +
--R                                4                               5
--R     0.0416666666 6666666666 7 x  + 0.0083333333 3333333333 34 x
--R   +
--R                                 6                               7
--R     0.0013888888 8888888888 89 x  + 0.0001984126 9841269841 27 x
--R   +
--R                                   8                                  9
--R     0.0000248015 8730158730 1587 x  + 0.0000027557 3192239858 90653 x
--R   +
--R                                   10      11
--R     0.2755731922 3985890653 E -6 x   + O(x  )
--R                                    Type: UnivariateTaylorSeries(Float,x,0.0)
--E 6
--S 7 of 44
eval(s,1)
--R
--R
--R             5 8 65 163 1957 685 109601 98641
--R   (5)  [1,2,-,-,--,---,----,---,------,-----,...]
--R             2 3 24  60  720 252  40320 36288
--R                                            Type: Stream(Expression(Integer))
--E 7
--S 8 of 44
%::(Stream Float)
--R
--R
--R   (6)
--R   [1.0, 2.0, 2.5, 2.6666666666 666666667, 2.7083333333 333333333,
--R    2.7166666666 666666667, 2.7180555555 555555556, 2.7182539682 53968254,
--R    2.7182787698 412698413, 2.7182815255 731922399, ...]
--R                                                          Type: Stream(Float)
--E 8
-- overloading interpreter maps on arity
--- Fixed by SCM, verified on 10/30/90

--S 9 of 44
f(x) == x+1
--R
--R                                                                   Type: Void
--E 9
--S 10 of 44
f(x,y) == x+y
--R
--R                                                                   Type: Void
--E 10
--S 11 of 44
f 3
--R
--R   Compiling function f with type PositiveInteger -> PositiveInteger
--R
--R   (3)  4
--R                                                        Type: PositiveInteger
--E 11
--S 12 of 44
f(3,4)
--R
--R   Compiling function f with type (PositiveInteger,PositiveInteger) ->
--R      PositiveInteger
--R
--R   (4)  7
--R                                                        Type: PositiveInteger
--E 12
--S 13 of 44
f(5)
--R
--R
--R   (5)  6
--R                                                        Type: PositiveInteger
--E 13
--S 14 of 44
f(1,x)
--R
--R   Compiling function f with type (PositiveInteger,Variable(x)) ->
--R      Polynomial(Integer)
--R
--R   (6)  x + 1
--R                                                    Type: Polynomial(Integer)
--E 14

-- targetted function requiring a coercion
--- Fixed by SCM, verified on 10/30/90
)clear all
--S 15 of 44
series(n +-> bernoulli(n)/factorial(n), t=0)
--R
--R
--R   (1)
--R       1      1  2    1   4     1    6      1     8       1     10      11
--R   1 - - t + -- t  - --- t  + ----- t  - ------- t  + -------- t   + O(t  )
--R       2     12      720      30240      1209600      47900160
--R                       Type: UnivariatePuiseuxSeries(Expression(Integer),t,0)
--E 15
-- in-homogeneous list mapping
--- Fixed by SCM, verified on 10/30/90
)clear all
--S 16 of 44
l := [1,2,-1]
--R
--R
--R   (1)  [1,2,- 1]
--R                                                          Type: List(Integer)
--E 16
--S 17 of 44
f : INT -> FRAC INT
--R
--R                                                                   Type: Void
--E 17
--S 18 of 44
f x == x
--R
--R                                                                   Type: Void
--E 18
--S 19 of 44
map(f, l)
--R
--R   Compiling function f with type Integer -> Fraction(Integer)
--R
--R   (4)  [1,2,- 1]
--R                                                Type: List(Fraction(Integer))
--E 19

-- Function args to interpreter functions
--- Fixed by SCM, verified on 10/30/90
)clear all
--S 20 of 44
f: INT -> INT
--R
--R                                                                   Type: Void
--E 20
--S 21 of 44
f x == x+1
--R
--R                                                                   Type: Void
--E 21
--S 22 of 44
u g == g 3
--R
--R                                                                   Type: Void
--E 22
--S 23 of 44
u f
--R
--R   Compiling function u with type (Integer -> Integer) -> Integer
--R   Compiling function f with type Integer -> Integer
--R
--R   (4)  4
--R                                                        Type: PositiveInteger
--E 23
-- category modemap requiring a field to be constructed
--- Fixed by SCM, verified on 10/30/90
)clear all
--S 24 of 44
groebner [x**2 - y, y**3+1]
--R
--R
--R              2  6
--R   (1)  [y - x ,x  + 1]
--R                                              Type: List(Polynomial(Integer))
--E 24
-- operations requiring polynomials, passed variables
--- Fixed by SCM, verified on 10/30/90

--S 25 of 44
factor x
--R
--R
--R   (1)  x
--R                                          Type: Factored(Polynomial(Integer))
--E 25
-- bracket parsing and empty-set types
--- Fixed by SCM, verified on 10/30/90
)clear all
--S 26 of 44
{}$(List INT)
--R
--R
--RDaly Bug
--R   The function SEQ is not implemented in List(Integer) .
--E 26
--S 27 of 44
{1}
--R
--R
--R   (1)  1
--R                                                        Type: PositiveInteger
--E 27
-- Shouldn't work, but no longer bombs the interpreter
--- Fixed by SCM, verified on 10/30/90
)clear all
--S 28 of 44
map(variable, [x,y])
--R
--R
--R   (1)  [x,y]
--R                       Type: List(Union(OrderedVariableList([x,y]),"failed"))
--E 28
-- Recursive map type analysis bug
--- Fixed by SCM, verified on 10/30/90
)set fun recur off
)clear all

--S 29 of 44
p(n,x) == if n=0 then 1 else (x+n-1)*p(n-1,x)
--R
--R                                                                   Type: Void
--E 29
--S 30 of 44
pp(n,x) == if n=0 then 1 else if n<0 then (-1)**n/p(-n,1-x) else p(n,x)
--R
--R                                                                   Type: Void
--E 30
--S 31 of 44
pp(-1,x) -- should be 1/(x-1)
--R
--R   Compiling function p with type (Integer,Polynomial(Integer)) ->
--R      Polynomial(Integer)
--R   Compiling function p with type (Integer,Variable(x)) -> Polynomial(
--R      Integer)
--R   Compiling function pp with type (Integer,Variable(x)) -> Fraction(
--R      Polynomial(Fraction(Integer)))
--R
--R          1
--R   (3)  -----
--R        x - 1
--R                                Type: Fraction(Polynomial(Fraction(Integer)))
--E 31
-- interpret-code mode for iterators is broken
)clear all
--S 32 of 44
f n ==
  for i in 1..n repeat
    j:=2*i
    m:SQMATRIX(j,?):=1
    print m
--R
--R                                                                   Type: Void
--E 32
--S 33 of 44
g n ==
    j:=2*n
    m:SQMATRIX(j,?):=1
    print m
--R
--R                                                                   Type: Void

--E 33
--S 34 of 44
g 3 -- Should work
--R
--R   Cannot compile the declaration for m because its (possible partial)
--R      type contains a local variable.
--R   AXIOM will attempt to step through and interpret the code.
--R   +1  0  0  0  0  0+
--R   |                |
--R   |0  1  0  0  0  0|
--R   |                |
--R   |0  0  1  0  0  0|
--R   |                |
--R   |0  0  0  1  0  0|
--R   |                |
--R   |0  0  0  0  1  0|
--R   |                |
--R   +0  0  0  0  0  1+
--R                                                                   Type: Void
--E 34
--S 35 of 44
f 3 -- Bombs
--R
--R   Cannot compile the declaration for m because its (possible partial)
--R      type contains a local variable.
--R   AXIOM will attempt to step through and interpret the code.
--R   +1  0+
--R   |    |
--R   +0  1+
--R   +1  0  0  0+
--R   |          |
--R   |0  1  0  0|
--R   |          |
--R   |0  0  1  0|
--R   |          |
--R   +0  0  0  1+
--R   +1  0  0  0  0  0+
--R   |                |
--R   |0  1  0  0  0  0|
--R   |                |
--R   |0  0  1  0  0  0|
--R   |                |
--R   |0  0  0  1  0  0|
--R   |                |
--R   |0  0  0  0  1  0|
--R   |                |
--R   +0  0  0  0  0  1+
--R                                                                   Type: Void

--E 35
-- Test interpreter list destructuring
)clear all
--S 36 of 44
mp(x,l) ==
  l is [a,:b] =>
    a*x**(#b)+ mp(x,b)
  0
--R
--R                                                                   Type: Void
--E 36
--S 37 of 44
mp(x, [1,3,4, 2])
--R
--R   Compiling function mp with type (Variable(x),List(PositiveInteger))
--R       -> Polynomial(Integer)
--R
--R         3     2
--R   (2)  x  + 3x  + 4x + 2
--R                                                    Type: Polynomial(Integer)
--E 37
--S 38 of 44
mp(x, [1,2,-3, 4])
--R
--R   Compiling function mp with type (Variable(x),List(Integer)) ->
--R      Polynomial(Integer)
--R
--R         3     2
--R   (3)  x  + 2x  - 3x + 4
--R                                                    Type: Polynomial(Integer)
--E 38
-- Tests compilation of recursive functions
)clear all
--S 39 of 44
f1 n ==
  if n=0 then 1 else if n=1 then 1 else f1(n-1)+f1(n-2)
--R
--R                                                                   Type: Void
--E 39
--S 40 of 44
f2 n ==

  m:=n
  if n=0 then 1 else if n=1 then 1 else f2(n-1)+f2(n-2)
--R
--R                                                                   Type: Void
--E 40
--S 41 of 44
f3 n ==
  n=0 => 1
  n=1 => 1
  f3(n-1)+f3(n-2)
--R
--R                                                                   Type: Void
--E 41
--S 42 of 44
f4 n ==
  m:=n
  n=0 => 1
  n=1 => 1
  m:=n
  f4(n-1)+f4(n-2)
--R
--R                                                                   Type: Void
--E 42
--S 43 of 44
f5 n == if n=0 or n=1 then 1 else f5(n-1)+f5(n-2)
--R
--R                                                                   Type: Void
--E 43
--S 44 of 44
[f1 3,f2 3, f3 3,f4 3,f5 3]
--R
--R   Compiling function f1 with type Integer -> PositiveInteger
--R   Compiling function f2 with type Integer -> PositiveInteger
--R   Compiling function f3 with type Integer -> PositiveInteger
--R   Compiling function f4 with type Integer -> PositiveInteger
--R   Compiling function f5 with type Integer -> PositiveInteger
--R
--R   (6)  [3,3,3,3,3]
--R                                                  Type: List(PositiveInteger)
--E 44
)spool
)lisp (bye)

———-

References^{[1] nothing}

14